Skip to contentSkip to conversation

gpio: export add/remove lookup table functions

PATCH In review Anatolij Gustschin 3 participants 6 messages Apr 20, 2017 – May 22, 2017 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: export add/remove lookup table functions

For hot-pluggable devices adding GPIOs dynamically we need to assemble and add the gpio lookup tables at probe time in modules, so that requesting these GPIOs in attached drivers can work. Export lookup table functions for modules.

---
 drivers/gpio/gpiolib.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpio/gpiolib.c +2 -0
index 4aa1e78..9196b1e 100644
@@ -3008,6 +3008,7 @@ void gpiod_add_lookup_table(struct gpiod_lookup_table *table)
 
 	mutex_unlock(&gpio_lookup_lock);
 }
+EXPORT_SYMBOL_GPL(gpiod_add_lookup_table);
 
 /**
  * gpiod_remove_lookup_table() - unregister GPIO device consumers
@@ -3021,6 +3022,7 @@ void gpiod_remove_lookup_table(struct gpiod_lookup_table *table)
 
 	mutex_unlock(&gpio_lookup_lock);
 }
+EXPORT_SYMBOL_GPL(gpiod_remove_lookup_table);
 
 static struct gpiod_lookup_table *gpiod_find_lookup_table(struct device *dev)
 {
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Anatolij Gustschin

For hot-pluggable devices adding GPIOs dynamically we need to assemble and add the gpio lookup tables at probe time in modules, so that requesting these GPIOs in attached drivers can work. Export lookup table functions for modules.

...and still a question "Do we go with stubs for them in case of !GPIOLIB?"

Patch below looks good to me:

Quoted 27 lines
---
 drivers/gpio/gpiolib.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpio/gpiolib.c +2 -1
index 4aa1e78..9196b1e 100644
@@ -3008,6 +3008,7 @@ void gpiod_add_lookup_table(struct gpiod_lookup_table *table)
 
        mutex_unlock(&gpio_lookup_lock);
 }
+EXPORT_SYMBOL_GPL(gpiod_add_lookup_table);
 
 /**
  * gpiod_remove_lookup_table() - unregister GPIO device consumers
@@ -3021,6 +3022,7 @@ void gpiod_remove_lookup_table(struct gpiod_lookup_table *table)
 
        mutex_unlock(&gpio_lookup_lock);
 }
+EXPORT_SYMBOL_GPL(gpiod_remove_lookup_table);
 
 static struct gpiod_lookup_table *gpiod_find_lookup_table(struct device *dev)
 {
--

2.7.4

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw

PATCH 1/1 gpiolib: Add stubs for gpiod lookup table interface

Add stubs for gpiod_add_lookup_table() and gpiod_remove_lookup_table() for the !GPIOLIB case to prevent build errors. Also add prototypes.

---
 include/linux/gpio/consumer.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
include/linux/gpio/consumer.h +15 -0
index 933d936..6c0cc67 100644
@@ -144,6 +144,11 @@ struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
 						enum gpiod_flags flags,
 						const char *label);
 
+struct gpiod_lookup_table;
+
+void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
+void gpiod_remove_lookup_table(struct gpiod_lookup_table *table);
+
 #else /* CONFIG_GPIOLIB */
 
 static inline int gpiod_count(struct device *dev, const char *con_id)
@@ -435,6 +440,16 @@ struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
 	return ERR_PTR(-ENOSYS);
 }
 
+struct gpiod_lookup_table;
+
+static inline void gpiod_add_lookup_table(struct gpiod_lookup_table *table)
+{
+}
+
+static inline void gpiod_remove_lookup_table(struct gpiod_lookup_table *table)
+{
+}
+
 #endif /* CONFIG_GPIOLIB */
 
 static inline
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#3 lore raw

Re: [PATCH] gpiolib: Add stubs for gpiod lookup table interface

In reply to Anatolij Gustschin
Quoted 2 lines · Anatolij Gustschin

Add stubs for gpiod_add_lookup_table() and gpiod_remove_lookup_table() for the !GPIOLIB case to prevent build errors. Also add prototypes.

One nit below, otherwise
FWIW:

Linus, it would be nice if are okay with this approach. It will fix that one user which might break a buiid on some kernel configurations.

Quoted 11 lines
---
 include/linux/gpio/consumer.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
include/linux/gpio/consumer.h +0 -0
index 933d936..6c0cc67 100644

include/linux/gpio/consumer.h struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev, · line 151

Quoted 8 lines
include/linux/gpio/consumer.h +2 -0
@@ -144,6 +144,11 @@ struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
                                                enum gpiod_flags flags,
                                                const char *label);
 
+struct gpiod_lookup_table;
 
 #else /* CONFIG_GPIOLIB */
 
+struct gpiod_lookup_table;

No need to duplicate this. Just move out of #ifdef.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
In reply to Anatolij Gustschin
Quoted 6 lines · Anatolij Gustschin

For hot-pluggable devices adding GPIOs dynamically we need to assemble and add the gpio lookup tables at probe time in modules, so that requesting these GPIOs in attached drivers can work. Export lookup table functions for modules.

Patch applied with Andy's Review tag, sorry for missing it, it was indeed sent to me I just randomly forgot the patch.

Yours,
Linus Walleij