gpiolib: Move gpiochip_get_data() upper in the code
PATCH 1/2 gpiolib: Move gpiochip_get_data() upper in the code
Move gpiochip_get_data() upper in the code as a preparation for further refactoring.
Signed-off-by Andy Shevchenko <[email protected]>
--- drivers/gpio/gpiolib.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/gpio/gpiolib.c +13 -13
@@ -681,6 +681,19 @@ static void gpiochip_setup_devs(void) } } +/** +* gpiochip_get_data() - get per-subdriver data for the chip +* @gc: GPIO chip +* +* Returns: +* The per-subdriver data for the chip. +*/ +void *gpiochip_get_data (struct gpio_chip *gc) +{ +return gc->gpiodev->data; +} +EXPORT_SYMBOL_GPL (gpiochip_get_data); +int gpiochip_add_data_with_key (struct gpio_chip *gc,void *data,struct lock_class_key *lock_key,struct lock_class_key *request_key)
@@ -939,19 +952,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, }EXPORT_SYMBOL_GPL (gpiochip_add_data_with_key); -/** -* gpiochip_get_data() - get per-subdriver data for the chip -* @gc: GPIO chip -* -* Returns: -* The per-subdriver data for the chip. -*/ -void *gpiochip_get_data (struct gpio_chip *gc) -{ -return gc->gpiodev->data; -} -EXPORT_SYMBOL_GPL (gpiochip_get_data); -/** * gpiochip_remove() - unregister a gpio_chip * @gc: the chip to unregister
Signature · 1 line
2.40.0.1.gaa8946217a0b
PATCH 2/2 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 <[email protected]>
--- drivers/gpio/gpiolib.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpio/gpiolib.c +9 -3
@@ -681,6 +681,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
@@ -723,7 +728,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);
@@ -790,7 +797,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);
@@ -978,9 +984,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++) {
Signature · 1 line
2.40.0.1.gaa8946217a0b
Quoted 54 lines · Andy Shevchenko
Move
gpiochip_get_data()upper in the code as a preparation for further refactoring.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/gpio/gpiolib.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)drivers/gpio/gpiolib.c +13
-14@@ -681,6 +681,19 @@ static void gpiochip_setup_devs(void) } } +/** +* gpiochip_get_data() - get per-subdriver data for the chip +* @gc: GPIO chip +* +* Returns: +* The per-subdriver data for the chip. +*/ +void *gpiochip_get_data (struct gpio_chip *gc) +{ +return gc->gpiodev->data; +} +EXPORT_SYMBOL_GPL (gpiochip_get_data); +int gpiochip_add_data_with_key (struct gpio_chip *gc,void *data,struct lock_class_key *lock_key,struct lock_class_key *request_key)@@ -939,19 +952,6 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, }EXPORT_SYMBOL_GPL (gpiochip_add_data_with_key); -/** -* gpiochip_get_data() - get per-subdriver data for the chip -* @gc: GPIO chip -* -* Returns: -* The per-subdriver data for the chip. -*/ -void *gpiochip_get_data (struct gpio_chip *gc) -{ -return gc->gpiodev->data; -} -EXPORT_SYMBOL_GPL (gpiochip_get_data); -/** * gpiochip_remove() - unregister a gpio_chip * @gc: the chip to unregister --
Quoted 2 lines
2.40.0.1.gaa8946217a0b
Both applied, thanks!
Bart