Skip to contentSkip to conversation

iio: dac: ad8801: Make use of the helper function dev_err_probe()

PATCH Superseded Cai Huoqing 3 participants 11 messages Sep 28, 2021 – Oct 7, 2021

Subsystems (5)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/8 iio: dac: ad8801: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value gets printed.

---
 drivers/iio/dac/ad8801.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/iio/dac/ad8801.c +7 -8
index 6354b7c8f052..8acb9fee273c 100644
@@ -123,10 +123,9 @@ static int ad8801_probe(struct spi_device *spi)
 	id = spi_get_device_id(spi);
 
 	state->vrefh_reg = devm_regulator_get(&spi->dev, "vrefh");
-	if (IS_ERR(state->vrefh_reg)) {
-		dev_err(&spi->dev, "Vrefh regulator not specified\n");
-		return PTR_ERR(state->vrefh_reg);
-	}
+	if (IS_ERR(state->vrefh_reg))
+		return dev_err_probe(&spi->dev, PTR_ERR(state->vrefh_reg),
+				     "Vrefh regulator not specified\n");
 
 	ret = regulator_enable(state->vrefh_reg);
 	if (ret) {
@@ -146,15 +145,15 @@ static int ad8801_probe(struct spi_device *spi)
 	if (id->driver_data == ID_AD8803) {
 		state->vrefl_reg = devm_regulator_get(&spi->dev, "vrefl");
 		if (IS_ERR(state->vrefl_reg)) {
-			dev_err(&spi->dev, "Vrefl regulator not specified\n");
-			ret = PTR_ERR(state->vrefl_reg);
+			ret = dev_err_probe(&spi->dev, PTR_ERR(state->vrefl_reg),
+					    "Vrefl regulator not specified\n");
 			goto error_disable_vrefh_reg;
 		}
 
 		ret = regulator_enable(state->vrefl_reg);
 		if (ret) {
-			dev_err(&spi->dev, "Failed to enable vrefl regulator: %d\n",
-					ret);
+			dev_err(&spi->dev,
+				"Failed to enable vrefl regulator: %d\n", ret);
 			goto error_disable_vrefh_reg;
 		}
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 2/8 iio: dac: lpc18xx_dac: Make use of the helper function dev_err_probe()

When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value gets printed.

---
v1->v2: Remove the separate line of PTR_ERR().

 drivers/iio/dac/lpc18xx_dac.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/iio/dac/lpc18xx_dac.c +6 -8
index 9e38607a189e..afb37647b035 100644
@@ -121,16 +121,14 @@ static int lpc18xx_dac_probe(struct platform_device *pdev)
 		return PTR_ERR(dac->base);
 
 	dac->clk = devm_clk_get(&pdev->dev, NULL);
-	if (IS_ERR(dac->clk)) {
-		dev_err(&pdev->dev, "error getting clock\n");
-		return PTR_ERR(dac->clk);
-	}
+	if (IS_ERR(dac->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(dac->clk),
+				     "error getting clock\n");
 
 	dac->vref = devm_regulator_get(&pdev->dev, "vref");
-	if (IS_ERR(dac->vref)) {
-		dev_err(&pdev->dev, "error getting regulator\n");
-		return PTR_ERR(dac->vref);
-	}
+	if (IS_ERR(dac->vref))
+		return dev_err_probe(&pdev->dev, PTR_ERR(dac->vref),
+				     "error getting regulator\n");
 
 	indio_dev->name = dev_name(&pdev->dev);
 	indio_dev->info = &lpc18xx_dac_info;
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 3/8 iio: dac: ltc1660: Make use of the helper function dev_err_probe()

In reply to Cai Huoqing

When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value gets printed.

---
 drivers/iio/dac/ltc1660.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/iio/dac/ltc1660.c +3 -4
index dc10188540ca..f6ec9bf5815e 100644
@@ -172,10 +172,9 @@ static int ltc1660_probe(struct spi_device *spi)
 	}
 
 	priv->vref_reg = devm_regulator_get(&spi->dev, "vref");
-	if (IS_ERR(priv->vref_reg)) {
-		dev_err(&spi->dev, "vref regulator not specified\n");
-		return PTR_ERR(priv->vref_reg);
-	}
+	if (IS_ERR(priv->vref_reg))
+		return dev_err_probe(&spi->dev, PTR_ERR(priv->vref_reg),
+				     "vref regulator not specified\n");
 
 	ret = regulator_enable(priv->vref_reg);
 	if (ret) {
Signature · 7 lines
2.25.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Reviewed-by on v2 3/8
#3 lore raw

Re: [PATCH v2 3/8] iio: dac: ltc1660: Make use of the helper function dev_err_probe()

Hi,

Quoted 7 lines · Cai Huoqing

When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value gets printed.

#4 lore raw

PATCH v2 4/8 iio: dac: ds4424: Make use of the helper function dev_err_probe()

In reply to Cai Huoqing

When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value gets printed.

---
 drivers/iio/dac/ds4424.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/iio/dac/ds4424.c +3 -6
index 79527fbc250a..5a5e967b0be4 100644
@@ -232,12 +232,9 @@ static int ds4424_probe(struct i2c_client *client,
 	indio_dev->name = id->name;
 
 	data->vcc_reg = devm_regulator_get(&client->dev, "vcc");
-	if (IS_ERR(data->vcc_reg)) {
-		dev_err(&client->dev,
-			"Failed to get vcc-supply regulator. err: %ld\n",
-				PTR_ERR(data->vcc_reg));
-		return PTR_ERR(data->vcc_reg);
-	}
+	if (IS_ERR(data->vcc_reg))
+		return dev_err_probe(&client->dev, PTR_ERR(data->vcc_reg),
+				     "Failed to get vcc-supply regulator.\n");
 
 	mutex_init(&data->lock);
 	ret = regulator_enable(data->vcc_reg);
Signature · 1 line
2.25.1
#5 lore raw

PATCH v2 5/8 iio: dac: max5821: Make use of the helper function dev_err_probe()

In reply to Cai Huoqing

When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value gets printed.

---
 drivers/iio/dac/max5821.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/iio/dac/max5821.c +3 -6
index bd0b7f361154..7da4710a6408 100644
@@ -321,12 +321,9 @@ static int max5821_probe(struct i2c_client *client,
 	}
 
 	data->vref_reg = devm_regulator_get(&client->dev, "vref");
-	if (IS_ERR(data->vref_reg)) {
-		ret = PTR_ERR(data->vref_reg);
-		dev_err(&client->dev,
-			"Failed to get vref regulator: %d\n", ret);
-		return ret;
-	}
+	if (IS_ERR(data->vref_reg))
+		return dev_err_probe(&client->dev, PTR_ERR(data->vref_reg),
+				     "Failed to get vref regulator\n");
 
 	ret = regulator_enable(data->vref_reg);
 	if (ret) {
Signature · 1 line
2.25.1
#6 lore raw

PATCH v2 6/8 iio: dac: mcp4922: Make use of the helper function dev_err_probe()

In reply to Cai Huoqing

When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value gets printed.

---
 drivers/iio/dac/mcp4922.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/iio/dac/mcp4922.c +3 -4
index c4e430b4050e..0ae414ee1716 100644
@@ -130,10 +130,9 @@ static int mcp4922_probe(struct spi_device *spi)
 	state = iio_priv(indio_dev);
 	state->spi = spi;
 	state->vref_reg = devm_regulator_get(&spi->dev, "vref");
-	if (IS_ERR(state->vref_reg)) {
-		dev_err(&spi->dev, "Vref regulator not specified\n");
-		return PTR_ERR(state->vref_reg);
-	}
+	if (IS_ERR(state->vref_reg))
+		return dev_err_probe(&spi->dev, PTR_ERR(state->vref_reg),
+				     "Vref regulator not specified\n");
 
 	ret = regulator_enable(state->vref_reg);
 	if (ret) {
Signature · 1 line
2.25.1
#7 lore raw

PATCH v2 7/8 iio: dac: stm32-dac: Make use of the helper function dev_err_probe()

In reply to Cai Huoqing

When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value gets printed.

---
 drivers/iio/dac/stm32-dac-core.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/iio/dac/stm32-dac-core.c +4 -10
index 9a6a68b11b2a..bd7a3b20e645 100644
@@ -116,18 +116,12 @@ static int stm32_dac_probe(struct platform_device *pdev)
 	priv->common.regmap = regmap;
 
 	priv->pclk = devm_clk_get(dev, "pclk");
-	if (IS_ERR(priv->pclk)) {
-		ret = PTR_ERR(priv->pclk);
-		dev_err(dev, "pclk get failed\n");
-		return ret;
-	}
+	if (IS_ERR(priv->pclk))
+		return dev_err_probe(dev, PTR_ERR(priv->pclk), "pclk get failed\n");
 
 	priv->vref = devm_regulator_get(dev, "vref");
-	if (IS_ERR(priv->vref)) {
-		ret = PTR_ERR(priv->vref);
-		dev_err(dev, "vref get failed, %d\n", ret);
-		return ret;
-	}
+	if (IS_ERR(priv->vref))
+		return dev_err_probe(dev, PTR_ERR(priv->vref), "vref get failed\n");
 
 	pm_runtime_get_noresume(dev);
 	pm_runtime_set_active(dev);
Signature · 1 line
2.25.1
#8 lore raw

PATCH v2 8/8 iio: dac: ti-dac7311: Make use of the helper function dev_err_probe()

In reply to Cai Huoqing

When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value gets printed.

---
 drivers/iio/dac/ti-dac7311.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/iio/dac/ti-dac7311.c +3 -4
index 9d0b253be841..09218c3029f0 100644
@@ -266,10 +266,9 @@ static int ti_dac_probe(struct spi_device *spi)
 	ti_dac->resolution = spec->resolution;
 
 	ti_dac->vref = devm_regulator_get(dev, "vref");
-	if (IS_ERR(ti_dac->vref)) {
-		dev_err(dev, "error to get regulator\n");
-		return PTR_ERR(ti_dac->vref);
-	}
+	if (IS_ERR(ti_dac->vref))
+		return dev_err_probe(dev, PTR_ERR(ti_dac->vref),
+				     "error to get regulator\n");
 
 	ret = regulator_enable(ti_dac->vref);
 	if (ret < 0) {
Signature · 1 line
2.25.1
maintainer
#9 lore raw

Re: [PATCH v2 8/8] iio: dac: ti-dac7311: Make use of the helper function dev_err_probe()

Quoted 7 lines · On Tue, 28 Sep 2021 09:39:01 +0800 Cai Huoqing <[email protected]> wrote:

When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value gets printed.

Series applied to the togreg branch of iio.git and pushed out as testing for 0-day to see if it can find any problems before I push this out in a place where it can make a mess of linux-next

Thanks,

Jonathan

Quoted 22 lines
---
 drivers/iio/dac/ti-dac7311.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/iio/dac/ti-dac7311.c +3 -4
index 9d0b253be841..09218c3029f0 100644
@@ -266,10 +266,9 @@ static int ti_dac_probe(struct spi_device *spi)
 	ti_dac->resolution = spec->resolution;
 
 	ti_dac->vref = devm_regulator_get(dev, "vref");
-	if (IS_ERR(ti_dac->vref)) {
-		dev_err(dev, "error to get regulator\n");
-		return PTR_ERR(ti_dac->vref);
-	}
+	if (IS_ERR(ti_dac->vref))
+		return dev_err_probe(dev, PTR_ERR(ti_dac->vref),
+				     "error to get regulator\n");
 
 	ret = regulator_enable(ti_dac->vref);
 	if (ret < 0) {
maintainer
#10 lore raw
In reply to Cai Huoqing
Quoted 7 lines · On Tue, 28 Sep 2021 09:38:54 +0800 Cai Huoqing <[email protected]> wrote:

When possible use dev_err_probe help to properly deal with the PROBE_DEFER error, the benefit is that DEFER issue will be logged in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value gets printed.

Hi Cai,

I made a modification to this patch whilst applying as described below. Please take care to not mix different types of change like you did here in one patch.

With that change applied to the togreg branch of iio.git and pushed out as testing for 0-day to work it's magic and see if we missed anything,

Thanks,

Jonathan

Quoted 29 lines
---
 drivers/iio/dac/ad8801.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/iio/dac/ad8801.c +4 -6
index 6354b7c8f052..8acb9fee273c 100644
@@ -123,10 +123,9 @@ static int ad8801_probe(struct spi_device *spi)
 	id = spi_get_device_id(spi);
 
 	state->vrefh_reg = devm_regulator_get(&spi->dev, "vrefh");
-	if (IS_ERR(state->vrefh_reg)) {
-		dev_err(&spi->dev, "Vrefh regulator not specified\n");
-		return PTR_ERR(state->vrefh_reg);
-	}
+	if (IS_ERR(state->vrefh_reg))
+		return dev_err_probe(&spi->dev, PTR_ERR(state->vrefh_reg),
+				     "Vrefh regulator not specified\n");
 
 	ret = regulator_enable(state->vrefh_reg);
 	if (ret) {
@@ -146,15 +145,15 @@ static int ad8801_probe(struct spi_device *spi)
 	if (id->driver_data == ID_AD8803) {
 		state->vrefl_reg = devm_regulator_get(&spi->dev, "vrefl");
 		if (IS_ERR(state->vrefl_reg)) {
-			dev_err(&spi->dev, "Vrefl regulator not specified\n");
-			ret = PTR_ERR(state->vrefl_reg);
+			ret = dev_err_probe(&spi->dev, PTR_ERR(state->vrefl_reg),

drivers/iio/dac/ad8801.c static int ad8801_probe(struct spi_device *spi) · line 156

Quoted 10 lines
drivers/iio/dac/ad8801.c +3 -2
+					    "Vrefl regulator not specified\n");
 			goto error_disable_vrefh_reg;
 		}
 
 		ret = regulator_enable(state->vrefl_reg);
 		if (ret) {
-			dev_err(&spi->dev, "Failed to enable vrefl regulator: %d\n",
-					ret);
+			dev_err(&spi->dev,
+				"Failed to enable vrefl regulator: %d\n", ret);

This last change is unconnected to the rest of the patch. I've dropped it whilst applying.

Quoted 3 lines
drivers/iio/dac/ad8801.c +0 -0
 			goto error_disable_vrefh_reg;
 		}