usb: musb: fix incorrect usage of resource pointer
authorFelipe Balbi <balbi@ti.com>
Wed, 24 Apr 2013 14:21:42 +0000 (17:21 +0300)
committerFelipe Balbi <balbi@ti.com>
Tue, 28 May 2013 16:00:49 +0000 (19:00 +0300)
We can't simply pass the resource pointer from our
device down to our children, otherwise module
reinsertion will not work as the resource will
continue to be marked as busy.

Fix it by building a proper struct resource for
our child musb device.

Tested-by: Dmitry Lifshitz <lifshitz@compulab.co.il>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/musb/blackfin.c
drivers/usb/musb/da8xx.c
drivers/usb/musb/davinci.c
drivers/usb/musb/omap2430.c
drivers/usb/musb/tusb6010.c
drivers/usb/musb/ux500.c

index 5e63b160db0c10bd2087cbfcf21c611c5ce3a7af..6ba8439bd5a6e037d124a2fd5db152387fa3dd5a 100644 (file)
@@ -450,6 +450,7 @@ static u64 bfin_dmamask = DMA_BIT_MASK(32);
 
 static int bfin_probe(struct platform_device *pdev)
 {
+       struct resource musb_resources[2];
        struct musb_hdrc_platform_data  *pdata = pdev->dev.platform_data;
        struct platform_device          *musb;
        struct bfin_glue                *glue;
@@ -479,8 +480,21 @@ static int bfin_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, glue);
 
