Re: [PATCH] leds: simatic-ipc-leds-gpio: make sure we have the GPIO providing driver

From: Henning Schild
Date: Fri Aug 05 2022 - 08:20:15 EST


This applies on top of
"[PATCH v6 00/12] platform/x86: introduce p2sb_bar() helper"

where it could also be squashed into p12.

Am Fri, 5 Aug 2022 14:03:43 +0200
schrieb Henning Schild <henning.schild@xxxxxxxxxxx>:

> If we register a "leds-gpio" platform device for GPIO pins that do not
> exist we get a -EPROBE_DEFER and the probe will be tried again later.
> If there is not driver to provide that pin we will poll forever and
> also create a lot of log messages.

When i did build a kernel without PINCTRL_BROXTON and booted that, i
quickly filled up my disk with gigabytes of log messages from
"leds-gpio".

> So check if that GPIO driver is configured, if so it will come up
> eventually. If not we exit our probe function early and do not even
> bother registering the "leds-gpio". This method was chosen over
> "Kconfig depends" since this way we can add support for more devices
> and GPIO backends more easily without "depends"ing on all GPIO
> backends.

The series "[PATCH 0/4] add support for another simatic board" shows
how a second board would be added, using

if (!IS_ENABLED(CONFIG_GPIO_F7188X))
return -ENODEV;

I am not too happy with the solution. But it is better than "depends"
because we do not need to build all possible GPIO providers if we want
a minimal kernel for a board, while having all simatic gpio based
boards in one led driver.

And we will anyhow need to "name the provider" in case it does not
auto-probe. Also to be seen in that other series where we

request_module("gpio-f7188x");

regards,
Henning

> Signed-off-by: Henning Schild <henning.schild@xxxxxxxxxxx>
> ---
> drivers/leds/simple/simatic-ipc-leds-gpio.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/leds/simple/simatic-ipc-leds-gpio.c
> b/drivers/leds/simple/simatic-ipc-leds-gpio.c index
> 4c9e663a90ba..0c96ba98e338 100644 ---
> a/drivers/leds/simple/simatic-ipc-leds-gpio.c +++
> b/drivers/leds/simple/simatic-ipc-leds-gpio.c @@ -57,6 +57,8 @@
> static int simatic_ipc_leds_gpio_probe(struct platform_device *pdev)
> struct gpio_desc *gpiod; int err;
>
> + if (!IS_ENABLED(CONFIG_PINCTRL_BROXTON))
> + return -ENODEV;
> gpiod_add_lookup_table(&simatic_ipc_led_gpio_table);
> simatic_leds_pdev = platform_device_register_resndata(NULL,
> "leds-gpio", PLATFORM_DEVID_NONE, NULL, 0,