[PATCH v2 07/10] gpio: aggregator: clean up gpio_aggregator_free()

Koichiro Den posted 10 patches 1 year ago
There is a newer version of this series
[PATCH v2 07/10] gpio: aggregator: clean up gpio_aggregator_free()
Posted by Koichiro Den 1 year ago
- Rename gpio_aggregator_free() to use the "aggr_" prefix for
  consistency with other functions that modify struct gpio_aggregator
  internals.
- Replace four lines within the function to invoke aggr_deactivate()
- Move it to a more natural location.

This is a preparatory change for the next commit.

No functional change.

Signed-off-by: Koichiro Den <koichiro.den@canonical.com>
---
 drivers/gpio/gpio-aggregator.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
index 123906c821b1..d5fd9fe58164 100644
--- a/drivers/gpio/gpio-aggregator.c
+++ b/drivers/gpio/gpio-aggregator.c
@@ -1092,6 +1092,12 @@ static int aggr_parse(struct gpio_aggregator *aggr)
 	return 0;
 }
 
+static void aggr_free(struct gpio_aggregator *aggr)
+{
+	aggr_deactivate(aggr);
+	kfree(aggr);
+}
+
 static ssize_t new_device_store(struct device_driver *driver, const char *buf,
 				size_t count)
 {
@@ -1160,15 +1166,6 @@ static ssize_t new_device_store(struct device_driver *driver, const char *buf,
 
 static DRIVER_ATTR_WO(new_device);
 
-static void gpio_aggregator_free(struct gpio_aggregator *aggr)
-{
-	platform_device_unregister(aggr->pdev);
-	gpiod_remove_lookup_table(aggr->lookups);
-	kfree(aggr->lookups->dev_id);
-	kfree(aggr->lookups);
-	kfree(aggr);
-}
-
 static ssize_t delete_device_store(struct device_driver *driver,
 				   const char *buf, size_t count)
 {
@@ -1189,7 +1186,7 @@ static ssize_t delete_device_store(struct device_driver *driver,
 	if (!aggr)
 		return -ENOENT;
 
-	gpio_aggregator_free(aggr);
+	aggr_free(aggr);
 	return count;
 }
 static DRIVER_ATTR_WO(delete_device);
@@ -1261,7 +1258,7 @@ static struct platform_driver gpio_aggregator_driver = {
 
 static int __exit gpio_aggregator_idr_remove(int id, void *p, void *data)
 {
-	gpio_aggregator_free(p);
+	aggr_free(p);
 	return 0;
 }
 
-- 
2.45.2
Re: [PATCH v2 07/10] gpio: aggregator: clean up gpio_aggregator_free()
Posted by Geert Uytterhoeven 12 months ago
On Mon, 3 Feb 2025 at 04:14, Koichiro Den <koichiro.den@canonical.com> wrote:
> - Rename gpio_aggregator_free() to use the "aggr_" prefix for
>   consistency with other functions that modify struct gpio_aggregator
>   internals.
> - Replace four lines within the function to invoke aggr_deactivate()
> - Move it to a more natural location.
>
> This is a preparatory change for the next commit.
>
> No functional change.
>
> Signed-off-by: Koichiro Den <koichiro.den@canonical.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds