Skip to contentSkip to conversation

gpio: include <linux/gpio.h> not <asm/gpio.h>

PATCH In review H Hartley Sweeten 3 participants 4 messages Jul 31, 2009 – Aug 5, 2009 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: include <linux/gpio.h> not <asm/gpio.h>

Drivers should be including <linux/gpio.h> not <asm/gpio.h>.

---

drivers/gpio/bt8xxgpio.c +1 -2
index 984b587..fd1c54d 100644
@@ -46,8 +46,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/spinlock.h>
-
-#include <asm/gpio.h>
+#include <linux/gpio.h>
 
 /* Steal the hardware definitions from the bttv driver. */
 #include "../media/video/bt8xx/bt848.h"
drivers/gpio/mcp23s08.c +1 -3
index f6fae0e..125f921 100644
@@ -6,12 +6,10 @@
 #include <linux/device.h>
 #include <linux/workqueue.h>
 #include <linux/mutex.h>
-
+#include <linux/gpio.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/mcp23s08.h>
 
-#include <asm/gpio.h>
-
 
 /* Registers are all 8 bits wide.
  *
drivers/gpio/pca953x.c +1 -2
index cdb6574..8f8fefd 100644
@@ -13,6 +13,7 @@
 
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/gpio.h>
 #include <linux/i2c.h>
 #include <linux/i2c/pca953x.h>
 #ifdef CONFIG_OF_GPIO
@@ -20,8 +21,6 @@
 #include <linux/of_gpio.h>
 #endif
 
-#include <asm/gpio.h>
-
 #define PCA953X_INPUT          0
 #define PCA953X_OUTPUT         1
 #define PCA953X_INVERT         2
drivers/gpio/pcf857x.c +1 -2
index 9525724..72f2449 100644
@@ -20,11 +20,10 @@
 
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/gpio.h>
 #include <linux/i2c.h>
 #include <linux/i2c/pcf857x.h>
 
-#include <asm/gpio.h>
-
 
 static const struct i2c_device_id pcf857x_id[] = {
 	{ "pcf8574", 8 },
#1 lore raw
Quoted 11 lines · On Fri, 31 Jul 2009 10:59:50 -0700 H Hartley Sweeten…

Drivers should be including <linux/gpio.h> not <asm/gpio.h>.

---

drivers/gpio/bt8xxgpio.c +0 -0
index 984b587..fd1c54d 100644

drivers/gpio/bt8xxgpio.c line 49

Quoted 6 lines
drivers/gpio/bt8xxgpio.c +1 -2
@@ -46,8 +46,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/spinlock.h>
-
-#include <asm/gpio.h>
+#include <linux/gpio.h>

There's some potential for breakage here. include/linux/gpio.h has

#ifdef CONFIG_GENERIC_GPIO
#include <asm/gpio.h>

#else

...

#endif

So if there's some configuration which forgot to set CONFIG_GENERIC_GPIO, the driver will be switched over to use the include/linux/gpio.h stubs and will break.

Please convince me that this cannot happen ;)

#2 lore raw
Quoted 27 lines · Andrew Morton
Quoted 11 lines

Drivers should be including <linux/gpio.h> not <asm/gpio.h>.

---

drivers/gpio/bt8xxgpio.c +0 -0
index 984b587..fd1c54d 100644

drivers/gpio/bt8xxgpio.c line 49

Quoted 6 lines
drivers/gpio/bt8xxgpio.c +1 -2
@@ -46,8 +46,7 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include <linux/spinlock.h>
-
-#include <asm/gpio.h>
+#include <linux/gpio.h>

There's some potential for breakage here. include/linux/gpio.h has

#ifdef CONFIG_GENERIC_GPIO
#include <asm/gpio.h>

#else

...

Quoted 8 lines

#endif

So if there's some configuration which forgot to set CONFIG_GENERIC_GPIO, the driver will be switched over to use the include/linux/gpio.h stubs and will break.

Please convince me that this cannot happen ;)

Can't happen for these drivers. Everything in drivers/gpio requires GPIOLIB which selects GENERIC_GPIO. Please see drivers/gpio/Kconfig.

Thanks,
Hartley

#3 lore raw
In reply to H Hartley Sweeten
Quoted 1 line · H Hartley Sweeten

Drivers should be including <linux/gpio.h> not <asm/gpio.h>.

True. But for the record, that's the "new" way, which is intentionally compatibe wit the "old way". :)