All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/15] iio: let spi drivers return 0 in .remove()
@ 2021-10-13 20:32 Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 01/15] iio: accel: bma400: Make bma400_remove() return void Uwe Kleine-König
                   ` (15 more replies)
  0 siblings, 16 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Dan Robertson, Jonathan Cameron, Lars-Peter Clausen, Michael Hennerich
  Cc: Mark Brown, Wolfram Sang, kernel, linux-i2c, linux-iio, linux-spi

Hello,

this series is part of my quest to change the return type of the spi
driver .remove() callback to void. In this first stage I fix all drivers
to return 0 to be able to mechanically change all drivers in the final
step.

Returning an error code (which actually very few drivers do) doesn't
make much sense, because the only effect is that the spi core emits an
error message.

The same holds try for i2c drivers, some of them are fixed en passant.

There are no interdependencies in this series, and there is some more
work to do for the final conversion, so apply the patches from this
series at will :-)

Best regards
Uwe

Uwe Kleine-König (15):
  iio: accel: bma400: Make bma400_remove() return void
  iio: accel: bmc150: Make bmc150_accel_core_remove() return void
  iio: accel: bmi088: Make bmi088_accel_core_remove() return void
  iio: accel: kxsd9: Make kxsd9_common_remove() return void
  iio: accel: mma7455: Make mma7455_core_remove() return void
  iio: accel: ad5064: Make ad5064_core_remove() return void
  iio: dac: ad5380: Make ad5380_remove() return void
  iio: dac: ad5446: Make ad5446_remove() return void
  iio: dac: ad5592r: Make ad5592r_remove() return void
  iio: dac: ad5686: Make ad5686_remove() return void
  iio: health: afe4403: Don't return an error in .remove()
  iio: imu: st_lsm9ds0: Make st_lsm9ds0_remove() return void
  iio: magn: hmc5843: Make hmc5843_common_remove() return void
  iio: potentiometer: max5487: Don't return an error in .remove()
  iio: pressure: ms5611: Make ms5611_remove() return void

 drivers/iio/accel/bma400.h                   |  2 +-
 drivers/iio/accel/bma400_core.c              |  7 ++++---
 drivers/iio/accel/bma400_i2c.c               |  4 +++-
 drivers/iio/accel/bma400_spi.c               |  4 +++-
 drivers/iio/accel/bmc150-accel-core.c        |  4 +---
 drivers/iio/accel/bmc150-accel-i2c.c         |  4 +++-
 drivers/iio/accel/bmc150-accel-spi.c         |  4 +++-
 drivers/iio/accel/bmc150-accel.h             |  2 +-
 drivers/iio/accel/bmi088-accel-core.c        |  4 +---
 drivers/iio/accel/bmi088-accel-spi.c         |  4 +++-
 drivers/iio/accel/bmi088-accel.h             |  2 +-
 drivers/iio/accel/kxsd9-i2c.c                |  4 +++-
 drivers/iio/accel/kxsd9-spi.c                |  4 +++-
 drivers/iio/accel/kxsd9.c                    |  4 +---
 drivers/iio/accel/kxsd9.h                    |  2 +-
 drivers/iio/accel/mma7455.h                  |  2 +-
 drivers/iio/accel/mma7455_core.c             |  4 +---
 drivers/iio/accel/mma7455_i2c.c              |  4 +++-
 drivers/iio/accel/mma7455_spi.c              |  4 +++-
 drivers/iio/dac/ad5064.c                     | 12 +++++++-----
 drivers/iio/dac/ad5380.c                     | 15 ++++++++-------
 drivers/iio/dac/ad5446.c                     | 12 +++++++-----
 drivers/iio/dac/ad5592r-base.c               |  4 +---
 drivers/iio/dac/ad5592r-base.h               |  2 +-
 drivers/iio/dac/ad5592r.c                    |  4 +++-
 drivers/iio/dac/ad5593r.c                    |  4 +++-
 drivers/iio/dac/ad5686-spi.c                 |  4 +++-
 drivers/iio/dac/ad5686.c                     |  4 +---
 drivers/iio/dac/ad5686.h                     |  2 +-
 drivers/iio/dac/ad5696-i2c.c                 |  4 +++-
 drivers/iio/health/afe4403.c                 |  6 ++----
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h      |  2 +-
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c |  4 +---
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c  |  4 +++-
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c  |  4 +++-
 drivers/iio/magnetometer/hmc5843.h           |  2 +-
 drivers/iio/magnetometer/hmc5843_core.c      |  4 +---
 drivers/iio/magnetometer/hmc5843_i2c.c       |  4 +++-
 drivers/iio/magnetometer/hmc5843_spi.c       |  4 +++-
 drivers/iio/potentiometer/max5487.c          |  7 ++++++-
 drivers/iio/pressure/ms5611.h                |  2 +-
 drivers/iio/pressure/ms5611_core.c           |  4 +---
 drivers/iio/pressure/ms5611_i2c.c            |  4 +++-
 drivers/iio/pressure/ms5611_spi.c            |  4 +++-
 44 files changed, 110 insertions(+), 81 deletions(-)


base-commit: 9e1ff307c779ce1f0f810c7ecce3d95bbae40896
-- 
2.30.2


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

* [PATCH 01/15] iio: accel: bma400: Make bma400_remove() return void
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 02/15] iio: accel: bmc150: Make bmc150_accel_core_remove() " Uwe Kleine-König
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Dan Robertson, Jonathan Cameron
  Cc: Lars-Peter Clausen, Mark Brown, Wolfram Sang, kernel, linux-i2c,
	linux-iio, linux-spi

When an i2c or spi driver's remove function returns a non-zero error
code nothing happens apart from emitting a generic error message. Make
this error message more device specific and return zero instead in the
remove callbacks. As the return value of bma400_remove() is unused then,
change the function to not yield a return value.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/accel/bma400.h      | 2 +-
 drivers/iio/accel/bma400_core.c | 7 ++++---
 drivers/iio/accel/bma400_i2c.c  | 4 +++-
 drivers/iio/accel/bma400_spi.c  | 4 +++-
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/accel/bma400.h b/drivers/iio/accel/bma400.h
index 5ad10db9819f..c4c8d74155c2 100644
--- a/drivers/iio/accel/bma400.h
+++ b/drivers/iio/accel/bma400.h
@@ -94,6 +94,6 @@ extern const struct regmap_config bma400_regmap_config;
 
 int bma400_probe(struct device *dev, struct regmap *regmap, const char *name);
 
-int bma400_remove(struct device *dev);
+void bma400_remove(struct device *dev);
 
 #endif
diff --git a/drivers/iio/accel/bma400_core.c b/drivers/iio/accel/bma400_core.c
index 21520e022a21..fd2647b728d3 100644
--- a/drivers/iio/accel/bma400_core.c
+++ b/drivers/iio/accel/bma400_core.c
@@ -828,7 +828,7 @@ int bma400_probe(struct device *dev, struct regmap *regmap, const char *name)
 }
 EXPORT_SYMBOL(bma400_probe);
 
-int bma400_remove(struct device *dev)
+void bma400_remove(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct bma400_data *data = iio_priv(indio_dev);
@@ -838,12 +838,13 @@ int bma400_remove(struct device *dev)
 	ret = bma400_set_power_mode(data, POWER_MODE_SLEEP);
 	mutex_unlock(&data->mutex);
 
+	if (ret)
+		dev_warn(dev, "Failed to put device into sleep mode (%pe)\n", ERR_PTR(ret));
+
 	regulator_bulk_disable(ARRAY_SIZE(data->regulators),
 			       data->regulators);
 
 	iio_device_unregister(indio_dev);
-
-	return ret;
 }
 EXPORT_SYMBOL(bma400_remove);
 
diff --git a/drivers/iio/accel/bma400_i2c.c b/drivers/iio/accel/bma400_i2c.c
index 9dcb7cc9996e..f50df5310beb 100644
--- a/drivers/iio/accel/bma400_i2c.c
+++ b/drivers/iio/accel/bma400_i2c.c
@@ -29,7 +29,9 @@ static int bma400_i2c_probe(struct i2c_client *client,
 
 static int bma400_i2c_remove(struct i2c_client *client)
 {
-	return bma400_remove(&client->dev);
+	bma400_remove(&client->dev);
+
+	return 0;
 }
 
 static const struct i2c_device_id bma400_i2c_ids[] = {
diff --git a/drivers/iio/accel/bma400_spi.c b/drivers/iio/accel/bma400_spi.c
index 7c2825904e08..9f622e37477b 100644
--- a/drivers/iio/accel/bma400_spi.c
+++ b/drivers/iio/accel/bma400_spi.c
@@ -89,7 +89,9 @@ static int bma400_spi_probe(struct spi_device *spi)
 
 static int bma400_spi_remove(struct spi_device *spi)
 {
-	return bma400_remove(&spi->dev);
+	bma400_remove(&spi->dev);
+
+	return 0;
 }
 
 static const struct spi_device_id bma400_spi_ids[] = {
-- 
2.30.2


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

* [PATCH 02/15] iio: accel: bmc150: Make bmc150_accel_core_remove() return void
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 01/15] iio: accel: bma400: Make bma400_remove() return void Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 03/15] iio: accel: bmi088: Make bmi088_accel_core_remove() " Uwe Kleine-König
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Mark Brown, Wolfram Sang, kernel, linux-i2c,
	linux-iio, linux-spi

Up to now bmc150_accel_core_remove() returns zero unconditionally. Make
it return void instead which makes it easier to see in the callers that
there is no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/accel/bmc150-accel-core.c | 4 +---
 drivers/iio/accel/bmc150-accel-i2c.c  | 4 +++-
 drivers/iio/accel/bmc150-accel-spi.c  | 4 +++-
 drivers/iio/accel/bmc150-accel.h      | 2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index e8693a42ad46..590016830a6f 100644
--- a/drivers/iio/accel/bmc150-accel-core.c
+++ b/drivers/iio/accel/bmc150-accel-core.c
@@ -1799,7 +1799,7 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
 }
 EXPORT_SYMBOL_GPL(bmc150_accel_core_probe);
 
-int bmc150_accel_core_remove(struct device *dev)
+void bmc150_accel_core_remove(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct bmc150_accel_data *data = iio_priv(indio_dev);
@@ -1819,8 +1819,6 @@ int bmc150_accel_core_remove(struct device *dev)
 
 	regulator_bulk_disable(ARRAY_SIZE(data->regulators),
 			       data->regulators);
-
-	return 0;
 }
 EXPORT_SYMBOL_GPL(bmc150_accel_core_remove);
 
diff --git a/drivers/iio/accel/bmc150-accel-i2c.c b/drivers/iio/accel/bmc150-accel-i2c.c
index 88bd8a25f142..9e52df9a8f07 100644
--- a/drivers/iio/accel/bmc150-accel-i2c.c
+++ b/drivers/iio/accel/bmc150-accel-i2c.c
@@ -213,7 +213,9 @@ static int bmc150_accel_remove(struct i2c_client *client)
 {
 	bmc150_acpi_dual_accel_remove(client);
 
-	return bmc150_accel_core_remove(&client->dev);
+	bmc150_accel_core_remove(&client->dev);
+
+	return 0;
 }
 
 static const struct acpi_device_id bmc150_accel_acpi_match[] = {
diff --git a/drivers/iio/accel/bmc150-accel-spi.c b/drivers/iio/accel/bmc150-accel-spi.c
index 191e312dc91a..11559567cb39 100644
--- a/drivers/iio/accel/bmc150-accel-spi.c
+++ b/drivers/iio/accel/bmc150-accel-spi.c
@@ -37,7 +37,9 @@ static int bmc150_accel_probe(struct spi_device *spi)
 
 static int bmc150_accel_remove(struct spi_device *spi)
 {
-	return bmc150_accel_core_remove(&spi->dev);
+	bmc150_accel_core_remove(&spi->dev);
+
+	return 0;
 }
 
 static const struct acpi_device_id bmc150_accel_acpi_match[] = {
diff --git a/drivers/iio/accel/bmc150-accel.h b/drivers/iio/accel/bmc150-accel.h
index 1bb5023e8ed9..7775c5edaeef 100644
--- a/drivers/iio/accel/bmc150-accel.h
+++ b/drivers/iio/accel/bmc150-accel.h
@@ -88,7 +88,7 @@ struct bmc150_accel_data {
 int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
 			    enum bmc150_type type, const char *name,
 			    bool block_supported);
-int bmc150_accel_core_remove(struct device *dev);
+void bmc150_accel_core_remove(struct device *dev);
 extern const struct dev_pm_ops bmc150_accel_pm_ops;
 extern const struct regmap_config bmc150_regmap_conf;
 
-- 
2.30.2


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

* [PATCH 03/15] iio: accel: bmi088: Make bmi088_accel_core_remove() return void
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 01/15] iio: accel: bma400: Make bma400_remove() return void Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 02/15] iio: accel: bmc150: Make bmc150_accel_core_remove() " Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 04/15] iio: accel: kxsd9: Make kxsd9_common_remove() " Uwe Kleine-König
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Mark Brown, kernel, linux-iio, linux-spi

Up to now bmi088_accel_core_remove() returns zero unconditionally. Make
it return void instead which makes it easier to see in the callers that
there is no error to handle.

Also the return value of spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/accel/bmi088-accel-core.c | 4 +---
 drivers/iio/accel/bmi088-accel-spi.c  | 4 +++-
 drivers/iio/accel/bmi088-accel.h      | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/accel/bmi088-accel-core.c b/drivers/iio/accel/bmi088-accel-core.c
index a06dae5c971d..d74465214feb 100644
--- a/drivers/iio/accel/bmi088-accel-core.c
+++ b/drivers/iio/accel/bmi088-accel-core.c
@@ -536,7 +536,7 @@ int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap,
 EXPORT_SYMBOL_GPL(bmi088_accel_core_probe);
 
 
-int bmi088_accel_core_remove(struct device *dev)
+void bmi088_accel_core_remove(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct bmi088_accel_data *data = iio_priv(indio_dev);
@@ -546,8 +546,6 @@ int bmi088_accel_core_remove(struct device *dev)
 	pm_runtime_disable(dev);
 	pm_runtime_set_suspended(dev);
 	bmi088_accel_power_down(data);
-
-	return 0;
 }
 EXPORT_SYMBOL_GPL(bmi088_accel_core_remove);
 
diff --git a/drivers/iio/accel/bmi088-accel-spi.c b/drivers/iio/accel/bmi088-accel-spi.c
index dd1e3f6cf211..758ad2f12896 100644
--- a/drivers/iio/accel/bmi088-accel-spi.c
+++ b/drivers/iio/accel/bmi088-accel-spi.c
@@ -58,7 +58,9 @@ static int bmi088_accel_probe(struct spi_device *spi)
 
 static int bmi088_accel_remove(struct spi_device *spi)
 {
-	return bmi088_accel_core_remove(&spi->dev);
+	bmi088_accel_core_remove(&spi->dev);
+
+	return 0;
 }
 
 static const struct spi_device_id bmi088_accel_id[] = {
diff --git a/drivers/iio/accel/bmi088-accel.h b/drivers/iio/accel/bmi088-accel.h
index 5c25f16b672c..5d40c7cf1cbc 100644
--- a/drivers/iio/accel/bmi088-accel.h
+++ b/drivers/iio/accel/bmi088-accel.h
@@ -13,6 +13,6 @@ extern const struct dev_pm_ops bmi088_accel_pm_ops;
 
 int bmi088_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
 			    const char *name, bool block_supported);
-int bmi088_accel_core_remove(struct device *dev);
+void bmi088_accel_core_remove(struct device *dev);
 
 #endif /* BMI088_ACCEL_H */
-- 
2.30.2


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

* [PATCH 04/15] iio: accel: kxsd9: Make kxsd9_common_remove() return void
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2021-10-13 20:32 ` [PATCH 03/15] iio: accel: bmi088: Make bmi088_accel_core_remove() " Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 05/15] iio: accel: mma7455: Make mma7455_core_remove() " Uwe Kleine-König
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Mark Brown, Wolfram Sang, kernel, linux-i2c,
	linux-iio, linux-spi

