Re: [PATCH 1/2] mfd: ucb1x00: register software node for GPIO controller

From: Bartosz Golaszewski

Date: Tue Jul 07 2026 - 04:17:15 EST


On Tue, 7 Jul 2026 01:08:04 +0200, Dmitry Torokhov
<dmitry.torokhov@xxxxxxxxx> said:
> Define a static software node for the UCB1x00 GPIO controller and attach
> it to the core MFD device in ucb1x00_probe(). This node will also be
> used by the created GPIO chip.
>
> This allows machine subdrivers (such as Assabet evaluation board
> support) to reference the UCB1x00 GPIO controller in property entries
> when converting legacy platform data to software nodes, resolving pin
> bindings directly via the attached firmware node without relying on
> name matching.
>
> Assisted-by: Antigravity:gemini-3.5-flash
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
> ---
> drivers/mfd/ucb1x00-core.c | 12 ++++++++++++
> include/linux/mfd/ucb1x00.h | 3 +++
> 2 files changed, 15 insertions(+)
>
> diff --git a/drivers/mfd/ucb1x00-core.c b/drivers/mfd/ucb1x00-core.c
> index 16f64e2b2f77..8d1c34c53955 100644
> --- a/drivers/mfd/ucb1x00-core.c
> +++ b/drivers/mfd/ucb1x00-core.c
> @@ -25,8 +25,13 @@
> #include <linux/mutex.h>
> #include <linux/mfd/ucb1x00.h>
> #include <linux/pm.h>
> +#include <linux/property.h>
> #include <linux/gpio/driver.h>
>
> +const struct software_node ucb1x00_gpiochip_node = {
> + .name = "ucb1x00-gpio",
> +};
> +
> static DEFINE_MUTEX(ucb1x00_mutex);
> static LIST_HEAD(ucb1x00_drivers);
> static LIST_HEAD(ucb1x00_devices);
> @@ -530,6 +535,10 @@ static int ucb1x00_probe(struct mcp *mcp)
> ucb->id = id;
> ucb->mcp = mcp;
>
> + ret = device_add_software_node(&ucb->dev, &ucb1x00_gpiochip_node);
> + if (ret)
> + goto err_swnode_add;
> +
> ret = device_add(&ucb->dev);
> if (ret)
> goto err_dev_add;
> @@ -604,6 +613,8 @@ static int ucb1x00_probe(struct mcp *mcp)
> err_no_irq:
> device_del(&ucb->dev);
> err_dev_add:
> + device_remove_software_node(&ucb->dev);
> + err_swnode_add:
> put_device(&ucb->dev);
> out:
> if (pdata && pdata->reset)
> @@ -630,6 +641,7 @@ static void ucb1x00_remove(struct mcp *mcp)
>
> irq_set_chained_handler(ucb->irq, NULL);
> irq_free_descs(ucb->irq_base, 16);
> + device_remove_software_node(&ucb->dev);
> device_unregister(&ucb->dev);
>
> if (pdata && pdata->reset)
> diff --git a/include/linux/mfd/ucb1x00.h b/include/linux/mfd/ucb1x00.h
> index ede237384723..214c71a12e84 100644
> --- a/include/linux/mfd/ucb1x00.h
> +++ b/include/linux/mfd/ucb1x00.h
> @@ -103,6 +103,9 @@
> #define UCB_MODE_DYN_VFLAG_ENA (1 << 12)
> #define UCB_MODE_AUD_OFF_CAN (1 << 13)
>
> +struct software_node;

Like I commented elsewhere, my preference for forward declarations is to have
them right under the includes but I won't die on that hill.

Bart

> +extern const struct software_node ucb1x00_gpiochip_node;
> +
> enum ucb1x00_reset {
> UCB_RST_PROBE,
> UCB_RST_RESUME,
>
> --
> 2.55.0.rc2.803.g1fd1e6609c-goog
>
>