aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2013-06-17 13:43:09 -0400
committerDavid Brown <davidb@codeaurora.org>2013-06-24 16:06:41 -0400
commit519b371dcd3b175bcffa97bc88a7122e41afd318 (patch)
tree105e5f8a40c06cf87eb9563771e5931d3d825eb3 /drivers/tty
parentf98cf83d0c7c6bf803a75eb1e7c99b6457f12f98 (diff)
msm_serial: Use devm_clk_get() and properly return errors
Clocks are not clk_put() in this driver's error paths during probe. The code that checks for clock errors also fails to properly return the error code from the pclk member if it turns out to be the failing clock, leading to potentially confusing error values if the clk member is not an error pointer. Fix these problems with devm_clk_get() and proper error checking. Removing the clk_put() in msm_serial_remove() also points out that msm_port is unused. Furthermore, msm_port is the wrong type and so the clk_put() would be using the wrong pointer. Replace it with the proper type and call uart_remove_one_port() to do the proper cleanup. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: David Brown <davidb@codeaurora.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/msm_serial.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 01496035304e..2c6cfb3cf032 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -884,19 +884,22 @@ static int __init msm_serial_probe(struct platform_device *pdev)
884 msm_port->is_uartdm = 0; 884 msm_port->is_uartdm = 0;
885 885
886 if (msm_port->is_uartdm) { 886 if (msm_port->is_uartdm) {
887 msm_port->clk = clk_get(&pdev->dev, "gsbi_uart_clk"); 887 msm_port->clk = devm_clk_get(&pdev->dev, "gsbi_uart_clk");
888 msm_port->pclk = clk_get(&pdev->dev, "gsbi_pclk"); 888 msm_port->pclk = devm_clk_get(&pdev->dev, "gsbi_pclk");
889 } else { 889 } else {
890 msm_port->clk = clk_get(&pdev->dev, "uart_clk"); 890 msm_port->clk = devm_clk_get(&pdev->dev, "uart_clk");
891 msm_port->pclk = ERR_PTR(-ENOENT); 891 msm_port->pclk = ERR_PTR(-ENOENT);
892 } 892 }
893 893
894 if (unlikely(IS_ERR(msm_port->clk) || (IS_ERR(msm_port->pclk) && 894 if (IS_ERR(msm_port->clk))
895 msm_port->is_uartdm))) 895 return PTR_ERR(msm_port->clk);
896 return PTR_ERR(msm_port->clk); 896
897 if (msm_port->is_uartdm) {
898 if (IS_ERR(msm_port->pclk))
899 return PTR_ERR(msm_port->pclk);
897 900
898 if (msm_port->is_uartdm)
899 clk_set_rate(msm_port->clk, 1843200); 901 clk_set_rate(msm_port->clk, 1843200);
902 }
900 903
901 port->uartclk = clk_get_rate(msm_port->clk); 904 port->uartclk = clk_get_rate(msm_port->clk);
902 printk(KERN_INFO "uartclk = %d\n", port->uartclk); 905 printk(KERN_INFO "uartclk = %d\n", port->uartclk);
@@ -919,9 +922,9 @@ static int __init msm_serial_probe(struct platform_device *pdev)
919 922
920static int msm_serial_remove(struct platform_device *pdev) 923static int msm_serial_remove(struct platform_device *pdev)
921{ 924{
922 struct msm_port *msm_port = platform_get_drvdata(pdev); 925 struct uart_port *port = platform_get_drvdata(pdev);
923 926
924 clk_put(msm_port->clk); 927 uart_remove_one_port(&msm_uart_driver, port);
925 928
926 return 0; 929 return 0;
927} 930}