Up to now kxsd9_common_remove() returns zero unconditionally. Make it
return void instead which makes it easier to see in the callers that
there is no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/accel/kxsd9-i2c.c | 4 +++-
 drivers/iio/accel/kxsd9-spi.c | 4 +++-
 drivers/iio/accel/kxsd9.c     | 4 +---
 drivers/iio/accel/kxsd9.h     | 2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/accel/kxsd9-i2c.c b/drivers/iio/accel/kxsd9-i2c.c
index b580d605f848..274b41a6e603 100644
--- a/drivers/iio/accel/kxsd9-i2c.c
+++ b/drivers/iio/accel/kxsd9-i2c.c
@@ -34,7 +34,9 @@ static int kxsd9_i2c_probe(struct i2c_client *i2c,
 
 static int kxsd9_i2c_remove(struct i2c_client *client)
 {
-	return kxsd9_common_remove(&client->dev);
+	kxsd9_common_remove(&client->dev);
+
+	return 0;
 }
 
 static const struct of_device_id kxsd9_of_match[] = {
diff --git a/drivers/iio/accel/kxsd9-spi.c b/drivers/iio/accel/kxsd9-spi.c
index 7971ec1eeb7e..441e6b764281 100644
--- a/drivers/iio/accel/kxsd9-spi.c
+++ b/drivers/iio/accel/kxsd9-spi.c
@@ -34,7 +34,9 @@ static int kxsd9_spi_probe(struct spi_device *spi)
 
 static int kxsd9_spi_remove(struct spi_device *spi)
 {
-	return kxsd9_common_remove(&spi->dev);
+	kxsd9_common_remove(&spi->dev);
+
+	return 0;
 }
 
 static const struct spi_device_id kxsd9_spi_id[] = {
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
index bf7ed9e7d00f..2faf85ca996e 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -478,7 +478,7 @@ int kxsd9_common_probe(struct device *dev,
 }
 EXPORT_SYMBOL(kxsd9_common_probe);
 
-int kxsd9_common_remove(struct device *dev)
+void kxsd9_common_remove(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct kxsd9_state *st = iio_priv(indio_dev);
@@ -489,8 +489,6 @@ int kxsd9_common_remove(struct device *dev)
 	pm_runtime_put_noidle(dev);
 	pm_runtime_disable(dev);
 	kxsd9_power_down(st);
-
-	return 0;
 }
 EXPORT_SYMBOL(kxsd9_common_remove);
 
diff --git a/drivers/iio/accel/kxsd9.h b/drivers/iio/accel/kxsd9.h
index 5e3ca212f5be..c04dbfa4e0d0 100644
--- a/drivers/iio/accel/kxsd9.h
+++ b/drivers/iio/accel/kxsd9.h
@@ -8,6 +8,6 @@
 int kxsd9_common_probe(struct device *dev,
 		       struct regmap *map,
 		       const char *name);
-int kxsd9_common_remove(struct device *dev);
+void kxsd9_common_remove(struct device *dev);
 
 extern const struct dev_pm_ops kxsd9_dev_pm_ops;
-- 
2.30.2


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

* [PATCH 05/15] iio: accel: mma7455: Make mma7455_core_remove() return void
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
                   ` (3 preceding siblings ...)
  2021-10-13 20:32 ` [PATCH 04/15] iio: accel: kxsd9: Make kxsd9_common_remove() " Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 06/15] iio: accel: ad5064: Make ad5064_core_remove() " Uwe Kleine-König
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Mark Brown, Wolfram Sang, kernel, linux-i2c,
	linux-iio, linux-spi

Up to now mma7455_core_remove() returns zero unconditionally. Make it
return void instead which makes it easier to see in the callers that
there is no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/accel/mma7455.h      | 2 +-
 drivers/iio/accel/mma7455_core.c | 4 +---
 drivers/iio/accel/mma7455_i2c.c  | 4 +++-
 drivers/iio/accel/mma7455_spi.c  | 4 +++-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/accel/mma7455.h b/drivers/iio/accel/mma7455.h
index 4e3fa988f690..1fcc4b64b3af 100644
--- a/drivers/iio/accel/mma7455.h
+++ b/drivers/iio/accel/mma7455.h
@@ -11,6 +11,6 @@ extern const struct regmap_config mma7455_core_regmap;
 
 int mma7455_core_probe(struct device *dev, struct regmap *regmap,
 		       const char *name);
-int mma7455_core_remove(struct device *dev);
+void mma7455_core_remove(struct device *dev);
 
 #endif
diff --git a/drivers/iio/accel/mma7455_core.c b/drivers/iio/accel/mma7455_core.c
index 922bd38ff6ea..777c6c384b09 100644
--- a/drivers/iio/accel/mma7455_core.c
+++ b/drivers/iio/accel/mma7455_core.c
@@ -294,7 +294,7 @@ int mma7455_core_probe(struct device *dev, struct regmap *regmap,
 }
 EXPORT_SYMBOL_GPL(mma7455_core_probe);
 
-int mma7455_core_remove(struct device *dev)
+void mma7455_core_remove(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct mma7455_data *mma7455 = iio_priv(indio_dev);
@@ -304,8 +304,6 @@ int mma7455_core_remove(struct device *dev)
 
 	regmap_write(mma7455->regmap, MMA7455_REG_MCTL,
 		     MMA7455_MCTL_MODE_STANDBY);
-
-	return 0;
 }
 EXPORT_SYMBOL_GPL(mma7455_core_remove);
 
diff --git a/drivers/iio/accel/mma7455_i2c.c b/drivers/iio/accel/mma7455_i2c.c
index cddeaa9e230a..8a5256516f9f 100644
--- a/drivers/iio/accel/mma7455_i2c.c
+++ b/drivers/iio/accel/mma7455_i2c.c
@@ -28,7 +28,9 @@ static int mma7455_i2c_probe(struct i2c_client *i2c,
 
 static int mma7455_i2c_remove(struct i2c_client *i2c)
 {
-	return mma7455_core_remove(&i2c->dev);
+	mma7455_core_remove(&i2c->dev);
+
+	return 0;
 }
 
 static const struct i2c_device_id mma7455_i2c_ids[] = {
diff --git a/drivers/iio/accel/mma7455_spi.c b/drivers/iio/accel/mma7455_spi.c
index eb82cdfa8abc..ecf690692dcc 100644
--- a/drivers/iio/accel/mma7455_spi.c
+++ b/drivers/iio/accel/mma7455_spi.c
@@ -24,7 +24,9 @@ static int mma7455_spi_probe(struct spi_device *spi)
 
 static int mma7455_spi_remove(struct spi_device *spi)
 {
-	return mma7455_core_remove(&spi->dev);
+	mma7455_core_remove(&spi->dev);
+
+	return 0;
 }
 
 static const struct spi_device_id mma7455_spi_ids[] = {
-- 
2.30.2


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

* [PATCH 06/15] iio: accel: ad5064: Make ad5064_core_remove() return void
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
                   ` (4 preceding siblings ...)
  2021-10-13 20:32 ` [PATCH 05/15] iio: accel: mma7455: Make mma7455_core_remove() " Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-14 17:29   ` Jonathan Cameron
  2021-10-13 20:32 ` [PATCH 07/15] iio: dac: ad5380: Make ad5380_remove() " Uwe Kleine-König
                   ` (9 subsequent siblings)
  15 siblings, 1 reply; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Michael Hennerich
  Cc: Mark Brown, Wolfram Sang, kernel, linux-i2c, linux-iio, linux-spi

Up to now ad5064_core_remove() returns zero unconditionally. Make it
return void instead which makes it easier to see in the callers that
there is no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/dac/ad5064.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c
index dff623b65e4f..6f66796942c0 100644
--- a/drivers/iio/dac/ad5064.c
+++ b/drivers/iio/dac/ad5064.c
@@ -900,7 +900,7 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
 	return ret;
 }
 
-static int ad5064_remove(struct device *dev)
+static void ad5064_remove(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct ad5064_state *st = iio_priv(indio_dev);
@@ -909,8 +909,6 @@ static int ad5064_remove(struct device *dev)
 
 	if (!st->use_internal_vref)
 		regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg);
-
-	return 0;
 }
 
 #if IS_ENABLED(CONFIG_SPI_MASTER)
@@ -934,7 +932,9 @@ static int ad5064_spi_probe(struct spi_device *spi)
 
 static int ad5064_spi_remove(struct spi_device *spi)
 {
-	return ad5064_remove(&spi->dev);
+	ad5064_remove(&spi->dev);
+
+	return 0;
 }
 
 static const struct spi_device_id ad5064_spi_ids[] = {
@@ -1021,7 +1021,9 @@ static int ad5064_i2c_probe(struct i2c_client *i2c,
 
 static int ad5064_i2c_remove(struct i2c_client *i2c)
 {
-	return ad5064_remove(&i2c->dev);
+	ad5064_remove(&i2c->dev);
+
+	return 0;
 }
 
 static const struct i2c_device_id ad5064_i2c_ids[] = {
-- 
2.30.2


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

* [PATCH 07/15] iio: dac: ad5380: Make ad5380_remove() return void
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
                   ` (5 preceding siblings ...)
  2021-10-13 20:32 ` [PATCH 06/15] iio: accel: ad5064: Make ad5064_core_remove() " Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 08/15] iio: dac: ad5446: Make ad5446_remove() " Uwe Kleine-König
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Michael Hennerich
  Cc: Mark Brown, Wolfram Sang, kernel, linux-i2c, linux-iio, linux-spi

Up to now ad5380_remove() returns zero unconditionally. Make it return
void instead which makes it easier to see in the callers that there is
no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/dac/ad5380.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c
index 53db5b4e4c53..8ca26bb4b62f 100644
--- a/drivers/iio/dac/ad5380.c
+++ b/drivers/iio/dac/ad5380.c
@@ -444,7 +444,7 @@ static int ad5380_probe(struct device *dev, struct regmap *regmap,
 	return ret;
 }
 
-static int ad5380_remove(struct device *dev)
+static void ad5380_remove(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct ad5380_state *st = iio_priv(indio_dev);
@@ -453,11 +453,8 @@ static int ad5380_remove(struct device *dev)
 
 	kfree(indio_dev->channels);
 
-	if (!IS_ERR(st->vref_reg)) {
+	if (!IS_ERR(st->vref_reg))
 		regulator_disable(st->vref_reg);
-	}
-
-	return 0;
 }
 
 static bool ad5380_reg_false(struct device *dev, unsigned int reg)
@@ -493,7 +490,9 @@ static int ad5380_spi_probe(struct spi_device *spi)
 
 static int ad5380_spi_remove(struct spi_device *spi)
 {
-	return ad5380_remove(&spi->dev);
+	ad5380_remove(&spi->dev);
+
+	return 0;
 }
 
 static const struct spi_device_id ad5380_spi_ids[] = {
@@ -566,7 +565,9 @@ static int ad5380_i2c_probe(struct i2c_client *i2c,
 
 static int ad5380_i2c_remove(struct i2c_client *i2c)
 {
-	return ad5380_remove(&i2c->dev);
+	ad5380_remove(&i2c->dev);
+
+	return 0;
 }
 
 static const struct i2c_device_id ad5380_i2c_ids[] = {
-- 
2.30.2


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

* [PATCH 08/15] iio: dac: ad5446: Make ad5446_remove() return void
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
                   ` (6 preceding siblings ...)
  2021-10-13 20:32 ` [PATCH 07/15] iio: dac: ad5380: Make ad5380_remove() " Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 09/15] iio: dac: ad5592r: Make ad5592r_remove() " Uwe Kleine-König
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Michael Hennerich
  Cc: Mark Brown, Wolfram Sang, kernel, linux-i2c, linux-iio, linux-spi

Up to now ad5446_remove() returns zero unconditionally. Make it return
void instead which makes it easier to see in the callers that there is
no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/dac/ad5446.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c
index 488ec69967d6..0ef761521e87 100644
--- a/drivers/iio/dac/ad5446.c
+++ b/drivers/iio/dac/ad5446.c
@@ -283,7 +283,7 @@ static int ad5446_probe(struct device *dev, const char *name,
 	return ret;
 }
 
-static int ad5446_remove(struct device *dev)
+static void ad5446_remove(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct ad5446_state *st = iio_priv(indio_dev);
@@ -291,8 +291,6 @@ static int ad5446_remove(struct device *dev)
 	iio_device_unregister(indio_dev);
 	if (!IS_ERR(st->reg))
 		regulator_disable(st->reg);
-
-	return 0;
 }
 
 #if IS_ENABLED(CONFIG_SPI_MASTER)
@@ -495,7 +493,9 @@ static int ad5446_spi_probe(struct spi_device *spi)
 
 static int ad5446_spi_remove(struct spi_device *spi)
 {
-	return ad5446_remove(&spi->dev);
+	ad5446_remove(&spi->dev);
+
+	return 0;
 }
 
 static struct spi_driver ad5446_spi_driver = {
@@ -572,7 +572,9 @@ static int ad5446_i2c_probe(struct i2c_client *i2c,
 
 static int ad5446_i2c_remove(struct i2c_client *i2c)
 {
-	return ad5446_remove(&i2c->dev);
+	ad5446_remove(&i2c->dev);
+
+	return 0;
 }
 
 static const struct i2c_device_id ad5446_i2c_ids[] = {
-- 
2.30.2


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

* [PATCH 09/15] iio: dac: ad5592r: Make ad5592r_remove() return void
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
                   ` (7 preceding siblings ...)
  2021-10-13 20:32 ` [PATCH 08/15] iio: dac: ad5446: Make ad5446_remove() " Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 10/15] iio: dac: ad5686: Make ad5686_remove() " Uwe Kleine-König
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Michael Hennerich
  Cc: Mark Brown, Wolfram Sang, kernel, linux-i2c, linux-iio, linux-spi

Up to now ad5592r_remove() returns zero unconditionally. Make it return
void instead which makes it easier to see in the callers that there is
no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/dac/ad5592r-base.c | 4 +---
 drivers/iio/dac/ad5592r-base.h | 2 +-
 drivers/iio/dac/ad5592r.c      | 4 +++-
 drivers/iio/dac/ad5593r.c      | 4 +++-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c
index 0405e92b9e8c..2fcc59728fd6 100644
--- a/drivers/iio/dac/ad5592r-base.c
+++ b/drivers/iio/dac/ad5592r-base.c
@@ -663,7 +663,7 @@ int ad5592r_probe(struct device *dev, const char *name,
 }
 EXPORT_SYMBOL_GPL(ad5592r_probe);
 
-int ad5592r_remove(struct device *dev)
+void ad5592r_remove(struct device *dev)
 {
 	struct iio_dev *iio_dev = dev_get_drvdata(dev);
 	struct ad5592r_state *st = iio_priv(iio_dev);
@@ -674,8 +674,6 @@ int ad5592r_remove(struct device *dev)
 
 	if (st->reg)
 		regulator_disable(st->reg);
-
-	return 0;
 }
 EXPORT_SYMBOL_GPL(ad5592r_remove);
 
diff --git a/drivers/iio/dac/ad5592r-base.h b/drivers/iio/dac/ad5592r-base.h
index 23dac2f1ff8a..2a22ef691996 100644
--- a/drivers/iio/dac/ad5592r-base.h
+++ b/drivers/iio/dac/ad5592r-base.h
@@ -71,6 +71,6 @@ struct ad5592r_state {
 
 int ad5592r_probe(struct device *dev, const char *name,
 		const struct ad5592r_rw_ops *ops);
-int ad5592r_remove(struct device *dev);
+void ad5592r_remove(struct device *dev);
 
 #endif /* __DRIVERS_IIO_DAC_AD5592R_BASE_H__ */
diff --git a/drivers/iio/dac/ad5592r.c b/drivers/iio/dac/ad5592r.c
index 41f651500668..6bfd7951e18c 100644
--- a/drivers/iio/dac/ad5592r.c
+++ b/drivers/iio/dac/ad5592r.c
@@ -132,7 +132,9 @@ static int ad5592r_spi_probe(struct spi_device *spi)
 
 static int ad5592r_spi_remove(struct spi_device *spi)
 {
-	return ad5592r_remove(&spi->dev);
+	ad5592r_remove(&spi->dev);
+
+	return 0;
 }
 
 static const struct spi_device_id ad5592r_spi_ids[] = {
diff --git a/drivers/iio/dac/ad5593r.c b/drivers/iio/dac/ad5593r.c
index 5b4df36fdc2a..64dd7a0bddf7 100644
--- a/drivers/iio/dac/ad5593r.c
+++ b/drivers/iio/dac/ad5593r.c
@@ -99,7 +99,9 @@ static int ad5593r_i2c_probe(struct i2c_client *i2c,
 
 static int ad5593r_i2c_remove(struct i2c_client *i2c)
 {
-	return ad5592r_remove(&i2c->dev);
+	ad5592r_remove(&i2c->dev);
+
+	return 0;
 }
 
 static const struct i2c_device_id ad5593r_i2c_ids[] = {
-- 
2.30.2


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

* [PATCH 10/15] iio: dac: ad5686: Make ad5686_remove() return void
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
                   ` (8 preceding siblings ...)
  2021-10-13 20:32 ` [PATCH 09/15] iio: dac: ad5592r: Make ad5592r_remove() " Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 11/15] iio: health: afe4403: Don't return an error in .remove() Uwe Kleine-König
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, Michael Hennerich
  Cc: Mark Brown, Wolfram Sang, kernel, linux-i2c, linux-iio, linux-spi

Up to now ad5686_remove() returns zero unconditionally. Make it return
void instead which makes it easier to see in the callers that there is
no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/dac/ad5686-spi.c | 4 +++-
 drivers/iio/dac/ad5686.c     | 4 +---
 drivers/iio/dac/ad5686.h     | 2 +-
 drivers/iio/dac/ad5696-i2c.c | 4 +++-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c
index 0188ded5137c..2628810fdbb1 100644
--- a/drivers/iio/dac/ad5686-spi.c
+++ b/drivers/iio/dac/ad5686-spi.c
@@ -97,7 +97,9 @@ static int ad5686_spi_probe(struct spi_device *spi)
 
 static int ad5686_spi_remove(struct spi_device *spi)
 {
-	return ad5686_remove(&spi->dev);
+	ad5686_remove(&spi->dev);
+
+	return 0;
 }
 
 static const struct spi_device_id ad5686_spi_id[] = {
diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
index fcb64f20ff64..8f001db775f4 100644
--- a/drivers/iio/dac/ad5686.c
+++ b/drivers/iio/dac/ad5686.c
@@ -538,7 +538,7 @@ int ad5686_probe(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(ad5686_probe);
 
-int ad5686_remove(struct device *dev)
+void ad5686_remove(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct ad5686_state *st = iio_priv(indio_dev);
@@ -546,8 +546,6 @@ int ad5686_remove(struct device *dev)
 	iio_device_unregister(indio_dev);
 	if (!IS_ERR(st->reg))
 		regulator_disable(st->reg);
-
-	return 0;
 }
 EXPORT_SYMBOL_GPL(ad5686_remove);
 
diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h
index f89a6f92b427..cd5fff9e9d53 100644
--- a/drivers/iio/dac/ad5686.h
+++ b/drivers/iio/dac/ad5686.h
@@ -154,7 +154,7 @@ int ad5686_probe(struct device *dev,
 		 const char *name, ad5686_write_func write,
 		 ad5686_read_func read);
 
-int ad5686_remove(struct device *dev);
+void ad5686_remove(struct device *dev);
 
 
 #endif /* __DRIVERS_IIO_DAC_AD5686_H__ */
diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c
index 24a6a4a5a2e0..93f0e0e66c22 100644
--- a/drivers/iio/dac/ad5696-i2c.c
+++ b/drivers/iio/dac/ad5696-i2c.c
@@ -67,7 +67,9 @@ static int ad5686_i2c_probe(struct i2c_client *i2c,
 
 static int ad5686_i2c_remove(struct i2c_client *i2c)
 {
-	return ad5686_remove(&i2c->dev);
+	ad5686_remove(&i2c->dev);
+
+	return 0;
 }
 
 static const struct i2c_device_id ad5686_i2c_id[] = {
-- 
2.30.2


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

* [PATCH 11/15] iio: health: afe4403: Don't return an error in .remove()
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
                   ` (9 preceding siblings ...)
  2021-10-13 20:32 ` [PATCH 10/15] iio: dac: ad5686: Make ad5686_remove() " Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 12/15] iio: imu: st_lsm9ds0: Make st_lsm9ds0_remove() return void Uwe Kleine-König
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Mark Brown, kernel, linux-iio, linux-spi

The only effect of returning an error in an spi .remove() callback is
that the spi core issues another warning message. Don't report the same
problem twice and return 0 unconditionally instead. Also degrade the log
level to warning, as nothing really bad is expected from a failure to
put the device in suspend mode.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/health/afe4403.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/health/afe4403.c b/drivers/iio/health/afe4403.c
index d4921385aaf7..0c355063072c 100644
--- a/drivers/iio/health/afe4403.c
+++ b/drivers/iio/health/afe4403.c
@@ -589,10 +589,8 @@ static int afe4403_remove(struct spi_device *spi)
 		iio_trigger_unregister(afe->trig);
 
 	ret = regulator_disable(afe->regulator);
-	if (ret) {
-		dev_err(afe->dev, "Unable to disable regulator\n");
-		return ret;
-	}
+	if (ret)
+		dev_warn(afe->dev, "Unable to disable regulator\n");
 
 	return 0;
 }
-- 
2.30.2


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

* [PATCH 12/15] iio: imu: st_lsm9ds0: Make st_lsm9ds0_remove() return void
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
                   ` (10 preceding siblings ...)
  2021-10-13 20:32 ` [PATCH 11/15] iio: health: afe4403: Don't return an error in .remove() Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-14 17:32   ` Jonathan Cameron
  2021-10-13 20:32 ` [PATCH 13/15] iio: magn: hmc5843: Make hmc5843_common_remove() " Uwe Kleine-König
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Mark Brown, Wolfram Sang, kernel, linux-i2c,
	linux-iio, linux-spi

Up to now st_lsm9ds0_remove() returns zero unconditionally. Make it
return void instead which makes it easier to see in the callers that
there is no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h      | 2 +-
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c | 4 +---
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c  | 4 +++-
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c  | 4 +++-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h
index 146393afd9a7..3f0b24e9eeea 100644
--- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h
+++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h
@@ -18,6 +18,6 @@ struct st_lsm9ds0 {
 };
 
 int st_lsm9ds0_probe(struct st_lsm9ds0 *lsm9ds0, struct regmap *regmap);
-int st_lsm9ds0_remove(struct st_lsm9ds0 *lsm9ds0);
+void st_lsm9ds0_remove(struct st_lsm9ds0 *lsm9ds0);
 
 #endif /* ST_LSM9DS0_H */
diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
index 5e6625140db7..bfd7da4353a8 100644
--- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
+++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
@@ -150,12 +150,10 @@ int st_lsm9ds0_probe(struct st_lsm9ds0 *lsm9ds0, struct regmap *regmap)
 }
 EXPORT_SYMBOL_GPL(st_lsm9ds0_probe);
 
-int st_lsm9ds0_remove(struct st_lsm9ds0 *lsm9ds0)
+void st_lsm9ds0_remove(struct st_lsm9ds0 *lsm9ds0)
 {
 	st_magn_common_remove(lsm9ds0->magn);
 	st_accel_common_remove(lsm9ds0->accel);
-
-	return 0;
 }
 EXPORT_SYMBOL_GPL(st_lsm9ds0_remove);
 
diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
index 78bede358747..e9205b46a4e6 100644
--- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
+++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
@@ -66,7 +66,9 @@ static int st_lsm9ds0_i2c_probe(struct i2c_client *client)
 
 static int st_lsm9ds0_i2c_remove(struct i2c_client *client)
 {
-	return st_lsm9ds0_remove(i2c_get_clientdata(client));
+	st_lsm9ds0_remove(i2c_get_clientdata(client));
+
+	return 0;
 }
 
 static struct i2c_driver st_lsm9ds0_driver = {
diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
index 180b54e66438..c51164c9f151 100644
--- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
+++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
@@ -65,7 +65,9 @@ static int st_lsm9ds0_spi_probe(struct spi_device *spi)
 
 static int st_lsm9ds0_spi_remove(struct spi_device *spi)
 {
-	return st_lsm9ds0_remove(spi_get_drvdata(spi));
+	st_lsm9ds0_remove(spi_get_drvdata(spi));
+
+	return 0;
 }
 
 static struct spi_driver st_lsm9ds0_driver = {
-- 
2.30.2


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

* [PATCH 13/15] iio: magn: hmc5843: Make hmc5843_common_remove() return void
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
                   ` (11 preceding siblings ...)
  2021-10-13 20:32 ` [PATCH 12/15] iio: imu: st_lsm9ds0: Make st_lsm9ds0_remove() return void Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 14/15] iio: potentiometer: max5487: Don't return an error in .remove() Uwe Kleine-König
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Mark Brown, Wolfram Sang, kernel, linux-i2c,
	linux-iio, linux-spi

Up to now hmc5843_common_remove() returns zero unconditionally. Make it
return void instead which makes it easier to see in the callers that
there is no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/magnetometer/hmc5843.h      | 2 +-
 drivers/iio/magnetometer/hmc5843_core.c | 4 +---
 drivers/iio/magnetometer/hmc5843_i2c.c  | 4 +++-
 drivers/iio/magnetometer/hmc5843_spi.c  | 4 +++-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/magnetometer/hmc5843.h b/drivers/iio/magnetometer/hmc5843.h
index 242f742f2643..9120c8bbf3dd 100644
--- a/drivers/iio/magnetometer/hmc5843.h
+++ b/drivers/iio/magnetometer/hmc5843.h
@@ -50,7 +50,7 @@ struct hmc5843_data {
 
 int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
 			 enum hmc5843_ids id, const char *name);
-int hmc5843_common_remove(struct device *dev);
+void hmc5843_common_remove(struct device *dev);
 
 int hmc5843_common_suspend(struct device *dev);
 int hmc5843_common_resume(struct device *dev);
diff --git a/drivers/iio/magnetometer/hmc5843_core.c b/drivers/iio/magnetometer/hmc5843_core.c
index cf62057480cf..f08726bf5ec3 100644
--- a/drivers/iio/magnetometer/hmc5843_core.c
+++ b/drivers/iio/magnetometer/hmc5843_core.c
@@ -671,7 +671,7 @@ int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
 }
 EXPORT_SYMBOL(hmc5843_common_probe);
 
-int hmc5843_common_remove(struct device *dev)
+void hmc5843_common_remove(struct device *dev)
 {
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 
@@ -680,8 +680,6 @@ int hmc5843_common_remove(struct device *dev)
 
 	/*  sleep mode to save power */
 	hmc5843_set_mode(iio_priv(indio_dev), HMC5843_MODE_SLEEP);
-
-	return 0;
 }
 EXPORT_SYMBOL(hmc5843_common_remove);
 
diff --git a/drivers/iio/magnetometer/hmc5843_i2c.c b/drivers/iio/magnetometer/hmc5843_i2c.c
index 67fe657fdb3e..bc6e12f1d521 100644
--- a/drivers/iio/magnetometer/hmc5843_i2c.c
+++ b/drivers/iio/magnetometer/hmc5843_i2c.c
@@ -67,7 +67,9 @@ static int hmc5843_i2c_probe(struct i2c_client *cli,
 
 static int hmc5843_i2c_remove(struct i2c_client *client)
 {
-	return hmc5843_common_remove(&client->dev);
+	hmc5843_common_remove(&client->dev);
+
+	return 0;
 }
 
 static const struct i2c_device_id hmc5843_id[] = {
diff --git a/drivers/iio/magnetometer/hmc5843_spi.c b/drivers/iio/magnetometer/hmc5843_spi.c
index d827554c346e..89cf59a62c28 100644
--- a/drivers/iio/magnetometer/hmc5843_spi.c
+++ b/drivers/iio/magnetometer/hmc5843_spi.c
@@ -76,7 +76,9 @@ static int hmc5843_spi_probe(struct spi_device *spi)
 
 static int hmc5843_spi_remove(struct spi_device *spi)
 {
-	return hmc5843_common_remove(&spi->dev);
+	hmc5843_common_remove(&spi->dev);
+
+	return 0;
 }
 
 static const struct spi_device_id hmc5843_id[] = {
-- 
2.30.2


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

* [PATCH 14/15] iio: potentiometer: max5487: Don't return an error in .remove()
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
                   ` (12 preceding siblings ...)
  2021-10-13 20:32 ` [PATCH 13/15] iio: magn: hmc5843: Make hmc5843_common_remove() " Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-13 20:32 ` [PATCH 15/15] iio: pressure: ms5611: Make ms5611_remove() return void Uwe Kleine-König
  2021-10-14  7:45 ` [PATCH 00/15] iio: let spi drivers return 0 in .remove() Alexandru Ardelean
  15 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Mark Brown, kernel, linux-iio, linux-spi

The only effect of returning an error in an spi .remove() callback is
that the spi core issues a generic warning message. Instead emit a more
specific error message and return 0 to not report the same issue twice.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/potentiometer/max5487.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/potentiometer/max5487.c b/drivers/iio/potentiometer/max5487.c
index 1c0d46a96200..007c2bd324cb 100644
--- a/drivers/iio/potentiometer/max5487.c
+++ b/drivers/iio/potentiometer/max5487.c
@@ -115,11 +115,16 @@ static int max5487_spi_probe(struct spi_device *spi)
 static int max5487_spi_remove(struct spi_device *spi)
 {
 	struct iio_dev *indio_dev = spi_get_drvdata(spi);
+	int ret;
 
 	iio_device_unregister(indio_dev);
 
 	/* save both wiper regs to NV regs */
-	return max5487_write_cmd(spi, MAX5487_COPY_AB_TO_NV);
+	ret = max5487_write_cmd(spi, MAX5487_COPY_AB_TO_NV);
+	if (ret)
+		dev_warn(&spi->dev, "Failed to save wiper regs to NV regs\n");
+
+	return 0;
 }
 
 static const struct spi_device_id max5487_id[] = {
-- 
2.30.2


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

* [PATCH 15/15] iio: pressure: ms5611: Make ms5611_remove() return void
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
                   ` (13 preceding siblings ...)
  2021-10-13 20:32 ` [PATCH 14/15] iio: potentiometer: max5487: Don't return an error in .remove() Uwe Kleine-König
@ 2021-10-13 20:32 ` Uwe Kleine-König
  2021-10-14  7:45 ` [PATCH 00/15] iio: let spi drivers return 0 in .remove() Alexandru Ardelean
  15 siblings, 0 replies; 20+ messages in thread
From: Uwe Kleine-König @ 2021-10-13 20:32 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Lars-Peter Clausen, Mark Brown, Wolfram Sang, kernel, linux-i2c,
	linux-iio, linux-spi

Up to now ms5611_remove() returns zero unconditionally. Make it return
void instead which makes it easier to see in the callers that there is
no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/iio/pressure/ms5611.h      | 2 +-
 drivers/iio/pressure/ms5611_core.c | 4 +---
 drivers/iio/pressure/ms5611_i2c.c  | 4 +++-
 drivers/iio/pressure/ms5611_spi.c  | 4 +++-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/pressure/ms5611.h b/drivers/iio/pressure/ms5611.h
index bc06271fa38b..86b1c4b1820d 100644
--- a/drivers/iio/pressure/ms5611.h
+++ b/drivers/iio/pressure/ms5611.h
@@ -61,6 +61,6 @@ struct ms5611_state {
 
 int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
 		 const char *name, int type);
-int ms5611_remove(struct iio_dev *indio_dev);
+void ms5611_remove(struct iio_dev *indio_dev);
 
 #endif /* _MS5611_H */
diff --git a/drivers/iio/pressure/ms5611_core.c b/drivers/iio/pressure/ms5611_core.c
index 214b0d25f598..ee75f08655c9 100644
--- a/drivers/iio/pressure/ms5611_core.c
+++ b/drivers/iio/pressure/ms5611_core.c
@@ -474,13 +474,11 @@ int ms5611_probe(struct iio_dev *indio_dev, struct device *dev,
 }
 EXPORT_SYMBOL(ms5611_probe);
 
-int ms5611_remove(struct iio_dev *indio_dev)
+void ms5611_remove(struct iio_dev *indio_dev)
 {
 	iio_device_unregister(indio_dev);
 	iio_triggered_buffer_cleanup(indio_dev);
 	ms5611_fini(indio_dev);
-
-	return 0;
 }
 EXPORT_SYMBOL(ms5611_remove);
 
diff --git a/drivers/iio/pressure/ms5611_i2c.c b/drivers/iio/pressure/ms5611_i2c.c
index 7c04f730430c..5c82d80f85b6 100644
--- a/drivers/iio/pressure/ms5611_i2c.c
+++ b/drivers/iio/pressure/ms5611_i2c.c
@@ -110,7 +110,9 @@ static int ms5611_i2c_probe(struct i2c_client *client,
 
 static int ms5611_i2c_remove(struct i2c_client *client)
 {
-	return ms5611_remove(i2c_get_clientdata(client));
+	ms5611_remove(i2c_get_clientdata(client));
+
+	return 0;
 }
 
 static const struct of_device_id ms5611_i2c_matches[] = {
diff --git a/drivers/iio/pressure/ms5611_spi.c b/drivers/iio/pressure/ms5611_spi.c
index 45d3a7d5be8e..79bed64c9b68 100644
--- a/drivers/iio/pressure/ms5611_spi.c
+++ b/drivers/iio/pressure/ms5611_spi.c
@@ -112,7 +112,9 @@ static int ms5611_spi_probe(struct spi_device *spi)
 
 static int ms5611_spi_remove(struct spi_device *spi)
 {
-	return ms5611_remove(spi_get_drvdata(spi));
+	ms5611_remove(spi_get_drvdata(spi));
+
+	return 0;
 }
 
 static const struct of_device_id ms5611_spi_matches[] = {
-- 
2.30.2


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

* Re: [PATCH 00/15] iio: let spi drivers return 0 in .remove()
  2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
                   ` (14 preceding siblings ...)
  2021-10-13 20:32 ` [PATCH 15/15] iio: pressure: ms5611: Make ms5611_remove() return void Uwe Kleine-König
@ 2021-10-14  7:45 ` Alexandru Ardelean
  2021-10-14 17:35   ` Jonathan Cameron
  15 siblings, 1 reply; 20+ messages in thread
From: Alexandru Ardelean @ 2021-10-14  7:45 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Dan Robertson, Jonathan Cameron, Lars-Peter Clausen,
	Michael Hennerich, Mark Brown, Wolfram Sang, kernel, linux-i2c,
	linux-iio, linux-spi

On Wed, Oct 13, 2021 at 11:33 PM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> Hello,
>
> this series is part of my quest to change the return type of the spi
> driver .remove() callback to void. In this first stage I fix all drivers
> to return 0 to be able to mechanically change all drivers in the final
> step.
>
> Returning an error code (which actually very few drivers do) doesn't
> make much sense, because the only effect is that the spi core emits an
> error message.
>
> The same holds try for i2c drivers, some of them are fixed en passant.
>
> There are no interdependencies in this series, and there is some more
> work to do for the final conversion, so apply the patches from this
> series at will :-)
>

Series looks good.
However this set also makes a case for doing more conversions to devm_
usage in probe.

With devm_ , we get slightly less code, with some mirrored unwinding
in error and remove paths.
There are currently ~170 places (not necessarily the same amount of
drivers), where devm_ can be used.

What I typically do is run this command in a kernel tree:  "git grep
-w iio_device_unregister | wc -l"
When I run it without "wc -l", I will pick a file and take a look
inside it and check it's convertibility to using
devm_iio_device_unregister()
The rationale is, that for IIO drivers, if you get
devm_iio_device_unregister() (properly) called last, then it's fully
converted to devm_ functions.

For this series particularly:

Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>

> Best regards
> Uwe
>
> Uwe Kleine-König (15):
>   iio: accel: bma400: Make bma400_remove() return void
>   iio: accel: bmc150: Make bmc150_accel_core_remove() return void
>   iio: accel: bmi088: Make bmi088_accel_core_remove() return void
>   iio: accel: kxsd9: Make kxsd9_common_remove() return void
>   iio: accel: mma7455: Make mma7455_core_remove() return void
>   iio: accel: ad5064: Make ad5064_core_remove() return void
>   iio: dac: ad5380: Make ad5380_remove() return void
>   iio: dac: ad5446: Make ad5446_remove() return void
>   iio: dac: ad5592r: Make ad5592r_remove() return void
>   iio: dac: ad5686: Make ad5686_remove() return void
>   iio: health: afe4403: Don't return an error in .remove()
>   iio: imu: st_lsm9ds0: Make st_lsm9ds0_remove() return void
>   iio: magn: hmc5843: Make hmc5843_common_remove() return void
>   iio: potentiometer: max5487: Don't return an error in .remove()
>   iio: pressure: ms5611: Make ms5611_remove() return void
>
>  drivers/iio/accel/bma400.h                   |  2 +-
>  drivers/iio/accel/bma400_core.c              |  7 ++++---
>  drivers/iio/accel/bma400_i2c.c               |  4 +++-
>  drivers/iio/accel/bma400_spi.c               |  4 +++-
>  drivers/iio/accel/bmc150-accel-core.c        |  4 +---
>  drivers/iio/accel/bmc150-accel-i2c.c         |  4 +++-
>  drivers/iio/accel/bmc150-accel-spi.c         |  4 +++-
>  drivers/iio/accel/bmc150-accel.h             |  2 +-
>  drivers/iio/accel/bmi088-accel-core.c        |  4 +---
>  drivers/iio/accel/bmi088-accel-spi.c         |  4 +++-
>  drivers/iio/accel/bmi088-accel.h             |  2 +-
>  drivers/iio/accel/kxsd9-i2c.c                |  4 +++-
>  drivers/iio/accel/kxsd9-spi.c                |  4 +++-
>  drivers/iio/accel/kxsd9.c                    |  4 +---
>  drivers/iio/accel/kxsd9.h                    |  2 +-
>  drivers/iio/accel/mma7455.h                  |  2 +-
>  drivers/iio/accel/mma7455_core.c             |  4 +---
>  drivers/iio/accel/mma7455_i2c.c              |  4 +++-
>  drivers/iio/accel/mma7455_spi.c              |  4 +++-
>  drivers/iio/dac/ad5064.c                     | 12 +++++++-----
>  drivers/iio/dac/ad5380.c                     | 15 ++++++++-------
>  drivers/iio/dac/ad5446.c                     | 12 +++++++-----
>  drivers/iio/dac/ad5592r-base.c               |  4 +---
>  drivers/iio/dac/ad5592r-base.h               |  2 +-
>  drivers/iio/dac/ad5592r.c                    |  4 +++-
>  drivers/iio/dac/ad5593r.c                    |  4 +++-
>  drivers/iio/dac/ad5686-spi.c                 |  4 +++-
>  drivers/iio/dac/ad5686.c                     |  4 +---
>  drivers/iio/dac/ad5686.h                     |  2 +-
>  drivers/iio/dac/ad5696-i2c.c                 |  4 +++-
>  drivers/iio/health/afe4403.c                 |  6 ++----
>  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h      |  2 +-
>  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c |  4 +---
>  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c  |  4 +++-
>  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c  |  4 +++-
>  drivers/iio/magnetometer/hmc5843.h           |  2 +-
>  drivers/iio/magnetometer/hmc5843_core.c      |  4 +---
>  drivers/iio/magnetometer/hmc5843_i2c.c       |  4 +++-
>  drivers/iio/magnetometer/hmc5843_spi.c       |  4 +++-
>  drivers/iio/potentiometer/max5487.c          |  7 ++++++-
>  drivers/iio/pressure/ms5611.h                |  2 +-
>  drivers/iio/pressure/ms5611_core.c           |  4 +---
>  drivers/iio/pressure/ms5611_i2c.c            |  4 +++-
>  drivers/iio/pressure/ms5611_spi.c            |  4 +++-
>  44 files changed, 110 insertions(+), 81 deletions(-)
>
>
> base-commit: 9e1ff307c779ce1f0f810c7ecce3d95bbae40896
> --
> 2.30.2
>

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

* Re: [PATCH 06/15] iio: accel: ad5064: Make ad5064_core_remove() return void
  2021-10-13 20:32 ` [PATCH 06/15] iio: accel: ad5064: Make ad5064_core_remove() " Uwe Kleine-König
@ 2021-10-14 17:29   ` Jonathan Cameron
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2021-10-14 17:29 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Lars-Peter Clausen, Michael Hennerich, Mark Brown, Wolfram Sang,
	kernel, linux-i2c, linux-iio, linux-spi

On Wed, 13 Oct 2021 22:32:14 +0200
Uwe Kleine-König         <u.kleine-koenig@pengutronix.de> wrote:

> Up to now ad5064_core_remove() returns zero unconditionally. Make it
> return void instead which makes it easier to see in the callers that
> there is no error to handle.
> 
> Also the return value of i2c and spi remove callbacks is ignored anyway.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Skipping this one as it has since been converted to all devm_

Thanks,

Jonathan

> ---
>  drivers/iio/dac/ad5064.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c
> index dff623b65e4f..6f66796942c0 100644
> --- a/drivers/iio/dac/ad5064.c
> +++ b/drivers/iio/dac/ad5064.c
> @@ -900,7 +900,7 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
>  	return ret;
>  }
>  
> -static int ad5064_remove(struct device *dev)
> +static void ad5064_remove(struct device *dev)
>  {
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct ad5064_state *st = iio_priv(indio_dev);
> @@ -909,8 +909,6 @@ static int ad5064_remove(struct device *dev)
>  
>  	if (!st->use_internal_vref)
>  		regulator_bulk_disable(ad5064_num_vref(st), st->vref_reg);
> -
> -	return 0;
>  }
>  
>  #if IS_ENABLED(CONFIG_SPI_MASTER)
> @@ -934,7 +932,9 @@ static int ad5064_spi_probe(struct spi_device *spi)
>  
>  static int ad5064_spi_remove(struct spi_device *spi)
>  {
> -	return ad5064_remove(&spi->dev);
> +	ad5064_remove(&spi->dev);
> +
> +	return 0;
>  }
>  
>  static const struct spi_device_id ad5064_spi_ids[] = {
> @@ -1021,7 +1021,9 @@ static int ad5064_i2c_probe(struct i2c_client *i2c,
>  
>  static int ad5064_i2c_remove(struct i2c_client *i2c)
>  {
> -	return ad5064_remove(&i2c->dev);
> +	ad5064_remove(&i2c->dev);
> +
> +	return 0;
>  }
>  
>  static const struct i2c_device_id ad5064_i2c_ids[] = {


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

* Re: [PATCH 12/15] iio: imu: st_lsm9ds0: Make st_lsm9ds0_remove() return void
  2021-10-13 20:32 ` [PATCH 12/15] iio: imu: st_lsm9ds0: Make st_lsm9ds0_remove() return void Uwe Kleine-König
@ 2021-10-14 17:32   ` Jonathan Cameron
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2021-10-14 17:32 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Lars-Peter Clausen, Mark Brown, Wolfram Sang, kernel, linux-i2c,
	linux-iio, linux-spi

On Wed, 13 Oct 2021 22:32:20 +0200
Uwe Kleine-König <u.kleine-koenig@pengutronix.de> wrote:

> Up to now st_lsm9ds0_remove() returns zero unconditionally. Make it
> return void instead which makes it easier to see in the callers that
> there is no error to handle.
> 
> Also the return value of i2c and spi remove callbacks is ignored anyway.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Skipped as I've accepted a patch in the meantime that removes this
code by doing a full devm_ handled remove path.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h      | 2 +-
>  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c | 4 +---
>  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c  | 4 +++-
>  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c  | 4 +++-
>  4 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h
> index 146393afd9a7..3f0b24e9eeea 100644
> --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h
> +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h
> @@ -18,6 +18,6 @@ struct st_lsm9ds0 {
>  };
>  
>  int st_lsm9ds0_probe(struct st_lsm9ds0 *lsm9ds0, struct regmap *regmap);
> -int st_lsm9ds0_remove(struct st_lsm9ds0 *lsm9ds0);
> +void st_lsm9ds0_remove(struct st_lsm9ds0 *lsm9ds0);
>  
>  #endif /* ST_LSM9DS0_H */
> diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
> index 5e6625140db7..bfd7da4353a8 100644
> --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
> +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c
> @@ -150,12 +150,10 @@ int st_lsm9ds0_probe(struct st_lsm9ds0 *lsm9ds0, struct regmap *regmap)
>  }
>  EXPORT_SYMBOL_GPL(st_lsm9ds0_probe);
>  
> -int st_lsm9ds0_remove(struct st_lsm9ds0 *lsm9ds0)
> +void st_lsm9ds0_remove(struct st_lsm9ds0 *lsm9ds0)
>  {
>  	st_magn_common_remove(lsm9ds0->magn);
>  	st_accel_common_remove(lsm9ds0->accel);
> -
> -	return 0;
>  }
>  EXPORT_SYMBOL_GPL(st_lsm9ds0_remove);
>  
> diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
> index 78bede358747..e9205b46a4e6 100644
> --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
> +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
> @@ -66,7 +66,9 @@ static int st_lsm9ds0_i2c_probe(struct i2c_client *client)
>  
>  static int st_lsm9ds0_i2c_remove(struct i2c_client *client)
>  {
> -	return st_lsm9ds0_remove(i2c_get_clientdata(client));
> +	st_lsm9ds0_remove(i2c_get_clientdata(client));
> +
> +	return 0;
>  }
>  
>  static struct i2c_driver st_lsm9ds0_driver = {
> diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> index 180b54e66438..c51164c9f151 100644
> --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> @@ -65,7 +65,9 @@ static int st_lsm9ds0_spi_probe(struct spi_device *spi)
>  
>  static int st_lsm9ds0_spi_remove(struct spi_device *spi)
>  {
> -	return st_lsm9ds0_remove(spi_get_drvdata(spi));
> +	st_lsm9ds0_remove(spi_get_drvdata(spi));
> +
> +	return 0;
>  }
>  
>  static struct spi_driver st_lsm9ds0_driver = {


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

* Re: [PATCH 00/15] iio: let spi drivers return 0 in .remove()
  2021-10-14  7:45 ` [PATCH 00/15] iio: let spi drivers return 0 in .remove() Alexandru Ardelean
@ 2021-10-14 17:35   ` Jonathan Cameron
  0 siblings, 0 replies; 20+ messages in thread
From: Jonathan Cameron @ 2021-10-14 17:35 UTC (permalink / raw)
  To: Alexandru Ardelean
  Cc: Uwe Kleine-König, Dan Robertson, Lars-Peter Clausen,
	Michael Hennerich, Mark Brown, Wolfram Sang, kernel, linux-i2c,
	linux-iio, linux-spi

On Thu, 14 Oct 2021 10:45:36 +0300
Alexandru Ardelean <ardeleanalex@gmail.com> wrote:

> On Wed, Oct 13, 2021 at 11:33 PM Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> >
> > Hello,
> >
> > this series is part of my quest to change the return type of the spi
> > driver .remove() callback to void. In this first stage I fix all drivers
> > to return 0 to be able to mechanically change all drivers in the final
> > step.
> >
> > Returning an error code (which actually very few drivers do) doesn't
> > make much sense, because the only effect is that the spi core emits an
> > error message.
> >
> > The same holds try for i2c drivers, some of them are fixed en passant.
> >
> > There are no interdependencies in this series, and there is some more
> > work to do for the final conversion, so apply the patches from this
> > series at will :-)
> >  
> 
> Series looks good.
> However this set also makes a case for doing more conversions to devm_
> usage in probe.
Indeed. 2 of these were already done :)

Rest of the series applied to the togreg branch of iio.git and pushed out
as testing for 0-day to poke at it and see if we missed anything.

Thanks,

Jonathan

> 
> With devm_ , we get slightly less code, with some mirrored unwinding
> in error and remove paths.
> There are currently ~170 places (not necessarily the same amount of
> drivers), where devm_ can be used.
> 
> What I typically do is run this command in a kernel tree:  "git grep
> -w iio_device_unregister | wc -l"
> When I run it without "wc -l", I will pick a file and take a look
> inside it and check it's convertibility to using
> devm_iio_device_unregister()
> The rationale is, that for IIO drivers, if you get
> devm_iio_device_unregister() (properly) called last, then it's fully
> converted to devm_ functions.
> 
> For this series particularly:
> 
> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
> 
> > Best regards
> > Uwe
> >
> > Uwe Kleine-König (15):
> >   iio: accel: bma400: Make bma400_remove() return void
> >   iio: accel: bmc150: Make bmc150_accel_core_remove() return void
> >   iio: accel: bmi088: Make bmi088_accel_core_remove() return void
> >   iio: accel: kxsd9: Make kxsd9_common_remove() return void
> >   iio: accel: mma7455: Make mma7455_core_remove() return void
> >   iio: accel: ad5064: Make ad5064_core_remove() return void
> >   iio: dac: ad5380: Make ad5380_remove() return void
> >   iio: dac: ad5446: Make ad5446_remove() return void
> >   iio: dac: ad5592r: Make ad5592r_remove() return void
> >   iio: dac: ad5686: Make ad5686_remove() return void
> >   iio: health: afe4403: Don't return an error in .remove()
> >   iio: imu: st_lsm9ds0: Make st_lsm9ds0_remove() return void
> >   iio: magn: hmc5843: Make hmc5843_common_remove() return void
> >   iio: potentiometer: max5487: Don't return an error in .remove()
> >   iio: pressure: ms5611: Make ms5611_remove() return void
> >
> >  drivers/iio/accel/bma400.h                   |  2 +-
> >  drivers/iio/accel/bma400_core.c              |  7 ++++---
> >  drivers/iio/accel/bma400_i2c.c               |  4 +++-
> >  drivers/iio/accel/bma400_spi.c               |  4 +++-
> >  drivers/iio/accel/bmc150-accel-core.c        |  4 +---
> >  drivers/iio/accel/bmc150-accel-i2c.c         |  4 +++-
> >  drivers/iio/accel/bmc150-accel-spi.c         |  4 +++-
> >  drivers/iio/accel/bmc150-accel.h             |  2 +-
> >  drivers/iio/accel/bmi088-accel-core.c        |  4 +---
> >  drivers/iio/accel/bmi088-accel-spi.c         |  4 +++-
> >  drivers/iio/accel/bmi088-accel.h             |  2 +-
> >  drivers/iio/accel/kxsd9-i2c.c                |  4 +++-
> >  drivers/iio/accel/kxsd9-spi.c                |  4 +++-
> >  drivers/iio/accel/kxsd9.c                    |  4 +---
> >  drivers/iio/accel/kxsd9.h                    |  2 +-
> >  drivers/iio/accel/mma7455.h                  |  2 +-
> >  drivers/iio/accel/mma7455_core.c             |  4 +---
> >  drivers/iio/accel/mma7455_i2c.c              |  4 +++-
> >  drivers/iio/accel/mma7455_spi.c              |  4 +++-
> >  drivers/iio/dac/ad5064.c                     | 12 +++++++-----
> >  drivers/iio/dac/ad5380.c                     | 15 ++++++++-------
> >  drivers/iio/dac/ad5446.c                     | 12 +++++++-----
> >  drivers/iio/dac/ad5592r-base.c               |  4 +---
> >  drivers/iio/dac/ad5592r-base.h               |  2 +-
> >  drivers/iio/dac/ad5592r.c                    |  4 +++-
> >  drivers/iio/dac/ad5593r.c                    |  4 +++-
> >  drivers/iio/dac/ad5686-spi.c                 |  4 +++-
> >  drivers/iio/dac/ad5686.c                     |  4 +---
> >  drivers/iio/dac/ad5686.h                     |  2 +-
> >  drivers/iio/dac/ad5696-i2c.c                 |  4 +++-
> >  drivers/iio/health/afe4403.c                 |  6 ++----
> >  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0.h      |  2 +-
> >  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_core.c |  4 +---
> >  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c  |  4 +++-
> >  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c  |  4 +++-
> >  drivers/iio/magnetometer/hmc5843.h           |  2 +-
> >  drivers/iio/magnetometer/hmc5843_core.c      |  4 +---
> >  drivers/iio/magnetometer/hmc5843_i2c.c       |  4 +++-
> >  drivers/iio/magnetometer/hmc5843_spi.c       |  4 +++-
> >  drivers/iio/potentiometer/max5487.c          |  7 ++++++-
> >  drivers/iio/pressure/ms5611.h                |  2 +-
> >  drivers/iio/pressure/ms5611_core.c           |  4 +---
> >  drivers/iio/pressure/ms5611_i2c.c            |  4 +++-
> >  drivers/iio/pressure/ms5611_spi.c            |  4 +++-
> >  44 files changed, 110 insertions(+), 81 deletions(-)
> >
> >
> > base-commit: 9e1ff307c779ce1f0f810c7ecce3d95bbae40896
> > --
> > 2.30.2
> >  


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

end of thread, other threads:[~2021-10-14 17:31 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 20:32 [PATCH 00/15] iio: let spi drivers return 0 in .remove() Uwe Kleine-König
2021-10-13 20:32 ` [PATCH 01/15] iio: accel: bma400: Make bma400_remove() return void Uwe Kleine-König
2021-10-13 20:32 ` [PATCH 02/15] iio: accel: bmc150: Make bmc150_accel_core_remove() " Uwe Kleine-König
2021-10-13 20:32 ` [PATCH 03/15] iio: accel: bmi088: Make bmi088_accel_core_remove() " Uwe Kleine-König
2021-10-13 20:32 ` [PATCH 04/15] iio: accel: kxsd9: Make kxsd9_common_remove() " Uwe Kleine-König
2021-10-13 20:32 ` [PATCH 05/15] iio: accel: mma7455: Make mma7455_core_remove() " Uwe Kleine-König
2021-10-13 20:32 ` [PATCH 06/15] iio: accel: ad5064: Make ad5064_core_remove() " Uwe Kleine-König
2021-10-14 17:29   ` Jonathan Cameron
2021-10-13 20:32 ` [PATCH 07/15] iio: dac: ad5380: Make ad5380_remove() " Uwe Kleine-König
2021-10-13 20:32 ` [PATCH 08/15] iio: dac: ad5446: Make ad5446_remove() " Uwe Kleine-König
2021-10-13 20:32 ` [PATCH 09/15] iio: dac: ad5592r: Make ad5592r_remove() " Uwe Kleine-König
2021-10-13 20:32 ` [PATCH 10/15] iio: dac: ad5686: Make ad5686_remove() " Uwe Kleine-König
2021-10-13 20:32 ` [PATCH 11/15] iio: health: afe4403: Don't return an error in .remove() Uwe Kleine-König
2021-10-13 20:32 ` [PATCH 12/15] iio: imu: st_lsm9ds0: Make st_lsm9ds0_remove() return void Uwe Kleine-König
2021-10-14 17:32   ` Jonathan Cameron
2021-10-13 20:32 ` [PATCH 13/15] iio: magn: hmc5843: Make hmc5843_common_remove() " Uwe Kleine-König
2021-10-13 20:32 ` [PATCH 14/15] iio: potentiometer: max5487: Don't return an error in .remove() Uwe Kleine-König
2021-10-13 20:32 ` [PATCH 15/15] iio: pressure: ms5611: Make ms5611_remove() return void Uwe Kleine-König
2021-10-14  7:45 ` [PATCH 00/15] iio: let spi drivers return 0 in .remove() Alexandru Ardelean
2021-10-14 17:35   ` 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.