All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] iio: pressure: hp03: update device probe to register with devm functions
@ 2021-08-09 20:30 Théo Borém Fabris
  2021-08-15 15:53 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Théo Borém Fabris @ 2021-08-09 20:30 UTC (permalink / raw)
  To: jic23, lars
  Cc: linux-iio, linux-kernel, marex, marek.vasut, Théo Borém Fabris

Update device probe to register resources with device-managed functions.
Further, get rid of device-specific remove callback which is no longer
needed.

Signed-off-by: Théo Borém Fabris <theobf@usp.br>
---
Changelog:
V1 -> V2: Tiny cleanup

 drivers/iio/pressure/hp03.c | 36 +++++++-----------------------------
 1 file changed, 7 insertions(+), 29 deletions(-)

diff --git a/drivers/iio/pressure/hp03.c b/drivers/iio/pressure/hp03.c
index e40b1d7dc12..9538118c964 100644
--- a/drivers/iio/pressure/hp03.c
+++ b/drivers/iio/pressure/hp03.c
@@ -242,47 +242,26 @@ static int hp03_probe(struct i2c_client *client,
 	 * which has it's dedicated I2C address and contains
 	 * the calibration constants for the sensor.
 	 */
-	priv->eeprom_client = i2c_new_dummy_device(client->adapter, HP03_EEPROM_ADDR);
+	priv->eeprom_client = devm_i2c_new_dummy_device(dev, client->adapter,
+							HP03_EEPROM_ADDR);
 	if (IS_ERR(priv->eeprom_client)) {
 		dev_err(dev, "New EEPROM I2C device failed\n");
 		return PTR_ERR(priv->eeprom_client);
 	}
 
-	priv->eeprom_regmap = regmap_init_i2c(priv->eeprom_client,
-					      &hp03_regmap_config);
+	priv->eeprom_regmap = devm_regmap_init_i2c(priv->eeprom_client,
+						   &hp03_regmap_config);
 	if (IS_ERR(priv->eeprom_regmap)) {
 		dev_err(dev, "Failed to allocate EEPROM regmap\n");
-		ret = PTR_ERR(priv->eeprom_regmap);
-		goto err_cleanup_eeprom_client;
+		return PTR_ERR(priv->eeprom_regmap);
 	}
 
-	ret = iio_device_register(indio_dev);
+	ret = devm_iio_device_register(dev, indio_dev);
 	if (ret) {
 		dev_err(dev, "Failed to register IIO device\n");
-		goto err_cleanup_eeprom_regmap;
+		return ret;
 	}
 
-	i2c_set_clientdata(client, indio_dev);
-
-	return 0;
-
-err_cleanup_eeprom_regmap:
-	regmap_exit(priv->eeprom_regmap);
-
-err_cleanup_eeprom_client:
-	i2c_unregister_device(priv->eeprom_client);
-	return ret;
-}
-
-static int hp03_remove(struct i2c_client *client)
-{
-	struct iio_dev *indio_dev = i2c_get_clientdata(client);
-	struct hp03_priv *priv = iio_priv(indio_dev);
-
-	iio_device_unregister(indio_dev);
-	regmap_exit(priv->eeprom_regmap);
-	i2c_unregister_device(priv->eeprom_client);
-
 	return 0;
 }
 
@@ -304,7 +283,6 @@ static struct i2c_driver hp03_driver = {
 		.of_match_table = hp03_of_match,
 	},
 	.probe		= hp03_probe,
-	.remove		= hp03_remove,
 	.id_table	= hp03_id,
 };
 module_i2c_driver(hp03_driver);
-- 
2.20.1


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

* Re: [PATCH v2] iio: pressure: hp03: update device probe to register with devm functions
  2021-08-09 20:30 [PATCH v2] iio: pressure: hp03: update device probe to register with devm functions Théo Borém Fabris
@ 2021-08-15 15:53 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2021-08-15 15:53 UTC (permalink / raw)
  To: Théo Borém Fabris
  Cc: lars, linux-iio, linux-kernel, marex, marek.vasut

