Skip to contentSkip to conversation

usb: musb dsps: fix pdev cast in suspend/resume

PATCH New Daniel Mack 1 participant 1 message Aug 13, 2013

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

PATCH v2 1/1 usb: musb dsps: fix pdev cast in suspend/resume

dsps_suspend() and dsps_resume() are called with the device that has the glue assigned as drvdata. Using dev->parent seems wrong and causes a NULL pointer exception on an AM33xx board.

The code was introduced by commit c68bb4c6 ("usb: musb: dsps: control module handling (quirk)") but I wonder whether it was ever used.

As suggested by Felipe, this patch gets rid of the platform_device access entirely by using dev_get_drvdata().

---
 drivers/usb/musb/musb_dsps.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/musb/musb_dsps.c +2 -4
index 5233804..16e36a3 100644
@@ -692,8 +692,7 @@ static int dsps_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int dsps_suspend(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev->parent);
-	struct dsps_glue *glue = platform_get_drvdata(pdev);
+	struct dsps_glue *glue = dev_get_drvdata(dev);
 	const struct dsps_musb_wrapper *wrp = glue->wrp;
 	int i;
 
@@ -705,8 +704,7 @@ static int dsps_suspend(struct device *dev)
 
 static int dsps_resume(struct device *dev)
 {
-	struct platform_device *pdev = to_platform_device(dev->parent);
-	struct dsps_glue *glue = platform_get_drvdata(pdev);
+	struct dsps_glue *glue = dev_get_drvdata(dev);
 	const struct dsps_musb_wrapper *wrp = glue->wrp;
 	int i;
 
Signature · 1 line
1.8.3.1