Skip to content

Commit

Permalink
mfd: Constify static struct resources
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
  • Loading branch information
rikardfalkeborn authored and Lee Jones committed Nov 19, 2020
1 parent 4bdcbbb commit c4a164f
Show file tree
Hide file tree
Showing 15 changed files with 82 additions and 82 deletions.
2 changes: 1 addition & 1 deletion drivers/mfd/88pm800.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
50 changes: 25 additions & 25 deletions drivers/mfd/88pm860x-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,99 +26,99 @@

#define INT_STATUS_NUM 3

static struct resource bk0_resources[] = {
static const struct resource bk0_resources[] = {
{2, 2, "duty cycle", IORESOURCE_REG, },
{3, 3, "always on", IORESOURCE_REG, },
{3, 3, "current", IORESOURCE_REG, },
};
static struct resource bk1_resources[] = {
static const struct resource bk1_resources[] = {
{4, 4, "duty cycle", IORESOURCE_REG, },
{5, 5, "always on", IORESOURCE_REG, },
{5, 5, "current", IORESOURCE_REG, },
};
static struct resource bk2_resources[] = {
static const struct resource bk2_resources[] = {
{6, 6, "duty cycle", IORESOURCE_REG, },
{7, 7, "always on", IORESOURCE_REG, },
{5, 5, "current", IORESOURCE_REG, },
};

static struct resource led0_resources[] = {
static const struct resource led0_resources[] = {
/* RGB1 Red LED */
{0xd, 0xd, "control", IORESOURCE_REG, },
{0xc, 0xc, "blink", IORESOURCE_REG, },
};
static struct resource led1_resources[] = {
static const struct resource led1_resources[] = {
/* RGB1 Green LED */
{0xe, 0xe, "control", IORESOURCE_REG, },
{0xc, 0xc, "blink", IORESOURCE_REG, },
};
static struct resource led2_resources[] = {
static const struct resource led2_resources[] = {
/* RGB1 Blue LED */
{0xf, 0xf, "control", IORESOURCE_REG, },
{0xc, 0xc, "blink", IORESOURCE_REG, },
};
static struct resource led3_resources[] = {
static const struct resource led3_resources[] = {
/* RGB2 Red LED */
{0x9, 0x9, "control", IORESOURCE_REG, },
{0x8, 0x8, "blink", IORESOURCE_REG, },
};
static struct resource led4_resources[] = {
static const struct resource led4_resources[] = {
/* RGB2 Green LED */
{0xa, 0xa, "control", IORESOURCE_REG, },
{0x8, 0x8, "blink", IORESOURCE_REG, },
};
static struct resource led5_resources[] = {
static const struct resource led5_resources[] = {
/* RGB2 Blue LED */
{0xb, 0xb, "control", IORESOURCE_REG, },
{0x8, 0x8, "blink", IORESOURCE_REG, },
};

static struct resource buck1_resources[] = {
static const struct resource buck1_resources[] = {
{0x24, 0x24, "buck set", IORESOURCE_REG, },
};
static struct resource buck2_resources[] = {
static const struct resource buck2_resources[] = {
{0x25, 0x25, "buck set", IORESOURCE_REG, },
};
static struct resource buck3_resources[] = {
static const struct resource buck3_resources[] = {
{0x26, 0x26, "buck set", IORESOURCE_REG, },
};
static struct resource ldo1_resources[] = {
static const struct resource ldo1_resources[] = {
{0x10, 0x10, "ldo set", IORESOURCE_REG, },
};
static struct resource ldo2_resources[] = {
static const struct resource ldo2_resources[] = {
{0x11, 0x11, "ldo set", IORESOURCE_REG, },
};
static struct resource ldo3_resources[] = {
static const struct resource ldo3_resources[] = {
{0x12, 0x12, "ldo set", IORESOURCE_REG, },
};
static struct resource ldo4_resources[] = {
static const struct resource ldo4_resources[] = {
{0x13, 0x13, "ldo set", IORESOURCE_REG, },
};
static struct resource ldo5_resources[] = {
static const struct resource ldo5_resources[] = {
{0x14, 0x14, "ldo set", IORESOURCE_REG, },
};
static struct resource ldo6_resources[] = {
static const struct resource ldo6_resources[] = {
{0x15, 0x15, "ldo set", IORESOURCE_REG, },
};
static struct resource ldo7_resources[] = {
static const struct resource ldo7_resources[] = {
{0x16, 0x16, "ldo set", IORESOURCE_REG, },
};
static struct resource ldo8_resources[] = {
static const struct resource ldo8_resources[] = {
{0x17, 0x17, "ldo set", IORESOURCE_REG, },
};
static struct resource ldo9_resources[] = {
static const struct resource ldo9_resources[] = {
{0x18, 0x18, "ldo set", IORESOURCE_REG, },
};
static struct resource ldo10_resources[] = {
static const struct resource ldo10_resources[] = {
{0x19, 0x19, "ldo set", IORESOURCE_REG, },
};
static struct resource ldo12_resources[] = {
static const struct resource ldo12_resources[] = {
{0x1a, 0x1a, "ldo set", IORESOURCE_REG, },
};
static struct resource ldo_vibrator_resources[] = {
static const struct resource ldo_vibrator_resources[] = {
{0x28, 0x28, "ldo set", IORESOURCE_REG, },
};
static struct resource ldo14_resources[] = {
static const struct resource ldo14_resources[] = {
{0x1b, 0x1b, "ldo set", IORESOURCE_REG, },
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/mfd/hi655x-pmic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions drivers/mfd/intel_quark_i2c_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand All @@ -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,
},
Expand Down
16 changes: 8 additions & 8 deletions drivers/mfd/ioc3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -242,15 +242,15 @@ 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),
sizeof_field(struct ioc3, ssram)),
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)),
};
Expand Down Expand Up @@ -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)
};

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]),
Expand Down
56 changes: 28 additions & 28 deletions drivers/mfd/max8925-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <linux/of.h>
#include <linux/of_platform.h>

static struct resource bk_resources[] = {
static const struct resource bk_resources[] = {
{ 0x84, 0x84, "mode control", IORESOURCE_REG, },
{ 0x85, 0x85, "control", IORESOURCE_REG, },
};
Expand All @@ -33,7 +33,7 @@ static struct mfd_cell bk_devs[] = {
},
};

static struct resource touch_resources[] = {
static const struct resource touch_resources[] = {
{
.name = "max8925-tsc",
.start = MAX8925_TSC_IRQ,
Expand All @@ -51,7 +51,7 @@ static const struct mfd_cell touch_devs[] = {
},
};

static struct resource power_supply_resources[] = {
static const struct resource power_supply_resources[] = {
{
.name = "max8925-power",
.start = MAX8925_CHG_IRQ1,
Expand All @@ -69,7 +69,7 @@ static const struct mfd_cell power_devs[] = {
},
};

static struct resource rtc_resources[] = {
static const struct resource rtc_resources[] = {
{
.name = "max8925-rtc",
.start = MAX8925_IRQ_RTC_ALARM0,
Expand All @@ -87,7 +87,7 @@ static const struct mfd_cell rtc_devs[] = {
},
};

static struct resource onkey_resources[] = {
static const struct resource onkey_resources[] = {
{
.name = "max8925-onkey",
.start = MAX8925_IRQ_GPM_SW_R,
Expand All @@ -110,95 +110,95 @@ static const struct mfd_cell onkey_devs[] = {
},
};

static struct resource sd1_resources[] = {
static const struct resource sd1_resources[] = {
{0x06, 0x06, "sdv", IORESOURCE_REG, },
};

static struct resource sd2_resources[] = {
static const struct resource sd2_resources[] = {
{0x09, 0x09, "sdv", IORESOURCE_REG, },
};

static struct resource sd3_resources[] = {
static const struct resource sd3_resources[] = {
{0x0c, 0x0c, "sdv", IORESOURCE_REG, },
};

static struct resource ldo1_resources[] = {
static const struct resource ldo1_resources[] = {
{0x1a, 0x1a, "ldov", IORESOURCE_REG, },
};

static struct resource ldo2_resources[] = {
static const struct resource ldo2_resources[] = {
{0x1e, 0x1e, "ldov", IORESOURCE_REG, },
};

static struct resource ldo3_resources[] = {
static const struct resource ldo3_resources[] = {
{0x22, 0x22, "ldov", IORESOURCE_REG, },
};

static struct resource ldo4_resources[] = {
static const struct resource ldo4_resources[] = {
{0x26, 0x26, "ldov", IORESOURCE_REG, },
};

static struct resource ldo5_resources[] = {
static const struct resource ldo5_resources[] = {
{0x2a, 0x2a, "ldov", IORESOURCE_REG, },
};

static struct resource ldo6_resources[] = {
static const struct resource ldo6_resources[] = {
{0x2e, 0x2e, "ldov", IORESOURCE_REG, },
};

static struct resource ldo7_resources[] = {
static const struct resource ldo7_resources[] = {
{0x32, 0x32, "ldov", IORESOURCE_REG, },
};

static struct resource ldo8_resources[] = {
static const struct resource ldo8_resources[] = {
{0x36, 0x36, "ldov", IORESOURCE_REG, },
};

static struct resource ldo9_resources[] = {
static const struct resource ldo9_resources[] = {
{0x3a, 0x3a, "ldov", IORESOURCE_REG, },
};

static struct resource ldo10_resources[] = {
static const struct resource ldo10_resources[] = {
{0x3e, 0x3e, "ldov", IORESOURCE_REG, },
};

static struct resource ldo11_resources[] = {
static const struct resource ldo11_resources[] = {
{0x42, 0x42, "ldov", IORESOURCE_REG, },
};

static struct resource ldo12_resources[] = {
static const struct resource ldo12_resources[] = {
{0x46, 0x46, "ldov", IORESOURCE_REG, },
};

static struct resource ldo13_resources[] = {
static const struct resource ldo13_resources[] = {
{0x4a, 0x4a, "ldov", IORESOURCE_REG, },
};

static struct resource ldo14_resources[] = {
static const struct resource ldo14_resources[] = {
{0x4e, 0x4e, "ldov", IORESOURCE_REG, },
};

static struct resource ldo15_resources[] = {
static const struct resource ldo15_resources[] = {
{0x52, 0x52, "ldov", IORESOURCE_REG, },
};

static struct resource ldo16_resources[] = {
static const struct resource ldo16_resources[] = {
{0x12, 0x12, "ldov", IORESOURCE_REG, },
};

static struct resource ldo17_resources[] = {
static const struct resource ldo17_resources[] = {
{0x16, 0x16, "ldov", IORESOURCE_REG, },
};

static struct resource ldo18_resources[] = {
static const struct resource ldo18_resources[] = {
{0x74, 0x74, "ldov", IORESOURCE_REG, },
};

static struct resource ldo19_resources[] = {
static const struct resource ldo19_resources[] = {
{0x5e, 0x5e, "ldov", IORESOURCE_REG, },
};

static struct resource ldo20_resources[] = {
static const struct resource ldo20_resources[] = {
{0x9e, 0x9e, "ldov", IORESOURCE_REG, },
};

Expand Down
Loading

0 comments on commit c4a164f

Please sign in to comment.