Skip to content

Commit 7b59bdb

Browse files
andy-shevBartosz Golaszewski
authored andcommitted
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>
1 parent 8deb779 commit 7b59bdb

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

drivers/gpio/gpiolib.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,11 @@ static void gpiochip_setup_devs(void)
680680
}
681681
}
682682

683+
static void gpiochip_set_data(struct gpio_chip *gc, void *data)
684+
{
685+
gc->gpiodev->data = data;
686+
}
687+
683688
/**
684689
* gpiochip_get_data() - get per-subdriver data for the chip
685690
* @gc: GPIO chip
@@ -722,7 +727,9 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
722727
gdev->dev.bus = &gpio_bus_type;
723728
gdev->dev.parent = gc->parent;
724729
gdev->chip = gc;
730+
725731
gc->gpiodev = gdev;
732+
gpiochip_set_data(gc, data);
726733

727734
device_set_node(&gdev->dev, gc->fwnode);
728735

@@ -789,7 +796,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
789796
}
790797

791798
gdev->ngpio = gc->ngpio;
792-
gdev->data = data;
793799

794800
spin_lock_irqsave(&gpio_lock, flags);
795801

@@ -977,9 +983,9 @@ void gpiochip_remove(struct gpio_chip *gc)
977983
gpiochip_free_valid_mask(gc);
978984
/*
979985
* We accept no more calls into the driver from this point, so
980-
* NULL the driver data pointer
986+
* NULL the driver data pointer.
981987
*/
982-
gdev->data = NULL;
988+
gpiochip_set_data(gc, NULL);
983989

984990
spin_lock_irqsave(&gpio_lock, flags);
985991
for (i = 0; i < gdev->ngpio; i++) {

0 commit comments

Comments
 (0)