Commit 519b371d authored by Stephen Boyd's avatar Stephen Boyd Committed by David Brown

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: default avatarStephen Boyd <sboyd@codeaurora.org>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarDavid Brown <davidb@codeaurora.org>
parent f98cf83d
...@@ -884,19 +884,22 @@ static int __init msm_serial_probe(struct platform_device *pdev) ...@@ -884,19 +884,22 @@ static int __init msm_serial_probe(struct platform_device *pdev)
msm_port->is_uartdm = 0; msm_port->is_uartdm = 0;
if (msm_port->is_uartdm) { if (msm_port->is_uartdm) {
msm_port->clk = clk_get(&pdev->dev, "gsbi_uart_clk"); msm_port->clk = devm_clk_get(&pdev->dev, "gsbi_uart_clk");
msm_port->pclk = clk_get(&pdev->dev, "gsbi_pclk"); msm_port->pclk = devm_clk_get(&pdev->dev, "gsbi_pclk");
} else { } else {
msm_port->clk = clk_get(&pdev->dev, "uart_clk"); msm_port->clk = devm_clk_get(&pdev->dev, "uart_clk");
msm_port->pclk = ERR_PTR(-ENOENT); msm_port->pclk = ERR_PTR(-ENOENT);
} }
if (unlikely(IS_ERR(msm_port->clk) || (IS_ERR(msm_port->pclk) && if (IS_ERR(msm_port->clk))
msm_port->is_uartdm)))
return PTR_ERR(msm_port->clk); return PTR_ERR(msm_port->clk);
if (msm_port->is_uartdm) if (msm_port->is_uartdm) {
if (IS_ERR(msm_port->pclk))
return PTR_ERR(msm_port->pclk);
clk_set_rate(msm_port->clk, 1843200); clk_set_rate(msm_port->clk, 1843200);
}
port->uartclk = clk_get_rate(msm_port->clk); port->uartclk = clk_get_rate(msm_port->clk);
printk(KERN_INFO "uartclk = %d\n", port->uartclk); printk(KERN_INFO "uartclk = %d\n", port->uartclk);
...@@ -919,9 +922,9 @@ static int __init msm_serial_probe(struct platform_device *pdev) ...@@ -919,9 +922,9 @@ static int __init msm_serial_probe(struct platform_device *pdev)
static int msm_serial_remove(struct platform_device *pdev) static int msm_serial_remove(struct platform_device *pdev)
{ {
struct msm_port *msm_port = platform_get_drvdata(pdev); struct uart_port *port = platform_get_drvdata(pdev);
clk_put(msm_port->clk); uart_remove_one_port(&msm_uart_driver, port);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment