summaryrefslogtreecommitdiff
path: root/drivers/gpio/gpiolib.h
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2022-11-28 22:00:54 +0300
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>2022-11-29 16:52:20 +0300
commit3b7c7478eda00945987d45f902bc3942c89243d3 (patch)
tree2546a2c739b292b6edd924e9e6713e2b4fbc6b28 /drivers/gpio/gpiolib.h
parent4ef339bc053a62dac9017f80f7bb8cff0412bd29 (diff)
downloadlinux-3b7c7478eda00945987d45f902bc3942c89243d3.tar.xz
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.h')
-rw-r--r--drivers/gpio/gpiolib.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
index d900ecdbac46..e443c1023a37 100644
--- a/drivers/gpio/gpiolib.h
+++ b/drivers/gpio/gpiolib.h
@@ -20,9 +20,9 @@
/**
* struct gpio_device - internal state container for GPIO devices
- * @id: numerical ID number for the GPIO chip
* @dev: the GPIO device struct
* @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
* NULL)
* @owner: helps prevent removal of modules exporting active GPIOs
@@ -47,9 +47,9 @@
* userspace.
*/
struct gpio_device {
- int id;
struct device dev;
struct cdev chrdev;
+ int id;
struct device *mockdev;
struct module *owner;
struct gpio_chip *chip;
@@ -72,6 +72,11 @@ struct gpio_device {
#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 */
static __maybe_unused const char * const gpio_suffixes[] = { "gpios", "gpio" };