Skip to contentSkip to conversation

drivers/mfd: Constify static struct resource

PATCH Applied Rikard Falkeborn 5 participants 22 messages Sep 22, 2020 – Nov 4, 2020

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

cover drivers/mfd: Constify static struct resource

Constify a number of static struct resource to allow the compiler to put them in read-only memory. Typically, the only usage of these is to assign their address to the resources field in the mfd_cell struct, which is a const pointer (a few drivers also read the value of the start field).

I went through the rest of the static instances of struct resource in drivers/mfd and all of them are either directly modified by the driver or has its address passed to mfd_add_devices() which takes a non-const pointer.

The series is compile-tested only.

I split this into patches per maintainer, I'll happily split it (or squash it) some other way if that's preferable.

Rikard Falkeborn (8):
mfd: da: Constify static struct resource
mfd: intel: Constify static struct resource
mfd: Constify static struct resource in OMAP2+ drivers
mfd: wm: Constify static struct resource
mfd: lp8788: Constify static struct resource
mfd: stmpe: Constify static struct resource
mfd: sun4i-gpadc: Constify static struct resource
mfd: Constify static struct resource

 drivers/mfd/88pm800.c                 |  2 +-
 drivers/mfd/88pm860x-core.c           | 50 ++++++++++++------------
 drivers/mfd/da9055-core.c             |  8 ++--
 drivers/mfd/da9062-core.c             | 24 ++++++------
 drivers/mfd/da9063-core.c             |  8 ++--
 drivers/mfd/da9150-core.c             |  6 +--
 drivers/mfd/hi655x-pmic.c             |  2 +-
 drivers/mfd/intel_msic.c              | 18 ++++-----
 drivers/mfd/intel_quark_i2c_gpio.c    |  4 +-
 drivers/mfd/intel_soc_pmic_bxtwc.c    | 14 +++----
 drivers/mfd/intel_soc_pmic_chtdc_ti.c | 10 ++---
 drivers/mfd/intel_soc_pmic_chtwc.c    |  4 +-
 drivers/mfd/intel_soc_pmic_crc.c      | 10 ++---
 drivers/mfd/ioc3.c                    | 16 ++++----
 drivers/mfd/lp8788.c                  |  4 +-
 drivers/mfd/max8925-core.c            | 56 +++++++++++++--------------
 drivers/mfd/rdc321x-southbridge.c     |  4 +-
 drivers/mfd/retu-mfd.c                |  4 +-
 drivers/mfd/rk808.c                   |  8 ++--
 drivers/mfd/stmpe.c                   | 10 ++---
 drivers/mfd/sun4i-gpadc.c             |  2 +-
 drivers/mfd/tc3589x.c                 |  4 +-
 drivers/mfd/tc6387xb.c                |  2 +-
 drivers/mfd/tc6393xb.c                |  6 +--
 drivers/mfd/tps65090.c                |  2 +-
 drivers/mfd/tps65217.c                |  4 +-
 drivers/mfd/tps6586x.c                |  2 +-
 drivers/mfd/tps65910.c                |  2 +-
 drivers/mfd/tps80031.c                |  2 +-
 drivers/mfd/wm831x-core.c             | 52 ++++++++++++-------------
 drivers/mfd/wm8994-core.c             |  4 +-
 31 files changed, 172 insertions(+), 172 deletions(-)
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/8 mfd: da: Constify static struct resource

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/da9055-core.c |  8 ++++----
 drivers/mfd/da9062-core.c | 24 ++++++++++++------------
 drivers/mfd/da9063-core.c |  8 ++++----
 drivers/mfd/da9150-core.c |  6 +++---
 4 files changed, 23 insertions(+), 23 deletions(-)
drivers/mfd/da9055-core.c +4 -4
index 6d0af8486269..d074d213e661 100644
@@ -254,14 +254,14 @@ const struct regmap_config da9055_regmap_config = {
 };
 EXPORT_SYMBOL_GPL(da9055_regmap_config);
 
