Commit 213aefe2 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

greybus: gpio-gb: allow it to build properly for all current kernel versions.

GPIO remove changed the api for 3.17 to try to make up for some
previously foolish design decisions.  Handle that in kernel_ver.h to
make the code simple.
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 6ce3e03f
...@@ -799,12 +799,11 @@ int gb_gpio_controller_init(struct gb_connection *connection) ...@@ -799,12 +799,11 @@ int gb_gpio_controller_init(struct gb_connection *connection)
void gb_gpio_controller_exit(struct gb_connection *connection) void gb_gpio_controller_exit(struct gb_connection *connection)
{ {
struct gb_gpio_controller *gb_gpio_controller = connection->private; struct gb_gpio_controller *gb_gpio_controller = connection->private;
int ret;
if (!gb_gpio_controller) if (!gb_gpio_controller)
return; return;
ret = gpiochip_remove(&gb_gpio_controller->chip); gb_gpiochip_remove(&gb_gpio_controller->chip);
/* kref_put(gb_gpio_controller->connection) */ /* kref_put(gb_gpio_controller->connection) */
kfree(gb_gpio_controller); kfree(gb_gpio_controller);
} }
......
...@@ -26,4 +26,26 @@ ...@@ -26,4 +26,26 @@
#define U16_MAX ((u16)(~0U)) #define U16_MAX ((u16)(~0U))
#endif /* !U16_MAX */ #endif /* !U16_MAX */
/*
* The GPIO api sucks rocks in places, like removal, so work around their
* explicit requirements of catching the return value for kernels older than
* 3.17, which they explicitly changed in the 3.17 kernel. Consistency is
* overrated.
*/
#include <linux/version.h>
#include <linux/gpio.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,17,0)
static inline void gb_gpiochip_remove(struct gpio_chip *chip)
{
gpiochip_remove(chip);
}
#else
static inline void gb_gpiochip_remove(struct gpio_chip *chip)
{
int ret;
ret = gpiochip_remove(chip);
}
#endif
#endif /* __GREYBUS_KERNEL_VER_H */ #endif /* __GREYBUS_KERNEL_VER_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment