Skip to contentSkip to conversation

gpiolib: of: Reshuffle contents of consumer.h for new library layout

PATCH In review Andy Shevchenko 2 participants 6 messages Jul 30, 2019

Subsystems (7)
Sound ACPI ASoC GPIO +3 more subsystems
lore
Share & tools
lore

Andy Shevchenko

author maintainer
#0 lore raw

PATCH v2 1/3 gpiolib: of: Reshuffle contents of consumer.h for new library layout

Kernel build bot reported a compilation error after the commit

f626d6dfb709 ("gpio: of: Break out OF-only code"):

drivers/gpio/gpiolib-devres.o: In function `devm_gpiod_get_from_of_node':
gpiolib-devres.c:(.text+0x19a): undefined reference to `gpiod_get_from_of_node'

This happens due to move the latter under umbrella of CONFIG_OF_GPIO while customer.h contains staled data.

Fix it by reshuffling contents of consumer.h to satisfy build dependencies.

Fixes f626d6dfb709 ("gpio: of: Break out OF-only code"):

---
v2: no change

 include/linux/gpio/consumer.h | 78 +++++++++++++++++++++--------------
 1 file changed, 48 insertions(+), 30 deletions(-)
include/linux/gpio/consumer.h +48 -30
index a7f08fb0f865..b548a3fb5eee 100644
@@ -170,18 +170,8 @@ struct gpio_desc *gpio_to_desc(unsigned gpio);
 int desc_to_gpio(const struct gpio_desc *desc);
 
 /* Child properties interface */
-struct device_node;
 struct fwnode_handle;
 
-struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
-					 const char *propname, int index,
-					 enum gpiod_flags dflags,
-					 const char *label);
-struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev,
-					      struct device_node *node,
-					      const char *propname, int index,
-					      enum gpiod_flags dflags,
-					      const char *label);
 struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
 					 const char *propname, int index,
 					 enum gpiod_flags dflags,
@@ -530,28 +520,8 @@ static inline int desc_to_gpio(const struct gpio_desc *desc)
 }
 
 /* Child properties interface */
-struct device_node;
 struct fwnode_handle;
 
-static inline
-struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
-					 const char *propname, int index,
-					 enum gpiod_flags dflags,
-					 const char *label)
-{
-	return ERR_PTR(-ENOSYS);
-}
-
-static inline
-struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev,
-					      struct device_node *node,
-					      const char *propname, int index,
-					      enum gpiod_flags dflags,
-					      const char *label)
-{
-	return ERR_PTR(-ENOSYS);
-}
-
 static inline
 struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
 					 const char *propname, int index,
@@ -584,6 +554,54 @@ struct gpio_desc *devm_fwnode_get_gpiod_from_child(struct device *dev,
 						      flags, label);
 }
 
+#if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_OF_GPIO)
+struct device_node;
+
+struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
+					 const char *propname, int index,
+					 enum gpiod_flags dflags,
+					 const char *label);
+
+#else  /* CONFIG_GPIOLIB && CONFIG_OF_GPIO */
+
+struct device_node;
+
+static inline
+struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
+					 const char *propname, int index,
+					 enum gpiod_flags dflags,
+					 const char *label)
+{
+	return ERR_PTR(-ENOSYS);
+}
+
+#endif /* CONFIG_GPIOLIB && CONFIG_OF_GPIO */
+
+#ifdef CONFIG_GPIOLIB
+struct device_node;
+
+struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev,
+					      struct device_node *node,
+					      const char *propname, int index,
+					      enum gpiod_flags dflags,
+					      const char *label);
+
+#else  /* CONFIG_GPIOLIB */
+
+struct device_node;
+
+static inline
+struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev,
+					      struct device_node *node,
+					      const char *propname, int index,
+					      enum gpiod_flags dflags,
+					      const char *label)
+{
+	return ERR_PTR(-ENOSYS);
+}
+
+#endif /* CONFIG_GPIOLIB */
+
 #if IS_ENABLED(CONFIG_GPIOLIB) && IS_ENABLED(CONFIG_GPIO_SYSFS)
 
 int gpiod_export(struct gpio_desc *desc, bool direction_may_change);
Signature · 1 line
2.20.1
author maintainer
#1 lore raw

PATCH v2 2/3 gpiolib: acpi: Split ACPI stuff to gpiolib-acpi.h

This is a follow up to the commit

f626d6dfb709 ("gpio: of: Break out OF-only code")

which broke down OF parts of GPIO library. Here we do the similar to ACPI.

---
v2: Cc to ACPI people

 drivers/gpio/gpio-dwapb.c    |   1 +
 drivers/gpio/gpio-mb86s7x.c  |   1 +
 drivers/gpio/gpio-xgene-sb.c |   1 +
 drivers/gpio/gpiolib-acpi.c  |   1 +
 drivers/gpio/gpiolib-acpi.h  | 104 +++++++++++++++++++++++++++++++++++
 drivers/gpio/gpiolib.c       |   1 +
 drivers/gpio/gpiolib.h       |  93 -------------------------------
 7 files changed, 109 insertions(+), 93 deletions(-)
 create mode 100644 drivers/gpio/gpiolib-acpi.h
drivers/gpio/gpio-dwapb.c +1 -0
index 3108be5e208c..92e127e74813 100644
@@ -27,6 +27,7 @@
 #include <linux/slab.h>
 
 #include "gpiolib.h"
+#include "gpiolib-acpi.h"
 
 #define GPIO_SWPORTA_DR		0x00
 #define GPIO_SWPORTA_DDR	0x04
drivers/gpio/gpio-mb86s7x.c +1 -0
index 8f466993cd24..501e89548f53 100644
@@ -21,6 +21,7 @@
 #include <linux/slab.h>
 
 #include "gpiolib.h"
+#include "gpiolib-acpi.h"
 
 /*
  * Only first 8bits of a register correspond to each pin,
drivers/gpio/gpio-xgene-sb.c +1 -0
index 38c01912c7b2..25d86441666e 100644
@@ -16,6 +16,7 @@
 #include <linux/acpi.h>
 
 #include "gpiolib.h"
+#include "gpiolib-acpi.h"
 
 /* Common property names */
 #define XGENE_NIRQ_PROPERTY		"apm,nr-irqs"
drivers/gpio/gpiolib-acpi.c +1 -0
index 39f2f9035c11..d54fc6e7c8a9 100644
@@ -18,6 +18,7 @@
 #include <linux/pinctrl/pinctrl.h>
 
 #include "gpiolib.h"
