aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-01-09 21:04:21 -0500
committerGrant Likely <grant.likely@secretlab.ca>2013-02-05 08:19:43 -0500
commit4eb770067f3ad616d5cc37be4c58eb918fce5062 (patch)
treec8ac337e24d2c6716cf53985ba932dc9b9517c19 /drivers/spi
parent3133fba3bb3a37cc3d589cb8435e0c0976fb75cd (diff)
spi/s3c64xx: Use devm_clk_get() and devm_request_irq()
Use devm_clk_get() and devm_request_irq() rather than clk_get() and request_irq() to make cleanup paths more simple. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-s3c64xx.c41
1 files changed, 15 insertions, 26 deletions
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index a82bfa4af601..1f2f7f8329f1 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -1282,7 +1282,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
1282 if (sdd->regs == NULL) { 1282 if (sdd->regs == NULL) {
1283 dev_err(&pdev->dev, "Unable to remap IO\n"); 1283 dev_err(&pdev->dev, "Unable to remap IO\n");
1284 ret = -ENXIO; 1284 ret = -ENXIO;
1285 goto err1; 1285 goto err0;
1286 } 1286 }
1287 1287
1288 if (!sci->cfg_gpio && pdev->dev.of_node) { 1288 if (!sci->cfg_gpio && pdev->dev.of_node) {
@@ -1291,36 +1291,36 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
1291 } else if (sci->cfg_gpio == NULL || sci->cfg_gpio()) { 1291 } else if (sci->cfg_gpio == NULL || sci->cfg_gpio()) {
1292 dev_err(&pdev->dev, "Unable to config gpio\n"); 1292 dev_err(&pdev->dev, "Unable to config gpio\n");
1293 ret = -EBUSY; 1293 ret = -EBUSY;
1294 goto err2; 1294 goto err0;
1295 } 1295 }
1296 1296
1297 /* Setup clocks */ 1297 /* Setup clocks */
1298 sdd->clk = clk_get(&pdev->dev, "spi"); 1298 sdd->clk = devm_clk_get(&pdev->dev, "spi");
1299 if (IS_ERR(sdd->clk)) { 1299 if (IS_ERR(sdd->clk)) {
1300 dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n"); 1300 dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n");
1301 ret = PTR_ERR(sdd->clk); 1301 ret = PTR_ERR(sdd->clk);
1302 goto err3; 1302 goto err1;
1303 } 1303 }
1304 1304
1305 if (clk_prepare_enable(sdd->clk)) { 1305 if (clk_prepare_enable(sdd->clk)) {
1306 dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n"); 1306 dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n");
1307 ret = -EBUSY; 1307 ret = -EBUSY;
1308 goto err4; 1308 goto err1;
1309 } 1309 }
1310 1310
1311 sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr); 1311 sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr);
1312 sdd->src_clk = clk_get(&pdev->dev, clk_name); 1312 sdd->src_clk = devm_clk_get(&pdev->dev, clk_name);
1313 if (IS_ERR(sdd->src_clk)) { 1313 if (IS_ERR(sdd->src_clk)) {
1314 dev_err(&pdev->dev, 1314 dev_err(&pdev->dev,
1315 "Unable to acquire clock '%s'\n", clk_name); 1315 "Unable to acquire clock '%s'\n", clk_name);
1316 ret = PTR_ERR(sdd->src_clk); 1316 ret = PTR_ERR(sdd->src_clk);
1317 goto err5; 1317 goto err2;
1318 } 1318 }
1319 1319
1320 if (clk_prepare_enable(sdd->src_clk)) { 1320 if (clk_prepare_enable(sdd->src_clk)) {
1321 dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", clk_name); 1321 dev_err(&pdev->dev, "Couldn't enable clock '%s'\n", clk_name);
1322 ret = -EBUSY; 1322 ret = -EBUSY;
1323 goto err6; 1323 goto err2;
1324 } 1324 }
1325 1325
1326 /* Setup Deufult Mode */ 1326 /* Setup Deufult Mode */
@@ -1330,11 +1330,12 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
1330 init_completion(&sdd->xfer_completion); 1330 init_completion(&sdd->xfer_completion);
1331 INIT_LIST_HEAD(&sdd->queue); 1331 INIT_LIST_HEAD(&sdd->queue);
1332 1332
1333 ret = request_irq(irq, s3c64xx_spi_irq, 0, "spi-s3c64xx", sdd); 1333 ret = devm_request_irq(&pdev->dev, irq, s3c64xx_spi_irq, 0,
1334 "spi-s3c64xx", sdd);
1334 if (ret != 0) { 1335 if (ret != 0) {
1335 dev_err(&pdev->dev, "Failed to request IRQ %d: %d\n", 1336 dev_err(&pdev->dev, "Failed to request IRQ %d: %d\n",
1336 irq, ret); 1337 irq, ret);
1337 goto err7; 1338 goto err3;
1338 } 1339 }
1339 1340
1340 writel(S3C64XX_SPI_INT_RX_OVERRUN_EN | S3C64XX_SPI_INT_RX_UNDERRUN_EN | 1341 writel(S3C64XX_SPI_INT_RX_OVERRUN_EN | S3C64XX_SPI_INT_RX_UNDERRUN_EN |
@@ -1344,7 +1345,7 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
1344 if (spi_register_master(master)) { 1345 if (spi_register_master(master)) {
1345 dev_err(&pdev->dev, "cannot register SPI master\n"); 1346 dev_err(&pdev->dev, "cannot register SPI master\n");
1346 ret = -EBUSY; 1347 ret = -EBUSY;
1347 goto err8; 1348 goto err3;
1348 } 1349 }
1349 1350
1350 dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d " 1351 dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d "
@@ -1358,21 +1359,13 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
1358 1359
1359 return 0; 1360 return 0;
1360 1361
1361err8: 1362err3:
1362 free_irq(irq, sdd);
1363err7:
1364 clk_disable_unprepare(sdd->src_clk); 1363 clk_disable_unprepare(sdd->src_clk);
1365err6: 1364err2:
1366 clk_put(sdd->src_clk);
1367err5:
1368 clk_disable_unprepare(sdd->clk); 1365 clk_disable_unprepare(sdd->clk);
1369err4: 1366err1:
1370 clk_put(sdd->clk);
1371err3:
1372 if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node) 1367 if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node)
1373 s3c64xx_spi_dt_gpio_free(sdd); 1368 s3c64xx_spi_dt_gpio_free(sdd);
1374err2:
1375err1:
1376err0: 1369err0:
1377 platform_set_drvdata(pdev, NULL); 1370 platform_set_drvdata(pdev, NULL);
1378 spi_master_put(master); 1371 spi_master_put(master);
@@ -1391,13 +1384,9 @@ static int s3c64xx_spi_remove(struct platform_device *pdev)
1391 1384
1392 writel(0, sdd->regs + S3C64XX_SPI_INT_EN); 1385 writel(0, sdd->regs + S3C64XX_SPI_INT_EN);
1393 1386
1394 free_irq(platform_get_irq(pdev, 0), sdd);
1395
1396 clk_disable_unprepare(sdd->src_clk); 1387 clk_disable_unprepare(sdd->src_clk);
1397 clk_put(sdd->src_clk);
1398 1388
1399 clk_disable_unprepare(sdd->clk); 1389 clk_disable_unprepare(sdd->clk);
1400 clk_put(sdd->clk);
1401 1390
1402 if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node) 1391 if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node)
1403 s3c64xx_spi_dt_gpio_free(sdd); 1392 s3c64xx_spi_dt_gpio_free(sdd);