Skip to contentSkip to conversation

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

PATCH Superseded Daniel Mack 2 participants 4 messages Aug 13, 2013 – Aug 21, 2013

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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

---
 drivers/usb/musb/musb_dsps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/musb/musb_dsps.c +2 -2
index 5233804..f20218e 100644
@@ -692,7 +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 platform_device *pdev = to_platform_device(dev);
 	struct dsps_glue *glue = platform_get_drvdata(pdev);
 	const struct dsps_musb_wrapper *wrp = glue->wrp;
 	int i;
@@ -705,7 +705,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 platform_device *pdev = to_platform_device(dev);
 	struct dsps_glue *glue = platform_get_drvdata(pdev);
 	const struct dsps_musb_wrapper *wrp = glue->wrp;
 	int i;
Signature · 1 line
1.8.3.1
#1 lore raw

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

Quoted 17 lines · Daniel Mack

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.

---
 drivers/usb/musb/musb_dsps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/musb/musb_dsps.c +0 -0
index 5233804..f20218e 100644

drivers/usb/musb/musb_dsps.c static int dsps_remove(struct platform_device *pdev) · line 696

Quoted 6 lines
drivers/usb/musb/musb_dsps.c +1 -1
@@ -692,7 +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 platform_device *pdev = to_platform_device(dev);
 	struct dsps_glue *glue = platform_get_drvdata(pdev);

actually, can you get rid of the platform_device access here ? The following should work:

	struct dsps_glue *glue = dev_get_drvdata(dev);
Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130813/498c8e60/attachment-0001.sig>
#2 lore raw

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

Quoted 17 lines · Felipe Balbi

drivers/usb/musb/musb_dsps.c static int dsps_remove(struct platform_device *pdev) · line 696

Quoted 11 lines · Daniel Mack
drivers/usb/musb/musb_dsps.c +1 -1
index 5233804..f20218e 100644
@@ -692,7 +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 platform_device *pdev = to_platform_device(dev);
 	struct dsps_glue *glue = platform_get_drvdata(pdev);

actually, can you get rid of the platform_device access here ? The following should work:

Quoted 2 lines
	struct dsps_glue *glue = dev_get_drvdata(dev);

Right, thank you Felipe. I just sent out v2.

Daniel

#3 lore raw

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

In reply to Daniel Mack
Quoted 8 lines · Daniel Mack

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.

Felipe, is this one good to go in?

Thanks,
Daniel

Quoted 27 lines
---
 drivers/usb/musb/musb_dsps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/musb/musb_dsps.c +2 -2
index 5233804..f20218e 100644
@@ -692,7 +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 platform_device *pdev = to_platform_device(dev);
 	struct dsps_glue *glue = platform_get_drvdata(pdev);
 	const struct dsps_musb_wrapper *wrp = glue->wrp;
 	int i;
@@ -705,7 +705,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 platform_device *pdev = to_platform_device(dev);
 	struct dsps_glue *glue = platform_get_drvdata(pdev);
 	const struct dsps_musb_wrapper *wrp = glue->wrp;
 	int i;