From: Greg Kroah-Hartman Date: Mon, 20 Oct 2014 05:40:02 +0000 (+0800) Subject: greybus: gpio-gb: allow it to build properly for all current kernel versions. X-Git-Tag: v4.9-rc1~119^2~378^2~21^2~1999 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=213aefe206d288eee4a2d480d9c6b2889b441682;p=karo-tx-linux.git 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: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/gpio-gb.c b/drivers/staging/greybus/gpio-gb.c index 7f03676ef46f..53464e39ba6d 100644 --- a/drivers/staging/greybus/gpio-gb.c +++ b/drivers/staging/greybus/gpio-gb.c @@ -799,12 +799,11 @@ out_err: void gb_gpio_controller_exit(struct gb_connection *connection) { struct gb_gpio_controller *gb_gpio_controller = connection->private; - int ret; if (!gb_gpio_controller) return; - ret = gpiochip_remove(&gb_gpio_controller->chip); + gb_gpiochip_remove(&gb_gpio_controller->chip); /* kref_put(gb_gpio_controller->connection) */ kfree(gb_gpio_controller); } diff --git a/drivers/staging/greybus/kernel_ver.h b/drivers/staging/greybus/kernel_ver.h index c9ea7a94f4e6..e0fea182c3b5 100644 --- a/drivers/staging/greybus/kernel_ver.h +++ b/drivers/staging/greybus/kernel_ver.h @@ -26,4 +26,26 @@ #define U16_MAX ((u16)(~0U)) #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 +#include + +#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 */