diff options
author | Rikard Falkeborn <rikard.falkeborn@gmail.com> | 2020-10-04 21:32:02 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-10-05 13:21:49 +0200 |
commit | 6925478cad2721432e4cecf11174d64b22ed3b94 (patch) | |
tree | 014e1e4bd3be6db21c895dd3bcdfe5a175f710ee /drivers/power/supply/bq27xxx_battery_hdq.c | |
parent | w1: Constify static w1_family_ops structs (diff) | |
download | linux-6925478cad2721432e4cecf11174d64b22ed3b94.tar.xz linux-6925478cad2721432e4cecf11174d64b22ed3b94.zip |
power: supply: Constify static w1_family_ops structs
The only usage of these structs is to assign their address to the fops
field in the w1_family struct, which is a const pointer. Make them const
to allow the compiler to put them in read-only memory.
This was done with the following Coccinelle semantic patch
(http://coccinelle.lip6.fr/):
// <smpl>
@r1 disable optional_qualifier @
identifier i;
position p;
@@
static struct w1_family_ops i@p = {...};
@ok1@
identifier r1.i;
position p;
identifier s;
@@
static struct w1_family s = {
.fops=&i@p,
};
@bad1@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p
@depends on !bad1 disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct w1_family_ops i={};
// </smpl>
Acked-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Link: https://lore.kernel.org/r/20201004193202.4044-4-rikard.falkeborn@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/power/supply/bq27xxx_battery_hdq.c')
-rw-r--r-- | drivers/power/supply/bq27xxx_battery_hdq.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/power/supply/bq27xxx_battery_hdq.c b/drivers/power/supply/bq27xxx_battery_hdq.c index 29771967df2e..d56b3e19e996 100644 --- a/drivers/power/supply/bq27xxx_battery_hdq.c +++ b/drivers/power/supply/bq27xxx_battery_hdq.c @@ -104,7 +104,7 @@ static void bq27xxx_battery_hdq_remove_slave(struct w1_slave *sl) bq27xxx_battery_teardown(di); } -static struct w1_family_ops bq27xxx_battery_hdq_fops = { +static const struct w1_family_ops bq27xxx_battery_hdq_fops = { .add_slave = bq27xxx_battery_hdq_add_slave, .remove_slave = bq27xxx_battery_hdq_remove_slave, }; |