Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>

authored by

Daniel Mack and committed by
Felipe Balbi
0fca91b8 5cdf7d5b

+2 -3
+2 -3
drivers/usb/musb/musb_dsps.c
··· 470 470 struct dsps_glue *glue = dev_get_drvdata(dev->parent); 471 471 472 472 del_timer_sync(&glue->timer); 473 - 474 473 usb_phy_shutdown(musb->xceiv); 474 + debugfs_remove_recursive(glue->dbgfs_root); 475 + 475 476 return 0; 476 477 } 477 478 ··· 708 707 /* disable usbss clocks */ 709 708 pm_runtime_put(&pdev->dev); 710 709 pm_runtime_disable(&pdev->dev); 711 - 712 - debugfs_remove_recursive(glue->dbgfs_root); 713 710 714 711 return 0; 715 712 }