提交 3b7c7478 编写于 作者: A Andy Shevchenko 提交者: Bartosz Golaszewski

gpiolib: Provide to_gpio_device() helper

Provide to_gpio_device() helper which can be utilized in the existing
and future code.

While at it, make sure it becomes no-op at compilation time.
Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: NBartosz Golaszewski <bartosz.golaszewski@linaro.org>
上级 4ef339bc
...@@ -549,7 +549,7 @@ EXPORT_SYMBOL_GPL(gpiochip_line_is_valid); ...@@ -549,7 +549,7 @@ EXPORT_SYMBOL_GPL(gpiochip_line_is_valid);
static void gpiodevice_release(struct device *dev) static void gpiodevice_release(struct device *dev)
{ {
struct gpio_device *gdev = container_of(dev, struct gpio_device, dev); struct gpio_device *gdev = to_gpio_device(dev);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&gpio_lock, flags); spin_lock_irqsave(&gpio_lock, flags);
......
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
/** /**
* struct gpio_device - internal state container for GPIO devices * struct gpio_device - internal state container for GPIO devices
* @id: numerical ID number for the GPIO chip
* @dev: the GPIO device struct * @dev: the GPIO device struct
* @chrdev: character device for the GPIO device * @chrdev: character device for the GPIO device
* @id: numerical ID number for the GPIO chip
* @mockdev: class device used by the deprecated sysfs interface (may be * @mockdev: class device used by the deprecated sysfs interface (may be
* NULL) * NULL)
* @owner: helps prevent removal of modules exporting active GPIOs * @owner: helps prevent removal of modules exporting active GPIOs
...@@ -47,9 +47,9 @@ ...@@ -47,9 +47,9 @@
* userspace. * userspace.
*/ */
struct gpio_device { struct gpio_device {
int id;
struct device dev; struct device dev;
struct cdev chrdev; struct cdev chrdev;
int id;
struct device *mockdev; struct device *mockdev;
struct module *owner; struct module *owner;
struct gpio_chip *chip; struct gpio_chip *chip;
...@@ -72,6 +72,11 @@ struct gpio_device { ...@@ -72,6 +72,11 @@ struct gpio_device {
#endif #endif
}; };
static inline struct gpio_device *to_gpio_device(struct device *dev)
{
return container_of(dev, struct gpio_device, dev);
}
/* gpio suffixes used for ACPI and device tree lookup */ /* gpio suffixes used for ACPI and device tree lookup */
static __maybe_unused const char * const gpio_suffixes[] = { "gpios", "gpio" }; static __maybe_unused const char * const gpio_suffixes[] = { "gpios", "gpio" };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册