summaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2023-03-21 15:53:32 +0200
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>2023-04-03 17:46:30 +0200
commit7b59bdbc3965ca8add53e084af394c13a2be22a8 (patch)
tree8e58d2b331924a7e2599baa85a37834a6db92635 /drivers/gpio
parent8deb779d36cb86c1c1c37d767317f5899b32fc76 (diff)
downloadlinux-7b59bdbc3965ca8add53e084af394c13a2be22a8.tar.gz
linux-7b59bdbc3965ca8add53e084af394c13a2be22a8.tar.bz2
linux-7b59bdbc3965ca8add53e084af394c13a2be22a8.zip
gpiolib: Add gpiochip_set_data() helper
There are too many 'data' parameters here and there. For the better maintenance keep access GPIO device data via getter and setter. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpiolib.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index fd997eb0857f..88dcf40aca90 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -680,6 +680,11 @@ static void gpiochip_setup_devs(void)
}
}
+static void gpiochip_set_data(struct gpio_chip *gc, void *data)
+{
+ gc->gpiodev->data = data;
+}
+
/**
* gpiochip_get_data() - get per-subdriver data for the chip
* @gc: GPIO chip
@@ -722,7 +727,9 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
gdev->dev.bus = &gpio_bus_type;
gdev->dev.parent = gc->parent;
gdev->chip = gc;
+
gc->gpiodev = gdev;
+ gpiochip_set_data(gc, data);
device_set_node(&gdev->dev, gc->fwnode);
@@ -789,7 +796,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
}
gdev->ngpio = gc->ngpio;
- gdev->data = data;
spin_lock_irqsave(&gpio_lock, flags);
@@ -977,9 +983,9 @@ void gpiochip_remove(struct gpio_chip *gc)
gpiochip_free_valid_mask(gc);
/*
* We accept no more calls into the driver from this point, so
- * NULL the driver data pointer
+ * NULL the driver data pointer.
*/
- gdev->data = NULL;
+ gpiochip_set_data(gc, NULL);
spin_lock_irqsave(&gpio_lock, flags);
for (i = 0; i < gdev->ngpio; i++) {