* [PATCH 1/3] iio:adjd_s311: Use devm_iio_device_alloc
@ 2013-07-29 22:18 Peter Meerwald
  2013-07-29 22:18 ` [PATCH 2/3] iio:vcnl4000: " Peter Meerwald
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Peter Meerwald @ 2013-07-29 22:18 UTC (permalink / raw)
  To: linux-iio; +Cc: Peter Meerwald
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/iio/light/adjd_s311.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c
index 5f4749e..55b9e18 100644
--- a/drivers/iio/light/adjd_s311.c
+++ b/drivers/iio/light/adjd_s311.c
@@ -293,11 +293,10 @@ static int adjd_s311_probe(struct i2c_client *client,
 	struct iio_dev *indio_dev;
 	int err;
 
-	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;
@@ -312,7 +311,7 @@ static int adjd_s311_probe(struct i2c_client *client,
 	err = iio_triggered_buffer_setup(indio_dev, NULL,
 		adjd_s311_trigger_handler, NULL);
 	if (err < 0)
-		goto exit_free_device;
+		return err;
 
 	err = iio_device_register(indio_dev);
 	if (err)
@@ -324,9 +323,6 @@ static int adjd_s311_probe(struct i2c_client *client,
 
 exit_unreg_buffer:
 	iio_triggered_buffer_cleanup(indio_dev);
-exit_free_device:
-	iio_device_free(indio_dev);
-exit:
 	return err;
 }
 
@@ -338,7 +334,6 @@ static int adjd_s311_remove(struct i2c_client *client)
 	iio_device_unregister(indio_dev);
 	iio_triggered_buffer_cleanup(indio_dev);
 	kfree(data->buffer);
-	iio_device_free(indio_dev);
 
 	return 0;
 }
-- 
1.8.3.4
^ permalink raw reply related	[flat|nested] 6+ messages in thread* [PATCH 2/3] iio:vcnl4000: Use devm_iio_device_alloc
  2013-07-29 22:18 [PATCH 1/3] iio:adjd_s311: Use devm_iio_device_alloc Peter Meerwald
@ 2013-07-29 22:18 ` 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:17 ` [PATCH 1/3] iio:adjd_s311: " Jonathan Cameron
  2 siblings, 1 reply; 6+ messages in thread
From: Peter Meerwald @ 2013-07-29 22:18 UTC (permalink / raw)
  To: linux-iio; +Cc: Peter Meerwald
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 drivers/iio/light/vcnl4000.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index 1014943..2bb3042 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -157,7 +157,7 @@ static int vcnl4000_probe(struct i2c_client *client,
 	struct iio_dev *indio_dev;
 	int ret;
 
-	indio_dev = iio_device_alloc(sizeof(*data));
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
 	if (!indio_dev)
 		return -ENOMEM;
 
@@ -167,7 +167,7 @@ static int vcnl4000_probe(struct i2c_client *client,
 
 	ret = i2c_smbus_read_byte_data(data->client, VCNL4000_PROD_REV);
 	if (ret < 0)
-		goto error_free_dev;
+		return ret;
 
 	dev_info(&client->dev, "VCNL4000 Ambient light/proximity sensor, Prod %02x, Rev: %02x\n",
 		ret >> 4, ret & 0xf);
@@ -181,22 +181,14 @@ static int vcnl4000_probe(struct i2c_client *client,
 
 	ret = iio_device_register(indio_dev);
 	if (ret < 0)
-		goto error_free_dev;
+		return ret;
 
 	return 0;
-
-error_free_dev:
-	iio_device_free(indio_dev);
-	return ret;
 }
 
 static int vcnl4000_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;
 }
 
-- 
1.8.3.4
^ permalink raw reply related	[flat|nested] 6+ messages in thread* Re: [PATCH 2/3] iio:vcnl4000: Use devm_iio_device_alloc
  2013-07-29 22:18 ` [PATCH 2/3] iio:vcnl4000: " Peter Meerwald
@ 2013-08-03 21:18   ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2013-08-03 21:18 UTC (permalink / raw)
  To: Peter Meerwald; +Cc: linux-iio
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/light/vcnl4000.c | 16 ++++------------
>  1 file changed, 4 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
> index 1014943..2bb3042 100644
> --- a/drivers/iio/light/vcnl4000.c
> +++ b/drivers/iio/light/vcnl4000.c
> @@ -157,7 +157,7 @@ static int vcnl4000_probe(struct i2c_client *client,
>  	struct iio_dev *indio_dev;
>  	int ret;
>  
> -	indio_dev = iio_device_alloc(sizeof(*data));
> +	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
>  	if (!indio_dev)
>  		return -ENOMEM;
>  
> @@ -167,7 +167,7 @@ static int vcnl4000_probe(struct i2c_client *client,
>  
>  	ret = i2c_smbus_read_byte_data(data->client, VCNL4000_PROD_REV);
>  	if (ret < 0)
> -		goto error_free_dev;
> +		return ret;
>  
>  	dev_info(&client->dev, "VCNL4000 Ambient light/proximity sensor, Prod %02x, Rev: %02x\n",
>  		ret >> 4, ret & 0xf);
> @@ -181,22 +181,14 @@ static int vcnl4000_probe(struct i2c_client *client,
>  
>  	ret = iio_device_register(indio_dev);
>  	if (ret < 0)
> -		goto error_free_dev;
> +		return ret;
>  
>  	return 0;
> -
> -error_free_dev:
> -	iio_device_free(indio_dev);
> -	return ret;
>  }
>  
>  static int vcnl4000_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;
>  }
>  
> 
^ permalink raw reply	[flat|nested] 6+ messages in thread
* [PATCH 3/3] iio:mcp4725: Use devm_iio_device_alloc
  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-07-29 22:18 ` Peter Meerwald
  2013-08-03 21:19   ` Jonathan Cameron
  2013-08-03 21:17 ` [PATCH 1/3] iio:adjd_s311: " Jonathan Cameron
  2 siblings, 1 reply; 6+ messages in thread
From: Peter Meerwald @ 2013-07-29 22:18 UTC (permalink / raw)
  To: linux-iio; +Cc: Peter Meerwald
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
---
 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;
 }
 
-- 
1.8.3.4
^ permalink raw reply related	[flat|nested] 6+ messages in thread* Re: [PATCH 3/3] iio:mcp4725: Use devm_iio_device_alloc
  2013-07-29 22:18 ` [PATCH 3/3] iio:mcp4725: " Peter Meerwald
@ 2013-08-03 21:19   ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2013-08-03 21:19 UTC (permalink / raw)
  To: Peter Meerwald; +Cc: linux-iio
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;
>  }
>  
> 
^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] iio:adjd_s311: Use devm_iio_device_alloc
  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-07-29 22:18 ` [PATCH 3/3] iio:mcp4725: " Peter Meerwald
@ 2013-08-03 21:17 ` Jonathan Cameron
  2 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2013-08-03 21:17 UTC (permalink / raw)
  To: Peter Meerwald; +Cc: linux-iio
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/light/adjd_s311.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/light/adjd_s311.c b/drivers/iio/light/adjd_s311.c
> index 5f4749e..55b9e18 100644
> --- a/drivers/iio/light/adjd_s311.c
> +++ b/drivers/iio/light/adjd_s311.c
> @@ -293,11 +293,10 @@ static int adjd_s311_probe(struct i2c_client *client,
>  	struct iio_dev *indio_dev;
>  	int err;
>  
> -	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;
> @@ -312,7 +311,7 @@ static int adjd_s311_probe(struct i2c_client *client,
>  	err = iio_triggered_buffer_setup(indio_dev, NULL,
>  		adjd_s311_trigger_handler, NULL);
>  	if (err < 0)
> -		goto exit_free_device;
> +		return err;
>  
>  	err = iio_device_register(indio_dev);
>  	if (err)
> @@ -324,9 +323,6 @@ static int adjd_s311_probe(struct i2c_client *client,
>  
>  exit_unreg_buffer:
>  	iio_triggered_buffer_cleanup(indio_dev);
> -exit_free_device:
> -	iio_device_free(indio_dev);
> -exit:
>  	return err;
>  }
>  
> @@ -338,7 +334,6 @@ static int adjd_s311_remove(struct i2c_client *client)
>  	iio_device_unregister(indio_dev);
>  	iio_triggered_buffer_cleanup(indio_dev);
>  	kfree(data->buffer);
> -	iio_device_free(indio_dev);
>  
>  	return 0;
>  }
> 
^ permalink raw reply	[flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-08-03 20:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2013-08-03 21:17 ` [PATCH 1/3] iio:adjd_s311: " Jonathan Cameron
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).