linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: Move gpiochip_lock/unlock_as_irq to gpio/driver.h
@ 2019-08-22  3:18 YueHaibing
  2019-08-23 10:00 ` Linus Walleij
  0 siblings, 1 reply; 5+ messages in thread
From: YueHaibing @ 2019-08-22  3:18 UTC (permalink / raw)
  To: linus.walleij, bgolaszewski, acourbot
  Cc: linux-kernel, linux-gpio, YueHaibing

If CONFIG_GPIOLIB is not, gpiochip_lock/unlock_as_irq will
conflict as this:

In file included from sound/soc/codecs/wm5100.c:18:0:
./include/linux/gpio.h:224:19: error: static declaration of gpiochip_lock_as_irq follows non-static declaration
 static inline int gpiochip_lock_as_irq(struct gpio_chip *chip,
                   ^~~~~~~~~~~~~~~~~~~~
In file included from sound/soc/codecs/wm5100.c:17:0:
./include/linux/gpio/driver.h:494:5: note: previous declaration of gpiochip_lock_as_irq was here
 int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
     ^~~~~~~~~~~~~~~~~~~~
In file included from sound/soc/codecs/wm5100.c:18:0:
./include/linux/gpio.h:231:20: error: static declaration of gpiochip_unlock_as_irq follows non-static declaration
 static inline void gpiochip_unlock_as_irq(struct gpio_chip *chip,
                    ^~~~~~~~~~~~~~~~~~~~~~
In file included from sound/soc/codecs/wm5100.c:17:0:
./include/linux/gpio/driver.h:495:6: note: previous declaration of gpiochip_unlock_as_irq was here
 void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
     ^~~~~~~~~~~~~~~~~~~~~~

Move them to gpio/driver.h and use CONFIG_GPIOLIB guard this.

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: d74be6dfea1b ("gpio: remove gpiod_lock/unlock_as_irq()")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 include/linux/gpio.h        | 13 -------------
 include/linux/gpio/driver.h | 19 ++++++++++++++++---
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index f757a58..2157717 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -221,19 +221,6 @@ static inline int gpio_to_irq(unsigned gpio)
 	return -EINVAL;
 }
 
-static inline int gpiochip_lock_as_irq(struct gpio_chip *chip,
-				       unsigned int offset)
-{
-	WARN_ON(1);
-	return -EINVAL;
-}
-
-static inline void gpiochip_unlock_as_irq(struct gpio_chip *chip,
-					  unsigned int offset)
-{
-	WARN_ON(1);
-}
-
 static inline int irq_to_gpio(unsigned irq)
 {
 	/* irq can never have been returned from gpio_to_irq() */
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index 4d2d7b7..1778106 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -490,9 +490,6 @@ extern int devm_gpiochip_add_data(struct device *dev, struct gpio_chip *chip,
 extern struct gpio_chip *gpiochip_find(void *data,
 			      int (*match)(struct gpio_chip *chip, void *data));
 
-/* lock/unlock as IRQ */
-int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
-void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
 bool gpiochip_line_is_irq(struct gpio_chip *chip, unsigned int offset);
 int gpiochip_reqres_irq(struct gpio_chip *chip, unsigned int offset);
 void gpiochip_relres_irq(struct gpio_chip *chip, unsigned int offset);
@@ -710,6 +707,10 @@ void devprop_gpiochip_set_names(struct gpio_chip *chip,
 
 struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);
 
+/* lock/unlock as IRQ */
+int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
+void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
+
 #else /* CONFIG_GPIOLIB */
 
 static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc)
@@ -719,6 +720,18 @@ static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc)
 	return ERR_PTR(-ENODEV);
 }
 
+static inline int gpiochip_lock_as_irq(struct gpio_chip *chip,
+				       unsigned int offset)
+{
+	WARN_ON(1);
+	return -EINVAL;
+}
+
+static inline void gpiochip_unlock_as_irq(struct gpio_chip *chip,
+					  unsigned int offset)
+{
+	WARN_ON(1);
+}
 #endif /* CONFIG_GPIOLIB */
 
 #endif /* __LINUX_GPIO_DRIVER_H */
-- 
2.7.4



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

* Re: [PATCH] gpio: Move gpiochip_lock/unlock_as_irq to gpio/driver.h
  2019-08-22  3:18 [PATCH] gpio: Move gpiochip_lock/unlock_as_irq to gpio/driver.h YueHaibing
@ 2019-08-23 10:00 ` Linus Walleij
  2019-09-04 15:46   ` [PATCH] gpio: Move gpiochip_.*lock_as_irq() to the proper ifdef Sebastian Andrzej Siewior
  0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2019-08-23 10:00 UTC (permalink / raw)
  To: YueHaibing
  Cc: Bartosz Golaszewski, Alexandre Courbot, linux-kernel,
	open list:GPIO SUBSYSTEM

On Thu, Aug 22, 2019 at 5:19 AM YueHaibing <yuehaibing@huawei.com> wrote:

> If CONFIG_GPIOLIB is not, gpiochip_lock/unlock_as_irq will
> conflict as this:
>
> In file included from sound/soc/codecs/wm5100.c:18:0:
> ./include/linux/gpio.h:224:19: error: static declaration of gpiochip_lock_as_irq follows non-static declaration
>  static inline int gpiochip_lock_as_irq(struct gpio_chip *chip,
>                    ^~~~~~~~~~~~~~~~~~~~
> In file included from sound/soc/codecs/wm5100.c:17:0:
> ./include/linux/gpio/driver.h:494:5: note: previous declaration of gpiochip_lock_as_irq was here
>  int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
>      ^~~~~~~~~~~~~~~~~~~~
> In file included from sound/soc/codecs/wm5100.c:18:0:
> ./include/linux/gpio.h:231:20: error: static declaration of gpiochip_unlock_as_irq follows non-static declaration
>  static inline void gpiochip_unlock_as_irq(struct gpio_chip *chip,
>                     ^~~~~~~~~~~~~~~~~~~~~~
> In file included from sound/soc/codecs/wm5100.c:17:0:
> ./include/linux/gpio/driver.h:495:6: note: previous declaration of gpiochip_unlock_as_irq was here
>  void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
>      ^~~~~~~~~~~~~~~~~~~~~~
>
> Move them to gpio/driver.h and use CONFIG_GPIOLIB guard this.
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Fixes: d74be6dfea1b ("gpio: remove gpiod_lock/unlock_as_irq()")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Patch applied with some fuzzing.

Yours,
Linus Walleij

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

* [PATCH] gpio: Move gpiochip_.*lock_as_irq() to the proper ifdef
  2019-08-23 10:00 ` Linus Walleij
