Re: [PATCH 1/3] bcma: gpio: Add and register software node for GPIO controller

From: Bartosz Golaszewski

Date: Mon Jul 06 2026 - 06:13:14 EST


On Sun, 5 Jul 2026 07:25:08 +0200, Dmitry Torokhov
<dmitry.torokhov@xxxxxxxxx> said:
> We want to convert the legacy gpio-keys platform device on BCM47XX
> boards to use software nodes. To do this properly and allow
> referencing the GPIO controller by address rather than relying on
> name-based matching (which is being removed from the gpiolib core),
> we need to associate the GPIO controller with a software node.
>
> Introduce bcma_gpio_swnode, register it if the device does not
> already have a firmware node, and associate it with the gpio_chip.
>
> Assisted-by: Antigravity:gemini-3.5-flash
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
> ---
> drivers/bcma/driver_gpio.c | 17 ++++++++++++++++-
> include/linux/bcma/bcma.h | 3 +++
> 2 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/bcma/driver_gpio.c b/drivers/bcma/driver_gpio.c
> index 658c7e2ac8bf..0dad8d6dbe5a 100644
> --- a/drivers/bcma/driver_gpio.c
> +++ b/drivers/bcma/driver_gpio.c
> @@ -19,6 +19,11 @@
>
> #define BCMA_GPIO_MAX_PINS 32
>
> +const struct software_node bcma_gpio_swnode = {
> + .name = "bcma-gpio",
> +};
> +EXPORT_SYMBOL_GPL(bcma_gpio_swnode);
> +
> static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
> {
> struct bcma_drv_cc *cc = gpiochip_get_data(chip);
> @@ -190,7 +195,15 @@ int bcma_gpio_init(struct bcma_drv_cc *cc)
> chip->direction_input = bcma_gpio_direction_input;
> chip->direction_output = bcma_gpio_direction_output;
> chip->parent = bus->dev;
> - chip->fwnode = dev_fwnode(&cc->core->dev);
> +
> + if (!dev_fwnode(&cc->core->dev)) {
> + err = software_node_register(&bcma_gpio_swnode);
> + if (err)
> + return err;
> + chip->fwnode = software_node_fwnode(&bcma_gpio_swnode);
> + } else {
> + chip->fwnode = dev_fwnode(&cc->core->dev);
> + }
>
> switch (bus->chipinfo.id) {
> case BCMA_CHIP_ID_BCM4707:
> @@ -234,5 +247,7 @@ int bcma_gpio_unregister(struct bcma_drv_cc *cc)
> {
> bcma_gpio_irq_exit(cc);
> gpiochip_remove(&cc->gpio);
> + if (cc->gpio.fwnode && is_software_node(cc->gpio.fwnode))
> + software_node_unregister(&bcma_gpio_swnode);
> return 0;
> }
> diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
> index f02cb3909375..aa88c2d64bfb 100644
> --- a/include/linux/bcma/bcma.h
> +++ b/include/linux/bcma/bcma.h
> @@ -486,4 +486,7 @@ extern u32 bcma_core_dma_translation(struct bcma_device *core);
>
> extern unsigned int bcma_core_irq(struct bcma_device *core, int num);
>
> +struct software_node;

Maybe move the forward declaration to the top of the file as is customary?

> +extern const struct software_node bcma_gpio_swnode;
> +
> #endif /* LINUX_BCMA_H_ */
>
> --
> 2.55.0.rc0.799.gd6f94ed593-goog
>
>

Bart