* [PATCH v1 1/2] gpiolib: Move gpiochip_get_data() upper in the code
@ 2023-03-21 13:53 Andy Shevchenko
2023-03-21 13:53 ` [PATCH v1 2/2] gpiolib: Add gpiochip_set_data() helper Andy Shevchenko
2023-04-03 15:47 ` [PATCH v1 1/2] gpiolib: Move gpiochip_get_data() upper in the code Bartosz Golaszewski
0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2023-03-21 13:53 UTC (permalink / raw)
To: Andy Shevchenko, Bartosz Golaszewski, linux-gpio, linux-kernel
Cc: Linus Walleij, Bartosz Golaszewski
Move gpiochip_get_data() upper in the code as a preparation
for further refactoring.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpiolib.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 62114d69bcea..2bfc474d99c3 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -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
--
2.40.0.1.gaa8946217a0b
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v1 2/2] gpiolib: Add gpiochip_set_data() helper
2023-03-21 13:53 [PATCH v1 1/2] gpiolib: Move gpiochip_get_data() upper in the code Andy Shevchenko
@ 2023-03-21 13:53 ` Andy Shevchenko
2023-04-03 15:47 ` [PATCH v1 1/2] gpiolib: Move gpiochip_get_data() upper in the code Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2023-03-21 13:53 UTC (permalink / raw)
To: Andy Shevchenko, Bartosz Golaszewski, linux-gpio, linux-kernel
Cc: Linus Walleij, Bartosz Golaszewski
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>
---
drivers/gpio/gpiolib.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 2bfc474d99c3..51a19cbe39a4 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -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++) {
--
2.40.0.1.gaa8946217a0b
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/2] gpiolib: Move gpiochip_get_data() upper in the code
2023-03-21 13:53 [PATCH v1 1/2] gpiolib: Move gpiochip_get_data() upper in the code Andy Shevchenko
2023-03-21 13:53 ` [PATCH v1 2/2] gpiolib: Add gpiochip_set_data() helper Andy Shevchenko
@ 2023-04-03 15:47 ` Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2023-04-03 15:47 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Bartosz Golaszewski, linux-gpio, linux-kernel, Linus Walleij
On Tue, Mar 21, 2023 at 2:52 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Move gpiochip_get_data() upper in the code as a preparation
> for further refactoring.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/gpio/gpiolib.c | 26 +++++++++++++-------------
> 1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 62114d69bcea..2bfc474d99c3 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -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
> --
> 2.40.0.1.gaa8946217a0b
>
Both applied, thanks!
Bart
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-03 15:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-21 13:53 [PATCH v1 1/2] gpiolib: Move gpiochip_get_data() upper in the code Andy Shevchenko
2023-03-21 13:53 ` [PATCH v1 2/2] gpiolib: Add gpiochip_set_data() helper Andy Shevchenko
2023-04-03 15:47 ` [PATCH v1 1/2] gpiolib: Move gpiochip_get_data() upper in the code Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).