@ 2019-09-04 15:46   ` Sebastian Andrzej Siewior
  2019-09-05  2:04     ` Yuehaibing
  0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-09-04 15:46 UTC (permalink / raw)
  To: Linus Walleij
  Cc: YueHaibing, Bartosz Golaszewski, Alexandre Courbot, linux-kernel,
	open list:GPIO SUBSYSTEM, Thomas Gleixner

In a recent commit the gpiochip_.*lock_as_irq() were moved and ended up
in the wrong `ifdef' section. Now for !CONFIG_GPIOLIB the function is
defined twice leading to an compile error.

Move the extern function declaration under CONFIG_GPIOLIB, the "static
inline" version is already under !CONFIG_GPIOLIB.

Fixes: c7663fa2a6631 ("gpio: Move gpiochip_lock/unlock_as_irq to gpio/driver.h")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/gpio/driver.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index b74a3bee85e5d..fb134ff20f6b2 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -702,14 +702,14 @@ void gpiochip_free_own_desc(struct gpio_desc *desc);
 void devprop_gpiochip_set_names(struct gpio_chip *chip,
 				const struct fwnode_handle *fwnode);
 
-/* lock/unlock as IRQ */
-int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
-void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
-
 #ifdef CONFIG_GPIOLIB
 
 struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);
 
+/* lock/unlock as IRQ */
+int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
+void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
+
 #else /* CONFIG_GPIOLIB */
 
 static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc)
-- 
2.23.0


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

* Re: [PATCH] gpio: Move gpiochip_.*lock_as_irq() to the proper ifdef
  2019-09-04 15:46   ` [PATCH] gpio: Move gpiochip_.*lock_as_irq() to the proper ifdef Sebastian Andrzej Siewior
