* [PATCH] mfd: rohm-bd71828: Constify some structures
@ 2025-06-15 16:32 Christophe JAILLET
2025-06-16 5:59 ` Matti Vaittinen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Christophe JAILLET @ 2025-06-15 16:32 UTC (permalink / raw)
To: Matti Vaittinen, Lee Jones
Cc: linux-kernel, kernel-janitors, Christophe JAILLET
Several structures are not modified in this driver. Constifying them moves
some data to a read-only section, so increases overall security, especially
when the structure holds some function pointers. This is the case for
'gpio_keys_platform_data' and 'mfd_cell'.
On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
18161 14112 192 32465 7ed1 drivers/mfd/rohm-bd71828.o
After:
=====
text data bss dec hex filename
22897 9376 192 32465 7ed1 drivers/mfd/rohm-bd71828.o
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only
---
drivers/mfd/rohm-bd71828.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/mfd/rohm-bd71828.c b/drivers/mfd/rohm-bd71828.c
index 738d8b3b9ffe..a14b7aa69c3c 100644
--- a/drivers/mfd/rohm-bd71828.c
+++ b/drivers/mfd/rohm-bd71828.c
@@ -25,7 +25,7 @@ static struct gpio_keys_button button = {
.type = EV_KEY,
};
-static struct gpio_keys_platform_data bd71828_powerkey_data = {
+static const struct gpio_keys_platform_data bd71828_powerkey_data = {
.buttons = &button,
.nbuttons = 1,
.name = "bd71828-pwrkey",
@@ -43,7 +43,7 @@ static const struct resource bd71828_rtc_irqs[] = {
DEFINE_RES_IRQ_NAMED(BD71828_INT_RTC2, "bd70528-rtc-alm-2"),
};
-static struct resource bd71815_power_irqs[] = {
+static const struct resource bd71815_power_irqs[] = {
DEFINE_RES_IRQ_NAMED(BD71815_INT_DCIN_RMV, "bd71815-dcin-rmv"),
DEFINE_RES_IRQ_NAMED(BD71815_INT_CLPS_OUT, "bd71815-clps-out"),
DEFINE_RES_IRQ_NAMED(BD71815_INT_CLPS_IN, "bd71815-clps-in"),
@@ -93,7 +93,7 @@ static struct resource bd71815_power_irqs[] = {
DEFINE_RES_IRQ_NAMED(BD71815_INT_TEMP_BAT_HI_DET, "bd71815-bat-hi-det"),
};
-static struct mfd_cell bd71815_mfd_cells[] = {
+static const struct mfd_cell bd71815_mfd_cells[] = {
{ .name = "bd71815-pmic", },
{ .name = "bd71815-clk", },
{ .name = "bd71815-gpo", },
@@ -109,7 +109,7 @@ static struct mfd_cell bd71815_mfd_cells[] = {
},
};
-static struct mfd_cell bd71828_mfd_cells[] = {
+static const struct mfd_cell bd71828_mfd_cells[] = {
{ .name = "bd71828-pmic", },
{ .name = "bd71828-gpio", },
{ .name = "bd71828-led", .of_compatible = "rohm,bd71828-leds" },
@@ -223,7 +223,7 @@ static unsigned int bit5_offsets[] = {3}; /* VSYS IRQ */
static unsigned int bit6_offsets[] = {1, 2}; /* DCIN IRQ */
static unsigned int bit7_offsets[] = {0}; /* BUCK IRQ */
-static struct regmap_irq_sub_irq_map bd718xx_sub_irq_offsets[] = {
+static const struct regmap_irq_sub_irq_map bd718xx_sub_irq_offsets[] = {
REGMAP_IRQ_MAIN_REG_OFFSET(bit0_offsets),
REGMAP_IRQ_MAIN_REG_OFFSET(bit1_offsets),
REGMAP_IRQ_MAIN_REG_OFFSET(bit2_offsets),
@@ -493,7 +493,7 @@ static int bd71828_i2c_probe(struct i2c_client *i2c)
const struct regmap_config *regmap_config;
const struct regmap_irq_chip *irqchip;
unsigned int chip_type;
- struct mfd_cell *mfd;
+ const struct mfd_cell *mfd;
int cells;
int button_irq;
int clkmode_reg;
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mfd: rohm-bd71828: Constify some structures
2025-06-15 16:32 [PATCH] mfd: rohm-bd71828: Constify some structures Christophe JAILLET
@ 2025-06-16 5:59 ` Matti Vaittinen
2025-06-19 12:00 ` Lee Jones
2025-06-25 10:12 ` (subset) " Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Matti Vaittinen @ 2025-06-16 5:59 UTC (permalink / raw)
To: Christophe JAILLET, Lee Jones; +Cc: linux-kernel, kernel-janitors
On 15/06/2025 19:32, Christophe JAILLET wrote:
> Several structures are not modified in this driver. Constifying them moves
> some data to a read-only section, so increases overall security, especially
> when the structure holds some function pointers. This is the case for
> 'gpio_keys_platform_data' and 'mfd_cell'.
>
> On a x86_64, with allmodconfig:
> Before:
> ======
> text data bss dec hex filename
> 18161 14112 192 32465 7ed1 drivers/mfd/rohm-bd71828.o
>
> After:
> =====
> text data bss dec hex filename
> 22897 9376 192 32465 7ed1 drivers/mfd/rohm-bd71828.o
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mfd: rohm-bd71828: Constify some structures
2025-06-15 16:32 [PATCH] mfd: rohm-bd71828: Constify some structures Christophe JAILLET
2025-06-16 5:59 ` Matti Vaittinen
@ 2025-06-19 12:00 ` Lee Jones
2025-06-25 10:12 ` (subset) " Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2025-06-19 12:00 UTC (permalink / raw)
To: Christophe JAILLET; +Cc: Matti Vaittinen, linux-kernel, kernel-janitors
On Sun, 15 Jun 2025, Christophe JAILLET wrote:
> Several structures are not modified in this driver. Constifying them moves
> some data to a read-only section, so increases overall security, especially
> when the structure holds some function pointers. This is the case for
> 'gpio_keys_platform_data' and 'mfd_cell'.
>
> On a x86_64, with allmodconfig:
> Before:
> ======
> text data bss dec hex filename
> 18161 14112 192 32465 7ed1 drivers/mfd/rohm-bd71828.o
>
> After:
> =====
> text data bss dec hex filename
> 22897 9376 192 32465 7ed1 drivers/mfd/rohm-bd71828.o
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only
> ---
> drivers/mfd/rohm-bd71828.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
Doesn't apply. Please rebase and resubmit.
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: (subset) [PATCH] mfd: rohm-bd71828: Constify some structures
2025-06-15 16:32 [PATCH] mfd: rohm-bd71828: Constify some structures Christophe JAILLET
2025-06-16 5:59 ` Matti Vaittinen
2025-06-19 12:00 ` Lee Jones
@ 2025-06-25 10:12 ` Lee Jones
2 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2025-06-25 10:12 UTC (permalink / raw)
To: Matti Vaittinen, Lee Jones, Christophe JAILLET
Cc: linux-kernel, kernel-janitors
On Sun, 15 Jun 2025 18:32:48 +0200, Christophe JAILLET wrote:
> Several structures are not modified in this driver. Constifying them moves
> some data to a read-only section, so increases overall security, especially
> when the structure holds some function pointers. This is the case for
> 'gpio_keys_platform_data' and 'mfd_cell'.
>
> On a x86_64, with allmodconfig:
> Before:
> ======
> text data bss dec hex filename
> 18161 14112 192 32465 7ed1 drivers/mfd/rohm-bd71828.o
>
> [...]
Applied, thanks!
[1/1] mfd: rohm-bd71828: Constify some structures
commit: e905ffecc34f66c35c9d3209fe5b111686adc28a
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-25 10:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-15 16:32 [PATCH] mfd: rohm-bd71828: Constify some structures Christophe JAILLET
2025-06-16 5:59 ` Matti Vaittinen
2025-06-19 12:00 ` Lee Jones
2025-06-25 10:12 ` (subset) " Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).