diff options
author | Sachin Kamat <sachin.kamat@linaro.org> | 2012-09-03 06:18:18 -0400 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-09-03 10:09:10 -0400 |
commit | 78f0c53ef8563009bf089ef90c7204f526d4a589 (patch) | |
tree | 2b10430cf805a9dd9a66534ba94aa16dff43accd /drivers/usb/gadget/s3c-hsudc.c | |
parent | 9d2333d0d9bc03da3d8c11f92c602dac97ffea1e (diff) |
usb: gadget: s3c-hsudc: Use devm_* functions
devm_* functions are used to replace kzalloc, request_mem_region, ioremap
clk_get and request_irq functions in probe call. With the usage of devm_*
functions explicit freeing and unmapping is not required.
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/s3c-hsudc.c')
-rw-r--r-- | drivers/usb/gadget/s3c-hsudc.c | 41 |
1 files changed, 9 insertions, 32 deletions
diff --git a/drivers/usb/gadget/s3c-hsudc.c b/drivers/usb/gadget/s3c-hsudc.c index e26a4e7ed2bf..fe4a46197181 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; |
@@ -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 | ||