`bd957x_regmap` is not modified and can be declared as const
to move its data to a read-only section.
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
drivers/mfd/rohm-bd9576.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mfd/rohm-bd9576.c b/drivers/mfd/rohm-bd9576.c
index 3a9f61961721..634c65c7d108 100644
--- a/drivers/mfd/rohm-bd9576.c
+++ b/drivers/mfd/rohm-bd9576.c
@@ -57,7 +57,7 @@ static const struct regmap_access_table volatile_regs = {
.n_yes_ranges = ARRAY_SIZE(volatile_ranges),
};
-static struct regmap_config bd957x_regmap = {
+static const struct regmap_config bd957x_regmap = {
.reg_bits = 8,
.val_bits = 8,
.volatile_table = &volatile_regs,
--
2.40.1
On 7/3/24 18:37, Javier Carrasco wrote:
> `bd957x_regmap` is not modified and can be declared as const
> to move its data to a read-only section.
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
> ---
> drivers/mfd/rohm-bd9576.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/rohm-bd9576.c b/drivers/mfd/rohm-bd9576.c
> index 3a9f61961721..634c65c7d108 100644
> --- a/drivers/mfd/rohm-bd9576.c
> +++ b/drivers/mfd/rohm-bd9576.c
> @@ -57,7 +57,7 @@ static const struct regmap_access_table volatile_regs = {
> .n_yes_ranges = ARRAY_SIZE(volatile_ranges),
> };
>
> -static struct regmap_config bd957x_regmap = {
> +static const struct regmap_config bd957x_regmap = {
> .reg_bits = 8,
> .val_bits = 8,
> .volatile_table = &volatile_regs,
>
Thanks a ton Javier. This looks good to me but if you feel like going an
extra mile while you are at it... Do you think this could be extended to:
diff --git a/drivers/mfd/rohm-bd9576.c b/drivers/mfd/rohm-bd9576.c
index 3a9f61961721..17323ae39803 100644
--- a/drivers/mfd/rohm-bd9576.c
+++ b/drivers/mfd/rohm-bd9576.c
@@ -57,7 +57,7 @@ static const struct regmap_access_table volatile_regs = {
.n_yes_ranges = ARRAY_SIZE(volatile_ranges),
};
-static struct regmap_config bd957x_regmap = {
+static const struct regmap_config bd957x_regmap = {
.reg_bits = 8,
.val_bits = 8,
.volatile_table = &volatile_regs,
@@ -65,7 +65,7 @@ static struct regmap_config bd957x_regmap = {
.cache_type = REGCACHE_MAPLE,
};
-static struct regmap_irq bd9576_irqs[] = {
+static const struct regmap_irq bd9576_irqs[] = {
REGMAP_IRQ_REG(BD9576_INT_THERM, 0, BD957X_MASK_INT_MAIN_THERM),
REGMAP_IRQ_REG(BD9576_INT_OVP, 0, BD957X_MASK_INT_MAIN_OVP),
REGMAP_IRQ_REG(BD9576_INT_SCP, 0, BD957X_MASK_INT_MAIN_SCP),
@@ -76,7 +76,7 @@ static struct regmap_irq bd9576_irqs[] = {
REGMAP_IRQ_REG(BD9576_INT_SYS, 0, BD957X_MASK_INT_MAIN_SYS),
};
-static struct regmap_irq_chip bd9576_irq_chip = {
+static const struct regmap_irq_chip bd9576_irq_chip = {
.name = "bd9576_irq",
.irqs = &bd9576_irqs[0],
.num_irqs = ARRAY_SIZE(bd9576_irqs),
Yours,
-- Matti
--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland
~~ When things go utterly wrong vim users can always type :help! ~~
On 04/07/2024 06:50, Matti Vaittinen wrote:
> On 7/3/24 18:37, Javier Carrasco wrote:
>> `bd957x_regmap` is not modified and can be declared as const
>> to move its data to a read-only section.
>>
>> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
>> ---
>> drivers/mfd/rohm-bd9576.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mfd/rohm-bd9576.c b/drivers/mfd/rohm-bd9576.c
>> index 3a9f61961721..634c65c7d108 100644
>> --- a/drivers/mfd/rohm-bd9576.c
>> +++ b/drivers/mfd/rohm-bd9576.c
>> @@ -57,7 +57,7 @@ static const struct regmap_access_table
>> volatile_regs = {
>> .n_yes_ranges = ARRAY_SIZE(volatile_ranges),
>> };
>> -static struct regmap_config bd957x_regmap = {
>> +static const struct regmap_config bd957x_regmap = {
>> .reg_bits = 8,
>> .val_bits = 8,
>> .volatile_table = &volatile_regs,
>>
>
> Thanks a ton Javier. This looks good to me but if you feel like going an
> extra mile while you are at it... Do you think this could be extended to:
>
>
> diff --git a/drivers/mfd/rohm-bd9576.c b/drivers/mfd/rohm-bd9576.c
> index 3a9f61961721..17323ae39803 100644
> --- a/drivers/mfd/rohm-bd9576.c
> +++ b/drivers/mfd/rohm-bd9576.c
> @@ -57,7 +57,7 @@ static const struct regmap_access_table volatile_regs = {
> .n_yes_ranges = ARRAY_SIZE(volatile_ranges),
> };
>
> -static struct regmap_config bd957x_regmap = {
> +static const struct regmap_config bd957x_regmap = {
> .reg_bits = 8,
> .val_bits = 8,
> .volatile_table = &volatile_regs,
> @@ -65,7 +65,7 @@ static struct regmap_config bd957x_regmap = {
> .cache_type = REGCACHE_MAPLE,
> };
>
> -static struct regmap_irq bd9576_irqs[] = {
> +static const struct regmap_irq bd9576_irqs[] = {
> REGMAP_IRQ_REG(BD9576_INT_THERM, 0, BD957X_MASK_INT_MAIN_THERM),
> REGMAP_IRQ_REG(BD9576_INT_OVP, 0, BD957X_MASK_INT_MAIN_OVP),
> REGMAP_IRQ_REG(BD9576_INT_SCP, 0, BD957X_MASK_INT_MAIN_SCP),
> @@ -76,7 +76,7 @@ static struct regmap_irq bd9576_irqs[] = {
> REGMAP_IRQ_REG(BD9576_INT_SYS, 0, BD957X_MASK_INT_MAIN_SYS),
> };
>
> -static struct regmap_irq_chip bd9576_irq_chip = {
> +static const struct regmap_irq_chip bd9576_irq_chip = {
> .name = "bd9576_irq",
> .irqs = &bd9576_irqs[0],
> .num_irqs = ARRAY_SIZE(bd9576_irqs),
>
>
> Yours,
> -- Matti
>
Sure, I will generalize it and update the series to cover regmap_irq and
regmap_irq_chip as well, of course including these two cases too.
Best regards,
Javier Carrasco
© 2016 - 2026 Red Hat, Inc.