Skip to contentSkip to conversation

usb: musb_dsps: fix the exit routine for debugfs

PATCH In review Olivier Gayot 4 participants 4 messages Apr 23, 2014 – Apr 24, 2014 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: musb_dsps: fix the exit routine for debugfs

The following commit introduced the debugfs :

40f099e32c2a06bad7d75683421e30fcc74924cd

Author: Markus Pargmann <[email protected]>
Date:   Fri Jan 17 10:22:35 2014 +0100

usb: musb: dsps, debugfs files

Unfortunately, a forgotten call to a cleanup function prevents the probing of musb in case of deferred probe.

Because musb_init_controller() often retries and creates a new debugfs directory each time it is called, we need to remove that directory in case the initialization fails. Otherwise, the debugfs_create_dir() fails at subsequent calls because the directory already exists.

Fixed by calling debugfs_remove_recursive() in the exit function.

Cc Markus Pargmann <[email protected]>
---
 drivers/usb/musb/musb_dsps.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/usb/musb/musb_dsps.c +2 -0
index 3372ded..c3de0a5 100644
@@ -471,6 +471,8 @@ static int dsps_musb_exit(struct musb *musb)
 
 	del_timer_sync(&glue->timer);
 
+	debugfs_remove_recursive(glue->dbgfs_root);
+
 	usb_phy_shutdown(musb->xceiv);
 	return 0;
 }
Signature · 1 line
1.7.9.5

A message that is not in the archive (sent off-list or not yet received): 1398267583-19159-1-git-send-email-ogayot-rdvid1DuHRBWk0Htik3J/[email protected]

#2 lore raw
Quoted 29 lines · Olivier Gayot

The following commit introduced the debugfs :

40f099e32c2a06bad7d75683421e30fcc74924cd

Author: Markus Pargmann <[email protected]>
Date:   Fri Jan 17 10:22:35 2014 +0100

usb: musb: dsps, debugfs files

Unfortunately, a forgotten call to a cleanup function prevents the probing of musb in case of deferred probe.

Because musb_init_controller() often retries and creates a new debugfs directory each time it is called, we need to remove that directory in case the initialization fails. Otherwise, the debugfs_create_dir() fails at subsequent calls because the directory already exists.

Fixed by calling debugfs_remove_recursive() in the exit function.

---
 drivers/usb/musb/musb_dsps.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/usb/musb/musb_dsps.c +0 -0
index 3372ded..c3de0a5 100644

drivers/usb/musb/musb_dsps.c static int dsps_musb_exit(struct musb *musb) · line 477

Quoted 7 lines
drivers/usb/musb/musb_dsps.c +2 -0
@@ -471,6 +471,8 @@ static int dsps_musb_exit(struct musb *musb)
 
 	del_timer_sync(&glue->timer);
 
+	debugfs_remove_recursive(glue->dbgfs_root);
+
 	usb_phy_shutdown(musb->xceiv);
 	return 0;

First of all this commit is wrong, second of all I already have the proper commit:

commit 0fca91b8a446d4a38b8f3d4772c4a8665ebcd7b2

Author: Daniel Mack <[email protected]>
Date:   Wed Apr 2 11:46:51 2014 +0200

usb: musb: dsps: move debugfs_remove_recursive()

When the platform initialization fails due to missing resources, it will return -EPROBE_DEFER after dsps_musb_init() has been called.

dsps_musb_init() calls dsps_musb_dbg_init() to allocate the debugfs nodes. At a later point in time, the probe will be retried, and dsps_musb_dbg_init() will be called again. debugfs_create_dir() will fail this time, as the node already exists, and so the entire device probe will fail with -ENOMEM.

Fix this by moving debugfs_remove_recursive() from dsps_remove() to the plaform's exit function, so it will be cleanly torn down when the probe fails. It also feels more natural this way, as .exit is the counterpart to .init.

drivers/usb/musb/musb_dsps.c +2 -3
index 3372ded..e2fd263 100644
@@ -470,8 +470,9 @@ static int dsps_musb_exit(struct musb *musb)
 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
 
 	del_timer_sync(&glue->timer);
