From: Florian Fainelli <florian@openwrt.org>
To: Axel Lin <axel.lin@ingics.com>, Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>, linux-gpio@vger.kernel.org
Subject: Re: [PATCH 2/2] gpio: rdc321x: Convert to use devm_kzalloc
Date: Sun, 20 Apr 2014 11:32:09 -0700 [thread overview]
Message-ID: <535412A9.5090304@openwrt.org> (raw)
In-Reply-To: <1397196961.12922.4.camel@phoenix>
Le 10/04/2014 23:16, Axel Lin a écrit :
> This saves a few unwind code.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Florian Fainelli <florian@openwrt.org>
> ---
> drivers/gpio/gpio-rdc321x.c | 19 ++++++-------------
> 1 file changed, 6 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpio/gpio-rdc321x.c b/drivers/gpio/gpio-rdc321x.c
> index 9e7da2d..3027591 100644
> --- a/drivers/gpio/gpio-rdc321x.c
> +++ b/drivers/gpio/gpio-rdc321x.c
> @@ -141,7 +141,8 @@ static int rdc321x_gpio_probe(struct platform_device *pdev)
> return -ENODEV;
> }
>
> - rdc321x_gpio_dev = kzalloc(sizeof(struct rdc321x_gpio), GFP_KERNEL);
> + rdc321x_gpio_dev = devm_kzalloc(&pdev->dev, sizeof(struct rdc321x_gpio),
> + GFP_KERNEL);
> if (!rdc321x_gpio_dev) {
> dev_err(&pdev->dev, "failed to allocate private data\n");
> return -ENOMEM;
> @@ -150,8 +151,7 @@ static int rdc321x_gpio_probe(struct platform_device *pdev)
> r = platform_get_resource_byname(pdev, IORESOURCE_IO, "gpio-reg1");
> if (!r) {
> dev_err(&pdev->dev, "failed to get gpio-reg1 resource\n");
> - err = -ENODEV;
> - goto out_free;
> + return -ENODEV;
> }
>
> spin_lock_init(&rdc321x_gpio_dev->lock);
> @@ -162,8 +162,7 @@ static int rdc321x_gpio_probe(struct platform_device *pdev)
> r = platform_get_resource_byname(pdev, IORESOURCE_IO, "gpio-reg2");
> if (!r) {
> dev_err(&pdev->dev, "failed to get gpio-reg2 resource\n");
> - err = -ENODEV;
> - goto out_free;
> + return -ENODEV;
> }
>
> rdc321x_gpio_dev->reg2_ctrl_base = r->start;
> @@ -187,21 +186,17 @@ static int rdc321x_gpio_probe(struct platform_device *pdev)
> rdc321x_gpio_dev->reg1_data_base,
> &rdc321x_gpio_dev->data_reg[0]);
> if (err)
> - goto out_free;
> + return err;
>
> err = pci_read_config_dword(rdc321x_gpio_dev->sb_pdev,
> rdc321x_gpio_dev->reg2_data_base,
> &rdc321x_gpio_dev->data_reg[1]);
> if (err)
> - goto out_free;
> + return err;
>
> dev_info(&pdev->dev, "registering %d GPIOs\n",
> rdc321x_gpio_dev->chip.ngpio);
> return gpiochip_add(&rdc321x_gpio_dev->chip);
> -
> -out_free:
> - kfree(rdc321x_gpio_dev);
> - return err;
> }
>
> static int rdc321x_gpio_remove(struct platform_device *pdev)
> @@ -213,8 +208,6 @@ static int rdc321x_gpio_remove(struct platform_device *pdev)
> if (ret)
> dev_err(&pdev->dev, "failed to unregister chip\n");
>
> - kfree(rdc321x_gpio_dev);
> -
> return ret;
> }
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-04-20 18:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-11 6:14 [PATCH 1/2] gpio: rdc321x: Fix off-by-one for ngpio setting Axel Lin
2014-04-11 6:16 ` [PATCH 2/2] gpio: rdc321x: Convert to use devm_kzalloc Axel Lin
2014-04-20 18:32 ` Florian Fainelli [this message]
2014-04-23 13:27 ` Linus Walleij
2014-04-20 18:31 ` [PATCH 1/2] gpio: rdc321x: Fix off-by-one for ngpio setting Florian Fainelli
2014-04-23 13:25 ` Linus Walleij
2014-04-23 14:00 ` Axel Lin
2014-04-23 21:53 ` Linus Walleij
2014-04-23 21:55 ` Florian Fainelli
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=535412A9.5090304@openwrt.org \
--to=florian@openwrt.org \
--cc=axel.lin@ingics.com \
--cc=gnurou@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.