Re: [PATCH v4 1/4] mfd: wm831x: Support software nodes for DCDC regulators

From: Lee Jones

Date: Wed Nov 04 2026 - 13:19:21 EST


On Sat, 24 Oct 2026, Dmitry Torokhov wrote:

> Allow passing software nodes to wm831x DCDC regulators via PMIC platform
> data. This is useful for non-DT/non-ACPI platforms that want to
> associate device properties (like DVS GPIOs) with the regulator devices
> using software nodes.
>
> Add software node pointers to the PMIC platform data and have the MFD
> core assign them to the buckv cells.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
> ---
> drivers/mfd/wm831x-core.c | 47 ++++++++++++++++++++++++++++++----------
> include/linux/mfd/wm831x/pdata.h | 2 ++
> 2 files changed, 37 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mfd/wm831x-core.c b/drivers/mfd/wm831x-core.c
> index df8e76e000cc..c4793be419ba 100644
> --- a/drivers/mfd/wm831x-core.c
> +++ b/drivers/mfd/wm831x-core.c
> @@ -14,6 +14,7 @@
> #include <linux/delay.h>
> #include <linux/mfd/core.h>
> #include <linux/slab.h>
> +#include <linux/string.h>
> #include <linux/err.h>
>
> #include <linux/mfd/wm831x/core.h>
> @@ -1449,6 +1450,32 @@ const struct of_device_id wm831x_of_match[] = {
> };
> EXPORT_SYMBOL_GPL(wm831x_of_match);
>
> +static int wm831x_add_devices(struct wm831x *wm831x, int wm831x_num,
> + const struct mfd_cell *cells, int num_cells)
> +{
> + struct wm831x_pdata *pdata = &wm831x->pdata;
> + int i;
> +
> + struct mfd_cell *local_cells __free(kfree) =
> + kmemdup_array(cells, num_cells, sizeof(*cells), GFP_KERNEL);
> + if (!local_cells)
> + return -ENOMEM;
> +
> + for (i = 0; i < num_cells; i++) {
> + struct mfd_cell *cell = &local_cells[i];
> +
> + if (strcmp(cell->name, "wm831x-buckv") == 0) {
> + int id = cell->id - 1;
> +
> + if (id >= 0 && id < WM831X_MAX_DCDC)
> + cell->swnode = pdata->dcdc_swnodes[id];
> + }
> + }

I can't begin to tell you how much I hate this.

Why are we duplicating massive static const structs just to add a S/W
node? Is there no other way we can do this statically?

Since pdata is being populated already, why not just pass that on to the
consuming child device (the regulator)?

> + return mfd_add_devices(wm831x->dev, wm831x_num, local_cells, num_cells,
> + NULL, 0, NULL);
> +}

--
Lee Jones