Commit 1f5eb8b1 authored by Kent Gibson's avatar Kent Gibson Committed by Bartosz Golaszewski

gpiolib: fix sysfs when cdev is not selected

In gpiochip_setup_dev() the call to gpiolib_cdev_register() indirectly
calls device_add().  This is still required for the sysfs even when
CONFIG_GPIO_CDEV is not selected in the build.

Replace the stubbed functions in gpiolib-cdev.h with macros in gpiolib.c
that perform the required device_add() and device_del() when
CONFIG_GPIO_CDEV is not selected.

Fixes: d143493c (gpiolib: make cdev a build option)
Reported-by: default avatarNicolas Schichan <nschichan@freebox.fr>
Signed-off-by: default avatarKent Gibson <warthog618@gmail.com>
Tested-by: default avatarNicolas Schichan <nschichan@freebox.fr>
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
parent 560b6ac3
...@@ -7,22 +7,7 @@ ...@@ -7,22 +7,7 @@
struct gpio_device; struct gpio_device;
#ifdef CONFIG_GPIO_CDEV
int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt); int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt);
void gpiolib_cdev_unregister(struct gpio_device *gdev); void gpiolib_cdev_unregister(struct gpio_device *gdev);
#else
static inline int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt)
{
return 0;
}
static inline void gpiolib_cdev_unregister(struct gpio_device *gdev)
{
}
#endif /* CONFIG_GPIO_CDEV */
#endif /* GPIOLIB_CDEV_H */ #endif /* GPIOLIB_CDEV_H */
...@@ -480,11 +480,23 @@ static void gpiodevice_release(struct device *dev) ...@@ -480,11 +480,23 @@ static void gpiodevice_release(struct device *dev)
kfree(gdev); kfree(gdev);
} }
#ifdef CONFIG_GPIO_CDEV
#define gcdev_register(gdev, devt) gpiolib_cdev_register((gdev), (devt))
#define gcdev_unregister(gdev) gpiolib_cdev_unregister((gdev))
#else
/*
* gpiolib_cdev_register() indirectly calls device_add(), which is still
* required even when cdev is not selected.
*/
#define gcdev_register(gdev, devt) device_add(&(gdev)->dev)
#define gcdev_unregister(gdev) device_del(&(gdev)->dev)
#endif
static int gpiochip_setup_dev(struct gpio_device *gdev) static int gpiochip_setup_dev(struct gpio_device *gdev)
{ {
int ret; int ret;
ret = gpiolib_cdev_register(gdev, gpio_devt); ret = gcdev_register(gdev, gpio_devt);
if (ret) if (ret)
return ret; return ret;
...@@ -500,7 +512,7 @@ static int gpiochip_setup_dev(struct gpio_device *gdev) ...@@ -500,7 +512,7 @@ static int gpiochip_setup_dev(struct gpio_device *gdev)
return 0; return 0;
err_remove_device: err_remove_device:
gpiolib_cdev_unregister(gdev); gcdev_unregister(gdev);
return ret; return ret;
} }
...@@ -825,7 +837,7 @@ void gpiochip_remove(struct gpio_chip *gc) ...@@ -825,7 +837,7 @@ void gpiochip_remove(struct gpio_chip *gc)
* be removed, else it will be dangling until the last user is * be removed, else it will be dangling until the last user is
* gone. * gone.
*/ */
gpiolib_cdev_unregister(gdev); gcdev_unregister(gdev);
put_device(&gdev->dev); put_device(&gdev->dev);
} }
EXPORT_SYMBOL_GPL(gpiochip_remove); EXPORT_SYMBOL_GPL(gpiochip_remove);
......
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