aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/ux500.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/musb/ux500.c')
-rw-r--r--drivers/usb/musb/ux500.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index a8c0fadce1b0..d62a91fedc22 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -74,25 +74,34 @@ static int __devinit ux500_probe(struct platform_device *pdev)
74 goto err0; 74 goto err0;
75 } 75 }
76 76
77 musb = platform_device_alloc("musb-hdrc", -1); 77 /* get the musb id */
78 musbid = musb_get_id(&pdev->dev, GFP_KERNEL);
79 if (musbid < 0) {
80 dev_err(&pdev->dev, "failed to allocate musb id\n");
81 ret = -ENOMEM;
82 goto err1;
83 }
84
85 musb = platform_device_alloc("musb-hdrc", musbid);
78 if (!musb) { 86 if (!musb) {
79 dev_err(&pdev->dev, "failed to allocate musb device\n"); 87 dev_err(&pdev->dev, "failed to allocate musb device\n");
80 goto err1; 88 goto err2;
81 } 89 }
82 90
83 clk = clk_get(&pdev->dev, "usb"); 91 clk = clk_get(&pdev->dev, "usb");
84 if (IS_ERR(clk)) { 92 if (IS_ERR(clk)) {
85 dev_err(&pdev->dev, "failed to get clock\n"); 93 dev_err(&pdev->dev, "failed to get clock\n");
86 ret = PTR_ERR(clk); 94 ret = PTR_ERR(clk);
87 goto err2; 95 goto err3;
88 } 96 }
89 97
90 ret = clk_enable(clk); 98 ret = clk_enable(clk);
91 if (ret) { 99 if (ret) {
92 dev_err(&pdev->dev, "failed to enable clock\n"); 100 dev_err(&pdev->dev, "failed to enable clock\n");
93 goto err3; 101 goto err4;
94 } 102 }
95 103
104 musb->id = musbid;
96 musb->dev.parent = &pdev->dev; 105 musb->dev.parent = &pdev->dev;
97 musb->dev.dma_mask = pdev->dev.dma_mask; 106 musb->dev.dma_mask = pdev->dev.dma_mask;
98 musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask; 107 musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask;
@@ -109,32 +118,35 @@ static int __devinit ux500_probe(struct platform_device *pdev)
109 pdev->num_resources); 118 pdev->num_resources);
110 if (ret) { 119 if (ret) {
111 dev_err(&pdev->dev, "failed to add resources\n"); 120 dev_err(&pdev->dev, "failed to add resources\n");
112 goto err4; 121 goto err5;
113 } 122 }
114 123
115 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 124 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
116 if (ret) { 125 if (ret) {
117 dev_err(&pdev->dev, "failed to add platform_data\n"); 126 dev_err(&pdev->dev, "failed to add platform_data\n");
118 goto err4; 127 goto err5;
119 } 128 }
120 129
121 ret = platform_device_add(musb); 130 ret = platform_device_add(musb);
122 if (ret) { 131 if (ret) {
123 dev_err(&pdev->dev, "failed to register musb device\n"); 132 dev_err(&pdev->dev, "failed to register musb device\n");
124 goto err4; 133 goto err5;
125 } 134 }
126 135
127 return 0; 136 return 0;
128 137
129err4: 138err5:
130 clk_disable(clk); 139 clk_disable(clk);
131 140
132err3: 141err4:
133 clk_put(clk); 142 clk_put(clk);
134 143
135err2: 144err3:
136 platform_device_put(musb); 145 platform_device_put(musb);
137 146
147err2:
148 musb_put_id(&pdev->dev, musbid);
149
138err1: 150err1:
139 kfree(glue); 151 kfree(glue);
140 152
@@ -146,6 +158,7 @@ static int __devexit ux500_remove(struct platform_device *pdev)
146{ 158{
147 struct ux500_glue *glue = platform_get_drvdata(pdev); 159 struct ux500_glue *glue = platform_get_drvdata(pdev);
148 160
161 musb_put_id(&pdev->dev, glue->musb->id);
149 platform_device_del(glue->musb); 162 platform_device_del(glue->musb);
150 platform_device_put(glue->musb); 163 platform_device_put(glue->musb);
151 clk_disable(glue->clk); 164 clk_disable(glue->clk);