@ 2019-09-05  2:04     ` Yuehaibing
  2019-09-05  9:36       ` Linus Walleij
  0 siblings, 1 reply; 5+ messages in thread
From: Yuehaibing @ 2019-09-05  2:04 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, Linus Walleij
  Cc: Bartosz Golaszewski, Alexandre Courbot, linux-kernel,
	open list:GPIO SUBSYSTEM, Thomas Gleixner

On 2019/9/4 23:46, Sebastian Andrzej Siewior wrote:
> In a recent commit the gpiochip_.*lock_as_irq() were moved and ended up
> in the wrong `ifdef' section. Now for !CONFIG_GPIOLIB the function is
> defined twice leading to an compile error.
> 
> Move the extern function declaration under CONFIG_GPIOLIB, the "static
> inline" version is already under !CONFIG_GPIOLIB.
> 
> Fixes: c7663fa2a6631 ("gpio: Move gpiochip_lock/unlock_as_irq to gpio/driver.h")
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  include/linux/gpio/driver.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
> index b74a3bee85e5d..fb134ff20f6b2 100644
> --- a/include/linux/gpio/driver.h
> +++ b/include/linux/gpio/driver.h
> @@ -702,14 +702,14 @@ void gpiochip_free_own_desc(struct gpio_desc *desc);
>  void devprop_gpiochip_set_names(struct gpio_chip *chip,
>  				const struct fwnode_handle *fwnode);
>  
> -/* lock/unlock as IRQ */
> -int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
> -void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
> -
>  #ifdef CONFIG_GPIOLIB
>  
>  struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);
>  
> +/* lock/unlock as IRQ */
> +int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
> +void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
> +
>  #else /* CONFIG_GPIOLIB */

Interesting, my patch indeed do the correct thing:

+/* lock/unlock as IRQ */
+int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
+void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);
+
 #else /* CONFIG_GPIOLIB */

however, now in include/linux/gpio/driver.h, it is:

/* lock/unlock as IRQ */
int gpiochip_lock_as_irq(struct gpio_chip *chip, unsigned int offset);
void gpiochip_unlock_as_irq(struct gpio_chip *chip, unsigned int offset);

#ifdef CONFIG_GPIOLIB

struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc);

#else /* CONFIG_GPIOLIB */


Maybe this caused by the fuzzing?  Anyway, this fix the issue, so

Reviewed-by: YueHaibing <yuehaibing@huawei.com>

>  
>  static inline struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc)
> 


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

* Re: [PATCH] gpio: Move gpiochip_.*lock_as_irq() to the proper ifdef
  2019-09-05  2:04     ` Yuehaibing
@ 2019-09-05  9:36       ` Linus Walleij
  0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2019-09-05  9:36 UTC (permalink / raw)
  To: Yuehaibing
  Cc: Sebastian Andrzej Siewior, Bartosz Golaszewski,
	Alexandre Courbot, linux-kernel, open list:GPIO SUBSYSTEM,
	Thomas Gleixner

I aldready fixed this up in my tree.

On Thu, Sep 5, 2019 at 4:04 AM Yuehaibing <yuehaibing@huawei.com> wrote:

> Interesting, my patch indeed do the correct thing:

It is a classic merge collision. Something fun for the subsystem
maintainer to deal with :D

Yours,
Linus Walleij

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

end of thread, other threads:[~2019-09-05  9:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-22  3:18 [PATCH] gpio: Move gpiochip_lock/unlock_as_irq to gpio/driver.h YueHaibing
2019-08-23 10:00 ` Linus Walleij
2019-09-04 15:46   ` [PATCH] gpio: Move gpiochip_.*lock_as_irq() to the proper ifdef Sebastian Andrzej Siewior
2019-09-05  2:04     ` Yuehaibing
2019-09-05  9:36       ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).