* [PATCH 1/4] serial: mxs-auart: Remove unneeded goto label
@ 2014-11-27 19:08 Fabio Estevam
2014-11-27 19:08 ` [PATCH 2/4] serial: mxs-auart: Use devm_kzalloc() Fabio Estevam
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Fabio Estevam @ 2014-11-27 19:08 UTC (permalink / raw)
To: gregkh; +Cc: j.uzycki, linux-serial, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
Instead of jumping to the 'out' label, let's return the error immediately, which
makes the code shorter and cleaner.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
drivers/tty/serial/mxs-auart.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index ec553f8..a9e7fa6 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1232,10 +1232,8 @@ static int mxs_auart_probe(struct platform_device *pdev)
struct resource *r;
s = kzalloc(sizeof(struct mxs_auart_port), GFP_KERNEL);
- if (!s) {
- ret = -ENOMEM;
- goto out;
- }
+ if (!s)
+ return -ENOMEM;
ret = serial_mxs_probe_dt(s, pdev);
if (ret > 0)
@@ -1314,7 +1312,6 @@ out_free_clk:
clk_put(s->clk);
out_free:
kfree(s);
-out:
return ret;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/4] serial: mxs-auart: Use devm_kzalloc()
2014-11-27 19:08 [PATCH 1/4] serial: mxs-auart: Remove unneeded goto label Fabio Estevam
@ 2014-11-27 19:08 ` Fabio Estevam
2014-11-27 19:08 ` [PATCH 3/4] serial: mxs-auart: Use devm_clk_get() Fabio Estevam
2014-11-27 19:08 ` [PATCH 4/4] serial: mxs-auart: Use devm_request_irq() Fabio Estevam
2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2014-11-27 19:08 UTC (permalink / raw)
To: gregkh; +Cc: j.uzycki, linux-serial, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
By using devm_kzalloc() we can have a shorter and cleaner code.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
drivers/tty/serial/mxs-auart.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index a9e7fa6..0b5f0ea 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1231,7 +1231,7 @@ static int mxs_auart_probe(struct platform_device *pdev)
int ret = 0;
struct resource *r;
- s = kzalloc(sizeof(struct mxs_auart_port), GFP_KERNEL);
+ s = devm_kzalloc(&pdev->dev, sizeof(*s), GFP_KERNEL);
if (!s)
return -ENOMEM;
@@ -1239,7 +1239,7 @@ static int mxs_auart_probe(struct platform_device *pdev)
if (ret > 0)
s->port.line = pdev->id < 0 ? 0 : pdev->id;
else if (ret < 0)
- goto out_free;
+ return ret;
if (of_id) {
pdev->id_entry = of_id->data;
@@ -1247,10 +1247,8 @@ static int mxs_auart_probe(struct platform_device *pdev)
}
s->clk = clk_get(&pdev->dev, NULL);
- if (IS_ERR(s->clk)) {
- ret = PTR_ERR(s->clk);
- goto out_free;
- }
+ if (IS_ERR(s->clk))
+ return PTR_ERR(s->clk);
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!r) {
@@ -1310,8 +1308,6 @@ out_free_irq:
free_irq(s->irq, s);
out_free_clk:
clk_put(s->clk);
-out_free:
- kfree(s);
return ret;
}
@@ -1326,7 +1322,6 @@ static int mxs_auart_remove(struct platform_device *pdev)
mxs_auart_free_gpio_irq(s);
clk_put(s->clk);
free_irq(s->irq, s);
- kfree(s);
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/4] serial: mxs-auart: Use devm_clk_get()
2014-11-27 19:08 [PATCH 1/4] serial: mxs-auart: Remove unneeded goto label Fabio Estevam
2014-11-27 19:08 ` [PATCH 2/4] serial: mxs-auart: Use devm_kzalloc() Fabio Estevam
@ 2014-11-27 19:08 ` Fabio Estevam
2014-11-27 19:08 ` [PATCH 4/4] serial: mxs-auart: Use devm_request_irq() Fabio Estevam
2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2014-11-27 19:08 UTC (permalink / raw)
To: gregkh; +Cc: j.uzycki, linux-serial, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
By using devm_clk_get() we can have a shorter and cleaner code.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
drivers/tty/serial/mxs-auart.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 0b5f0ea..9309082 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1246,15 +1246,14 @@ static int mxs_auart_probe(struct platform_device *pdev)
s->devtype = pdev->id_entry->driver_data;
}
- s->clk = clk_get(&pdev->dev, NULL);
+ s->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(s->clk))
return PTR_ERR(s->clk);
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!r) {
- ret = -ENXIO;
- goto out_free_clk;
- }
+ if (!r)
+ return -ENXIO;
+
s->port.mapbase = r->start;
s->port.membase = ioremap(r->start, resource_size(r));
@@ -1271,7 +1270,7 @@ static int mxs_auart_probe(struct platform_device *pdev)
s->port.irq = s->irq;
ret = request_irq(s->irq, mxs_auart_irq_handle, 0, dev_name(&pdev->dev), s);
if (ret)
- goto out_free_clk;
+ return ret;
platform_set_drvdata(pdev, s);
@@ -1306,8 +1305,6 @@ out_free_gpio_irq:
out_free_irq:
auart_port[pdev->id] = NULL;
free_irq(s->irq, s);
-out_free_clk:
- clk_put(s->clk);
return ret;
}
@@ -1320,7 +1317,6 @@ static int mxs_auart_remove(struct platform_device *pdev)
auart_port[pdev->id] = NULL;
mxs_auart_free_gpio_irq(s);
- clk_put(s->clk);
free_irq(s->irq, s);
return 0;
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 4/4] serial: mxs-auart: Use devm_request_irq()
2014-11-27 19:08 [PATCH 1/4] serial: mxs-auart: Remove unneeded goto label Fabio Estevam
2014-11-27 19:08 ` [PATCH 2/4] serial: mxs-auart: Use devm_kzalloc() Fabio Estevam
2014-11-27 19:08 ` [PATCH 3/4] serial: mxs-auart: Use devm_clk_get() Fabio Estevam
@ 2014-11-27 19:08 ` Fabio Estevam
2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2014-11-27 19:08 UTC (permalink / raw)
To: gregkh; +Cc: j.uzycki, linux-serial, Fabio Estevam
From: Fabio Estevam <fabio.estevam@freescale.com>
By using devm_request_irq() we can have a shorter and cleaner code.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
drivers/tty/serial/mxs-auart.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 9309082..1e9fb37 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -1268,7 +1268,8 @@ static int mxs_auart_probe(struct platform_device *pdev)
s->irq = platform_get_irq(pdev, 0);
s->port.irq = s->irq;
- ret = request_irq(s->irq, mxs_auart_irq_handle, 0, dev_name(&pdev->dev), s);
+ ret = devm_request_irq(&pdev->dev, s->irq, mxs_auart_irq_handle, 0,
+ dev_name(&pdev->dev), s);
if (ret)
return ret;
@@ -1283,7 +1284,7 @@ static int mxs_auart_probe(struct platform_device *pdev)
*/
ret = mxs_auart_request_gpio_irq(s);
if (ret)
- goto out_free_irq;
+ return ret;
auart_port[s->port.line] = s;
@@ -1302,9 +1303,7 @@ static int mxs_auart_probe(struct platform_device *pdev)
out_free_gpio_irq:
mxs_auart_free_gpio_irq(s);
-out_free_irq:
auart_port[pdev->id] = NULL;
- free_irq(s->irq, s);
return ret;
}
@@ -1313,11 +1312,8 @@ static int mxs_auart_remove(struct platform_device *pdev)
struct mxs_auart_port *s = platform_get_drvdata(pdev);
uart_remove_one_port(&auart_driver, &s->port);
-
auart_port[pdev->id] = NULL;
-
mxs_auart_free_gpio_irq(s);
- free_irq(s->irq, s);
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-27 19:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-27 19:08 [PATCH 1/4] serial: mxs-auart: Remove unneeded goto label Fabio Estevam
2014-11-27 19:08 ` [PATCH 2/4] serial: mxs-auart: Use devm_kzalloc() Fabio Estevam
2014-11-27 19:08 ` [PATCH 3/4] serial: mxs-auart: Use devm_clk_get() Fabio Estevam
2014-11-27 19:08 ` [PATCH 4/4] serial: mxs-auart: Use devm_request_irq() Fabio Estevam
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).