All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpiolib: Add stubs for GPIO lookup functions
@ 2024-03-22 16:13 Mark Brown
  2024-03-22 16:53 ` Krzysztof Kozlowski
  2024-04-02 12:30 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Brown @ 2024-03-22 16:13 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: Krzysztof Kozlowski, linux-gpio, linux-kernel, Mark Brown

The gpio_device_find_by_() functions do not have stubs which means that if
they are referenced from code with an optiona dependency on gpiolib then
the code will fail to link. Add stubs for lookups via fwnode and label. I
have not added a stub for plain gpio_device_find() since it seems harder to
see a use case for that which does not depend on gpiolib.

With the addition of the GPIO reset controller (which lacks a gpiolib
dependency) to the arm64 defconfig this is causing build breaks for arm64
virtconfig in -next:

aarch64-linux-gnu-ld: drivers/reset/core.o: in function `__reset_add_reset_gpio_lookup':
 /build/stage/linux/drivers/reset/core.c:861:(.text+0xccc): undefined reference to `gpio_device_find_by_fwnode'

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 include/linux/gpio/driver.h | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index dc75f802e284..f8617eaf08ba 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -646,8 +646,6 @@ int devm_gpiochip_add_data_with_key(struct device *dev, struct gpio_chip *gc,
 struct gpio_device *gpio_device_find(const void *data,
 				int (*match)(struct gpio_chip *gc,
 					     const void *data));
-struct gpio_device *gpio_device_find_by_label(const char *label);
-struct gpio_device *gpio_device_find_by_fwnode(const struct fwnode_handle *fwnode);
 
 struct gpio_device *gpio_device_get(struct gpio_device *gdev);
 void gpio_device_put(struct gpio_device *gdev);
@@ -814,6 +812,9 @@ struct gpio_device *gpiod_to_gpio_device(struct gpio_desc *desc);
 int gpio_device_get_base(struct gpio_device *gdev);
 const char *gpio_device_get_label(struct gpio_device *gdev);
 
+struct gpio_device *gpio_device_find_by_label(const char *label);
+struct gpio_device *gpio_device_find_by_fwnode(const struct fwnode_handle *fwnode);
+
 #else /* CONFIG_GPIOLIB */
 
 #include <asm/bug.h>
@@ -843,6 +844,18 @@ static inline const char *gpio_device_get_label(struct gpio_device *gdev)
 	return NULL;
 }
 
+static inline struct gpio_device *gpio_device_find_by_label(const char *label)
+{
+	WARN_ON(1);
+	return NULL;
+}
+
+static inline struct gpio_device *gpio_device_find_by_fwnode(const struct fwnode_handle *fwnode)
+{
+	WARN_ON(1);
+	return NULL;
+}
+
 static inline int gpiochip_lock_as_irq(struct gpio_chip *gc,
 				       unsigned int offset)
 {

---
base-commit: 13ee4a7161b6fd938aef6688ff43b163f6d83e37
change-id: 20240322-gpiolib-find-by-fwnode-stub-565f2a82b0ec

Best regards,
-- 
Mark Brown <broonie@kernel.org>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpiolib: Add stubs for GPIO lookup functions
  2024-03-22 16:13 [PATCH] gpiolib: Add stubs for GPIO lookup functions Mark Brown
@ 2024-03-22 16:53 ` Krzysztof Kozlowski
  2024-04-02 12:30 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2024-03-22 16:53 UTC (permalink / raw)
  To: Mark Brown, Linus Walleij, Bartosz Golaszewski; +Cc: linux-gpio, linux-kernel

On 22/03/2024 17:13, Mark Brown wrote:
> The gpio_device_find_by_() functions do not have stubs which means that if
> they are referenced from code with an optiona dependency on gpiolib then

Maybe can be fixed while applying:
s/optiona/optional/

> the code will fail to link. Add stubs for lookups via fwnode and label. I
> have not added a stub for plain gpio_device_find() since it seems harder to
> see a use case for that which does not depend on gpiolib.
> 
> With the addition of the GPIO reset controller (which lacks a gpiolib
> dependency) to the arm64 defconfig this is causing build breaks for arm64
> virtconfig in -next:
> 
> aarch64-linux-gnu-ld: drivers/reset/core.o: in function `__reset_add_reset_gpio_lookup':
>  /build/stage/linux/drivers/reset/core.c:861:(.text+0xccc): undefined reference to `gpio_device_find_by_fwnode'
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpiolib: Add stubs for GPIO lookup functions
  2024-03-22 16:13 [PATCH] gpiolib: Add stubs for GPIO lookup functions Mark Brown
  2024-03-22 16:53 ` Krzysztof Kozlowski
@ 2024-04-02 12:30 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2024-04-02 12:30 UTC (permalink / raw)
  To: Mark Brown
  Cc: Bartosz Golaszewski, Krzysztof Kozlowski, linux-gpio, linux-kernel

On Fri, Mar 22, 2024 at 5:14 PM Mark Brown <broonie@kernel.org> wrote:

> The gpio_device_find_by_() functions do not have stubs which means that if
> they are referenced from code with an optiona dependency on gpiolib then
> the code will fail to link. Add stubs for lookups via fwnode and label. I
> have not added a stub for plain gpio_device_find() since it seems harder to
> see a use case for that which does not depend on gpiolib.
>
> With the addition of the GPIO reset controller (which lacks a gpiolib
> dependency) to the arm64 defconfig this is causing build breaks for arm64
> virtconfig in -next:
>
> aarch64-linux-gnu-ld: drivers/reset/core.o: in function `__reset_add_reset_gpio_lookup':
>  /build/stage/linux/drivers/reset/core.c:861:(.text+0xccc): undefined reference to `gpio_device_find_by_fwnode'
>
> Signed-off-by: Mark Brown <broonie@kernel.org>

Since we have already exposed the innards of gpiolib as much
as we have I guess it's a must:
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-02 12:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-22 16:13 [PATCH] gpiolib: Add stubs for GPIO lookup functions Mark Brown
2024-03-22 16:53 ` Krzysztof Kozlowski
2024-04-02 12:30 ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.