提交 46778bca 编写于 作者: F Fabio Estevam 提交者: Greg Kroah-Hartman

serial: mxs-auart: Use devm_kzalloc()

By using devm_kzalloc() we can have a shorter and cleaner code.
Signed-off-by: NFabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 11387b0a
...@@ -1231,7 +1231,7 @@ static int mxs_auart_probe(struct platform_device *pdev) ...@@ -1231,7 +1231,7 @@ static int mxs_auart_probe(struct platform_device *pdev)
int ret = 0; int ret = 0;
struct resource *r; struct resource *r;
s = kzalloc(sizeof(struct mxs_auart_port), GFP_KERNEL); s = devm_kzalloc(&pdev->dev, sizeof(*s), GFP_KERNEL);
if (!s) if (!s)
return -ENOMEM; return -ENOMEM;
...@@ -1239,7 +1239,7 @@ static int mxs_auart_probe(struct platform_device *pdev) ...@@ -1239,7 +1239,7 @@ static int mxs_auart_probe(struct platform_device *pdev)
if (ret > 0) if (ret > 0)
s->port.line = pdev->id < 0 ? 0 : pdev->id; s->port.line = pdev->id < 0 ? 0 : pdev->id;
else if (ret < 0) else if (ret < 0)
goto out_free; return ret;
if (of_id) { if (of_id) {
pdev->id_entry = of_id->data; pdev->id_entry = of_id->data;
...@@ -1247,10 +1247,8 @@ static int mxs_auart_probe(struct platform_device *pdev) ...@@ -1247,10 +1247,8 @@ static int mxs_auart_probe(struct platform_device *pdev)
} }
s->clk = clk_get(&pdev->dev, NULL); s->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(s->clk)) { if (IS_ERR(s->clk))
ret = PTR_ERR(s->clk); return PTR_ERR(s->clk);
goto out_free;
}
r = platform_get_resource(pdev, IORESOURCE_MEM, 0); r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r) { if (!r) {
...@@ -1310,8 +1308,6 @@ static int mxs_auart_probe(struct platform_device *pdev) ...@@ -1310,8 +1308,6 @@ static int mxs_auart_probe(struct platform_device *pdev)
free_irq(s->irq, s); free_irq(s->irq, s);
out_free_clk: out_free_clk:
clk_put(s->clk); clk_put(s->clk);
out_free:
kfree(s);
return ret; return ret;
} }
...@@ -1326,7 +1322,6 @@ static int mxs_auart_remove(struct platform_device *pdev) ...@@ -1326,7 +1322,6 @@ static int mxs_auart_remove(struct platform_device *pdev)
mxs_auart_free_gpio_irq(s); mxs_auart_free_gpio_irq(s);
clk_put(s->clk); clk_put(s->clk);
free_irq(s->irq, s); free_irq(s->irq, s);
kfree(s);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册