-static struct resource da9055_onkey_resource = {
+static const struct resource da9055_onkey_resource = {
 	.name = "ONKEY",
 	.start = DA9055_IRQ_NONKEY,
 	.end   = DA9055_IRQ_NONKEY,
 	.flags = IORESOURCE_IRQ,
 };
 
-static struct resource da9055_rtc_resource[] = {
+static const struct resource da9055_rtc_resource[] = {
 	{
 		.name = "ALM",
 		.start = DA9055_IRQ_ALARM,
@@ -276,14 +276,14 @@ static struct resource da9055_rtc_resource[] = {
 	},
 };
 
-static struct resource da9055_hwmon_resource = {
+static const struct resource da9055_hwmon_resource = {
 	.name = "HWMON",
 	.start = DA9055_IRQ_HWMON,
 	.end   = DA9055_IRQ_HWMON,
 	.flags = IORESOURCE_IRQ,
 };
 
-static struct resource da9055_ld05_6_resource = {
+static const struct resource da9055_ld05_6_resource = {
 	.name = "REGULATOR",
 	.start = DA9055_IRQ_REGULATOR,
 	.end   = DA9055_IRQ_REGULATOR,
drivers/mfd/da9062-core.c +12 -12
index fc30726e2e27..9583a98d3aae 100644
@@ -160,23 +160,23 @@ static struct regmap_irq_chip da9062_irq_chip = {
 	.ack_base = DA9062AA_EVENT_A,
 };
 
-static struct resource da9061_core_resources[] = {
+static const struct resource da9061_core_resources[] = {
 	DEFINE_RES_IRQ_NAMED(DA9061_IRQ_VDD_WARN, "VDD_WARN"),
 };
 
-static struct resource da9061_regulators_resources[] = {
+static const struct resource da9061_regulators_resources[] = {
 	DEFINE_RES_IRQ_NAMED(DA9061_IRQ_LDO_LIM, "LDO_LIM"),
 };
 
-static struct resource da9061_thermal_resources[] = {
+static const struct resource da9061_thermal_resources[] = {
 	DEFINE_RES_IRQ_NAMED(DA9061_IRQ_TEMP, "THERMAL"),
 };
 
-static struct resource da9061_wdt_resources[] = {
+static const struct resource da9061_wdt_resources[] = {
 	DEFINE_RES_IRQ_NAMED(DA9061_IRQ_WDG_WARN, "WD_WARN"),
 };
 
-static struct resource da9061_onkey_resources[] = {
+static const struct resource da9061_onkey_resources[] = {
 	DEFINE_RES_IRQ_NAMED(DA9061_IRQ_ONKEY, "ONKEY"),
 };
 
@@ -211,32 +211,32 @@ static const struct mfd_cell da9061_devs[] = {
 	},
 };
 
-static struct resource da9062_core_resources[] = {
+static const struct resource da9062_core_resources[] = {
 	DEFINE_RES_NAMED(DA9062_IRQ_VDD_WARN, 1, "VDD_WARN", IORESOURCE_IRQ),
 };
 
-static struct resource da9062_regulators_resources[] = {
+static const struct resource da9062_regulators_resources[] = {
 	DEFINE_RES_NAMED(DA9062_IRQ_LDO_LIM, 1, "LDO_LIM", IORESOURCE_IRQ),
 };
 
-static struct resource da9062_thermal_resources[] = {
+static const struct resource da9062_thermal_resources[] = {
 	DEFINE_RES_NAMED(DA9062_IRQ_TEMP, 1, "THERMAL", IORESOURCE_IRQ),
 };
 
-static struct resource da9062_wdt_resources[] = {
+static const struct resource da9062_wdt_resources[] = {
 	DEFINE_RES_NAMED(DA9062_IRQ_WDG_WARN, 1, "WD_WARN", IORESOURCE_IRQ),
 };
 
-static struct resource da9062_rtc_resources[] = {
+static const struct resource da9062_rtc_resources[] = {
 	DEFINE_RES_NAMED(DA9062_IRQ_ALARM, 1, "ALARM", IORESOURCE_IRQ),
 	DEFINE_RES_NAMED(DA9062_IRQ_TICK, 1, "TICK", IORESOURCE_IRQ),
 };
 
-static struct resource da9062_onkey_resources[] = {
+static const struct resource da9062_onkey_resources[] = {
 	DEFINE_RES_NAMED(DA9062_IRQ_ONKEY, 1, "ONKEY", IORESOURCE_IRQ),
 };
 
-static struct resource da9062_gpio_resources[] = {
+static const struct resource da9062_gpio_resources[] = {
 	DEFINE_RES_NAMED(DA9062_IRQ_GPI0, 1, "GPI0", IORESOURCE_IRQ),
 	DEFINE_RES_NAMED(DA9062_IRQ_GPI1, 1, "GPI1", IORESOURCE_IRQ),
 	DEFINE_RES_NAMED(DA9062_IRQ_GPI2, 1, "GPI2", IORESOURCE_IRQ),
drivers/mfd/da9063-core.c +4 -4
index a353d52210a9..df407c3afce3 100644
@@ -29,7 +29,7 @@
 #include <linux/uaccess.h>
 
 
-static struct resource da9063_regulators_resources[] = {
+static const struct resource da9063_regulators_resources[] = {
 	{
 		.name	= "LDO_LIM",
 		.start	= DA9063_IRQ_LDO_LIM,
@@ -38,7 +38,7 @@ static struct resource da9063_regulators_resources[] = {
 	},
 };
 
-static struct resource da9063_rtc_resources[] = {
+static const struct resource da9063_rtc_resources[] = {
 	{
 		.name	= "ALARM",
 		.start	= DA9063_IRQ_ALARM,
@@ -53,7 +53,7 @@ static struct resource da9063_rtc_resources[] = {
 	}
 };
 
-static struct resource da9063_onkey_resources[] = {
+static const struct resource da9063_onkey_resources[] = {
 	{
 		.name	= "ONKEY",
 		.start	= DA9063_IRQ_ONKEY,
@@ -62,7 +62,7 @@ static struct resource da9063_onkey_resources[] = {
 	},
 };
 
-static struct resource da9063_hwmon_resources[] = {
+static const struct resource da9063_hwmon_resources[] = {
 	{
 		.start	= DA9063_IRQ_ADC_RDY,
 		.end	= DA9063_IRQ_ADC_RDY,
drivers/mfd/da9150-core.c +3 -3
index 7f0aa1e8db96..d8b0cde48589 100644
@@ -350,18 +350,18 @@ static const struct regmap_irq_chip da9150_regmap_irq_chip = {
 	.num_irqs = ARRAY_SIZE(da9150_irqs),
 };
 
-static struct resource da9150_gpadc_resources[] = {
+static const struct resource da9150_gpadc_resources[] = {
 	DEFINE_RES_IRQ_NAMED(DA9150_IRQ_GPADC, "GPADC"),
 };
 
-static struct resource da9150_charger_resources[] = {
+static const struct resource da9150_charger_resources[] = {
 	DEFINE_RES_IRQ_NAMED(DA9150_IRQ_CHG, "CHG_STATUS"),
 	DEFINE_RES_IRQ_NAMED(DA9150_IRQ_TJUNC, "CHG_TJUNC"),
 	DEFINE_RES_IRQ_NAMED(DA9150_IRQ_VFAULT, "CHG_VFAULT"),
 	DEFINE_RES_IRQ_NAMED(DA9150_IRQ_VBUS, "CHG_VBUS"),
 };
 
-static struct resource da9150_fg_resources[] = {
+static const struct resource da9150_fg_resources[] = {
 	DEFINE_RES_IRQ_NAMED(DA9150_IRQ_FG, "FG"),
 };
 
Signature · 1 line
2.28.0
Acked-by on v1 1/8
#2 lore raw

RE: [PATCH 1/8] mfd: da: Constify static struct resource

Quoted 6 lines · Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

Applied
#3 lore raw

Re: [PATCH 1/8] mfd: da: Constify static struct resource

In reply to Rikard Falkeborn
Quoted 5 lines · Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

Quoted 7 lines
---
 drivers/mfd/da9055-core.c |  8 ++++----
 drivers/mfd/da9062-core.c | 24 ++++++++++++------------
 drivers/mfd/da9063-core.c |  8 ++++----
 drivers/mfd/da9150-core.c |  6 +++---
 4 files changed, 23 insertions(+), 23 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#4 lore raw

PATCH 2/8 mfd: intel: Constify static struct resource

In reply to Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/intel_msic.c              | 18 +++++++++---------
 drivers/mfd/intel_soc_pmic_bxtwc.c    | 14 +++++++-------
 drivers/mfd/intel_soc_pmic_chtdc_ti.c | 10 +++++-----
 drivers/mfd/intel_soc_pmic_chtwc.c    |  4 ++--
 drivers/mfd/intel_soc_pmic_crc.c      | 10 +++++-----
 5 files changed, 28 insertions(+), 28 deletions(-)
drivers/mfd/intel_msic.c +9 -9
index bb24c2a07900..daa772f8146b 100644
@@ -50,23 +50,23 @@ struct intel_msic {
 	void __iomem			*irq_base;
 };
 
-static struct resource msic_touch_resources[] = {
+static const struct resource msic_touch_resources[] = {
 	DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_adc_resources[] = {
+static const struct resource msic_adc_resources[] = {
 	DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_battery_resources[] = {
+static const struct resource msic_battery_resources[] = {
 	DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_gpio_resources[] = {
+static const struct resource msic_gpio_resources[] = {
 	DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_audio_resources[] = {
+static const struct resource msic_audio_resources[] = {
 	DEFINE_RES_IRQ_NAMED(0, "IRQ"),
 	/*
 	 * We will pass IRQ_BASE to the driver now but this can be removed
@@ -75,19 +75,19 @@ static struct resource msic_audio_resources[] = {
 	DEFINE_RES_MEM_NAMED(MSIC_IRQ_STATUS_ACCDET, 1, "IRQ_BASE"),
 };
 
-static struct resource msic_hdmi_resources[] = {
+static const struct resource msic_hdmi_resources[] = {
 	DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_thermal_resources[] = {
+static const struct resource msic_thermal_resources[] = {
 	DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_power_btn_resources[] = {
+static const struct resource msic_power_btn_resources[] = {
 	DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_ocd_resources[] = {
+static const struct resource msic_ocd_resources[] = {
 	DEFINE_RES_IRQ(0),
 };
 
drivers/mfd/intel_soc_pmic_bxtwc.c +7 -7
index eba89780dbe7..47d0d3a69a58 100644
@@ -200,32 +200,32 @@ static struct regmap_irq_chip bxtwc_regmap_irq_chip_crit = {
 	.num_regs = 1,
 };
 
-static struct resource gpio_resources[] = {
+static const struct resource gpio_resources[] = {
 	DEFINE_RES_IRQ_NAMED(BXTWC_GPIO_LVL1_IRQ, "GPIO"),
 };
 
-static struct resource adc_resources[] = {
+static const struct resource adc_resources[] = {
 	DEFINE_RES_IRQ_NAMED(BXTWC_ADC_IRQ, "ADC"),
 };
 
-static struct resource usbc_resources[] = {
+static const struct resource usbc_resources[] = {
 	DEFINE_RES_IRQ(BXTWC_USBC_IRQ),
 };
 
-static struct resource charger_resources[] = {
+static const struct resource charger_resources[] = {
 	DEFINE_RES_IRQ_NAMED(BXTWC_CHGR0_IRQ, "CHARGER"),
 	DEFINE_RES_IRQ_NAMED(BXTWC_CHGR1_IRQ, "CHARGER1"),
 };
 
-static struct resource thermal_resources[] = {
+static const struct resource thermal_resources[] = {
 	DEFINE_RES_IRQ(BXTWC_THRM_LVL1_IRQ),
 };
 
-static struct resource bcu_resources[] = {
+static const struct resource bcu_resources[] = {
 	DEFINE_RES_IRQ_NAMED(BXTWC_BCU_IRQ, "BCU"),
 };
 
-static struct resource tmu_resources[] = {
+static const struct resource tmu_resources[] = {
 	DEFINE_RES_IRQ_NAMED(BXTWC_TMU_IRQ, "TMU"),
 };
 
drivers/mfd/intel_soc_pmic_chtdc_ti.c +5 -5
index 64b5c3cc30e7..1c7577b881ff 100644
@@ -32,23 +32,23 @@ enum {
 	CHTDC_TI_CCEOCAL = 7,	/* battery */
 };
 
-static struct resource power_button_resources[] = {
+static const struct resource power_button_resources[] = {
 	DEFINE_RES_IRQ(CHTDC_TI_PWRBTN),
 };
 
-static struct resource thermal_resources[] = {
+static const struct resource thermal_resources[] = {
 	DEFINE_RES_IRQ(CHTDC_TI_DIETMPWARN),
 };
 
-static struct resource adc_resources[] = {
+static const struct resource adc_resources[] = {
 	DEFINE_RES_IRQ(CHTDC_TI_ADCCMPL),
 };
 
-static struct resource pwrsrc_resources[] = {
+static const struct resource pwrsrc_resources[] = {
 	DEFINE_RES_IRQ(CHTDC_TI_VBUSDET),
 };
 
-static struct resource battery_resources[] = {
+static const struct resource battery_resources[] = {
 	DEFINE_RES_IRQ(CHTDC_TI_VBATLOW),
 	DEFINE_RES_IRQ(CHTDC_TI_CCEOCAL),
 };
drivers/mfd/intel_soc_pmic_chtwc.c +2 -2
index be84bb2aa837..49c5f71664bc 100644
@@ -41,11 +41,11 @@ enum {
 	CHT_WC_CRIT_IRQ = 7,
 };
 
-static struct resource cht_wc_pwrsrc_resources[] = {
+static const struct resource cht_wc_pwrsrc_resources[] = {
 	DEFINE_RES_IRQ(CHT_WC_PWRSRC_IRQ),
 };
 
-static struct resource cht_wc_ext_charger_resources[] = {
+static const struct resource cht_wc_ext_charger_resources[] = {
 	DEFINE_RES_IRQ(CHT_WC_EXT_CHGR_IRQ),
 };
 
drivers/mfd/intel_soc_pmic_crc.c +5 -5
index 429efa1f8e55..38acb20e2d60 100644
@@ -28,23 +28,23 @@
 #define CRYSTAL_COVE_IRQ_GPIO		5
 #define CRYSTAL_COVE_IRQ_VHDMIOCP	6
 
-static struct resource gpio_resources[] = {
+static const struct resource gpio_resources[] = {
 	DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_GPIO, "GPIO"),
 };
 
-static struct resource pwrsrc_resources[] = {
+static const struct resource pwrsrc_resources[] = {
 	DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_PWRSRC, "PWRSRC"),
 };
 
-static struct resource adc_resources[] = {
+static const struct resource adc_resources[] = {
 	DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_ADC, "ADC"),
 };
 
-static struct resource thermal_resources[] = {
+static const struct resource thermal_resources[] = {
 	DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_THRM, "THERMAL"),
 };
 
-static struct resource bcu_resources[] = {
+static const struct resource bcu_resources[] = {
 	DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_BCU, "BCU"),
 };
 
Signature · 1 line
2.28.0
#5 lore raw

Re: [PATCH 2/8] mfd: intel: Constify static struct resource

Quoted 5 lines · Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

How had you tested this?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

Re: [PATCH 2/8] mfd: intel: Constify static struct resource

Quoted 10 lines · Andy Shevchenko
Quoted 5 lines · Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

How had you tested this?

It's compile-tested only.

Rikard

Reviewed-by on v1 2/8
#7 lore raw

Re: [PATCH 2/8] mfd: intel: Constify static struct resource

In reply to Rikard Falkeborn
Quoted 5 lines · Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

Okay, I have briefly checked the code and the patch seems correct (we don't use those structures to update data in them). FWIW,

Quoted 197 lines
---
 drivers/mfd/intel_msic.c              | 18 +++++++++---------
 drivers/mfd/intel_soc_pmic_bxtwc.c    | 14 +++++++-------
 drivers/mfd/intel_soc_pmic_chtdc_ti.c | 10 +++++-----
 drivers/mfd/intel_soc_pmic_chtwc.c    |  4 ++--
 drivers/mfd/intel_soc_pmic_crc.c      | 10 +++++-----
 5 files changed, 28 insertions(+), 28 deletions(-)
drivers/mfd/intel_msic.c +9 -9
index bb24c2a07900..daa772f8146b 100644
@@ -50,23 +50,23 @@ struct intel_msic {
        void __iomem                    *irq_base;
 };
 
-static struct resource msic_touch_resources[] = {
+static const struct resource msic_touch_resources[] = {
        DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_adc_resources[] = {
+static const struct resource msic_adc_resources[] = {
        DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_battery_resources[] = {
+static const struct resource msic_battery_resources[] = {
        DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_gpio_resources[] = {
+static const struct resource msic_gpio_resources[] = {
        DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_audio_resources[] = {
+static const struct resource msic_audio_resources[] = {
        DEFINE_RES_IRQ_NAMED(0, "IRQ"),
        /*
         * We will pass IRQ_BASE to the driver now but this can be removed
@@ -75,19 +75,19 @@ static struct resource msic_audio_resources[] = {
        DEFINE_RES_MEM_NAMED(MSIC_IRQ_STATUS_ACCDET, 1, "IRQ_BASE"),
 };
 
-static struct resource msic_hdmi_resources[] = {
+static const struct resource msic_hdmi_resources[] = {
        DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_thermal_resources[] = {
+static const struct resource msic_thermal_resources[] = {
        DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_power_btn_resources[] = {
+static const struct resource msic_power_btn_resources[] = {
        DEFINE_RES_IRQ(0),
 };
 
-static struct resource msic_ocd_resources[] = {
+static const struct resource msic_ocd_resources[] = {
        DEFINE_RES_IRQ(0),
 };
 
drivers/mfd/intel_soc_pmic_bxtwc.c +7 -7
index eba89780dbe7..47d0d3a69a58 100644
@@ -200,32 +200,32 @@ static struct regmap_irq_chip bxtwc_regmap_irq_chip_crit = {
        .num_regs = 1,
 };
 
-static struct resource gpio_resources[] = {
+static const struct resource gpio_resources[] = {
        DEFINE_RES_IRQ_NAMED(BXTWC_GPIO_LVL1_IRQ, "GPIO"),
 };
 
-static struct resource adc_resources[] = {
+static const struct resource adc_resources[] = {
        DEFINE_RES_IRQ_NAMED(BXTWC_ADC_IRQ, "ADC"),
 };
 
-static struct resource usbc_resources[] = {
+static const struct resource usbc_resources[] = {
        DEFINE_RES_IRQ(BXTWC_USBC_IRQ),
 };
 
-static struct resource charger_resources[] = {
+static const struct resource charger_resources[] = {
        DEFINE_RES_IRQ_NAMED(BXTWC_CHGR0_IRQ, "CHARGER"),
        DEFINE_RES_IRQ_NAMED(BXTWC_CHGR1_IRQ, "CHARGER1"),
 };
 
-static struct resource thermal_resources[] = {
+static const struct resource thermal_resources[] = {
        DEFINE_RES_IRQ(BXTWC_THRM_LVL1_IRQ),
 };
 
-static struct resource bcu_resources[] = {
+static const struct resource bcu_resources[] = {
        DEFINE_RES_IRQ_NAMED(BXTWC_BCU_IRQ, "BCU"),
 };
 
-static struct resource tmu_resources[] = {
+static const struct resource tmu_resources[] = {
        DEFINE_RES_IRQ_NAMED(BXTWC_TMU_IRQ, "TMU"),
 };
 
drivers/mfd/intel_soc_pmic_chtdc_ti.c +5 -5
index 64b5c3cc30e7..1c7577b881ff 100644
@@ -32,23 +32,23 @@ enum {
        CHTDC_TI_CCEOCAL = 7,   /* battery */
 };
 
-static struct resource power_button_resources[] = {
+static const struct resource power_button_resources[] = {
        DEFINE_RES_IRQ(CHTDC_TI_PWRBTN),
 };
 
-static struct resource thermal_resources[] = {
+static const struct resource thermal_resources[] = {
        DEFINE_RES_IRQ(CHTDC_TI_DIETMPWARN),
 };
 
-static struct resource adc_resources[] = {
+static const struct resource adc_resources[] = {
        DEFINE_RES_IRQ(CHTDC_TI_ADCCMPL),
 };
 
-static struct resource pwrsrc_resources[] = {
+static const struct resource pwrsrc_resources[] = {
        DEFINE_RES_IRQ(CHTDC_TI_VBUSDET),
 };
 
-static struct resource battery_resources[] = {
+static const struct resource battery_resources[] = {
        DEFINE_RES_IRQ(CHTDC_TI_VBATLOW),
        DEFINE_RES_IRQ(CHTDC_TI_CCEOCAL),
 };
drivers/mfd/intel_soc_pmic_chtwc.c +2 -2
index be84bb2aa837..49c5f71664bc 100644
@@ -41,11 +41,11 @@ enum {
        CHT_WC_CRIT_IRQ = 7,
 };
 
-static struct resource cht_wc_pwrsrc_resources[] = {
+static const struct resource cht_wc_pwrsrc_resources[] = {
        DEFINE_RES_IRQ(CHT_WC_PWRSRC_IRQ),
 };
 
-static struct resource cht_wc_ext_charger_resources[] = {
+static const struct resource cht_wc_ext_charger_resources[] = {
        DEFINE_RES_IRQ(CHT_WC_EXT_CHGR_IRQ),
 };
 
drivers/mfd/intel_soc_pmic_crc.c +5 -6
index 429efa1f8e55..38acb20e2d60 100644
@@ -28,23 +28,23 @@
 #define CRYSTAL_COVE_IRQ_GPIO          5
 #define CRYSTAL_COVE_IRQ_VHDMIOCP      6
 
-static struct resource gpio_resources[] = {
+static const struct resource gpio_resources[] = {
        DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_GPIO, "GPIO"),
 };
 
-static struct resource pwrsrc_resources[] = {
+static const struct resource pwrsrc_resources[] = {
        DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_PWRSRC, "PWRSRC"),
 };
 
-static struct resource adc_resources[] = {
+static const struct resource adc_resources[] = {
        DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_ADC, "ADC"),
 };
 
-static struct resource thermal_resources[] = {
+static const struct resource thermal_resources[] = {
        DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_THRM, "THERMAL"),
 };
 
-static struct resource bcu_resources[] = {
+static const struct resource bcu_resources[] = {
        DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_BCU, "BCU"),
 };
 
--

2.28.0

Signature · 2 lines
With Best Regards,
Andy Shevchenko
Applied
#8 lore raw

Re: [PATCH 2/8] mfd: intel: Constify static struct resource

In reply to Rikard Falkeborn
Quoted 5 lines · Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

Quoted 8 lines
---
 drivers/mfd/intel_msic.c              | 18 +++++++++---------
 drivers/mfd/intel_soc_pmic_bxtwc.c    | 14 +++++++-------
 drivers/mfd/intel_soc_pmic_chtdc_ti.c | 10 +++++-----
 drivers/mfd/intel_soc_pmic_chtwc.c    |  4 ++--
 drivers/mfd/intel_soc_pmic_crc.c      | 10 +++++-----
 5 files changed, 28 insertions(+), 28 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#9 lore raw

PATCH 3/8 mfd: Constify static struct resource in OMAP2+ drivers

In reply to Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/tps65217.c | 4 ++--
 drivers/mfd/tps65910.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/mfd/tps65217.c +2 -2
index 2d9c282ec917..8027b0a9e14f 100644
@@ -33,12 +33,12 @@
 #include <linux/mfd/core.h>
 #include <linux/mfd/tps65217.h>
 
-static struct resource charger_resources[] = {
+static const struct resource charger_resources[] = {
 	DEFINE_RES_IRQ_NAMED(TPS65217_IRQ_AC, "AC"),
 	DEFINE_RES_IRQ_NAMED(TPS65217_IRQ_USB, "USB"),
 };
 
-static struct resource pb_resources[] = {
+static const struct resource pb_resources[] = {
 	DEFINE_RES_IRQ_NAMED(TPS65217_IRQ_PB, "PB"),
 };
 
drivers/mfd/tps65910.c +1 -1
index 11959021b50a..a6c28df7aa38 100644
@@ -21,7 +21,7 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 
-static struct resource rtc_resources[] = {
+static const struct resource rtc_resources[] = {
 	{
 		.start  = TPS65910_IRQ_RTC_ALARM,
 		.end    = TPS65910_IRQ_RTC_ALARM,
Signature · 1 line
2.28.0
Applied
#10 lore raw

Re: [PATCH 3/8] mfd: Constify static struct resource in OMAP2+ drivers

Quoted 10 lines · Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/tps65217.c | 4 ++--
 drivers/mfd/tps65910.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#11 lore raw

PATCH 4/8 mfd: wm: Constify static struct resource

In reply to Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/wm831x-core.c | 52 +++++++++++++++++++--------------------
 drivers/mfd/wm8994-core.c |  4 +--
 2 files changed, 28 insertions(+), 28 deletions(-)
drivers/mfd/wm831x-core.c +26 -26
index b0344e5353e4..bcef08f58fb3 100644
@@ -616,7 +616,7 @@ int wm831x_set_bits(struct wm831x *wm831x, unsigned short reg,
 }
 EXPORT_SYMBOL_GPL(wm831x_set_bits);
 
-static struct resource wm831x_dcdc1_resources[] = {
+static const struct resource wm831x_dcdc1_resources[] = {
 	{
 		.start = WM831X_DC1_CONTROL_1,
 		.end   = WM831X_DC1_DVS_CONTROL,
@@ -637,7 +637,7 @@ static struct resource wm831x_dcdc1_resources[] = {
 };
 
 
-static struct resource wm831x_dcdc2_resources[] = {
+static const struct resource wm831x_dcdc2_resources[] = {
 	{
 		.start = WM831X_DC2_CONTROL_1,
 		.end   = WM831X_DC2_DVS_CONTROL,
@@ -657,7 +657,7 @@ static struct resource wm831x_dcdc2_resources[] = {
 	},
 };
 
-static struct resource wm831x_dcdc3_resources[] = {
+static const struct resource wm831x_dcdc3_resources[] = {
 	{
 		.start = WM831X_DC3_CONTROL_1,
 		.end   = WM831X_DC3_SLEEP_CONTROL,
@@ -671,7 +671,7 @@ static struct resource wm831x_dcdc3_resources[] = {
 	},
 };
 
-static struct resource wm831x_dcdc4_resources[] = {
+static const struct resource wm831x_dcdc4_resources[] = {
 	{
 		.start = WM831X_DC4_CONTROL,
 		.end   = WM831X_DC4_SLEEP_CONTROL,
@@ -685,7 +685,7 @@ static struct resource wm831x_dcdc4_resources[] = {
 	},
 };
 
-static struct resource wm8320_dcdc4_buck_resources[] = {
+static const struct resource wm8320_dcdc4_buck_resources[] = {
 	{
 		.start = WM831X_DC4_CONTROL,
 		.end   = WM832X_DC4_SLEEP_CONTROL,
@@ -699,7 +699,7 @@ static struct resource wm8320_dcdc4_buck_resources[] = {
 	},
 };
 
-static struct resource wm831x_gpio_resources[] = {
+static const struct resource wm831x_gpio_resources[] = {
 	{
 		.start = WM831X_IRQ_GPIO_1,
 		.end   = WM831X_IRQ_GPIO_16,
@@ -707,7 +707,7 @@ static struct resource wm831x_gpio_resources[] = {
 	},
 };
 
-static struct resource wm831x_isink1_resources[] = {
+static const struct resource wm831x_isink1_resources[] = {
 	{
 		.start = WM831X_CURRENT_SINK_1,
 		.end   = WM831X_CURRENT_SINK_1,
@@ -720,7 +720,7 @@ static struct resource wm831x_isink1_resources[] = {
 	},
 };
 
-static struct resource wm831x_isink2_resources[] = {
+static const struct resource wm831x_isink2_resources[] = {
 	{
 		.start = WM831X_CURRENT_SINK_2,
 		.end   = WM831X_CURRENT_SINK_2,
@@ -733,7 +733,7 @@ static struct resource wm831x_isink2_resources[] = {
 	},
 };
 
-static struct resource wm831x_ldo1_resources[] = {
+static const struct resource wm831x_ldo1_resources[] = {
 	{
 		.start = WM831X_LDO1_CONTROL,
 		.end   = WM831X_LDO1_SLEEP_CONTROL,
@@ -747,7 +747,7 @@ static struct resource wm831x_ldo1_resources[] = {
 	},
 };
 
-static struct resource wm831x_ldo2_resources[] = {
+static const struct resource wm831x_ldo2_resources[] = {
 	{
 		.start = WM831X_LDO2_CONTROL,
 		.end   = WM831X_LDO2_SLEEP_CONTROL,
@@ -761,7 +761,7 @@ static struct resource wm831x_ldo2_resources[] = {
 	},
 };
 
-static struct resource wm831x_ldo3_resources[] = {
+static const struct resource wm831x_ldo3_resources[] = {
 	{
 		.start = WM831X_LDO3_CONTROL,
 		.end   = WM831X_LDO3_SLEEP_CONTROL,
@@ -775,7 +775,7 @@ static struct resource wm831x_ldo3_resources[] = {
 	},
 };
 
-static struct resource wm831x_ldo4_resources[] = {
+static const struct resource wm831x_ldo4_resources[] = {
 	{
 		.start = WM831X_LDO4_CONTROL,
 		.end   = WM831X_LDO4_SLEEP_CONTROL,
@@ -789,7 +789,7 @@ static struct resource wm831x_ldo4_resources[] = {
 	},
 };
 
-static struct resource wm831x_ldo5_resources[] = {
+static const struct resource wm831x_ldo5_resources[] = {
 	{
 		.start = WM831X_LDO5_CONTROL,
 		.end   = WM831X_LDO5_SLEEP_CONTROL,
@@ -803,7 +803,7 @@ static struct resource wm831x_ldo5_resources[] = {
 	},
 };
 
-static struct resource wm831x_ldo6_resources[] = {
+static const struct resource wm831x_ldo6_resources[] = {
 	{
 		.start = WM831X_LDO6_CONTROL,
 		.end   = WM831X_LDO6_SLEEP_CONTROL,
@@ -817,7 +817,7 @@ static struct resource wm831x_ldo6_resources[] = {
 	},
 };
 
-static struct resource wm831x_ldo7_resources[] = {
+static const struct resource wm831x_ldo7_resources[] = {
 	{
 		.start = WM831X_LDO7_CONTROL,
 		.end   = WM831X_LDO7_SLEEP_CONTROL,
@@ -831,7 +831,7 @@ static struct resource wm831x_ldo7_resources[] = {
 	},
 };
 
-static struct resource wm831x_ldo8_resources[] = {
+static const struct resource wm831x_ldo8_resources[] = {
 	{
 		.start = WM831X_LDO8_CONTROL,
 		.end   = WM831X_LDO8_SLEEP_CONTROL,
@@ -845,7 +845,7 @@ static struct resource wm831x_ldo8_resources[] = {
 	},
 };
 
-static struct resource wm831x_ldo9_resources[] = {
+static const struct resource wm831x_ldo9_resources[] = {
 	{
 		.start = WM831X_LDO9_CONTROL,
 		.end   = WM831X_LDO9_SLEEP_CONTROL,
@@ -859,7 +859,7 @@ static struct resource wm831x_ldo9_resources[] = {
 	},
 };
 
-static struct resource wm831x_ldo10_resources[] = {
+static const struct resource wm831x_ldo10_resources[] = {
 	{
 		.start = WM831X_LDO10_CONTROL,
 		.end   = WM831X_LDO10_SLEEP_CONTROL,
@@ -873,7 +873,7 @@ static struct resource wm831x_ldo10_resources[] = {
 	},
 };
 
-static struct resource wm831x_ldo11_resources[] = {
+static const struct resource wm831x_ldo11_resources[] = {
 	{
 		.start = WM831X_LDO11_ON_CONTROL,
 		.end   = WM831X_LDO11_SLEEP_CONTROL,
@@ -881,7 +881,7 @@ static struct resource wm831x_ldo11_resources[] = {
 	},
 };
 
-static struct resource wm831x_on_resources[] = {
+static const struct resource wm831x_on_resources[] = {
 	{
 		.start = WM831X_IRQ_ON,
 		.end   = WM831X_IRQ_ON,
@@ -890,7 +890,7 @@ static struct resource wm831x_on_resources[] = {
 };
 
 
-static struct resource wm831x_power_resources[] = {
+static const struct resource wm831x_power_resources[] = {
 	{
 		.name = "SYSLO",
 		.start = WM831X_IRQ_PPM_SYSLO,
@@ -959,7 +959,7 @@ static struct resource wm831x_power_resources[] = {
 	},
 };
 
-static struct resource wm831x_rtc_resources[] = {
+static const struct resource wm831x_rtc_resources[] = {
 	{
 		.name = "PER",
 		.start = WM831X_IRQ_RTC_PER,
@@ -974,7 +974,7 @@ static struct resource wm831x_rtc_resources[] = {
 	},
 };
 
-static struct resource wm831x_status1_resources[] = {
+static const struct resource wm831x_status1_resources[] = {
 	{
 		.start = WM831X_STATUS_LED_1,
 		.end   = WM831X_STATUS_LED_1,
@@ -982,7 +982,7 @@ static struct resource wm831x_status1_resources[] = {
 	},
 };
 
-static struct resource wm831x_status2_resources[] = {
+static const struct resource wm831x_status2_resources[] = {
 	{
 		.start = WM831X_STATUS_LED_2,
 		.end   = WM831X_STATUS_LED_2,
@@ -990,7 +990,7 @@ static struct resource wm831x_status2_resources[] = {
 	},
 };
 
-static struct resource wm831x_touch_resources[] = {
+static const struct resource wm831x_touch_resources[] = {
 	{
 		.name = "TCHPD",
 		.start = WM831X_IRQ_TCHPD,
@@ -1005,7 +1005,7 @@ static struct resource wm831x_touch_resources[] = {
 	},
 };
 
-static struct resource wm831x_wdt_resources[] = {
+static const struct resource wm831x_wdt_resources[] = {
 	{
 		.start = WM831X_IRQ_WDOG_TO,
 		.end   = WM831X_IRQ_WDOG_TO,
drivers/mfd/wm8994-core.c +2 -2
index 3b2b93c5bbcb..e6d2319f15b6 100644
@@ -40,7 +40,7 @@ static const struct mfd_cell wm8994_regulator_devs[] = {
 	},
 };
 
-static struct resource wm8994_codec_resources[] = {
+static const struct resource wm8994_codec_resources[] = {
 	{
 		.start = WM8994_IRQ_TEMP_SHUT,
 		.end   = WM8994_IRQ_TEMP_WARN,
@@ -48,7 +48,7 @@ static struct resource wm8994_codec_resources[] = {
 	},
 };
 
-static struct resource wm8994_gpio_resources[] = {
+static const struct resource wm8994_gpio_resources[] = {
 	{
 		.start = WM8994_IRQ_GPIO(1),
 		.end   = WM8994_IRQ_GPIO(11),
Signature · 1 line
2.28.0
Acked-by on v1 4/8
#12 lore raw

Re: [PATCH 4/8] mfd: wm: Constify static struct resource

Quoted 7 lines · Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

---

Thanks,
Charles

Applied
#13 lore raw

Re: [PATCH 4/8] mfd: wm: Constify static struct resource

In reply to Rikard Falkeborn
Quoted 10 lines · Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/wm831x-core.c | 52 +++++++++++++++++++--------------------
 drivers/mfd/wm8994-core.c |  4 +--
 2 files changed, 28 insertions(+), 28 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#14 lore raw

PATCH 5/8 mfd: lp8788: Constify static struct resource

In reply to Rikard Falkeborn

Constify a couple of static struct resource. The only usage of the structs is to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/lp8788.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/lp8788.c +2 -2
index 768d556b3fe9..c223d2c6a363 100644
@@ -34,7 +34,7 @@
 	.num_resources = num_resource,				\
 }
 
-static struct resource chg_irqs[] = {
+static const struct resource chg_irqs[] = {
 	/* Charger Interrupts */
 	{
 		.start = LP8788_INT_CHG_INPUT_STATE,
@@ -58,7 +58,7 @@ static struct resource chg_irqs[] = {
 	},
 };
 
-static struct resource rtc_irqs[] = {
+static const struct resource rtc_irqs[] = {
 	{
 		.start = LP8788_INT_RTC_ALARM1,
 		.end   = LP8788_INT_RTC_ALARM2,
Signature · 1 line
2.28.0
Applied
#15 lore raw

Re: [PATCH 5/8] mfd: lp8788: Constify static struct resource

Quoted 9 lines · Rikard Falkeborn

Constify a couple of static struct resource. The only usage of the structs is to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/lp8788.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#16 lore raw

PATCH 6/8 mfd: stmpe: Constify static struct resource

In reply to Rikard Falkeborn

Constify a couple of static struct resource. The only usage of the structs is to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/stmpe.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mfd/stmpe.c +5 -5
index 1aee3b3253fc..90f3292230c9 100644
@@ -312,7 +312,7 @@ EXPORT_SYMBOL_GPL(stmpe_set_altfunc);
  * GPIO (all variants)
  */
 
-static struct resource stmpe_gpio_resources[] = {
+static const struct resource stmpe_gpio_resources[] = {
 	/* Start and end filled dynamically */
 	{
 		.flags	= IORESOURCE_IRQ,
@@ -336,7 +336,7 @@ static const struct mfd_cell stmpe_gpio_cell_noirq = {
  * Keypad (1601, 2401, 2403)
  */
 
-static struct resource stmpe_keypad_resources[] = {
+static const struct resource stmpe_keypad_resources[] = {
 	{
 		.name	= "KEYPAD",
 		.flags	= IORESOURCE_IRQ,
@@ -357,7 +357,7 @@ static const struct mfd_cell stmpe_keypad_cell = {
 /*
  * PWM (1601, 2401, 2403)
  */
-static struct resource stmpe_pwm_resources[] = {
+static const struct resource stmpe_pwm_resources[] = {
 	{
 		.name	= "PWM0",
 		.flags	= IORESOURCE_IRQ,
@@ -445,7 +445,7 @@ static struct stmpe_variant_info stmpe801_noirq = {
  * Touchscreen (STMPE811 or STMPE610)
  */
 
-static struct resource stmpe_ts_resources[] = {
+static const struct resource stmpe_ts_resources[] = {
 	{
 		.name	= "TOUCH_DET",
 		.flags	= IORESOURCE_IRQ,
@@ -467,7 +467,7 @@ static const struct mfd_cell stmpe_ts_cell = {
  * ADC (STMPE811)
  */
 
-static struct resource stmpe_adc_resources[] = {
+static const struct resource stmpe_adc_resources[] = {
 	{
 		.name	= "STMPE_TEMP_SENS",
 		.flags	= IORESOURCE_IRQ,
Signature · 1 line
2.28.0
Applied
#17 lore raw

Re: [PATCH 6/8] mfd: stmpe: Constify static struct resource

Quoted 9 lines · Rikard Falkeborn

Constify a couple of static struct resource. The only usage of the structs is to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/stmpe.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#18 lore raw

PATCH 7/8 mfd: sun4i-gpadc: Constify static struct resource

In reply to Rikard Falkeborn

Constify adc_resources[]. The only usage is to assign its address to the resources field of the mfd_cell struct. This allows the compiler to put it in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/sun4i-gpadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/sun4i-gpadc.c +1 -1
index b346fbce3c01..aaa233d916b2 100644
@@ -18,7 +18,7 @@
 #define ARCH_SUN5I_A13 1
 #define ARCH_SUN6I_A31 2
 
-static struct resource adc_resources[] = {
+static const struct resource adc_resources[] = {
 	DEFINE_RES_IRQ_NAMED(SUN4I_GPADC_IRQ_FIFO_DATA, "FIFO_DATA_PENDING"),
 	DEFINE_RES_IRQ_NAMED(SUN4I_GPADC_IRQ_TEMP_DATA, "TEMP_DATA_PENDING"),
 };
Signature · 1 line
2.28.0
Applied
#19 lore raw

Re: [PATCH 7/8] mfd: sun4i-gpadc: Constify static struct resource

Quoted 8 lines · Rikard Falkeborn

Constify adc_resources[]. The only usage is to assign its address to the resources field of the mfd_cell struct. This allows the compiler to put it in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/sun4i-gpadc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#20 lore raw

PATCH 8/8 mfd: Constify static struct resource

In reply to Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/88pm800.c              |  2 +-
 drivers/mfd/88pm860x-core.c        | 50 +++++++++++++-------------
 drivers/mfd/hi655x-pmic.c          |  2 +-
 drivers/mfd/intel_quark_i2c_gpio.c |  4 +--
 drivers/mfd/ioc3.c                 | 16 ++++-----
 drivers/mfd/max8925-core.c         | 56 +++++++++++++++---------------
 drivers/mfd/rdc321x-southbridge.c  |  4 +--
 drivers/mfd/retu-mfd.c             |  4 +--
 drivers/mfd/rk808.c                |  8 ++---
 drivers/mfd/tc3589x.c              |  4 +--
 drivers/mfd/tc6387xb.c             |  2 +-
 drivers/mfd/tc6393xb.c             |  6 ++--
 drivers/mfd/tps65090.c             |  2 +-
 drivers/mfd/tps6586x.c             |  2 +-
 drivers/mfd/tps80031.c             |  2 +-
 15 files changed, 82 insertions(+), 82 deletions(-)
drivers/mfd/88pm800.c +1 -1
index 4e8d0d6b9b5c..c7f964996a91 100644
@@ -121,7 +121,7 @@ static const struct i2c_device_id pm80x_id_table[] = {
 };
 MODULE_DEVICE_TABLE(i2c, pm80x_id_table);
 
-static struct resource rtc_resources[] = {
+static const struct resource rtc_resources[] = {
 	{
 	 .name = "88pm80x-rtc",
 	 .start = PM800_IRQ_RTC,
drivers/mfd/88pm860x-core.c +25 -25

124 lines not on this page · raw message

drivers/mfd/hi655x-pmic.c +1 -1
index 7e3959aaa285..d3c86a7a3805 100644
@@ -49,7 +49,7 @@ static struct regmap_config hi655x_regmap_config = {
 	.max_register = HI655X_BUS_ADDR(0x400) - HI655X_STRIDE,
 };
 
-static struct resource pwrkey_resources[] = {
+static const struct resource pwrkey_resources[] = {
 	{
 		.name	= "down",
 		.start	= PWRON_D20R_INT,
drivers/mfd/intel_quark_i2c_gpio.c +2 -2
index 84ca7902e1df..fe8ca945f367 100644
@@ -72,7 +72,7 @@ static const struct dmi_system_id dmi_platform_info[] = {
 	{}
 };
 
-static struct resource intel_quark_i2c_res[] = {
+static const struct resource intel_quark_i2c_res[] = {
 	[INTEL_QUARK_IORES_MEM] = {
 		.flags = IORESOURCE_MEM,
 	},
@@ -85,7 +85,7 @@ static struct mfd_cell_acpi_match intel_quark_acpi_match_i2c = {
 	.adr = MFD_ACPI_MATCH_I2C,
 };
 
-static struct resource intel_quark_gpio_res[] = {
+static const struct resource intel_quark_gpio_res[] = {
 	[INTEL_QUARK_IORES_MEM] = {
 		.flags = IORESOURCE_MEM,
 	},
drivers/mfd/ioc3.c +8 -8
index d939ccc46509..c73ec78f255b 100644
@@ -158,13 +158,13 @@ static int ioc3_irq_domain_setup(struct ioc3_priv_data *ipd, int irq)
 	return -ENOMEM;
 }
 
-static struct resource ioc3_uarta_resources[] = {
+static const struct resource ioc3_uarta_resources[] = {
 	DEFINE_RES_MEM(offsetof(struct ioc3, sregs.uarta),
 		       sizeof_field(struct ioc3, sregs.uarta)),
 	DEFINE_RES_IRQ(IOC3_IRQ_SERIAL_A)
 };
 
-static struct resource ioc3_uartb_resources[] = {
+static const struct resource ioc3_uartb_resources[] = {
 	DEFINE_RES_MEM(offsetof(struct ioc3, sregs.uartb),
 		       sizeof_field(struct ioc3, sregs.uartb)),
 	DEFINE_RES_IRQ(IOC3_IRQ_SERIAL_B)
@@ -213,7 +213,7 @@ static int ioc3_serial_setup(struct ioc3_priv_data *ipd)
 	return 0;
 }
 
-static struct resource ioc3_kbd_resources[] = {
+static const struct resource ioc3_kbd_resources[] = {
 	DEFINE_RES_MEM(offsetof(struct ioc3, serio),
 		       sizeof_field(struct ioc3, serio)),
 	DEFINE_RES_IRQ(IOC3_IRQ_KBD)
@@ -242,7 +242,7 @@ static int ioc3_kbd_setup(struct ioc3_priv_data *ipd)
 	return 0;
 }
 
-static struct resource ioc3_eth_resources[] = {
+static const struct resource ioc3_eth_resources[] = {
 	DEFINE_RES_MEM(offsetof(struct ioc3, eth),
 		       sizeof_field(struct ioc3, eth)),
 	DEFINE_RES_MEM(offsetof(struct ioc3, ssram),
@@ -250,7 +250,7 @@ static struct resource ioc3_eth_resources[] = {
 	DEFINE_RES_IRQ(0)
 };
 
-static struct resource ioc3_w1_resources[] = {
+static const struct resource ioc3_w1_resources[] = {
 	DEFINE_RES_MEM(offsetof(struct ioc3, mcr),
 		       sizeof_field(struct ioc3, mcr)),
 };
@@ -294,7 +294,7 @@ static int ioc3_eth_setup(struct ioc3_priv_data *ipd)
 	return 0;
 }
 
-static struct resource ioc3_m48t35_resources[] = {
+static const struct resource ioc3_m48t35_resources[] = {
 	DEFINE_RES_MEM(IOC3_BYTEBUS_DEV0, M48T35_REG_SIZE)
 };
 
@@ -326,7 +326,7 @@ static struct ds1685_rtc_platform_data ip30_rtc_platform_data = {
 	.access_type = ds1685_reg_indirect,
 };
 
-static struct resource ioc3_rtc_ds1685_resources[] = {
+static const struct resource ioc3_rtc_ds1685_resources[] = {
 	DEFINE_RES_MEM(IOC3_BYTEBUS_DEV1, 1),
 	DEFINE_RES_MEM(IOC3_BYTEBUS_DEV2, 1),
 	DEFINE_RES_IRQ(0)
@@ -359,7 +359,7 @@ static int ioc3_ds1685_setup(struct ioc3_priv_data *ipd)
 };
 
 
-static struct resource ioc3_leds_resources[] = {
+static const struct resource ioc3_leds_resources[] = {
 	DEFINE_RES_MEM(offsetof(struct ioc3, gppr[0]),
 		       sizeof_field(struct ioc3, gppr[0])),
 	DEFINE_RES_MEM(offsetof(struct ioc3, gppr[1]),
drivers/mfd/max8925-core.c +28 -28

158 lines not on this page · raw message

drivers/mfd/rdc321x-southbridge.c +2 -2
index fbb1faf95e27..c44a76285147 100644
@@ -14,7 +14,7 @@
 
 static struct rdc321x_wdt_pdata rdc321x_wdt_pdata;
 
-static struct resource rdc321x_wdt_resource[] = {
+static const struct resource rdc321x_wdt_resource[] = {
 	{
 		.name	= "wdt-reg",
 		.start	= RDC321X_WDT_CTRL,
@@ -27,7 +27,7 @@ static struct rdc321x_gpio_pdata rdc321x_gpio_pdata = {
 	.max_gpios	= RDC321X_NUM_GPIO,
 };
 
-static struct resource rdc321x_gpio_resources[] = {
+static const struct resource rdc321x_gpio_resources[] = {
 	{
 		.name	= "gpio-reg1",
 		.start	= RDC321X_GPIO_CTRL_REG1,
drivers/mfd/retu-mfd.c +2 -2
index e7d27b7861c1..c748fd29a220 100644
@@ -45,7 +45,7 @@ struct retu_dev {
 	struct regmap_irq_chip_data	*irq_data;
 };
 
-static struct resource retu_pwrbutton_res[] = {
+static const struct resource retu_pwrbutton_res[] = {
 	{
 		.name	= "retu-pwrbutton",
 		.start	= RETU_INT_PWR,
@@ -84,7 +84,7 @@ static struct regmap_irq_chip retu_irq_chip = {
 /* Retu device registered for the power off. */
 static struct retu_dev *retu_pm_power_off;
 
-static struct resource tahvo_usb_res[] = {
+static const struct resource tahvo_usb_res[] = {
 	{
 		.name	= "tahvo-usb",
 		.start	= TAHVO_INT_VBUS,
drivers/mfd/rk808.c +4 -4
index d109b9f14407..ad923dd4e007 100644
@@ -107,20 +107,20 @@ static const struct regmap_config rk817_regmap_config = {
 	.volatile_reg = rk817_is_volatile_reg,
 };
 
-static struct resource rtc_resources[] = {
+static const struct resource rtc_resources[] = {
 	DEFINE_RES_IRQ(RK808_IRQ_RTC_ALARM),
 };
 
-static struct resource rk817_rtc_resources[] = {
+static const struct resource rk817_rtc_resources[] = {
 	DEFINE_RES_IRQ(RK817_IRQ_RTC_ALARM),
 };
 
-static struct resource rk805_key_resources[] = {
+static const struct resource rk805_key_resources[] = {
 	DEFINE_RES_IRQ(RK805_IRQ_PWRON_RISE),
 	DEFINE_RES_IRQ(RK805_IRQ_PWRON_FALL),
 };
 
-static struct resource rk817_pwrkey_resources[] = {
+static const struct resource rk817_pwrkey_resources[] = {
 	DEFINE_RES_IRQ(RK817_IRQ_PWRON_RISE),
 	DEFINE_RES_IRQ(RK817_IRQ_PWRON_FALL),
 };
drivers/mfd/tc3589x.c +2 -2
index 7882a37ffc35..7614f8fe0e91 100644
@@ -141,7 +141,7 @@ int tc3589x_set_bits(struct tc3589x *tc3589x, u8 reg, u8 mask, u8 val)
 }
 EXPORT_SYMBOL_GPL(tc3589x_set_bits);
 
-static struct resource gpio_resources[] = {
+static const struct resource gpio_resources[] = {
 	{
 		.start	= TC3589x_INT_GPIIRQ,
 		.end	= TC3589x_INT_GPIIRQ,
@@ -149,7 +149,7 @@ static struct resource gpio_resources[] = {
 	},
 };
 
-static struct resource keypad_resources[] = {
+static const struct resource keypad_resources[] = {
 	{
 		.start  = TC3589x_INT_KBDIRQ,
 		.end    = TC3589x_INT_KBDIRQ,
drivers/mfd/tc6387xb.c +1 -1
index c66a701ab21c..e846e4d26b6e 100644
@@ -25,7 +25,7 @@ struct tc6387xb {
 	struct resource rscr;
 };
 
-static struct resource tc6387xb_mmc_resources[] = {
+static const struct resource tc6387xb_mmc_resources[] = {
 	{
 		.start = 0x800,
 		.end   = 0x9ff,
drivers/mfd/tc6393xb.c +3 -3
index 05d5059ca203..3d5b14c60e20 100644
@@ -133,7 +133,7 @@ static int tc6393xb_nand_enable(struct platform_device *nand)
 	return 0;
 }
 
-static struct resource tc6393xb_nand_resources[] = {
+static const struct resource tc6393xb_nand_resources[] = {
 	{
 		.start	= 0x1000,
 		.end	= 0x1007,
@@ -151,7 +151,7 @@ static struct resource tc6393xb_nand_resources[] = {
 	},
 };
 
-static struct resource tc6393xb_mmc_resources[] = {
+static const struct resource tc6393xb_mmc_resources[] = {
 	{
 		.start	= 0x800,
 		.end	= 0x9ff,
@@ -192,7 +192,7 @@ static const struct resource tc6393xb_ohci_resources[] = {
 	},
 };
 
-static struct resource tc6393xb_fb_resources[] = {
+static const struct resource tc6393xb_fb_resources[] = {
 	{
 		.start	= 0x5000,
 		.end	= 0x51ff,
drivers/mfd/tps65090.c +1 -1
index 6cdf6c315034..bd6235308c6b 100644
@@ -38,7 +38,7 @@
 #define TPS65090_INT2_MASK_OVERLOAD_FET6		6
 #define TPS65090_INT2_MASK_OVERLOAD_FET7		7
 
-static struct resource charger_resources[] = {
+static const struct resource charger_resources[] = {
 	{
 		.start  = TPS65090_IRQ_VAC_STATUS_CHANGE,
 		.end    = TPS65090_IRQ_VAC_STATUS_CHANGE,
drivers/mfd/tps6586x.c +1 -1
index c36597797ddd..c9303d3d6602 100644
@@ -92,7 +92,7 @@ static const struct tps6586x_irq_data tps6586x_irqs[] = {
 	[TPS6586X_INT_RTC_ALM2] = TPS6586X_IRQ(TPS6586X_INT_MASK4, 1 << 1),
 };
 
-static struct resource tps6586x_rtc_resources[] = {
+static const struct resource tps6586x_rtc_resources[] = {
 	{
 		.start  = TPS6586X_INT_RTC_ALM1,
 		.end	= TPS6586X_INT_RTC_ALM1,
drivers/mfd/tps80031.c +1 -1
index 907452b86e32..902e33548dd0 100644
@@ -34,7 +34,7 @@
 #include <linux/regmap.h>
 #include <linux/slab.h>
 
-static struct resource tps80031_rtc_resources[] = {
+static const struct resource tps80031_rtc_resources[] = {
 	{
 		.start = TPS80031_INT_RTC_ALARM,
 		.end = TPS80031_INT_RTC_ALARM,
Signature · 1 line
2.28.0
Applied
#21 lore raw

Re: [PATCH 8/8] mfd: Constify static struct resource

Quoted 15 lines · Rikard Falkeborn

Constify a number of static struct resource. The only usage of the structs are to assign their address to the resources field in the mfd_cell struct. This allows the compiler to put them in read-only memory. Done with the help of Coccinelle.

---
 drivers/mfd/88pm800.c              |  2 +-
 drivers/mfd/88pm860x-core.c        | 50 +++++++++++++-------------
 drivers/mfd/hi655x-pmic.c          |  2 +-
 drivers/mfd/intel_quark_i2c_gpio.c |  4 +--
 drivers/mfd/ioc3.c                 | 16 ++++-----
 drivers/mfd/max8925-core.c         | 56 +++++++++++++++---------------
 drivers/mfd/rdc321x-southbridge.c  |  4 +--
 drivers/mfd/retu-mfd.c             |  4 +--
Quoted 8 lines
 drivers/mfd/rk808.c                |  8 ++---
 drivers/mfd/tc3589x.c              |  4 +--
 drivers/mfd/tc6387xb.c             |  2 +-
 drivers/mfd/tc6393xb.c             |  6 ++--
 drivers/mfd/tps65090.c             |  2 +-
 drivers/mfd/tps6586x.c             |  2 +-
 drivers/mfd/tps80031.c             |  2 +-
 15 files changed, 82 insertions(+), 82 deletions(-)

Applied, thanks.

Signature · 4 lines
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog