From: Fabio Estevam <festevam@gmail.com>
To: gregkh@linuxfoundation.org
Cc: j.uzycki@elproma.com.pl, linux-serial@vger.kernel.org,
Fabio Estevam <fabio.estevam@freescale.com>
Subject: [PATCH 2/4] serial: mxs-auart: Use devm_kzalloc()
Date: Thu, 27 Nov 2014 17:08:31 -0200 [thread overview]
Message-ID: <1417115313-24113-2-git-send-email-festevam@gmail.com> (raw)
In-Reply-To: <1417115313-24113-1-git-send-email-festevam@gmail.com>
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
next prev parent reply other threads:[~2014-11-27 19:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-27 19:08 [PATCH 1/4] serial: mxs-auart: Remove unneeded goto label Fabio Estevam
2014-11-27 19:08 ` Fabio Estevam [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1417115313-24113-2-git-send-email-festevam@gmail.com \
--to=festevam@gmail.com \
--cc=fabio.estevam@freescale.com \
--cc=gregkh@linuxfoundation.org \
--cc=j.uzycki@elproma.com.pl \
--cc=linux-serial@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).