mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 1/1] gpio: sx150x: convert to use devm_kzalloc()
@ 2013-05-28 21:29 Nikolay Balandin
  2013-05-30 19:35 ` Andy Shevchenko
  2013-05-30 20:17 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Nikolay Balandin @ 2013-05-28 21:29 UTC (permalink / raw)
  To: Linus Walleij, Grant Likely; +Cc: linux-kernel, Nikolay Balandin

From: Nikolay Balandin <nbalandin@dev.rtsoft.ru>

Use devm_kzalloc() to make cleanup paths simpler.

Signed-off-by: Nikolay Balandin <nbalandin@dev.rtsoft.ru>
---
 drivers/gpio/gpio-sx150x.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c
index 796b6c4..17c67be 100644
--- a/drivers/gpio/gpio-sx150x.c
+++ b/drivers/gpio/gpio-sx150x.c
@@ -591,18 +591,19 @@ static int sx150x_probe(struct i2c_client *client,
 	if (!i2c_check_functionality(client->adapter, i2c_funcs))
 		return -ENOSYS;
 
-	chip = kzalloc(sizeof(struct sx150x_chip), GFP_KERNEL);
+	chip = devm_kzalloc(&client->dev,
+		sizeof(struct sx150x_chip), GFP_KERNEL);
 	if (!chip)
 		return -ENOMEM;
 
 	sx150x_init_chip(chip, client, id->driver_data, pdata);
 	rc = sx150x_init_hw(chip, pdata);
 	if (rc < 0)
-		goto probe_fail_pre_gpiochip_add;
+		return rc;
 
 	rc = gpiochip_add(&chip->gpio_chip);
-	if (rc < 0)
-		goto probe_fail_pre_gpiochip_add;
+	if (rc)
+		return rc;
 
 	if (pdata->irq_summary >= 0) {
 		rc = sx150x_install_irq_chip(chip,
@@ -617,8 +618,6 @@ static int sx150x_probe(struct i2c_client *client,
 	return 0;
 probe_fail_post_gpiochip_add:
 	WARN_ON(gpiochip_remove(&chip->gpio_chip) < 0);
-probe_fail_pre_gpiochip_add:
-	kfree(chip);
 	return rc;
 }
 
@@ -635,8 +634,6 @@ static int sx150x_remove(struct i2c_client *client)
 	if (chip->irq_summary >= 0)
 		sx150x_remove_irq_chip(chip);
 
-	kfree(chip);
-
 	return 0;
 }
 
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/1] gpio: sx150x: convert to use devm_kzalloc()
  2013-05-28 21:29 [PATCH v2 1/1] gpio: sx150x: convert to use devm_kzalloc() Nikolay Balandin
@ 2013-05-30 19:35 ` Andy Shevchenko
  2013-05-30 20:17 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2013-05-30 19:35 UTC (permalink / raw)
  To: Nikolay Balandin
  Cc: Linus Walleij, Grant Likely, linux-kernel, Nikolay Balandin

On Wed, May 29, 2013 at 12:29 AM, Nikolay Balandin
<n.a.balandin@gmail.com> wrote:
> From: Nikolay Balandin <nbalandin@dev.rtsoft.ru>
>
> Use devm_kzalloc() to make cleanup paths simpler.

What about request_threaded_irq?

>
> Signed-off-by: Nikolay Balandin <nbalandin@dev.rtsoft.ru>
> ---
>  drivers/gpio/gpio-sx150x.c |   13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpio/gpio-sx150x.c b/drivers/gpio/gpio-sx150x.c
> index 796b6c4..17c67be 100644
> --- a/drivers/gpio/gpio-sx150x.c
> +++ b/drivers/gpio/gpio-sx150x.c
> @@ -591,18 +591,19 @@ static int sx150x_probe(struct i2c_client *client,
>         if (!i2c_check_functionality(client->adapter, i2c_funcs))
>                 return -ENOSYS;
>
> -       chip = kzalloc(sizeof(struct sx150x_chip), GFP_KERNEL);
> +       chip = devm_kzalloc(&client->dev,
> +               sizeof(struct sx150x_chip), GFP_KERNEL);
>         if (!chip)
>                 return -ENOMEM;
>
>         sx150x_init_chip(chip, client, id->driver_data, pdata);
>         rc = sx150x_init_hw(chip, pdata);
>         if (rc < 0)
> -               goto probe_fail_pre_gpiochip_add;
> +               return rc;
>
>         rc = gpiochip_add(&chip->gpio_chip);
> -       if (rc < 0)
> -               goto probe_fail_pre_gpiochip_add;
> +       if (rc)
> +               return rc;
>
>         if (pdata->irq_summary >= 0) {
>                 rc = sx150x_install_irq_chip(chip,
> @@ -617,8 +618,6 @@ static int sx150x_probe(struct i2c_client *client,
>         return 0;
>  probe_fail_post_gpiochip_add:
>         WARN_ON(gpiochip_remove(&chip->gpio_chip) < 0);
> -probe_fail_pre_gpiochip_add:
> -       kfree(chip);
>         return rc;
>  }
>
> @@ -635,8 +634,6 @@ static int sx150x_remove(struct i2c_client *client)
>         if (chip->irq_summary >= 0)
>                 sx150x_remove_irq_chip(chip);
>
> -       kfree(chip);
> -
>         return 0;
>  }
>
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



--
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 1/1] gpio: sx150x: convert to use devm_kzalloc()
  2013-05-28 21:29 [PATCH v2 1/1] gpio: sx150x: convert to use devm_kzalloc() Nikolay Balandin
  2013-05-30 19:35 ` Andy Shevchenko
@ 2013-05-30 20:17 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2013-05-30 20:17 UTC (permalink / raw)
  To: Nikolay Balandin; +Cc: Grant Likely, linux-kernel, Nikolay Balandin

On Tue, May 28, 2013 at 11:29 PM, Nikolay Balandin
<n.a.balandin@gmail.com> wrote:

> From: Nikolay Balandin <nbalandin@dev.rtsoft.ru>
>
> Use devm_kzalloc() to make cleanup paths simpler.
>
> Signed-off-by: Nikolay Balandin <nbalandin@dev.rtsoft.ru>

Patch applied.

What is wrong with you RTC?

Received: from localhost.localdomain
(ppp91-76-159-237.pppoe.mtu-net.ru. [91.76.159.237])
        by mx.google.com with ESMTPSA id t4sm17535255lbe.7.2013.05.30.12.21.07
        for <multiple recipients>
        (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 30 May 2013 12:21:08 -0700 (PDT)
(...)
Subject: [PATCH v2 1/1] gpio: sx150x: convert to use devm_kzalloc()
Date: Tue, 28 May 2013 14:29:44 -0700

The mail was clearly sent today but looks two days old.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-30 20:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-28 21:29 [PATCH v2 1/1] gpio: sx150x: convert to use devm_kzalloc() Nikolay Balandin
2013-05-30 19:35 ` Andy Shevchenko
2013-05-30 20:17 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®