aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/vt8500_serial.c
diff options
context:
space:
mode:
authorTony Prisk <linux@prisktech.co.nz>2013-01-17 21:05:32 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-17 21:54:33 -0500
commit49abd90c4bb7b35e84c430dbba6b6368786fbf62 (patch)
tree3256955920819a65de0dfc361f9b8e0cadcf919b /drivers/tty/serial/vt8500_serial.c
parent12faa35ae5cbfbd0d90e2103688e87ceb46c5886 (diff)
serial: vt8500: Cleanup code using devm_ function
Convert the last memory allocation (vt8500_port) to use devm_kzalloc and remove the fail path cleanup code from vt8500_serial_probe. Reorder iomem mapping above clk_enable to simplify fail code. The clock is only enabled if all other resources are available. Signed-off-by: Tony Prisk <linux@prisktech.co.nz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/vt8500_serial.c')
-rw-r--r--drivers/tty/serial/vt8500_serial.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index 798bf944a2e5..5fb59c53abf9 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -580,7 +580,8 @@ static int vt8500_serial_probe(struct platform_device *pdev)
580 return -EBUSY; 580 return -EBUSY;
581 } 581 }
582 582
583 vt8500_port = kzalloc(sizeof(struct vt8500_port), GFP_KERNEL); 583 vt8500_port = devm_kzalloc(&pdev->dev, sizeof(struct vt8500_port),
584 GFP_KERNEL);
584 if (!vt8500_port) 585 if (!vt8500_port)
585 return -ENOMEM; 586 return -ENOMEM;
586 587
@@ -591,14 +592,13 @@ static int vt8500_serial_probe(struct platform_device *pdev)
591 vt8500_port->clk = of_clk_get(pdev->dev.of_node, 0); 592 vt8500_port->clk = of_clk_get(pdev->dev.of_node, 0);
592 if (IS_ERR(vt8500_port->clk)) { 593 if (IS_ERR(vt8500_port->clk)) {
593 dev_err(&pdev->dev, "failed to get clock\n"); 594 dev_err(&pdev->dev, "failed to get clock\n");
594 ret = -EINVAL; 595 return -EINVAL;
595 goto err;
596 } 596 }
597 597
598 ret = clk_prepare_enable(vt8500_port->clk); 598 ret = clk_prepare_enable(vt8500_port->clk);
599 if (ret) { 599 if (ret) {
600 dev_err(&pdev->dev, "failed to enable clock\n"); 600 dev_err(&pdev->dev, "failed to enable clock\n");
601 goto err; 601 return ret;
602 } 602 }
603 603
604 vt8500_port->uart.type = PORT_VT8500; 604 vt8500_port->uart.type = PORT_VT8500;
@@ -622,10 +622,6 @@ static int vt8500_serial_probe(struct platform_device *pdev)
622 platform_set_drvdata(pdev, vt8500_port); 622 platform_set_drvdata(pdev, vt8500_port);
623 623
624 return 0; 624 return 0;
625
626err:
627 kfree(vt8500_port);
628 return ret;
629} 625}
630 626
631static int vt8500_serial_remove(struct platform_device *pdev) 627static int vt8500_serial_remove(struct platform_device *pdev)
@@ -635,7 +631,6 @@ static int vt8500_serial_remove(struct platform_device *pdev)
635 platform_set_drvdata(pdev, NULL); 631 platform_set_drvdata(pdev, NULL);
636 clk_disable_unprepare(vt8500_port->clk); 632 clk_disable_unprepare(vt8500_port->clk);
637 uart_remove_one_port(&vt8500_uart_driver, &vt8500_port->uart); 633 uart_remove_one_port(&vt8500_uart_driver, &vt8500_port->uart);
638 kfree(vt8500_port);
639 634
640 return 0; 635 return 0;
641} 636}