Skip to content

Commit bd941df

Browse files
rikardfalkebornbroonie
authored andcommitted
regmap: Constify static regmap_bus structs
The only usage of these is to pass their address to __regmap_init() or __devm_regmap_init(), both which takes pointers to const struct regmap_bus. Make them const to allow the compiler to put them in read-only memory. Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com> Link: https://lore.kernel.org/r/20220330214110.36337-1-rikard.falkeborn@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 3123109 commit bd941df

6 files changed

Lines changed: 8 additions & 8 deletions

File tree

drivers/base/regmap/regmap-i3c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static int regmap_i3c_read(void *context,
4040
return i3c_device_do_priv_xfers(i3c, xfers, 2);
4141
}
4242

43-
static struct regmap_bus regmap_i3c = {
43+
static const struct regmap_bus regmap_i3c = {
4444
.write = regmap_i3c_write,
4545
.read = regmap_i3c_read,
4646
};

drivers/base/regmap/regmap-sccb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static int regmap_sccb_write(void *context, unsigned int reg, unsigned int val)
8080
return i2c_smbus_write_byte_data(i2c, reg, val);
8181
}
8282

83-
static struct regmap_bus regmap_sccb_bus = {
83+
static const struct regmap_bus regmap_sccb_bus = {
8484
.reg_write = regmap_sccb_write,
8585
.reg_read = regmap_sccb_read,
8686
};

drivers/base/regmap/regmap-sdw-mbq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static int regmap_sdw_mbq_read(void *context, unsigned int reg, unsigned int *va
4242
return 0;
4343
}
4444

45-
static struct regmap_bus regmap_sdw_mbq = {
45+
static const struct regmap_bus regmap_sdw_mbq = {
4646
.reg_read = regmap_sdw_mbq_read,
4747
.reg_write = regmap_sdw_mbq_write,
4848
.reg_format_endian_default = REGMAP_ENDIAN_LITTLE,

drivers/base/regmap/regmap-sdw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static int regmap_sdw_read(void *context, unsigned int reg, unsigned int *val)
3030
return 0;
3131
}
3232

33-
static struct regmap_bus regmap_sdw = {
33+
static const struct regmap_bus regmap_sdw = {
3434
.reg_read = regmap_sdw_read,
3535
.reg_write = regmap_sdw_write,
3636
.reg_format_endian_default = REGMAP_ENDIAN_LITTLE,

drivers/base/regmap/regmap-slimbus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static int regmap_slimbus_read(void *context, const void *reg, size_t reg_size,
2222
return slim_read(sdev, *(u16 *)reg, val_size, val);
2323
}
2424

25-
static struct regmap_bus regmap_slimbus_bus = {
25+
static const struct regmap_bus regmap_slimbus_bus = {
2626
.write = regmap_slimbus_write,
2727
.read = regmap_slimbus_read,
2828
.reg_format_endian_default = REGMAP_ENDIAN_LITTLE,

drivers/base/regmap/regmap-w1.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,17 @@ static int w1_reg_a16_v16_write(void *context, unsigned int reg,
172172
* Various types of supported bus addressing
173173
*/
174174

175-
static struct regmap_bus regmap_w1_bus_a8_v8 = {
175+
static const struct regmap_bus regmap_w1_bus_a8_v8 = {
176176
.reg_read = w1_reg_a8_v8_read,
177177
.reg_write = w1_reg_a8_v8_write,
178178
};
179179

180-
static struct regmap_bus regmap_w1_bus_a8_v16 = {
180+
static const struct regmap_bus regmap_w1_bus_a8_v16 = {
181181
.reg_read = w1_reg_a8_v16_read,
182182
.reg_write = w1_reg_a8_v16_write,
183183
};
184184

185-
static struct regmap_bus regmap_w1_bus_a16_v16 = {
185+
static const struct regmap_bus regmap_w1_bus_a16_v16 = {
186186
.reg_read = w1_reg_a16_v16_read,
187187
.reg_write = w1_reg_a16_v16_write,
188188
};

0 commit comments

Comments
 (0)