Remove some empty bootdev_ops structures
Subsystems (4)
cover Remove some empty bootdev_ops structures
Hey all,
As part of Marek Vasut's work to add static and/or const to structs that should have it, but do not, it exposed a small problem with the bootdev uclass. This series fixes bootdev_get_bootflow to not require the ops field in the driver to be set and then removes the empty struct from the places which had been creating one.
Signature · 1 line
Tom
PATCH 1/5 bootdev: Fix the case where the driver ops field is null.
In the case where a bootdev does not have a custom get_bootflow function but instead relies on default_get_bootflow to provide one, bootdev_get_bootflow was not handling the case where ops was simply not set. Restructure the function to check for "ops && ops->get_bootflow" and add appropriate log_debug calls for both cases.
--- boot/bootdev-uclass.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
boot/bootdev-uclass.c +10 -5
@@ -566,13 +566,18 @@ int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, {const struct bootdev_ops *ops =bootdev_get_ops (dev); -log_debug ("->get_bootflow %s,%x=%p\n" , dev->name, iter->part, - ops->get_bootflow);bootflow_init (bflow, dev, iter->method); -if (!ops->get_bootflow) -return default_get_bootflow (dev, iter, bflow); -return ops->get_bootflow (dev, iter, bflow); +if (ops && ops->get_bootflow) { +log_debug ("->get_bootflow %s,%x=%p\n" , dev->name, iter->part, + ops->get_bootflow); + +return ops->get_bootflow (dev, iter, bflow); + } + +log_debug ("->get_bootflow %s,%x is unset\n" , dev->name, iter->part); + +return default_get_bootflow (dev, iter, bflow); } int bootdev_next_label(struct bootflow_iter *iter, struct udevice **devp,
Signature · 1 line
2.43.0
Re: [PATCH 1/5] bootdev: Fix the case where the driver ops field is null.
Quoted 7 lines · Tom Rini
In the case where a bootdev does not have a custom
get_bootflowfunction but instead relies ondefault_get_bootflowto provide one,bootdev_get_bootflowwas not handling the case where ops was simply not set. Restructure the function to check for "ops &&ops->get_bootflow" and add appropriatelog_debugcalls for both cases.Signed-off-by Tom Rini <[email protected]>
Thanks !
Re: [PATCH 1/5] bootdev: Fix the case where the driver ops field is null.
In reply to Tom RiniQuoted 8 lines · Tom Rini
bootdev: Fix the case where the driver ops field is null.
In the case where a bootdev does not have a custom
get_bootflowfunction but instead relies ondefault_get_bootflowto provide one,bootdev_get_bootflowwas not handling the case where ops was simply not set. Restructure the function to check for "ops &&ops->get_bootflow" and add appropriatelog_debugcalls for both cases.
Quoted 5 lines
Signed-off-by Tom Rini <[email protected]>Reviewed-by Marek Vasut <[email protected]>
boot/bootdev-uclass.c| 15 ++++++++++-----1 file changed, 10 insertions(+), 5 deletions(-)
PATCH 2/5 block: ide: Drop empty bootdev_ops structure
In reply to Tom RiniWe don't need to provide an empty struct here now that the caller can handle this being empty.
--- drivers/block/ide.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/block/ide.c +0 -4
@@ -969,9 +969,6 @@ static int ide_bootdev_hunt(struct bootdev_hunter *info, bool show)return 0 ; } -struct bootdev_ops ide_bootdev_ops = { -}; -static const struct udevice_id ide_bootdev_ids[] = { { .compatible ="u-boot,bootdev-ide" }, { }
@@ -980,7 +977,6 @@ static const struct udevice_id ide_bootdev_ids[] = {U_BOOT_DRIVER (ide_bootdev) = { .name ="ide_bootdev" , .id =UCLASS_BOOTDEV , - .ops = &ide_bootdev_ops, .bind = ide_bootdev_bind, .of_match = ide_bootdev_ids, };
Signature · 1 line
2.43.0
Re: [PATCH 2/5] block: ide: Drop empty bootdev_ops structure
Quoted 9 lines · Tom Rini
block: ide: Drop empty
bootdev_opsstructureWe don't need to provide an empty struct here now that the caller can handle this being empty.
Signed-off-by Tom Rini <[email protected]>
drivers/block/ide.c| 4 ----1 file changed, 4 deletions(-)
PATCH 3/5 ata: sata: Drop empty bootdev_ops structure
In reply to Tom RiniWe don't need to provide an empty struct here now that the caller can handle this being empty.
--- drivers/ata/sata_bootdev.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/ata/sata_bootdev.c +0 -4
@@ -37,9 +37,6 @@ static int sata_bootdev_hunt(struct bootdev_hunter *info, bool show)return 0 ; } -struct bootdev_ops sata_bootdev_ops = { -}; -static const struct udevice_id sata_bootdev_ids[] = { { .compatible ="u-boot,bootdev-sata" }, { }
@@ -48,7 +45,6 @@ static const struct udevice_id sata_bootdev_ids[] = {U_BOOT_DRIVER (sata_bootdev) = { .name ="sata_bootdev" , .id =UCLASS_BOOTDEV , - .ops = &sata_bootdev_ops, .bind = sata_bootdev_bind, .of_match = sata_bootdev_ids, };
Signature · 1 line
2.43.0
Re: [PATCH 3/5] ata: sata: Drop empty bootdev_ops structure
Quoted 9 lines · Tom Rini
ata: sata: Drop empty
bootdev_opsstructureWe don't need to provide an empty struct here now that the caller can handle this being empty.
Signed-off-by Tom Rini <[email protected]>
drivers/ata/sata_bootdev.c| 4 ----1 file changed, 4 deletions(-)
PATCH 4/5 scsi: Drop empty bootdev_ops structure
In reply to Tom RiniWe don't need to provide an empty struct here now that the caller can handle this being empty.
--- drivers/scsi/scsi_bootdev.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/scsi/scsi_bootdev.c +0 -4
@@ -37,9 +37,6 @@ static int scsi_bootdev_hunt(struct bootdev_hunter *info, bool show)return 0 ; } -struct bootdev_ops scsi_bootdev_ops = { -}; -static const struct udevice_id scsi_bootdev_ids[] = { { .compatible ="u-boot,bootdev-scsi" }, { }
@@ -48,7 +45,6 @@ static const struct udevice_id scsi_bootdev_ids[] = {U_BOOT_DRIVER (scsi_bootdev) = { .name ="scsi_bootdev" , .id =UCLASS_BOOTDEV , - .ops = &scsi_bootdev_ops, .bind = scsi_bootdev_bind, .of_match = scsi_bootdev_ids, };
Signature · 1 line
2.43.0
Re: [PATCH 4/5] scsi: Drop empty bootdev_ops structure
Quoted 9 lines · Tom Rini
scsi: Drop empty
bootdev_opsstructureWe don't need to provide an empty struct here now that the caller can handle this being empty.
Signed-off-by Tom Rini <[email protected]>
drivers/scsi/scsi_bootdev.c| 4 ----1 file changed, 4 deletions(-)
PATCH 5/5 virtio: Drop empty bootdev_ops structure
In reply to Tom RiniWe don't need to provide an empty struct here now that the caller can handle this being empty.
--- drivers/virtio/virtio-uclass.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/virtio/virtio-uclass.c +0 -4
@@ -400,9 +400,6 @@ UCLASS_DRIVER(virtio) = { .per_device_auto = sizeof(struct virtio_dev_priv), }; -struct bootdev_ops virtio_bootdev_ops = { -}; -static const struct udevice_id virtio_bootdev_ids[] = { { .compatible ="u-boot,bootdev-virtio" }, { }
@@ -411,7 +408,6 @@ static const struct udevice_id virtio_bootdev_ids[] = {U_BOOT_DRIVER (virtio_bootdev) = { .name ="virtio_bootdev" , .id =UCLASS_BOOTDEV , - .ops = &virtio_bootdev_ops, .bind = virtio_bootdev_bind, .of_match = virtio_bootdev_ids, };
Signature · 1 line
2.43.0
Re: [PATCH 5/5] virtio: Drop empty bootdev_ops structure
Quoted 9 lines · Tom Rini
virtio: Drop empty
bootdev_opsstructureWe don't need to provide an empty struct here now that the caller can handle this being empty.
Signed-off-by Tom Rini <[email protected]>
drivers/virtio/virtio-uclass.c| 4 ----1 file changed, 4 deletions(-)
Hi Tom,
Quoted 3 lines · Tom Rini
This series fixes
bootdev_get_bootflowto not require the ops field in the driver to be set and then removes the empty struct from the places which had been creating one.
Two more empty bootdev_ops structures fit this pattern:nvme_bootdev_ops and usb_bootdev_ops. Please can you fold those into v2 so we clean them all up together?
Quoted 3 lines
As part of Marek Vasut's work to add static and/or const to structs that should have it, but do not, it exposed a small problem with the bootdev uclass.
BTW for patch 1 it would be useful to update the comment for bootdev_get_ops() to indicate it can return NULL - normally, we don't allow this.
Regards,
Simon
Quoted 11 lines · Simon Glass
Hi Tom,
Quoted 3 lines · Tom Rini
This series fixes
bootdev_get_bootflowto not require the ops field in the driver to be set and then removes the empty struct from the places which had been creating one.Two more empty
bootdev_opsstructures fit this pattern:nvme_bootdev_opsandusb_bootdev_ops. Please can you fold those into v2 so we clean them all up together?
I'll follow-up and remove those later, and also update the doc and remove the mmc one.
Quoted 7 lines
Quoted 3 lines
As part of Marek Vasut's work to add static and/or const to structs that should have it, but do not, it exposed a small problem with the bootdev uclass.
BTW for patch 1 it would be useful to update the comment for
bootdev_get_ops()to indicate it can return NULL - normally, we don't allow this.
Don't allow which? I get the feeling you're saying I need to audit the reset of the uclasses for optional ops fields and then see who is just setting an empty struct and fix them too..
Signature · 1 line
Tom
Hi Tom,
Quoted 10 lines · Tom Rini
Quoted 8 lines · Simon Glass
Hi Tom,
Quoted 3 lines · Tom Rini
This series fixes
bootdev_get_bootflowto not require the ops field in the driver to be set and then removes the empty struct from the places which had been creating one.
Quoted 6 lines
Quoted 3 lines
Two more empty
bootdev_opsstructures fit this pattern:nvme_bootdev_opsandusb_bootdev_ops. Please can you fold those into v2 so we clean them all up together?I'll follow-up and remove those later, and also update the doc and remove the mmc one.
OK
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
As part of Marek Vasut's work to add static and/or const to structs that should have it, but do not, it exposed a small problem with the bootdev uclass.
Quoted 7 lines
Quoted 3 lines
BTW for patch 1 it would be useful to update the comment for
bootdev_get_ops()to indicate it can return NULL - normally, we don't allow this.Don't allow which? I get the feeling you're saying I need to audit the reset of the uclasses for optional ops fields and then see who is just setting an empty struct and fix them too..
No, I just mean that there should normally be an ops pointer, unless the uclass itself does not support any operations. The case of using NULL for the ops pointer is really just an optimisation. I'm fine with it, but it might create confusion for people, so it would be good to document it in the uclass header file, where supported.
Regards,
Simon
Quoted 35 lines · Simon Glass
Hi Tom,
Quoted 10 lines · Tom Rini
Quoted 8 lines · Simon Glass
Hi Tom,
Quoted 3 lines · Tom Rini
This series fixes
bootdev_get_bootflowto not require the ops field in the driver to be set and then removes the empty struct from the places which had been creating one.Quoted 6 lines
Quoted 3 lines
Two more empty
bootdev_opsstructures fit this pattern:nvme_bootdev_opsandusb_bootdev_ops. Please can you fold those into v2 so we clean them all up together?I'll follow-up and remove those later, and also update the doc and remove the mmc one.
OK
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
As part of Marek Vasut's work to add static and/or const to structs that should have it, but do not, it exposed a small problem with the bootdev uclass.
Quoted 7 lines
Quoted 3 lines
BTW for patch 1 it would be useful to update the comment for
bootdev_get_ops()to indicate it can return NULL - normally, we don't allow this.Don't allow which? I get the feeling you're saying I need to audit the reset of the uclasses for optional ops fields and then see who is just setting an empty struct and fix them too..
Quoted 5 lines
No, I just mean that there should normally be an ops pointer, unless the uclass itself does not support any operations. The case of using NULL for the ops pointer is really just an optimisation. I'm fine with it, but it might create confusion for people, so it would be good to document it in the uclass header file, where supported.
I'll make sure the documentation is clearer in the follow-up series. I think at this point the majority of implementation do not set one, btw.
Signature · 1 line
Tom
Hi Tom,
Quoted 37 lines · Tom Rini
Quoted 35 lines · Simon Glass
Hi Tom,
Quoted 10 lines · Tom Rini
Quoted 8 lines · Simon Glass
Hi Tom,
Quoted 3 lines · Tom Rini
This series fixes
bootdev_get_bootflowto not require the ops field in the driver to be set and then removes the empty struct from the places which had been creating one.Quoted 6 lines
Quoted 3 lines
Two more empty
bootdev_opsstructures fit this pattern:nvme_bootdev_opsandusb_bootdev_ops. Please can you fold those into v2 so we clean them all up together?I'll follow-up and remove those later, and also update the doc and remove the mmc one.
OK
Quoted 12 lines
Quoted 8 lines
Quoted 4 lines
As part of Marek Vasut's work to add static and/or const to structs that should have it, but do not, it exposed a small problem with the bootdev uclass.
BTW for patch 1 it would be useful to update the comment for
bootdev_get_ops()to indicate it can return NULL - normally, we don't allow this.Don't allow which? I get the feeling you're saying I need to audit the reset of the uclasses for optional ops fields and then see who is just setting an empty struct and fix them too..
Quoted 8 lines
Quoted 5 lines
No, I just mean that there should normally be an ops pointer, unless the uclass itself does not support any operations. The case of using NULL for the ops pointer is really just an optimisation. I'm fine with it, but it might create confusion for people, so it would be good to document it in the uclass header file, where supported.
I'll make sure the documentation is clearer in the follow-up series. I think at this point the majority of implementation do not set one, btw.
Loads of uclasses don't have operations, yes.
Regards,
Simon