linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] gpio: mockup: remove gpio debugfs when remove device
@ 2022-08-16 14:52 Wei Yongjun
  2022-08-19 12:49 ` Bartosz Golaszewski
  0 siblings, 1 reply; 6+ messages in thread
From: Wei Yongjun @ 2022-08-16 14:52 UTC (permalink / raw)
  To: Bamvor Jian Zhang, Linus Walleij, Bartosz Golaszewski
  Cc: Wei Yongjun, linux-gpio, linux-kernel

GPIO mockup debugfs is created in gpio_mockup_probe() but
forgot to remove when remove device. This patch add a devm
managed callback for removing them.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/gpio/gpio-mockup.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 8943cea92764..1fdc444b093b 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -373,6 +373,13 @@ static void gpio_mockup_debugfs_setup(struct device *dev,
 	}
 }
 
+static void gpio_mockup_debugfs_cleanup(void *data)
+{
+	struct gpio_mockup_chip *chip = data;
+
+	debugfs_remove_recursive(chip->dbg_dir);
+}
+
 static void gpio_mockup_dispose_mappings(void *data)
 {
 	struct gpio_mockup_chip *chip = data;
@@ -455,6 +462,10 @@ static int gpio_mockup_probe(struct platform_device *pdev)
 
 	gpio_mockup_debugfs_setup(dev, chip);
 
+	rv = devm_add_action_or_reset(dev, gpio_mockup_debugfs_cleanup, chip);
+	if (rv)
+		return rv;
+
 	return 0;
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-08-29  1:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-16 14:52 [PATCH -next] gpio: mockup: remove gpio debugfs when remove device Wei Yongjun
2022-08-19 12:49 ` Bartosz Golaszewski
2022-08-22  3:39   ` weiyongjun (A)
2022-08-22 13:27   ` weiyongjun (A)
2022-08-28 14:00     ` Bartosz Golaszewski
2022-08-29  1:15       ` weiyongjun (A)

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).