aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/tty/serial/imx.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 78f793617e4f..1a2488495f69 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1461,7 +1461,7 @@ static int serial_imx_probe(struct platform_device *pdev)
1461 struct resource *res; 1461 struct resource *res;
1462 struct pinctrl *pinctrl; 1462 struct pinctrl *pinctrl;
1463 1463
1464 sport = kzalloc(sizeof(*sport), GFP_KERNEL); 1464 sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL);
1465 if (!sport) 1465 if (!sport)
1466 return -ENOMEM; 1466 return -ENOMEM;
1467 1467
@@ -1469,19 +1469,15 @@ static int serial_imx_probe(struct platform_device *pdev)
1469 if (ret > 0) 1469 if (ret > 0)
1470 serial_imx_probe_pdata(sport, pdev); 1470 serial_imx_probe_pdata(sport, pdev);
1471 else if (ret < 0) 1471 else if (ret < 0)
1472 goto free; 1472 return ret;
1473 1473
1474 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1474 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1475 if (!res) { 1475 if (!res)
1476 ret = -ENODEV; 1476 return -ENODEV;
1477 goto free;
1478 }
1479 1477
1480 base = ioremap(res->start, PAGE_SIZE); 1478 base = devm_ioremap(&pdev->dev, res->start, PAGE_SIZE);
1481 if (!base) { 1479 if (!base)
1482 ret = -ENOMEM; 1480 return -ENOMEM;
1483 goto free;
1484 }
1485 1481
1486 sport->port.dev = &pdev->dev; 1482 sport->port.dev = &pdev->dev;
1487 sport->port.mapbase = res->start; 1483 sport->port.mapbase = res->start;
@@ -1503,21 +1499,21 @@ static int serial_imx_probe(struct platform_device *pdev)
1503 if (IS_ERR(pinctrl)) { 1499 if (IS_ERR(pinctrl)) {
1504 ret = PTR_ERR(pinctrl); 1500 ret = PTR_ERR(pinctrl);
1505 dev_err(&pdev->dev, "failed to get default pinctrl: %d\n", ret); 1501 dev_err(&pdev->dev, "failed to get default pinctrl: %d\n", ret);
1506 goto unmap; 1502 return ret;
1507 } 1503 }
1508 1504
1509 sport->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); 1505 sport->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
1510 if (IS_ERR(sport->clk_ipg)) { 1506 if (IS_ERR(sport->clk_ipg)) {
1511 ret = PTR_ERR(sport->clk_ipg); 1507 ret = PTR_ERR(sport->clk_ipg);
1512 dev_err(&pdev->dev, "failed to get ipg clk: %d\n", ret); 1508 dev_err(&pdev->dev, "failed to get ipg clk: %d\n", ret);
1513 goto unmap; 1509 return ret;
1514 } 1510 }
1515 1511
1516 sport->clk_per = devm_clk_get(&pdev->dev, "per"); 1512 sport->clk_per = devm_clk_get(&pdev->dev, "per");
1517 if (IS_ERR(sport->clk_per)) { 1513 if (IS_ERR(sport->clk_per)) {
1518 ret = PTR_ERR(sport->clk_per); 1514 ret = PTR_ERR(sport->clk_per);
1519 dev_err(&pdev->dev, "failed to get per clk: %d\n", ret); 1515 dev_err(&pdev->dev, "failed to get per clk: %d\n", ret);
1520 goto unmap; 1516 return ret;
1521 } 1517 }
1522 1518
1523 clk_prepare_enable(sport->clk_per); 1519 clk_prepare_enable(sport->clk_per);
@@ -1546,11 +1542,6 @@ deinit:
1546clkput: 1542clkput:
1547 clk_disable_unprepare(sport->clk_per); 1543 clk_disable_unprepare(sport->clk_per);
1548 clk_disable_unprepare(sport->clk_ipg); 1544 clk_disable_unprepare(sport->clk_ipg);
1549unmap:
1550 iounmap(sport->port.membase);
1551free:
1552 kfree(sport);
1553
1554 return ret; 1545 return ret;
1555} 1546}
1556 1547
@@ -1571,9 +1562,6 @@ static int serial_imx_remove(struct platform_device *pdev)
1571 if (pdata && pdata->exit) 1562 if (pdata && pdata->exit)
1572 pdata->exit(pdev); 1563 pdata->exit(pdev);
1573 1564
1574 iounmap(sport->port.membase);
1575 kfree(sport);
1576
1577 return 0; 1565 return 0;
1578} 1566}
1579 1567