pinctrl: free debugfs entries when unloading a pinmux driver
authorTony Lindgren <tony@atomide.com>
Fri, 20 Jan 2012 16:17:22 +0000 (08:17 -0800)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 24 Jan 2012 22:03:02 +0000 (23:03 +0100)
We were not cleaning up properly after unloading a pinmux
driver compiled as module.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/core.c
drivers/pinctrl/core.h

index 569bdb3ef1046155b021648390087a9010591d3b..d9d35fcbfc6b33885ab31124718be422702916d1 100644 (file)
@@ -510,10 +510,12 @@ static struct dentry *debugfs_root;
 
 static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev)
 {
-       static struct dentry *device_root;
+       struct dentry *device_root;
 
        device_root = debugfs_create_dir(dev_name(pctldev->dev),
                                         debugfs_root);
+       pctldev->device_root = device_root;
+
        if (IS_ERR(device_root) || !device_root) {
                pr_warn("failed to create debugfs directory for %s\n",
                        dev_name(pctldev->dev));
@@ -529,6 +531,11 @@ static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev)
        pinconf_init_device_debugfs(device_root, pctldev);
 }
 
+static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev)
+{
+       debugfs_remove_recursive(pctldev->device_root);
+}
+
 static void pinctrl_init_debugfs(void)
 {
        debugfs_root = debugfs_create_dir("pinctrl", NULL);
@@ -553,6 +560,10 @@ static void pinctrl_init_debugfs(void)
 {
 }
 
+static void pinctrl_remove_device_debugfs(struct pinctrl_dev *pctldev)
+{
+}
+
 #endif
 
 /**
@@ -641,6 +652,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev)
        if (pctldev == NULL)
                return;
 
+       pinctrl_remove_device_debugfs(pctldev);
        pinmux_unhog_maps(pctldev);
        /* TODO: check that no pinmuxes are still active? */
        mutex_lock(&pinctrldev_list_mutex);
index 177a3310547f31ceb8a9cd1191cb55f7f253469d..cfa86da6b4b15b546cbf78de371247812c162a9c 100644 (file)
@@ -41,6 +41,9 @@ struct pinctrl_dev {
        struct device *dev;
        struct module *owner;
        void *driver_data;
+#ifdef CONFIG_DEBUG_FS
+       struct dentry *device_root;
+#endif
 #ifdef CONFIG_PINMUX
        struct mutex pinmux_hogs_lock;
        struct list_head pinmux_hogs;