On Mon,  9 Aug 2021 17:30:14 -0300
Théo Borém Fabris <theobf@usp.br> wrote:

> Update device probe to register resources with device-managed functions.
> Further, get rid of device-specific remove callback which is no longer
> needed.
> 
> Signed-off-by: Théo Borém Fabris <theobf@usp.br>
Applied to the togreg branch of iio.git and pushed out as testing to see
if 0-day can find any problems that we've missed.

Thanks,

Jonathan

> ---
> Changelog:
> V1 -> V2: Tiny cleanup
> 
>  drivers/iio/pressure/hp03.c | 36 +++++++-----------------------------
>  1 file changed, 7 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/iio/pressure/hp03.c b/drivers/iio/pressure/hp03.c
> index e40b1d7dc12..9538118c964 100644
> --- a/drivers/iio/pressure/hp03.c
> +++ b/drivers/iio/pressure/hp03.c
> @@ -242,47 +242,26 @@ static int hp03_probe(struct i2c_client *client,
>  	 * which has it's dedicated I2C address and contains
>  	 * the calibration constants for the sensor.
>  	 */
> -	priv->eeprom_client = i2c_new_dummy_device(client->adapter, HP03_EEPROM_ADDR);
> +	priv->eeprom_client = devm_i2c_new_dummy_device(dev, client->adapter,
> +							HP03_EEPROM_ADDR);
>  	if (IS_ERR(priv->eeprom_client)) {
>  		dev_err(dev, "New EEPROM I2C device failed\n");
>  		return PTR_ERR(priv->eeprom_client);
>  	}
>  
> -	priv->eeprom_regmap = regmap_init_i2c(priv->eeprom_client,
> -					      &hp03_regmap_config);
> +	priv->eeprom_regmap = devm_regmap_init_i2c(priv->eeprom_client,
> +						   &hp03_regmap_config);
>  	if (IS_ERR(priv->eeprom_regmap)) {
>  		dev_err(dev, "Failed to allocate EEPROM regmap\n");
> -		ret = PTR_ERR(priv->eeprom_regmap);
> -		goto err_cleanup_eeprom_client;
> +		return PTR_ERR(priv->eeprom_regmap);
>  	}
>  
> -	ret = iio_device_register(indio_dev);
> +	ret = devm_iio_device_register(dev, indio_dev);
>  	if (ret) {
>  		dev_err(dev, "Failed to register IIO device\n");
> -		goto err_cleanup_eeprom_regmap;
> +		return ret;
>  	}
>  
> -	i2c_set_clientdata(client, indio_dev);
> -
> -	return 0;
> -
> -err_cleanup_eeprom_regmap:
> -	regmap_exit(priv->eeprom_regmap);
> -
> -err_cleanup_eeprom_client:
> -	i2c_unregister_device(priv->eeprom_client);
> -	return ret;
> -}
> -
> -static int hp03_remove(struct i2c_client *client)
> -{
> -	struct iio_dev *indio_dev = i2c_get_clientdata(client);
> -	struct hp03_priv *priv = iio_priv(indio_dev);
> -
> -	iio_device_unregister(indio_dev);
> -	regmap_exit(priv->eeprom_regmap);
> -	i2c_unregister_device(priv->eeprom_client);
> -
>  	return 0;
>  }
>  
> @@ -304,7 +283,6 @@ static struct i2c_driver hp03_driver = {
>  		.of_match_table = hp03_of_match,
>  	},
>  	.probe		= hp03_probe,
> -	.remove		= hp03_remove,
>  	.id_table	= hp03_id,
>  };
>  module_i2c_driver(hp03_driver);


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

end of thread, other threads:[~2021-08-15 15:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-09 20:30 [PATCH v2] iio: pressure: hp03: update device probe to register with devm functions Théo Borém Fabris
2021-08-15 15:53 ` Jonathan Cameron

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.