ata: make ata_port_operations const
PATCH 1/1 ata: make ata_port_operations const
Make ata_port_operations structures const as it is only stored in the inherits field of an ata_port_operations structure. Therefore make it const.
--- drivers/ata/pata_sis.c | 2 +- drivers/ata/sata_via.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/ata/pata_sis.c +1 -1
@@ -549,7 +549,7 @@ static unsigned long sis_133_mode_filter(struct ata_device *adev, unsigned long .cable_detect = sis_133_cable_detect, }; -static struct ata_port_operations sis_base_ops = { +static const struct ata_port_operations sis_base_ops = { .inherits = &ata_bmdma_port_ops, .prereset = sis_pre_reset, };
drivers/ata/sata_via.c +1 -1
@@ -129,7 +129,7 @@ struct svia_priv { ATA_BMDMA_SHT(DRV_NAME), }; -static struct ata_port_operations svia_base_ops = { +static const struct ata_port_operations svia_base_ops = { .inherits = &ata_bmdma_port_ops, .sff_tf_load = svia_tf_load, };
Signature · 1 line
1.9.1
Hello,
Quoted 5 lines · Bhumika Goyal
Make
ata_port_operationsstructures const as it is only stored in the inherits field of anata_port_operationsstructure. Therefore make it const.Signed-off-by Bhumika Goyal <[email protected]>
How did you test the patch?
Thanks.
Signature · 1 line
tejun
Quoted 11 lines · Tejun Heo
Hello,
Quoted 5 lines · Bhumika Goyal
Make
ata_port_operationsstructures const as it is only stored in the inherits field of anata_port_operationsstructure. Therefore make it const.Signed-off-by Bhumika Goyal <[email protected]>How did you test the patch?
I compiled the .o files and checked the size before and after compilation. After making the structure const, bytes should move from data to text segment of the memory and this is what happened. So, this is how I tested it.
Thanks,
Bhumika
Quoted 4 lines
Thanks.
--
tejun
Hello,
Quoted 4 lines · Bhumika Goyal
I compiled the .o files and checked the size before and after compilation. After making the structure const, bytes should move from data to text segment of the memory and this is what happened. So, this is how I tested it.
Ah, I see, so the port_operations is never used directly. I'm not sure whether it'd be a good idea to selectively pick these and makr them const. Let's just leave them be.
Thanks.
Signature · 1 line
tejun
Quoted 11 lines · Tejun Heo
Hello,
Quoted 4 lines · Bhumika Goyal
I compiled the .o files and checked the size before and after compilation. After making the structure const, bytes should move from data to text segment of the memory and this is what happened. So, this is how I tested it.
Ah, I see, so the
port_operationsis never used directly. I'm not sure whether it'd be a good idea to selectively pick these and makr them const. Let's just leave them be.
Why?
Things that are never accessed as other than const should be const no?
Why leave unnecessary exposure for muckery?
Quoted 9 lines · Joe Perches
Quoted 8 lines · Tejun Heo
Hello,
Quoted 4 lines · Bhumika Goyal
I compiled the .o files and checked the size before and after compilation. After making the structure const, bytes should move from data to text segment of the memory and this is what happened. So, this is how I tested it.
Quoted 9 lines
Quoted 3 lines
Ah, I see, so the
port_operationsis never used directly. I'm not sure whether it'd be a good idea to selectively pick these and makr them const. Let's just leave them be.Why?
Things that are never accessed as other than const should be const no?
I think it would be better to leave them as in most situations the ata_port_operations structures cannot be const as they are only used in the port_ops field of an ata_port_info structure and this field is not const. Having two ata_port_operations const and others non-const will cause code inconsistency.
Thanks,
Bhumika
Quoted 1 line
Why leave unnecessary exposure for muckery?