Re: [PATCH v2 1/2] mfd: Constify mfd_cell arrays

From: Andy Shevchenko

Date: Sat Oct 31 2026 - 10:38:59 EST


On Fri, Oct 30, 2026 at 03:02:41PM +0100, Krzysztof Kozlowski wrote:
> mfd_add_devices() takes pointer to const, so 'struct mfd_cell' arrays
> can be constified whenever driver does not modify it in the probe.

...

> drivers/mfd/intel_soc_pmic_bxtwc.c | 2 +-
> drivers/mfd/intel_soc_pmic_chtdc_ti.c | 2 +-
> drivers/mfd/intel_soc_pmic_chtwc.c | 2 +-
> drivers/mfd/intel_soc_pmic_crc.c | 6 +++---

> --- a/drivers/mfd/intel_soc_pmic_bxtwc.c
> +++ b/drivers/mfd/intel_soc_pmic_bxtwc.c
> @@ -245,7 +245,7 @@ static const struct resource tmu_resources[] = {
> DEFINE_RES_IRQ_NAMED(BXTWC_TMU_IRQ, "TMU"),
> };
>
> -static struct mfd_cell bxt_wc_dev[] = {
> +static const struct mfd_cell bxt_wc_dev[] = {
> {
> .name = "bxt_wcove_thermal",
> .num_resources = ARRAY_SIZE(thermal_resources),
> diff --git a/drivers/mfd/intel_soc_pmic_chtdc_ti.c b/drivers/mfd/intel_soc_pmic_chtdc_ti.c
> index 6daf33e07ea0..8412a25d37ff 100644
> --- a/drivers/mfd/intel_soc_pmic_chtdc_ti.c
> +++ b/drivers/mfd/intel_soc_pmic_chtdc_ti.c
> @@ -53,7 +53,7 @@ static const struct resource battery_resources[] = {
> DEFINE_RES_IRQ(CHTDC_TI_CCEOCAL),
> };
>
> -static struct mfd_cell chtdc_ti_dev[] = {
> +static const struct mfd_cell chtdc_ti_dev[] = {
> {
> .name = "chtdc_ti_pwrbtn",
> .num_resources = ARRAY_SIZE(power_button_resources),
> diff --git a/drivers/mfd/intel_soc_pmic_chtwc.c b/drivers/mfd/intel_soc_pmic_chtwc.c
> index aa71a7d83fcd..f27985a58c87 100644
> --- a/drivers/mfd/intel_soc_pmic_chtwc.c
> +++ b/drivers/mfd/intel_soc_pmic_chtwc.c
> @@ -50,7 +50,7 @@ static const struct resource cht_wc_ext_charger_resources[] = {
> DEFINE_RES_IRQ(CHT_WC_EXT_CHGR_IRQ),
> };
>
> -static struct mfd_cell cht_wc_dev[] = {
> +static const struct mfd_cell cht_wc_dev[] = {
> {
> .name = "cht_wcove_pwrsrc",
> .num_resources = ARRAY_SIZE(cht_wc_pwrsrc_resources),
> diff --git a/drivers/mfd/intel_soc_pmic_crc.c b/drivers/mfd/intel_soc_pmic_crc.c
> index 627a89334908..ce4c9ef59198 100644
> --- a/drivers/mfd/intel_soc_pmic_crc.c
> +++ b/drivers/mfd/intel_soc_pmic_crc.c
> @@ -54,7 +54,7 @@ static const struct resource gpio_resources[] = {
> DEFINE_RES_IRQ_NAMED(CRYSTAL_COVE_IRQ_GPIO, "GPIO"),
> };
>
> -static struct mfd_cell crystal_cove_byt_dev[] = {
> +static const struct mfd_cell crystal_cove_byt_dev[] = {
> {
> .name = "crystal_cove_pwrsrc",
> .num_resources = ARRAY_SIZE(pwrsrc_resources),
> @@ -93,7 +93,7 @@ static struct mfd_cell crystal_cove_byt_dev[] = {
> },
> };
>
> -static struct mfd_cell crystal_cove_cht_dev[] = {
> +static const struct mfd_cell crystal_cove_cht_dev[] = {
> {
> .name = "crystal_cove_gpio",
> .num_resources = ARRAY_SIZE(gpio_resources),
> @@ -142,7 +142,7 @@ static struct pwm_lookup crc_pwm_lookup[] = {
>
> struct crystal_cove_config {
> unsigned long irq_flags;
> - struct mfd_cell *cell_dev;
> + const struct mfd_cell *cell_dev;
> int n_cell_devs;
> const struct regmap_config *regmap_config;
> const struct regmap_irq_chip *irq_chip;

I haven't compiled, but I checked the code in the actual drivers and my reading
confirms that these structures may need to be marked with const qualifier.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> # Intel SoC PMIC drivers

--
With Best Regards,
Andy Shevchenko