linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: light: max44000: use device-managed functions in probe
@ 2021-09-13 12:00 Alexandru Ardelean
  2021-09-18 18:08 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Alexandru Ardelean @ 2021-09-13 12:00 UTC (permalink / raw)
  To: linux-kernel, linux-iio; +Cc: jic23, Alexandru Ardelean

This is a simple conversion. Both iio_device_register() and
iio_triggered_buffer_setup() functions have device-managed variants.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
---
 drivers/iio/light/max44000.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/iio/light/max44000.c b/drivers/iio/light/max44000.c
index b8e721bced5b..85689dffbcbf 100644
--- a/drivers/iio/light/max44000.c
+++ b/drivers/iio/light/max44000.c
@@ -540,7 +540,6 @@ static int max44000_probe(struct i2c_client *client,
 		return PTR_ERR(data->regmap);
 	}
 
-	i2c_set_clientdata(client, indio_dev);
 	mutex_init(&data->lock);
 	indio_dev->info = &max44000_info;
 	indio_dev->name = MAX44000_DRV_NAME;
@@ -589,23 +588,14 @@ static int max44000_probe(struct i2c_client *client,
 		return ret;
 	}
 
-	ret = iio_triggered_buffer_setup(indio_dev, NULL, max44000_trigger_handler, NULL);
+	ret = devm_iio_triggered_buffer_setup(&client->dev, indio_dev, NULL,
+					      max44000_trigger_handler, NULL);
 	if (ret < 0) {
 		dev_err(&client->dev, "iio triggered buffer setup failed\n");
 		return ret;
 	}
 
-	return iio_device_register(indio_dev);
-}
-
-static int max44000_remove(struct i2c_client *client)
-{
-	struct iio_dev *indio_dev = i2c_get_clientdata(client);
-
-	iio_device_unregister(indio_dev);
-	iio_triggered_buffer_cleanup(indio_dev);
-
-	return 0;
+	return devm_iio_device_register(&client->dev, indio_dev);
 }
 
 static const struct i2c_device_id max44000_id[] = {
@@ -628,7 +618,6 @@ static struct i2c_driver max44000_driver = {
 		.acpi_match_table = ACPI_PTR(max44000_acpi_match),
 	},
 	.probe		= max44000_probe,
-	.remove		= max44000_remove,
 	.id_table	= max44000_id,
 };
 
-- 
2.31.1


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

* Re: [PATCH] iio: light: max44000: use device-managed functions in probe
  2021-09-13 12:00 [PATCH] iio: light: max44000: use device-managed functions in probe Alexandru Ardelean
@ 2021-09-18 18:08 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2021-09-18 18:08 UTC (permalink / raw)
  To: Alexandru Ardelean; +Cc: linux-kernel, linux-iio

On Mon, 13 Sep 2021 15:00:02 +0300
Alexandru Ardelean <aardelean@deviqon.com> wrote:

> This is a simple conversion. Both iio_device_register() and
> iio_triggered_buffer_setup() functions have device-managed variants.
> 
> Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
Applied to the togreg branch of iio.git and pushed out as testing
as per normal.

Thanks,

Jonathan

> ---
>  drivers/iio/light/max44000.c | 17 +++--------------
>  1 file changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/iio/light/max44000.c b/drivers/iio/light/max44000.c
> index b8e721bced5b..85689dffbcbf 100644
> --- a/drivers/iio/light/max44000.c
> +++ b/drivers/iio/light/max44000.c
> @@ -540,7 +540,6 @@ static int max44000_probe(struct i2c_client *client,
>  		return PTR_ERR(data->regmap);
>  	}
>  
> -	i2c_set_clientdata(client, indio_dev);
>  	mutex_init(&data->lock);
>  	indio_dev->info = &max44000_info;
>  	indio_dev->name = MAX44000_DRV_NAME;
> @@ -589,23 +588,14 @@ static int max44000_probe(struct i2c_client *client,
>  		return ret;
>  	}
>  
> -	ret = iio_triggered_buffer_setup(indio_dev, NULL, max44000_trigger_handler, NULL);
> +	ret = devm_iio_triggered_buffer_setup(&client->dev, indio_dev, NULL,
> +					      max44000_trigger_handler, NULL);
>  	if (ret < 0) {
>  		dev_err(&client->dev, "iio triggered buffer setup failed\n");
>  		return ret;
>  	}
>  
> -	return iio_device_register(indio_dev);
> -}
> -
> -static int max44000_remove(struct i2c_client *client)
> -{
> -	struct iio_dev *indio_dev = i2c_get_clientdata(client);
> -
> -	iio_device_unregister(indio_dev);
> -	iio_triggered_buffer_cleanup(indio_dev);
> -
> -	return 0;
> +	return devm_iio_device_register(&client->dev, indio_dev);
>  }
>  
>  static const struct i2c_device_id max44000_id[] = {
> @@ -628,7 +618,6 @@ static struct i2c_driver max44000_driver = {
>  		.acpi_match_table = ACPI_PTR(max44000_acpi_match),
>  	},
>  	.probe		= max44000_probe,
> -	.remove		= max44000_remove,
>  	.id_table	= max44000_id,
>  };
>  


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

end of thread, other threads:[~2021-09-18 18:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 12:00 [PATCH] iio: light: max44000: use device-managed functions in probe Alexandru Ardelean
2021-09-18 18:08 ` 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).