Skip to contentSkip to conversation

gpiolib: Add stubs for gpiod lookup table interface

PATCH Superseded Anatolij Gustschin 2 participants 5 messages Apr 27, 2017 GPIO

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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.

---
Changes in v2:
move gpiod_lookup_table out of #ifdef

 include/linux/gpio/consumer.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
include/linux/gpio/consumer.h +13 -0
index 8f702fc..f4a3fed 100644
@@ -41,6 +41,8 @@ enum gpiod_flags {
 			  GPIOD_FLAGS_BIT_DIR_VAL,
 };
 
+struct gpiod_lookup_table;
+
 #ifdef CONFIG_GPIOLIB
 
 /* Return the number of GPIOs associated with a device / function */
@@ -144,6 +146,9 @@ struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
 						enum gpiod_flags flags,
 						const char *label);
 
+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,14 @@ struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
 	return ERR_PTR(-ENOSYS);
 }
 
+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
#1 lore raw
Quoted 5 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.

Oh, has to take my tag back. See below why.

include/linux/gpio/consumer.h

Quoted 2 lines
include/linux/gpio/consumer.h +0 -0

It is already defined in machine.h.

What you basically need is to add stubs for !GPIOLIB case

#ifdef ...
...existing prototypes...
#else /* GPIOLIB */
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 /* !GPIOLIB */

P.S. please notice how I put the stubs. It would be good to keep them in two lines.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 25 lines · On Thu, 27 Apr 2017 17:07:23 +0300 Andy Shevchenko [email protected]…
Quoted 5 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.

Oh, has to take my tag back. See below why.

include/linux/gpio/consumer.h

Quoted 2 lines
include/linux/gpio/consumer.h +0 -0

It is already defined in machine.h.

What you basically need is to add stubs for !GPIOLIB case

#ifdef ...
...existing prototypes...
#else /* GPIOLIB */
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 /* !GPIOLIB */

Quoted 2 lines

P.S. please notice how I put the stubs. It would be good to keep them in two lines.

this will exceed 80 char line limit.

Thanks,

Anatolij

#3 lore raw
Quoted 2 lines · On Thu, 27 Apr 2017 16:25:34 +0200 Anatolij Gustschin [email protected] wrote:

On Thu, 27 Apr 2017 17:07:23 +0300
Andy Shevchenko [email protected] wrote:

...

Quoted 9 lines
Quoted 7 lines

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 /* !GPIOLIB */

P.S. please notice how I put the stubs. It would be good to keep them in two lines.

this will exceed 80 char line limit.

I'll go with

static inline
void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {}

static inline
void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {}

Is it okay?

Thanks,

Anatolij

#4 lore raw
Quoted 11 lines · Anatolij Gustschin
Quoted 2 lines · On Thu, 27 Apr 2017 16:25:34 +0200 Anatolij Gustschin [email protected] wrote:

On Thu, 27 Apr 2017 17:07:23 +0300
Andy Shevchenko [email protected] wrote:

...

Quoted 5 lines
Quoted 5 lines

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 /* !GPIOLIB */

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

P.S. please notice how I put the stubs. It would be good to keep them in two lines.

this will exceed 80 char line limit.

Not for many (unimportant) symbols.

Quoted 9 lines

I'll go with

static inline
void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {}

static inline
void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {}

Is it okay?

Whatever Linus prefers. I'm fine with either.

Signature · 2 lines
With Best Regards,
Andy Shevchenko