Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gpiolib: provide gpio_device_to_device()

There are users in the kernel who need to retrieve the address of the
struct device backing the GPIO device. Currently they needlessly poke in
the internals of GPIOLIB. Add a dedicated getter function.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Peter Rosin <peda@axentia.se>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>

+19
+17
drivers/gpio/gpiolib.c
··· 1189 1189 } 1190 1190 EXPORT_SYMBOL_GPL(gpio_device_put); 1191 1191 1192 + /** 1193 + * gpio_device_to_device() - Retrieve the address of the underlying struct 1194 + * device. 1195 + * @gdev: GPIO device for which to return the address. 1196 + * 1197 + * This does not increase the reference count of the GPIO device nor the 1198 + * underlying struct device. 1199 + * 1200 + * Returns: 1201 + * Address of struct device backing this GPIO device. 1202 + */ 1203 + struct device *gpio_device_to_device(struct gpio_device *gdev) 1204 + { 1205 + return &gdev->dev; 1206 + } 1207 + EXPORT_SYMBOL_GPL(gpio_device_to_device); 1208 + 1192 1209 #ifdef CONFIG_GPIOLIB_IRQCHIP 1193 1210 1194 1211 /*
+2
include/linux/gpio/driver.h
··· 619 619 DEFINE_FREE(gpio_device_put, struct gpio_device *, 620 620 if (IS_ERR_OR_NULL(_T)) gpio_device_put(_T)); 621 621 622 + struct device *gpio_device_to_device(struct gpio_device *gdev); 623 + 622 624 bool gpiochip_line_is_irq(struct gpio_chip *gc, unsigned int offset); 623 625 int gpiochip_reqres_irq(struct gpio_chip *gc, unsigned int offset); 624 626 void gpiochip_relres_irq(struct gpio_chip *gc, unsigned int offset);