Skip to contentSkip to conversation

counter: microchip-tcb-capture: Constify mchp_tc_ops

PATCH In review Rikard Falkeborn 3 participants 3 messages Sep 22, 2020 – Sep 23, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 counter: microchip-tcb-capture: Constify mchp_tc_ops

The only usage of mchp_tc_ops is to assign its address to the ops field in the counter_device struct which is a const pointer. Make it const to allow the compiler to put it in read-only memory.

---
 drivers/counter/microchip-tcb-capture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/counter/microchip-tcb-capture.c +1 -1
index b7b252c5addf..039c54a78aa5 100644
@@ -253,7 +253,7 @@ static struct counter_count mchp_tc_counts[] = {
 	},
 };
 
-static struct counter_ops mchp_tc_ops = {
+static const struct counter_ops mchp_tc_ops = {
 	.signal_read  = mchp_tc_count_signal_read,
 	.count_read   = mchp_tc_count_read,
 	.function_get = mchp_tc_count_function_get,
Signature · 1 line
2.28.0
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Rikard Falkeborn

The only usage of mchp_tc_ops is to assign its address to the ops field in the counter_device struct which is a const pointer. Make it const to allow the compiler to put it in read-only memory.

Quoted 20 lines
---
 drivers/counter/microchip-tcb-capture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/counter/microchip-tcb-capture.c +1 -1
index b7b252c5addf..039c54a78aa5 100644
@@ -253,7 +253,7 @@ static struct counter_count mchp_tc_counts[] = {
 	},
 };
 
-static struct counter_ops mchp_tc_ops = {
+static const struct counter_ops mchp_tc_ops = {
 	.signal_read  = mchp_tc_count_signal_read,
 	.count_read   = mchp_tc_count_read,
 	.function_get = mchp_tc_count_function_get,
Signature · 1 line
2.28.0
maintainer
#2 lore raw
Quoted 8 lines · On Tue, 22 Sep 2020 21:48:38 -0400 William Breathitt Gray…
Quoted 5 lines · Rikard Falkeborn

The only usage of mchp_tc_ops is to assign its address to the ops field in the counter_device struct which is a const pointer. Make it const to allow the compiler to put it in read-only memory.

Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to poke at it.

I'm not sure if I'll get another pull request out this cycle, so it may have to wait for 5.11.

Thanks,

Jonathan

Quoted 21 lines
Quoted 21 lines
---
 drivers/counter/microchip-tcb-capture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/counter/microchip-tcb-capture.c +1 -1
index b7b252c5addf..039c54a78aa5 100644
@@ -253,7 +253,7 @@ static struct counter_count mchp_tc_counts[] = {
 	},
 };
 
-static struct counter_ops mchp_tc_ops = {
+static const struct counter_ops mchp_tc_ops = {
 	.signal_read  = mchp_tc_count_signal_read,
 	.count_read   = mchp_tc_count_read,
 	.function_get = mchp_tc_count_function_get,
Signature · 1 line
2.28.0