aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/tusb6010.c
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2010-12-02 02:35:58 -0500
committerFelipe Balbi <balbi@ti.com>2010-12-10 03:21:19 -0500
commit1add75d2bd1a44553e2c40e30db5f90a500dc1ab (patch)
treefa2a8d7a3ee80536e4e876909e2980004418b22e /drivers/usb/musb/tusb6010.c
parent0919dfc12a43d5ea21411e67984c268e84d05204 (diff)
usb: musb: tusb6010: give it a context structure
that structure currently only holds a device pointer to our own platform_device and musb's platform_device, but soon it will hold pointers to our clock structures and glue-specific bits and pieces. Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/tusb6010.c')
-rw-r--r--drivers/usb/musb/tusb6010.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index a8e26a0f2ad4..2ff78d6b2eff 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -25,6 +25,11 @@
25 25
26#include "musb_core.h" 26#include "musb_core.h"
27 27
28struct tusb6010_glue {
29 struct device *dev;
30 struct platform_device *musb;
31};
32
28static void tusb_musb_set_vbus(struct musb *musb, int is_on); 33static void tusb_musb_set_vbus(struct musb *musb, int is_on);
29 34
30#define TUSB_REV_MAJOR(reg_val) ((reg_val >> 4) & 0xf) 35#define TUSB_REV_MAJOR(reg_val) ((reg_val >> 4) & 0xf)
@@ -1193,32 +1198,42 @@ static int __init tusb_probe(struct platform_device *pdev)
1193{ 1198{
1194 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; 1199 struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data;
1195 struct platform_device *musb; 1200 struct platform_device *musb;
1201 struct tusb6010_glue *glue;
1196 1202
1197 int ret = -ENOMEM; 1203 int ret = -ENOMEM;
1198 1204
1205 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
1206 if (!glue) {
1207 dev_err(&pdev->dev, "failed to allocate glue context\n");
1208 goto err0;
1209 }
1210
1199 musb = platform_device_alloc("musb-hdrc", -1); 1211 musb = platform_device_alloc("musb-hdrc", -1);
1200 if (!musb) { 1212 if (!musb) {
1201 dev_err(&pdev->dev, "failed to allocate musb device\n"); 1213 dev_err(&pdev->dev, "failed to allocate musb device\n");
1202 goto err0; 1214 goto err1;
1203 } 1215 }
1204 1216
1205 musb->dev.parent = &pdev->dev; 1217 musb->dev.parent = &pdev->dev;
1206 musb->dev.dma_mask = &tusb_dmamask; 1218 musb->dev.dma_mask = &tusb_dmamask;
1207 musb->dev.coherent_dma_mask = tusb_dmamask; 1219 musb->dev.coherent_dma_mask = tusb_dmamask;
1208 1220
1209 platform_set_drvdata(pdev, musb); 1221 glue->dev = &pdev->dev;
1222 glue->musb = musb;
1223
1224 platform_set_drvdata(pdev, glue);
1210 1225
1211 ret = platform_device_add_resources(musb, pdev->resource, 1226 ret = platform_device_add_resources(musb, pdev->resource,
1212 pdev->num_resources); 1227 pdev->num_resources);
1213 if (ret) { 1228 if (ret) {
1214 dev_err(&pdev->dev, "failed to add resources\n"); 1229 dev_err(&pdev->dev, "failed to add resources\n");
1215 goto err1; 1230 goto err2;
1216 } 1231 }
1217 1232
1218 ret = platform_device_add_data(musb, pdata, sizeof(*pdata)); 1233 ret = platform_device_add_data(musb, pdata, sizeof(*pdata));
1219 if (ret) { 1234 if (ret) {
1220 dev_err(&pdev->dev, "failed to add platform_data\n"); 1235 dev_err(&pdev->dev, "failed to add platform_data\n");
1221 goto err1; 1236 goto err2;
1222 } 1237 }
1223 1238
1224 ret = platform_device_add(musb); 1239 ret = platform_device_add(musb);
@@ -1229,19 +1244,23 @@ static int __init tusb_probe(struct platform_device *pdev)
1229 1244
1230 return 0; 1245 return 0;
1231 1246
1232err1: 1247err2:
1233 platform_device_put(musb); 1248 platform_device_put(musb);
1234 1249
1250err1:
1251 kfree(glue);
1252
1235err0: 1253err0:
1236 return ret; 1254 return ret;
1237} 1255}
1238 1256
1239static int __exit tusb_remove(struct platform_device *pdev) 1257static int __exit tusb_remove(struct platform_device *pdev)
1240{ 1258{
1241 struct platform_device *musb = platform_get_drvdata(pdev); 1259 struct tusb6010_glue *glue = platform_get_drvdata(pdev);
1242 1260
1243 platform_device_del(musb); 1261 platform_device_del(glue->musb);
1244 platform_device_put(musb); 1262 platform_device_put(glue->musb);
1263 kfree(glue);
1245 1264
1246 return 0; 1265 return 0;
1247} 1266}