diff options
Diffstat (limited to 'drivers/usb/gadget/s3c-hsudc.c')
-rw-r--r-- | drivers/usb/gadget/s3c-hsudc.c | 51 |
1 files changed, 14 insertions, 37 deletions
diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index e26a4e7ed2bf..d8e785d4ad59 100644 --- a/drivers/usb/gadget/s3c-hsudc.c +++ b/drivers/usb/gadget/s3c-hsudc.c | |||
@@ -135,7 +135,6 @@ struct s3c_hsudc_req { | |||
135 | * @dev: The device reference used by probe function. | 135 | * @dev: The device reference used by probe function. |
136 | * @lock: Lock to synchronize the usage of Endpoints (EP's are indexed). | 136 | * @lock: Lock to synchronize the usage of Endpoints (EP's are indexed). |
137 | * @regs: Remapped base address of controller's register space. | 137 | * @regs: Remapped base address of controller's register space. |
138 | * @mem_rsrc: Device memory resource used for remapping device register space. | ||
139 | * irq: IRQ number used by the controller. | 138 | * irq: IRQ number used by the controller. |
140 | * uclk: Reference to the controller clock. | 139 | * uclk: Reference to the controller clock. |
141 | * ep0state: Current state of EP0. | 140 | * ep0state: Current state of EP0. |
@@ -150,7 +149,6 @@ struct s3c_hsudc { | |||
150 | struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)]; | 149 | struct regulator_bulk_data supplies[ARRAY_SIZE(s3c_hsudc_supply_names)]; |
151 | spinlock_t lock; | 150 | spinlock_t lock; |
152 | void __iomem *regs; | 151 | void __iomem *regs; |
153 | struct resource *mem_rsrc; | ||
154 | int irq; | 152 | int irq; |
155 | struct clk *uclk; | 153 | struct clk *uclk; |
156 | int ep0state; | 154 | int ep0state; |
@@ -835,9 +833,9 @@ static struct usb_request *s3c_hsudc_alloc_request(struct usb_ep *_ep, | |||
835 | { | 833 | { |
836 | struct s3c_hsudc_req *hsreq; | 834 | struct s3c_hsudc_req *hsreq; |
837 | 835 | ||
838 | hsreq = kzalloc(sizeof *hsreq, gfp_flags); | 836 | hsreq = kzalloc(sizeof(*hsreq), gfp_flags); |
839 | if (!hsreq) | 837 | if (!hsreq) |
840 | return 0; | 838 | return NULL; |
841 | 839 | ||
842 | INIT_LIST_HEAD(&hsreq->queue); | 840 | INIT_LIST_HEAD(&hsreq->queue); |
843 | return &hsreq->req; | 841 | return &hsreq->req; |
@@ -906,16 +904,16 @@ static int s3c_hsudc_queue(struct usb_ep *_ep, struct usb_request *_req, | |||
906 | csr = readl((u32)hsudc->regs + offset); | 904 | csr = readl((u32)hsudc->regs + offset); |
907 | if (!(csr & S3C_ESR_TX_SUCCESS) && | 905 | if (!(csr & S3C_ESR_TX_SUCCESS) && |
908 | (s3c_hsudc_write_fifo(hsep, hsreq) == 1)) | 906 | (s3c_hsudc_write_fifo(hsep, hsreq) == 1)) |
909 | hsreq = 0; | 907 | hsreq = NULL; |
910 | } else { | 908 | } else { |
911 | csr = readl((u32)hsudc->regs + offset); | 909 | csr = readl((u32)hsudc->regs + offset); |
912 | if ((csr & S3C_ESR_RX_SUCCESS) | 910 | if ((csr & S3C_ESR_RX_SUCCESS) |
913 | && (s3c_hsudc_read_fifo(hsep, hsreq) == 1)) | 911 | && (s3c_hsudc_read_fifo(hsep, hsreq) == 1)) |
914 | hsreq = 0; | 912 | hsreq = NULL; |
915 | } | 913 | } |
916 | } | 914 | } |
917 | 915 | ||
918 | if (hsreq != 0) | 916 | if (hsreq) |
919 | list_add_tail(&hsreq->queue, &hsep->queue); | 917 | list_add_tail(&hsreq->queue, &hsep->queue); |
920 | 918 | ||
921 | spin_unlock_irqrestore(&hsudc->lock, flags); | 919 | spin_unlock_irqrestore(&hsudc->lock, flags); |
@@ -1271,7 +1269,7 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) | |||
1271 | struct s3c24xx_hsudc_platdata *pd = pdev->dev.platform_data; | 1269 | struct s3c24xx_hsudc_platdata *pd = pdev->dev.platform_data; |
1272 | int ret, i; | 1270 | int ret, i; |
1273 | 1271 | ||
1274 | hsudc = kzalloc(sizeof(struct s3c_hsudc) + | 1272 | hsudc = devm_kzalloc(&pdev->dev, sizeof(struct s3c_hsudc) + |
1275 | sizeof(struct s3c_hsudc_ep) * pd->epnum, | 1273 | sizeof(struct s3c_hsudc_ep) * pd->epnum, |
1276 | GFP_KERNEL); | 1274 | GFP_KERNEL); |
1277 | if (!hsudc) { | 1275 | if (!hsudc) { |
@@ -1296,25 +1294,12 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) | |||
1296 | } | 1294 | } |
1297 | 1295 | ||
1298 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1296 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1299 | if (!res) { | ||
1300 | dev_err(dev, "unable to obtain driver resource data\n"); | ||
1301 | ret = -ENODEV; | ||
1302 | goto err_res; | ||
1303 | } | ||
1304 | |||
1305 | hsudc->mem_rsrc = request_mem_region(res->start, resource_size(res), | ||
1306 | dev_name(&pdev->dev)); | ||
1307 | if (!hsudc->mem_rsrc) { | ||
1308 | dev_err(dev, "failed to reserve register area\n"); | ||
1309 | ret = -ENODEV; | ||
1310 | goto err_res; | ||
1311 | } | ||
1312 | 1297 | ||
1313 | hsudc->regs = ioremap(res->start, resource_size(res)); | 1298 | hsudc->regs = devm_request_and_ioremap(&pdev->dev, res); |
1314 | if (!hsudc->regs) { | 1299 | if (!hsudc->regs) { |
1315 | dev_err(dev, "error mapping device register area\n"); | 1300 | dev_err(dev, "error mapping device register area\n"); |
1316 | ret = -EBUSY; | 1301 | ret = -EBUSY; |
1317 | goto err_remap; | 1302 | goto err_res; |
1318 | } | 1303 | } |
1319 | 1304 | ||
1320 | spin_lock_init(&hsudc->lock); | 1305 | spin_lock_init(&hsudc->lock); |
@@ -1337,21 +1322,22 @@ static int __devinit s3c_hsudc_probe(struct platform_device *pdev) | |||
1337 | ret = platform_get_irq(pdev, 0); | 1322 | ret = platform_get_irq(pdev, 0); |
1338 | if (ret < 0) { | 1323 | if (ret < 0) { |
1339 | dev_err(dev, "unable to obtain IRQ number\n"); | 1324 | dev_err(dev, "unable to obtain IRQ number\n"); |
1340 | goto err_irq; | 1325 | goto err_res; |
1341 | } | 1326 | } |
1342 | hsudc->irq = ret; | 1327 | hsudc->irq = ret; |
1343 | 1328 | ||
1344 | ret = request_irq(hsudc->irq, s3c_hsudc_irq, 0, driver_name, hsudc); | 1329 | ret = devm_request_irq(&pdev->dev, hsudc->irq, s3c_hsudc_irq, 0, |
1330 | driver_name, hsudc); | ||
1345 | if (ret < 0) { | 1331 | if (ret < 0) { |
1346 | dev_err(dev, "irq request failed\n"); | 1332 | dev_err(dev, "irq request failed\n"); |
1347 | goto err_irq; | 1333 | goto err_res; |
1348 | } | 1334 | } |
1349 | 1335 | ||
1350 | hsudc->uclk = clk_get(&pdev->dev, "usb-device"); | 1336 | hsudc->uclk = devm_clk_get(&pdev->dev, "usb-device"); |
1351 | if (IS_ERR(hsudc->uclk)) { | 1337 | if (IS_ERR(hsudc->uclk)) { |
1352 | dev_err(dev, "failed to find usb-device clock source\n"); | 1338 | dev_err(dev, "failed to find usb-device clock source\n"); |
1353 | ret = PTR_ERR(hsudc->uclk); | 1339 | ret = PTR_ERR(hsudc->uclk); |
1354 | goto err_clk; | 1340 | goto err_res; |
1355 | } | 1341 | } |
1356 | clk_enable(hsudc->uclk); | 1342 | clk_enable(hsudc->uclk); |
1357 | 1343 | ||
@@ -1377,21 +1363,12 @@ err_add_udc: | |||
1377 | device_unregister(&hsudc->gadget.dev); | 1363 | device_unregister(&hsudc->gadget.dev); |
1378 | err_add_device: | 1364 | err_add_device: |
1379 | clk_disable(hsudc->uclk); | 1365 | clk_disable(hsudc->uclk); |
1380 | clk_put(hsudc->uclk); | ||
1381 | err_clk: | ||
1382 | free_irq(hsudc->irq, hsudc); | ||
1383 | err_irq: | ||
1384 | iounmap(hsudc->regs); | ||
1385 | |||
1386 | err_remap: | ||
1387 | release_mem_region(res->start, resource_size(res)); | ||
1388 | err_res: | 1366 | err_res: |
1389 | if (!IS_ERR_OR_NULL(hsudc->transceiver)) | 1367 | if (!IS_ERR_OR_NULL(hsudc->transceiver)) |
1390 | usb_put_phy(hsudc->transceiver); | 1368 | usb_put_phy(hsudc->transceiver); |
1391 | 1369 | ||
1392 | regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); | 1370 | regulator_bulk_free(ARRAY_SIZE(hsudc->supplies), hsudc->supplies); |
1393 | err_supplies: | 1371 | err_supplies: |
1394 | kfree(hsudc); | ||
1395 | return ret; | 1372 | return ret; |
1396 | } | 1373 | } |
1397 | 1374 | ||