Commit 299a6257 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Greg Kroah-Hartman

serial8250-em: Convert to devm_* managed helpers

Replace kzalloc and clk_get by their managed counterparts to simplify
error and cleanup paths.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cf940ebe
...@@ -95,25 +95,23 @@ static int serial8250_em_probe(struct platform_device *pdev) ...@@ -95,25 +95,23 @@ static int serial8250_em_probe(struct platform_device *pdev)
struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
struct serial8250_em_priv *priv; struct serial8250_em_priv *priv;
struct uart_8250_port up; struct uart_8250_port up;
int ret = -EINVAL; int ret;
if (!regs || !irq) { if (!regs || !irq) {
dev_err(&pdev->dev, "missing registers or irq\n"); dev_err(&pdev->dev, "missing registers or irq\n");
goto err0; return -EINVAL;
} }
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv) { if (!priv) {
dev_err(&pdev->dev, "unable to allocate private data\n"); dev_err(&pdev->dev, "unable to allocate private data\n");
ret = -ENOMEM; return -ENOMEM;
goto err0;
} }
priv->sclk = clk_get(&pdev->dev, "sclk"); priv->sclk = devm_clk_get(&pdev->dev, "sclk");
if (IS_ERR(priv->sclk)) { if (IS_ERR(priv->sclk)) {
dev_err(&pdev->dev, "unable to get clock\n"); dev_err(&pdev->dev, "unable to get clock\n");
ret = PTR_ERR(priv->sclk); return PTR_ERR(priv->sclk);
goto err1;
} }
memset(&up, 0, sizeof(up)); memset(&up, 0, sizeof(up));
...@@ -136,20 +134,13 @@ static int serial8250_em_probe(struct platform_device *pdev) ...@@ -136,20 +134,13 @@ static int serial8250_em_probe(struct platform_device *pdev)
ret = serial8250_register_8250_port(&up); ret = serial8250_register_8250_port(&up);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "unable to register 8250 port\n"); dev_err(&pdev->dev, "unable to register 8250 port\n");
goto err2; clk_disable(priv->sclk);
return ret;
} }
priv->line = ret; priv->line = ret;
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
return 0; return 0;
err2:
clk_disable(priv->sclk);
clk_put(priv->sclk);
err1:
kfree(priv);
err0:
return ret;
} }
static int serial8250_em_remove(struct platform_device *pdev) static int serial8250_em_remove(struct platform_device *pdev)
...@@ -158,8 +149,6 @@ static int serial8250_em_remove(struct platform_device *pdev) ...@@ -158,8 +149,6 @@ static int serial8250_em_remove(struct platform_device *pdev)
serial8250_unregister_port(priv->line); serial8250_unregister_port(priv->line);
clk_disable(priv->sclk); clk_disable(priv->sclk);
clk_put(priv->sclk);
kfree(priv);
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