+#include "gpiolib-acpi.h"
 
 /**
  * struct acpi_gpio_event - ACPI GPIO event handler data
drivers/gpio/gpiolib-acpi.h new file +104 -0

104 lines not on this page · raw message

drivers/gpio/gpiolib.c +1 -0
index d45c9a2285f0..b1085d069dcf 100644
@@ -30,6 +30,7 @@
 
 #include "gpiolib.h"
 #include "gpiolib-of.h"
+#include "gpiolib-acpi.h"
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/gpio.h>
drivers/gpio/gpiolib.h +0 -93

108 lines not on this page · raw message

Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH v2 2/3] gpiolib: acpi: Split ACPI stuff to gpiolib-acpi.h

Quoted 9 lines · Andy Shevchenko

This is a follow up to the commit

f626d6dfb709 ("gpio: of: Break out OF-only code")

which broke down OF parts of GPIO library. Here we do the similar to ACPI.

---
v2: Cc to ACPI people

Patch applied.

Yours,
Linus Walleij

author maintainer
#3 lore raw

PATCH v2 3/3 gpiolib-acpi: Move acpi_dev_add_driver_gpios() et al to consumer.h

In reply to Andy Shevchenko

The API, which belongs to GPIO library, is foreign to ACPI headers. Earlier we moved out I²C out of the latter, and now it's time for acpi_dev_add_driver_gpios() et al.

For time being the acpi_gpio_get_irq_resource() and acpi_dev_gpio_irq_get() are left untouched as they need more thought about.

Note, it requires uninline acpi_dev_remove_driver_gpios() to keep purity of consumer.h.

Cc Pierre-Louis Bossart <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Jie Yang <[email protected]>
Cc Mark Brown <[email protected]>
Cc [email protected] (moderated list:INTEL ASoC DRIVERS)

---
v2: new patch

 drivers/gpio/gpiolib-acpi.c                  |  7 +++
 include/linux/acpi.h                         | 51 ------------------
 include/linux/gpio/consumer.h                | 57 ++++++++++++++++++++
 sound/soc/intel/boards/bytcht_cx2072x.c      |  1 +
 sound/soc/intel/boards/cht_bsw_max98090_ti.c |  1 +
 sound/soc/intel/boards/cht_bsw_rt5672.c      |  1 +
 6 files changed, 67 insertions(+), 51 deletions(-)
drivers/gpio/gpiolib-acpi.c +7 -0
index d54fc6e7c8a9..fdee8afa5339 100644
@@ -383,6 +383,13 @@ int acpi_dev_add_driver_gpios(struct acpi_device *adev,
 }
 EXPORT_SYMBOL_GPL(acpi_dev_add_driver_gpios);
 
+void acpi_dev_remove_driver_gpios(struct acpi_device *adev)
+{
+	if (adev)
+		adev->driver_gpios = NULL;
+}
+EXPORT_SYMBOL_GPL(acpi_dev_remove_driver_gpios);
+
 static void devm_acpi_dev_release_driver_gpios(struct device *dev, void *res)
 {
 	acpi_dev_remove_driver_gpios(ACPI_COMPANION(dev));
include/linux/acpi.h +0 -51

62 lines not on this page · raw message

include/linux/gpio/consumer.h +57 -0

63 lines not on this page · raw message

sound/soc/intel/boards/bytcht_cx2072x.c +1 -0
index 54ac2fd41925..67f06c95eec5 100644
@@ -6,6 +6,7 @@
 
 #include <linux/acpi.h>
 #include <linux/device.h>
+#include <linux/gpio/consumer.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
sound/soc/intel/boards/cht_bsw_max98090_ti.c +1 -0
index 33eb72545be6..05db311b579e 100644
@@ -12,6 +12,7 @@
  */
 
 #include <linux/dmi.h>
+#include <linux/gpio/consumer.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
sound/soc/intel/boards/cht_bsw_rt5672.c +1 -0
index 4977b5a65eb8..9d657421730a 100644
@@ -8,6 +8,7 @@
  *          Mengdong Lin <[email protected]>
  */
 
+#include <linux/gpio/consumer.h>
 #include <linux/input.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
Signature · 6 lines
2.20.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#4 lore raw

Re: [PATCH v2 3/3] gpiolib-acpi: Move acpi_dev_add_driver_gpios() et al to consumer.h

Quoted 10 lines · Andy Shevchenko

The API, which belongs to GPIO library, is foreign to ACPI headers. Earlier we moved out I²C out of the latter, and now it's time for acpi_dev_add_driver_gpios() et al.

For time being the acpi_gpio_get_irq_resource() and acpi_dev_gpio_irq_get() are left untouched as they need more thought about.

Note, it requires uninline acpi_dev_remove_driver_gpios() to keep purity of consumer.h.

Quoted 6 lines
Cc Pierre-Louis Bossart <[email protected]>
Cc Liam Girdwood <[email protected]>
Cc Jie Yang <[email protected]>
Cc Mark Brown <[email protected]>
Cc [email protected] (moderated list:INTEL ASoC DRIVERS)

Patch applied!

Just a bit worried that this will collide with Masahiro's #ifdef-reduction, but I wanted to keep your series together.

Yours,
Linus Walleij
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#5 lore raw
In reply to Andy Shevchenko
Quoted 10 lines · Andy Shevchenko

Kernel build bot reported a compilation error after the commit

f626d6dfb709 ("gpio: of: Break out OF-only code"):

drivers/gpio/gpiolib-devres.o: In function `devm_gpiod_get_from_of_node':
gpiolib-devres.c:(.text+0x19a): undefined reference to `gpiod_get_from_of_node'

This happens due to move the latter under umbrella of CONFIG_OF_GPIO while customer.h contains staled data.

Quoted 7 lines

Fix it by reshuffling contents of consumer.h to satisfy build dependencies.

Fixes f626d6dfb709 ("gpio: of: Break out OF-only code"):

---
v2: no change

Patch applied. THANKS for fixing this, I am on vacation so working on this a bit left-handedly.

Yours,
Linus Walleij