devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Cc: linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	Naveen Krishna Chatradhi
	<ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>,
	Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>,
	Doug Anderson <dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Tomasz Figa <tomasz.figa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Grant Likely
	<grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>,
	Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
Subject: Re: [PATCH 1/4] iio: max1363: Use devm_ functions whereever possible to allocate resources
Date: Sun, 03 Feb 2013 12:10:32 +0000	[thread overview]
Message-ID: <510E53B8.40803@kernel.org> (raw)
In-Reply-To: <1359853180-5664-2-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>

On 02/03/2013 12:59 AM, Guenter Roeck wrote:
> Signed-off-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
Applied to togreg branch of iio.git.

Note I'll probably rebase the togreg branch if / when Greg has pulled
last pull request (sent a few mins ago) so as to get a directly
applied fix for this driver.

> ---
>  drivers/iio/adc/max1363.c |   29 ++++++++++-------------------
>  1 file changed, 10 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c
> index ef868c9..1353fda 100644
> --- a/drivers/iio/adc/max1363.c
> +++ b/drivers/iio/adc/max1363.c
> @@ -1410,8 +1410,9 @@ static int max1363_alloc_scan_masks(struct iio_dev *indio_dev)
>  	unsigned long *masks;
>  	int i;
>  
> -	masks = kzalloc(BITS_TO_LONGS(MAX1363_MAX_CHANNELS)*sizeof(long)*
> -			  (st->chip_info->num_modes + 1), GFP_KERNEL);
> +	masks = devm_kzalloc(&indio_dev->dev,
> +			BITS_TO_LONGS(MAX1363_MAX_CHANNELS) * sizeof(long) *
> +			(st->chip_info->num_modes + 1), GFP_KERNEL);
>  	if (!masks)
>  		return -ENOMEM;
>  
> @@ -1546,7 +1547,7 @@ static int max1363_probe(struct i2c_client *client,
>  
>  	st = iio_priv(indio_dev);
>  
> -	st->reg = regulator_get(&client->dev, "vcc");
> +	st->reg = devm_regulator_get(&client->dev, "vcc");
>  	if (IS_ERR(st->reg)) {
>  		ret = PTR_ERR(st->reg);
>  		goto error_unregister_map;
> @@ -1554,7 +1555,7 @@ static int max1363_probe(struct i2c_client *client,
>  
>  	ret = regulator_enable(st->reg);
>  	if (ret)
> -		goto error_put_reg;
> +		goto error_unregister_map;
>  
>  	/* this is only used for device removal purposes */
>  	i2c_set_clientdata(client, indio_dev);
> @@ -1575,15 +1576,15 @@ static int max1363_probe(struct i2c_client *client,
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  	ret = max1363_initial_setup(st);
>  	if (ret < 0)
> -		goto error_free_available_scan_masks;
> +		goto error_disable_reg;
>  
>  	ret = iio_triggered_buffer_setup(indio_dev, NULL,
>  		&max1363_trigger_handler, &max1363_buffered_setup_ops);
>  	if (ret)
> -		goto error_free_available_scan_masks;
> +		goto error_disable_reg;
>  
>  	if (client->irq) {
> -		ret = request_threaded_irq(st->client->irq,
> +		ret = devm_request_threaded_irq(&client->dev, st->client->irq,
>  					   NULL,
>  					   &max1363_event_handler,
>  					   IRQF_TRIGGER_RISING | IRQF_ONESHOT,
> @@ -1596,20 +1597,14 @@ static int max1363_probe(struct i2c_client *client,
>  
>  	ret = iio_device_register(indio_dev);
>  	if (ret < 0)
> -		goto error_free_irq;
> +		goto error_uninit_buffer;
>  
>  	return 0;
> -error_free_irq:
> -	if (client->irq)
> -		free_irq(st->client->irq, indio_dev);
> +
>  error_uninit_buffer:
>  	iio_triggered_buffer_cleanup(indio_dev);
> -error_free_available_scan_masks:
> -	kfree(indio_dev->available_scan_masks);
>  error_disable_reg:
>  	regulator_disable(st->reg);
> -error_put_reg:
> -	regulator_put(st->reg);
>  error_unregister_map:
>  	iio_map_array_unregister(indio_dev);
>  error_free_device:
> @@ -1624,12 +1619,8 @@ static int max1363_remove(struct i2c_client *client)
>  	struct max1363_state *st = iio_priv(indio_dev);
>  
>  	iio_device_unregister(indio_dev);
> -	if (client->irq)
> -		free_irq(st->client->irq, indio_dev);
>  	iio_triggered_buffer_cleanup(indio_dev);
> -	kfree(indio_dev->available_scan_masks);
>  	regulator_disable(st->reg);
> -	regulator_put(st->reg);
>  	iio_map_array_unregister(indio_dev);
>  	iio_device_free(indio_dev);
>  
> 

  parent reply	other threads:[~2013-02-03 12:10 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-03  0:59 [RFC v2 0/4] iio: Devicetree support Guenter Roeck
     [not found] ` <1359853180-5664-1-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-03  0:59   ` [PATCH 1/4] iio: max1363: Use devm_ functions whereever possible to allocate resources Guenter Roeck
     [not found]     ` <1359853180-5664-2-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-03 12:10       ` Jonathan Cameron [this message]
     [not found]         ` <510E53B8.40803-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-02-03 17:18           ` Guenter Roeck
     [not found]             ` <20130203171852.GA29574-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-03 18:02               ` Jonathan Cameron
     [not found]                 ` <510EA651.6040509-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-02-03 18:16                   ` Guenter Roeck
2013-02-03  0:59   ` [PATCH v2 2/4] iio/adc: (max1363) Add support for external reference voltage Guenter Roeck
     [not found]     ` <1359853180-5664-3-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-03 12:12       ` Jonathan Cameron
2013-02-03  0:59   ` [PATCH RFC 3/4] iio: Update iio_channel_get API to use consumer device pointer as argument Guenter Roeck
2013-02-03  0:59   ` [PATCH v2 4/4] iio: Add OF support Guenter Roeck
     [not found]     ` <1359853180-5664-5-git-send-email-linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-03  1:30       ` Tomasz Figa
2013-02-03  2:06         ` Guenter Roeck
     [not found]           ` <20130203020651.GA7655-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-03 11:29             ` Lars-Peter Clausen
     [not found]               ` <510E4A13.3080800-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-02-03 11:52                 ` Tomasz Figa
2013-02-03 12:22                   ` Lars-Peter Clausen
2013-02-03 17:01                   ` Guenter Roeck
     [not found]                     ` <20130203170107.GD21576-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-03 17:30                       ` Tomasz Figa
2013-02-03 18:55                         ` Lars-Peter Clausen
     [not found]                           ` <510EB2B3.7090503-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-02-03 20:58                             ` Jonathan Cameron
     [not found]                               ` <510ECF91.8020800-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2013-02-03 22:44                                 ` Lars-Peter Clausen
2013-02-03 23:14                             ` Tomasz Figa
2013-02-04 17:12                               ` Guenter Roeck
     [not found]                                 ` <20130204171214.GA23170-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-04 17:41                                   ` Lars-Peter Clausen
2013-02-04 17:51                                   ` Guenter Roeck
     [not found]                                     ` <20130204175134.GA17776-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-04 18:00                                       ` Tomasz Figa
2013-02-04 18:09                                         ` Guenter Roeck
2013-02-03 16:31                 ` Guenter Roeck
     [not found]                   ` <20130203163124.GC21576-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-03 19:00                     ` Lars-Peter Clausen
2013-02-03 14:17       ` Lars-Peter Clausen
     [not found]         ` <510E7195.4070803-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-02-03 16:22           ` Guenter Roeck
     [not found]             ` <20130203162213.GA21576-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2013-02-04 16:37               ` Guenter Roeck

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=510E53B8.40803@kernel.org \
    --to=jic23-dgejt+ai2ygdnm+yrofe0a@public.gmane.org \
    --cc=ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=dianders-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org \
    --cc=lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org \
    --cc=linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org \
    --cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
    --cc=tomasz.figa-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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).