All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Peter Meerwald <pmeerw@pmeerw.net>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH 3/3] iio:mcp4725: Use devm_iio_device_alloc
Date: Sat, 03 Aug 2013 22:19:13 +0100	[thread overview]
Message-ID: <51FD73D1.4020300@kernel.org> (raw)
In-Reply-To: <1375136311-8523-3-git-send-email-pmeerw@pmeerw.net>

On 07/29/13 23:18, Peter Meerwald wrote:
> Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Applied to the togreg branch of iio.git

Thanks,
> ---
>  drivers/iio/dac/mcp4725.c | 26 +++++++-------------------
>  1 file changed, 7 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c
> index 18a78cd..1f4a48e 100644
> --- a/drivers/iio/dac/mcp4725.c
> +++ b/drivers/iio/dac/mcp4725.c
> @@ -292,15 +292,12 @@ static int mcp4725_probe(struct i2c_client *client,
>  
>  	if (!platform_data || !platform_data->vref_mv) {
>  		dev_err(&client->dev, "invalid platform data");
> -		err = -EINVAL;
> -		goto exit;
> +		return -EINVAL;
>  	}
>  
> -	indio_dev = iio_device_alloc(sizeof(*data));
> -	if (indio_dev == NULL) {
> -		err = -ENOMEM;
> -		goto exit;
> -	}
> +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> +	if (indio_dev == NULL)
> +		return -ENOMEM;
>  	data = iio_priv(indio_dev);
>  	i2c_set_clientdata(client, indio_dev);
>  	data->client = client;
> @@ -317,7 +314,7 @@ static int mcp4725_probe(struct i2c_client *client,
>  	err = i2c_master_recv(client, inbuf, 3);
>  	if (err < 0) {
>  		dev_err(&client->dev, "failed to read DAC value");
> -		goto exit_free_device;
> +		return err;
>  	}
>  	pd = (inbuf[0] >> 1) & 0x3;
>  	data->powerdown = pd > 0 ? true : false;
> @@ -326,25 +323,16 @@ static int mcp4725_probe(struct i2c_client *client,
>  
>  	err = iio_device_register(indio_dev);
>  	if (err)
> -		goto exit_free_device;
> +		return err;
>  
>  	dev_info(&client->dev, "MCP4725 DAC registered\n");
>  
>  	return 0;
> -
> -exit_free_device:
> -	iio_device_free(indio_dev);
> -exit:
> -	return err;
>  }
>  
>  static int mcp4725_remove(struct i2c_client *client)
>  {
> -	struct iio_dev *indio_dev = i2c_get_clientdata(client);
> -
> -	iio_device_unregister(indio_dev);
> -	iio_device_free(indio_dev);
> -
> +	iio_device_unregister(i2c_get_clientdata(client));
>  	return 0;
>  }
>  
> 

  reply	other threads:[~2013-08-03 20:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-29 22:18 [PATCH 1/3] iio:adjd_s311: Use devm_iio_device_alloc Peter Meerwald
2013-07-29 22:18 ` [PATCH 2/3] iio:vcnl4000: " Peter Meerwald
2013-08-03 21:18   ` Jonathan Cameron
2013-07-29 22:18 ` [PATCH 3/3] iio:mcp4725: " Peter Meerwald
2013-08-03 21:19   ` Jonathan Cameron [this message]
2013-08-03 21:17 ` [PATCH 1/3] iio:adjd_s311: " Jonathan Cameron

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=51FD73D1.4020300@kernel.org \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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.