-       ret = platform_device_add_resources(musb, pdev->resource,
-                       pdev->num_resources);
+       memset(musb_resources, 0x00, sizeof(*musb_resources) *
+                       ARRAY_SIZE(musb_resources));
+
+       musb_resources[0].name = pdev->resource[0].name;
+       musb_resources[0].start = pdev->resource[0].start;
+       musb_resources[0].end = pdev->resource[0].end;
+       musb_resources[0].flags = pdev->resource[0].flags;
+
+       musb_resources[1].name = pdev->resource[1].name;
+       musb_resources[1].start = pdev->resource[1].start;
+       musb_resources[1].end = pdev->resource[1].end;
+       musb_resources[1].flags = pdev->resource[1].flags;
+
+       ret = platform_device_add_resources(musb, musb_resources,
+                       ARRAY_SIZE(musb_resources));
        if (ret) {
                dev_err(&pdev->dev, "failed to add resources\n");
                goto err3;
index b903b744a2249d59b1a2aa681dfb2b3b70b6b5c4..0da6f648a9fe1393faab16726bcc8d8725eb316c 100644 (file)
@@ -476,6 +476,7 @@ static u64 da8xx_dmamask = DMA_BIT_MASK(32);
 
 static int da8xx_probe(struct platform_device *pdev)
 {
+       struct resource musb_resources[2];
        struct musb_hdrc_platform_data  *pdata = pdev->dev.platform_data;
        struct platform_device          *musb;
        struct da8xx_glue               *glue;
@@ -521,8 +522,21 @@ static int da8xx_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, glue);
 
-       ret = platform_device_add_resources(musb, pdev->resource,
-                       pdev->num_resources);
+       memset(musb_resources, 0x00, sizeof(*musb_resources) *
+                       ARRAY_SIZE(musb_resources));
+
+       musb_resources[0].name = pdev->resource[0].name;
+       musb_resources[0].start = pdev->resource[0].start;
+       musb_resources[0].end = pdev->resource[0].end;
+       musb_resources[0].flags = pdev->resource[0].flags;
+
+       musb_resources[1].name = pdev->resource[1].name;
+       musb_resources[1].start = pdev->resource[1].start;
+       musb_resources[1].end = pdev->resource[1].end;
+       musb_resources[1].flags = pdev->resource[1].flags;
+
+       ret = platform_device_add_resources(musb, musb_resources,
+                       ARRAY_SIZE(musb_resources));
        if (ret) {
                dev_err(&pdev->dev, "failed to add resources\n");
                goto err5;
index bea6cc35471c5f73bd5e26607e06d2087df08fe1..f8aeaf2e2cd1f88ba2526861b2b932b6d6081050 100644 (file)
@@ -509,6 +509,7 @@ static u64 davinci_dmamask = DMA_BIT_MASK(32);
 
 static int davinci_probe(struct platform_device *pdev)
 {
+       struct resource musb_resources[2];
        struct musb_hdrc_platform_data  *pdata = pdev->dev.platform_data;
        struct platform_device          *musb;
        struct davinci_glue             *glue;
@@ -553,8 +554,21 @@ static int davinci_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, glue);
 
-       ret = platform_device_add_resources(musb, pdev->resource,
-                       pdev->num_resources);
+       memset(musb_resources, 0x00, sizeof(*musb_resources) *
+                       ARRAY_SIZE(musb_resources));
+
+       musb_resources[0].name = pdev->resource[0].name;
+       musb_resources[0].start = pdev->resource[0].start;
+       musb_resources[0].end = pdev->resource[0].end;
+       musb_resources[0].flags = pdev->resource[0].flags;
+
+       musb_resources[1].name = pdev->resource[1].name;
+       musb_resources[1].start = pdev->resource[1].start;
+       musb_resources[1].end = pdev->resource[1].end;
+       musb_resources[1].flags = pdev->resource[1].flags;
+
+       ret = platform_device_add_resources(musb, musb_resources,
+                       ARRAY_SIZE(musb_resources));
        if (ret) {
                dev_err(&pdev->dev, "failed to add resources\n");
                goto err5;
index 628b93fe5cccf585d21759fa112086a345a2e92a..b3e77613e0af23a3344d59246eca47e2392961a8 100644 (file)
@@ -481,6 +481,7 @@ static u64 omap2430_dmamask = DMA_BIT_MASK(32);
 
 static int omap2430_probe(struct platform_device *pdev)
 {
+       struct resource musb_resouces[2];
        struct musb_hdrc_platform_data  *pdata = pdev->dev.platform_data;
        struct omap_musb_board_data     *data;
        struct platform_device          *musb;
@@ -567,8 +568,21 @@ static int omap2430_probe(struct platform_device *pdev)
 
        INIT_WORK(&glue->omap_musb_mailbox_work, omap_musb_mailbox_work);
 
-       ret = platform_device_add_resources(musb, pdev->resource,
-                       pdev->num_resources);
+       memset(musb_resouces, 0x00, sizeof(*musb_resources) *
+                       ARRAY_SIZE(musb_resources));
+
+       musb_resources[0].name = pdev->resource[0].name;
+       musb_resources[0].start = pdev->resource[0].start;
+       musb_resources[0].end = pdev->resource[0].end;
+       musb_resources[0].flags = pdev->resource[0].flags;
+
+       musb_resources[1].name = pdev->resource[1].name;
+       musb_resources[1].start = pdev->resource[1].start;
+       musb_resources[1].end = pdev->resource[1].end;
+       musb_resources[1].flags = pdev->resource[1].flags;
+
+       ret = platform_device_add_resources(musb, musb_resources,
+                       ARRAY_SIZE(musb_resources));
        if (ret) {
                dev_err(&pdev->dev, "failed to add resources\n");
                goto err2;
index 7369ba33c94f1edc529c93dd03444c99fae5c464..2c06a8969a9f793153d6f6f0546be9d5eb1ff8a0 100644 (file)
@@ -1156,6 +1156,7 @@ static u64 tusb_dmamask = DMA_BIT_MASK(32);
 
 static int tusb_probe(struct platform_device *pdev)
 {
+       struct resource musb_resources[2];
        struct musb_hdrc_platform_data  *pdata = pdev->dev.platform_data;
        struct platform_device          *musb;
        struct tusb6010_glue            *glue;
@@ -1185,8 +1186,21 @@ static int tusb_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, glue);
 
-       ret = platform_device_add_resources(musb, pdev->resource,
-                       pdev->num_resources);
+       memset(musb_resources, 0x00, sizeof(*musb_resources) *
+                       ARRAY_SIZE(musb_resources));
+
+       musb_resources[0].name = pdev->resource[0].name;
+       musb_resources[0].start = pdev->resource[0].start;
+       musb_resources[0].end = pdev->resource[0].end;
+       musb_resources[0].flags = pdev->resource[0].flags;
+
+       musb_resources[1].name = pdev->resource[1].name;
+       musb_resources[1].start = pdev->resource[1].start;
+       musb_resources[1].end = pdev->resource[1].end;
+       musb_resources[1].flags = pdev->resource[1].flags;
+
+       ret = platform_device_add_resources(musb, musb_resources,
+                       ARRAY_SIZE(musb_resources));
        if (ret) {
                dev_err(&pdev->dev, "failed to add resources\n");
                goto err3;
index 2c80004e0a83029b52b7ea13f2d4c97194f40412..028ff4d07dc74a3346df56c6a677e4e8d95bbf9e 100644 (file)
@@ -189,6 +189,7 @@ static const struct musb_platform_ops ux500_ops = {
 
 static int ux500_probe(struct platform_device *pdev)
 {
+       struct resource musb_resources[2];
        struct musb_hdrc_platform_data  *pdata = pdev->dev.platform_data;
        struct platform_device          *musb;
        struct ux500_glue               *glue;
@@ -232,8 +233,21 @@ static int ux500_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, glue);
 
-       ret = platform_device_add_resources(musb, pdev->resource,
-                       pdev->num_resources);
+       memset(musb_resources, 0x00, sizeof(*musb_resources) *
+                       ARRAY_SIZE(musb_resources));
+
+       musb_resources[0].name = pdev->resource[0].name;
+       musb_resources[0].start = pdev->resource[0].start;
+       musb_resources[0].end = pdev->resource[0].end;
+       musb_resources[0].flags = pdev->resource[0].flags;
+
+       musb_resources[1].name = pdev->resource[1].name;
+       musb_resources[1].start = pdev->resource[1].start;
+       musb_resources[1].end = pdev->resource[1].end;
+       musb_resources[1].flags = pdev->resource[1].flags;
+
+       ret = platform_device_add_resources(musb, musb_resources,
+                       ARRAY_SIZE(musb_resources));
        if (ret) {
                dev_err(&pdev->dev, "failed to add resources\n");
                goto err5;