-
 	usb_phy_shutdown(musb->xceiv);
+	debugfs_remove_recursive(glue->dbgfs_root);
+
 	return 0;
 }
 
@@ -708,8 +709,6 @@ static int dsps_remove(struct platform_device *pdev)
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-	debugfs_remove_recursive(glue->dbgfs_root);
-
 	return 0;
 }
 

a pull request has already been sent to Greg, should be in v3.15-rc3

Signature · 1 line
balbi

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Ok, thank you, I didn't notice the existing thread.

Quoted 90 lines · On Wed, 23 Apr 2014 10:55:29 -0500 Felipe Balbi…
Quoted 30 lines · Olivier Gayot

The following commit introduced the debugfs :

40f099e32c2a06bad7d75683421e30fcc74924cd

Author: Markus Pargmann <[email protected]>
Date:   Fri Jan 17 10:22:35 2014 +0100

usb: musb: dsps, debugfs files

Unfortunately, a forgotten call to a cleanup function prevents the probing of musb in case of deferred probe.

Because musb_init_controller() often retries and creates a new debugfs directory each time it is called, we need to remove that directory in case the initialization fails. Otherwise, the debugfs_create_dir() fails at subsequent calls because the directory already exists.

Fixed by calling debugfs_remove_recursive() in the exit function.

---
 drivers/usb/musb/musb_dsps.c |    2 ++
 1 file changed, 2 insertions(+)
(quoted diff) +0 -0

b/drivers/usb/musb/musb_dsps.c index 3372ded..c3de0a5 100644

drivers/usb/musb/musb_dsps.c static int dsps_musb_exit(struct musb *musb) · line 477

Quoted 7 lines
drivers/usb/musb/musb_dsps.c +2 -0
@@ -471,6 +471,8 @@ static int dsps_musb_exit(struct musb *musb)
 
 	del_timer_sync(&glue->timer);
 
+	debugfs_remove_recursive(glue->dbgfs_root);
+
 	usb_phy_shutdown(musb->xceiv);
 	return 0;

First of all this commit is wrong, second of all I already have the proper commit:

commit 0fca91b8a446d4a38b8f3d4772c4a8665ebcd7b2

Author: Daniel Mack <[email protected]>
Date:   Wed Apr 2 11:46:51 2014 +0200

usb: musb: dsps: move debugfs_remove_recursive()

When the platform initialization fails due to missing resources,
it will return -EPROBE_DEFER after dsps_musb_init() has been called.

dsps_musb_init() calls dsps_musb_dbg_init() to allocate the
debugfs nodes. At a later point in time, the probe will be retried, and dsps_musb_dbg_init() will be called again. debugfs_create_dir() will fail this time, as the node already exists, and so the entire device probe will fail with -ENOMEM.

Fix this by moving debugfs_remove_recursive() from dsps_remove()
to the plaform's exit function, so it will be cleanly torn down when the probe fails. It also feels more natural this way, as .exit is the counterpart to .init.

(quoted diff) +0 -0

b/drivers/usb/musb/musb_dsps.c index 3372ded..e2fd263 100644

drivers/usb/musb/musb_dsps.c +2 -3
@@ -470,8 +470,9 @@ static int dsps_musb_exit(struct musb *musb)
 	struct dsps_glue *glue = dev_get_drvdata(dev->parent);
 
 	del_timer_sync(&glue->timer);
-
 	usb_phy_shutdown(musb->xceiv);
+	debugfs_remove_recursive(glue->dbgfs_root);
+
 	return 0;
 }
 
@@ -708,8 +709,6 @@ static int dsps_remove(struct platform_device
 *pdev) pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-	debugfs_remove_recursive(glue->dbgfs_root);
-
 	return 0;
 }
 
Quoted 2 lines

a pull request has already been sent to Greg, should be in v3.15-rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Hi,

Quoted 1 line · Olivier Gayot

Ok, thank you, I didn't notice the existing thread.

no problem, but don't top-post please :-s

Signature · 1 line
balbi