Skip to contentSkip to conversation

iio: accel: bma180: Simplify with dev_err_probe()

PATCH In review Krzysztof Kozlowski 6 participants 31 messages Aug 29, 2020 – Sep 10, 2020 1 message not in the archive

Subsystems (14)
lore
Share & tools
lore

Krzysztof Kozlowski

author maintainer
#0 lore raw

PATCH v3 1/18 iio: accel: bma180: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---
 drivers/iio/accel/bma180.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/iio/accel/bma180.c +8 -12
index 5b7a467c7b27..448faed001fd 100644
@@ -1000,19 +1000,15 @@ static int bma180_probe(struct i2c_client *client,
 		return ret;
 
 	data->vdd_supply = devm_regulator_get(dev, "vdd");
-	if (IS_ERR(data->vdd_supply)) {
-		if (PTR_ERR(data->vdd_supply) != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get vdd regulator %d\n",
-				(int)PTR_ERR(data->vdd_supply));
-		return PTR_ERR(data->vdd_supply);
-	}
+	if (IS_ERR(data->vdd_supply))
+		return dev_err_probe(dev, PTR_ERR(data->vdd_supply),
+				     "Failed to get vdd regulator\n");
+
 	data->vddio_supply = devm_regulator_get(dev, "vddio");
-	if (IS_ERR(data->vddio_supply)) {
-		if (PTR_ERR(data->vddio_supply) != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get vddio regulator %d\n",
-				(int)PTR_ERR(data->vddio_supply));
-		return PTR_ERR(data->vddio_supply);
-	}
+	if (IS_ERR(data->vddio_supply))
+		return dev_err_probe(dev, PTR_ERR(data->vddio_supply),
+				     "Failed to get vddio regulator\n");
+
 	/* Typical voltage 2.4V these are min and max */
 	ret = regulator_set_voltage(data->vdd_supply, 1620000, 3600000);
 	if (ret)
Signature · 1 line
2.17.1
author maintainer
#1 lore raw

PATCH v3 2/18 iio: accel: mma8452: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---
 drivers/iio/accel/mma8452.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/iio/accel/mma8452.c +6 -14
index 4e6e70250048..104b87b98455 100644
@@ -1538,22 +1538,14 @@ static int mma8452_probe(struct i2c_client *client,
 	data->chip_info = match->data;
 
 	data->vdd_reg = devm_regulator_get(&client->dev, "vdd");
-	if (IS_ERR(data->vdd_reg)) {
-		if (PTR_ERR(data->vdd_reg) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
-
-		dev_err(&client->dev, "failed to get VDD regulator!\n");
-		return PTR_ERR(data->vdd_reg);
-	}
+	if (IS_ERR(data->vdd_reg))
+		return dev_err_probe(&client->dev, PTR_ERR(data->vdd_reg),
+				     "failed to get VDD regulator!\n");
 
 	data->vddio_reg = devm_regulator_get(&client->dev, "vddio");
-	if (IS_ERR(data->vddio_reg)) {
-		if (PTR_ERR(data->vddio_reg) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
-
-		dev_err(&client->dev, "failed to get VDDIO regulator!\n");
-		return PTR_ERR(data->vddio_reg);
-	}
+	if (IS_ERR(data->vddio_reg))
+		return dev_err_probe(&client->dev, PTR_ERR(data->vddio_reg),
+				     "failed to get VDDIO regulator!\n");
 
 	ret = regulator_enable(data->vdd_reg);
 	if (ret) {
Signature · 1 line
2.17.1
author maintainer
#2 lore raw

PATCH v3 3/18 iio: adc: envelope-detector: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---

Changes since v2:
1. Wrap dev_err_probe() lines at 80 character

Changes since v1:
1. Wrap dev_err_probe() lines at 100 character

---
 drivers/iio/adc/envelope-detector.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/iio/adc/envelope-detector.c +6 -10
index 2a4fd3bb64cf..d73eac36153f 100644
@@ -348,11 +348,9 @@ static int envelope_detector_probe(struct platform_device *pdev)
 	indio_dev->num_channels = 1;
 
 	env->dac = devm_iio_channel_get(dev, "dac");
-	if (IS_ERR(env->dac)) {
-		if (PTR_ERR(env->dac) != -EPROBE_DEFER)
-			dev_err(dev, "failed to get dac input channel\n");
-		return PTR_ERR(env->dac);
-	}
+	if (IS_ERR(env->dac))
+		return dev_err_probe(dev, PTR_ERR(env->dac),
+				     "failed to get dac input channel\n");
 
 	env->comp_irq = platform_get_irq_byname(pdev, "comp");
 	if (env->comp_irq < 0)
@@ -360,11 +358,9 @@ static int envelope_detector_probe(struct platform_device *pdev)
 
 	ret = devm_request_irq(dev, env->comp_irq, envelope_detector_comp_isr,
 			       0, "envelope-detector", env);
-	if (ret) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "failed to request interrupt\n");
-		return ret;
-	}
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to request interrupt\n");
+
 	env->comp_irq_trigger = irq_get_trigger_type(env->comp_irq);
 	if (env->comp_irq_trigger & IRQF_TRIGGER_RISING)
 		env->comp_irq_trigger_inv |= IRQF_TRIGGER_FALLING;
Signature · 1 line
2.17.1
author maintainer
#4 lore raw

PATCH v3 4/18 iio: adc: exynos_adc: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---

Changes since v2:
1. Wrap dev_err_probe() lines at 80 character

Changes since v1:
1. Wrap dev_err_probe() lines at 100 character

---
 drivers/iio/adc/exynos_adc.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/iio/adc/exynos_adc.c +3 -7
index 7d23b6c33284..20477b249f2a 100644
@@ -844,13 +844,9 @@ static int exynos_adc_probe(struct platform_device *pdev)
 	}
 
 	info->vdd = devm_regulator_get(&pdev->dev, "vdd");
-	if (IS_ERR(info->vdd)) {
-		if (PTR_ERR(info->vdd) != -EPROBE_DEFER)
-			dev_err(&pdev->dev,
-				"failed getting regulator, err = %ld\n",
-				PTR_ERR(info->vdd));
-		return PTR_ERR(info->vdd);
-	}
+	if (IS_ERR(info->vdd))
+		return dev_err_probe(&pdev->dev, PTR_ERR(info->vdd),
+				     "failed getting regulator");
 
 	ret = regulator_enable(info->vdd);
 	if (ret)
Signature · 7 lines
2.17.1


_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
author maintainer
#5 lore raw

PATCH v3 5/18 iio: adc: ltc2497: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---

Changes since v2:
1. Wrap dev_err_probe() lines at 80 character

Changes since v1:
1. Wrap dev_err_probe() lines at 100 character

---
 drivers/iio/adc/ltc2497-core.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/iio/adc/ltc2497-core.c +3 -7
index 9b8fd9c32364..2a485c8a1940 100644
@@ -180,13 +180,9 @@ int ltc2497core_probe(struct device *dev, struct iio_dev *indio_dev)
 		return ret;
 
 	ddata->ref = devm_regulator_get(dev, "vref");
-	if (IS_ERR(ddata->ref)) {
-		if (PTR_ERR(ddata->ref) != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get vref regulator: %pe\n",
-				ddata->ref);
-
-		return PTR_ERR(ddata->ref);
-	}
+	if (IS_ERR(ddata->ref))
+		return dev_err_probe(dev, PTR_ERR(ddata->ref),
+				     "Failed to get vref regulator\n");
 
 	ret = regulator_enable(ddata->ref);
 	if (ret < 0) {
Signature · 1 line
2.17.1
author maintainer
#6 lore raw

PATCH v3 6/18 iio: adc: meson_saradc: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---
 drivers/iio/adc/meson_saradc.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/iio/adc/meson_saradc.c +2 -5
index 93c2252c0b89..a9d06e8a576a 100644
@@ -719,11 +719,8 @@ static int meson_sar_adc_temp_sensor_init(struct iio_dev *indio_dev)
 		if (ret == -ENODEV)
 			return 0;
 
-		if (ret != -EPROBE_DEFER)
-			dev_err(indio_dev->dev.parent,
-				"failed to get temperature_calib cell\n");
-
-		return ret;
+		return dev_err_probe(indio_dev->dev.parent, ret,
+				     "failed to get temperature_calib cell\n");
 	}
 
 	priv->tsc_regmap =
Signature · 1 line
2.17.1
author maintainer
#8 lore raw

PATCH v3 7/18 iio: adc: rcar-gyroadc: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---

Changes since v2:
1. Wrap dev_err_probe() lines at 80 character

Changes since v1:
1. Wrap dev_err_probe() lines at 100 character

---
 drivers/iio/adc/rcar-gyroadc.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/iio/adc/rcar-gyroadc.c +3 -6
index d2c1419e72a0..dcaefc108ff6 100644
@@ -495,12 +495,9 @@ static int rcar_gyroadc_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->regs);
 
 	priv->clk = devm_clk_get(dev, "fck");
-	if (IS_ERR(priv->clk)) {
-		ret = PTR_ERR(priv->clk);
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get IF clock (ret=%i)\n", ret);
-		return ret;
-	}
+	if (IS_ERR(priv->clk))
+		return dev_err_probe(dev, PTR_ERR(priv->clk),
+				     "Failed to get IF clock\n");
 
 	ret = rcar_gyroadc_parse_subdevs(indio_dev);
 	if (ret)
Signature · 1 line
2.17.1
author maintainer
#9 lore raw

PATCH v3 8/18 iio: adc: stm32: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---

Changes since v2:
1. Wrap dev_err_probe() lines at 80 character

Changes since v1:
1. Convert to devm_clk_get_optional
2. Update also stm32-dfsdm-core and stm32-dac-core.
3. Wrap around 100 characters (accepted by checkpatch).

---
 drivers/iio/adc/stm32-adc-core.c   | 75 ++++++++++--------------------
 drivers/iio/adc/stm32-adc.c        | 10 ++--
 drivers/iio/adc/stm32-dfsdm-adc.c  | 10 ++--
 drivers/iio/adc/stm32-dfsdm-core.c |  9 ++--
 drivers/iio/dac/stm32-dac-core.c   |  5 +-
 5 files changed, 35 insertions(+), 74 deletions(-)
drivers/iio/adc/stm32-adc-core.c +25 -50
index 0e2068ec068b..3f27b4817a42 100644
@@ -582,11 +582,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
 	priv->syscfg = syscon_regmap_lookup_by_phandle(np, "st,syscfg");
 	if (IS_ERR(priv->syscfg)) {
 		ret = PTR_ERR(priv->syscfg);
-		if (ret != -ENODEV) {
-			if (ret != -EPROBE_DEFER)
-				dev_err(dev, "Can't probe syscfg: %d\n", ret);
-			return ret;
-		}
+		if (ret != -ENODEV)
+			return dev_err_probe(dev, ret, "Can't probe syscfg\n");
+
 		priv->syscfg = NULL;
 	}
 
@@ -596,12 +594,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
 		priv->booster = devm_regulator_get_optional(dev, "booster");
 		if (IS_ERR(priv->booster)) {
 			ret = PTR_ERR(priv->booster);
-			if (ret != -ENODEV) {
-				if (ret != -EPROBE_DEFER)
-					dev_err(dev, "can't get booster %d\n",
-						ret);
-				return ret;
-			}
+			if (ret != -ENODEV)
+				dev_err_probe(dev, ret, "can't get booster\n");
+
 			priv->booster = NULL;
 		}
 	}
@@ -612,11 +607,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
 		priv->vdd = devm_regulator_get_optional(dev, "vdd");
 		if (IS_ERR(priv->vdd)) {
 			ret = PTR_ERR(priv->vdd);
-			if (ret != -ENODEV) {
-				if (ret != -EPROBE_DEFER)
-					dev_err(dev, "can't get vdd %d\n", ret);
-				return ret;
-			}
+			if (ret != -ENODEV)
+				return dev_err_probe(dev, ret, "can't get vdd\n");
+
 			priv->vdd = NULL;
 		}
 	}
@@ -669,42 +662,24 @@ static int stm32_adc_probe(struct platform_device *pdev)
 	priv->common.phys_base = res->start;
 
 	priv->vdda = devm_regulator_get(&pdev->dev, "vdda");
-	if (IS_ERR(priv->vdda)) {
-		ret = PTR_ERR(priv->vdda);
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "vdda get failed, %d\n", ret);
-		return ret;
-	}
+	if (IS_ERR(priv->vdda))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->vdda),
+				     "vdda get failed\n");
 
 	priv->vref = devm_regulator_get(&pdev->dev, "vref");
-	if (IS_ERR(priv->vref)) {
-		ret = PTR_ERR(priv->vref);
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "vref get failed, %d\n", ret);
-		return ret;
-	}
-
-	priv->aclk = devm_clk_get(&pdev->dev, "adc");
-	if (IS_ERR(priv->aclk)) {
-		ret = PTR_ERR(priv->aclk);
-		if (ret != -ENOENT) {
-			if (ret != -EPROBE_DEFER)
-				dev_err(&pdev->dev, "Can't get 'adc' clock\n");
-			return ret;
-		}
-		priv->aclk = NULL;
-	}
-
-	priv->bclk = devm_clk_get(&pdev->dev, "bus");
-	if (IS_ERR(priv->bclk)) {
-		ret = PTR_ERR(priv->bclk);
-		if (ret != -ENOENT) {
-			if (ret != -EPROBE_DEFER)
-				dev_err(&pdev->dev, "Can't get 'bus' clock\n");
-			return ret;
-		}
-		priv->bclk = NULL;
-	}
+	if (IS_ERR(priv->vref))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->vref),
+				     "vref get failed\n");
+
+	priv->aclk = devm_clk_get_optional(&pdev->dev, "adc");
+	if (IS_ERR(priv->aclk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->aclk),
+				     "Can't get 'adc' clock\n");
+
+	priv->bclk = devm_clk_get_optional(&pdev->dev, "bus");
+	if (IS_ERR(priv->bclk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->bclk),
+				     "Can't get 'bus' clock\n");
 
 	ret = stm32_adc_core_switches_probe(dev, priv);
 	if (ret)
drivers/iio/adc/stm32-adc.c +3 -7
index 3eb9ebe8372f..b3f31f147347 100644
@@ -1805,13 +1805,9 @@ static int stm32_adc_dma_request(struct device *dev, struct iio_dev *indio_dev)
 	adc->dma_chan = dma_request_chan(dev, "rx");
 	if (IS_ERR(adc->dma_chan)) {
 		ret = PTR_ERR(adc->dma_chan);
-		if (ret != -ENODEV) {
-			if (ret != -EPROBE_DEFER)
-				dev_err(dev,
-					"DMA channel request failed with %d\n",
-					ret);
-			return ret;
-		}
+		if (ret != -ENODEV)
+			return dev_err_probe(dev, ret,
+					     "DMA channel request failed with\n");
 
 		/* DMA is optional: fall back to IRQ mode */
 		adc->dma_chan = NULL;
drivers/iio/adc/stm32-dfsdm-adc.c +3 -7
index 5e10fb4f3704..c7e0109315f8 100644
@@ -1473,13 +1473,9 @@ static int stm32_dfsdm_adc_init(struct device *dev, struct iio_dev *indio_dev)
 	/* Optionally request DMA */
 	ret = stm32_dfsdm_dma_request(dev, indio_dev);
 	if (ret) {
-		if (ret != -ENODEV) {
-			if (ret != -EPROBE_DEFER)
-				dev_err(dev,
-					"DMA channel request failed with %d\n",
-					ret);
-			return ret;
-		}
+		if (ret != -ENODEV)
+			return dev_err_probe(dev, ret,
+					     "DMA channel request failed with\n");
 
 		dev_dbg(dev, "No DMA support\n");
 		return 0;
drivers/iio/adc/stm32-dfsdm-core.c +3 -6
index 26e2011c5868..0b8bea88b011 100644
@@ -243,12 +243,9 @@ static int stm32_dfsdm_parse_of(struct platform_device *pdev,
 	 * on use case.
 	 */
 	priv->clk = devm_clk_get(&pdev->dev, "dfsdm");
-	if (IS_ERR(priv->clk)) {
-		ret = PTR_ERR(priv->clk);
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Failed to get clock (%d)\n", ret);
-		return ret;
-	}
+	if (IS_ERR(priv->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->clk),
+				     "Failed to get clock\n");
 
 	priv->aclk = devm_clk_get(&pdev->dev, "audio");
 	if (IS_ERR(priv->aclk))
drivers/iio/dac/stm32-dac-core.c +1 -4
index 7e5809ba0dee..906436780347 100644
@@ -150,10 +150,7 @@ static int stm32_dac_probe(struct platform_device *pdev)
 	rst = devm_reset_control_get_optional_exclusive(dev, NULL);
 	if (rst) {
 		if (IS_ERR(rst)) {
-			ret = PTR_ERR(rst);
-			if (ret != -EPROBE_DEFER)
-				dev_err(dev, "reset get failed, %d\n", ret);
-
+			ret = dev_err_probe(dev, PTR_ERR(rst), "reset get failed\n");
 			goto err_hw_stop;
 		}
 
Signature · 1 line
2.17.1
maintainer
#10 lore raw

Re: [PATCH v3 08/18] iio: adc: stm32: Simplify with dev_err_probe()

Quoted 6 lines · On Sat, 29 Aug 2020 08:47:16 +0200 Krzysztof Kozlowski <[email protected]> wrote:

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

I don't have the thread to hand, but this tripped a warning next and the patch was dropped as a result. See below.

Jonathan

Quoted 38 lines

---

Changes since v2:
1. Wrap dev_err_probe() lines at 80 character

Changes since v1:
1. Convert to devm_clk_get_optional
2. Update also stm32-dfsdm-core and stm32-dac-core.
3. Wrap around 100 characters (accepted by checkpatch).

---
 drivers/iio/adc/stm32-adc-core.c   | 75 ++++++++++--------------------
 drivers/iio/adc/stm32-adc.c        | 10 ++--
 drivers/iio/adc/stm32-dfsdm-adc.c  | 10 ++--
 drivers/iio/adc/stm32-dfsdm-core.c |  9 ++--
 drivers/iio/dac/stm32-dac-core.c   |  5 +-
 5 files changed, 35 insertions(+), 74 deletions(-)
drivers/iio/adc/stm32-adc-core.c +3 -5
index 0e2068ec068b..3f27b4817a42 100644
@@ -582,11 +582,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
 	priv->syscfg = syscon_regmap_lookup_by_phandle(np, "st,syscfg");
 	if (IS_ERR(priv->syscfg)) {
 		ret = PTR_ERR(priv->syscfg);
-		if (ret != -ENODEV) {
-			if (ret != -EPROBE_DEFER)
-				dev_err(dev, "Can't probe syscfg: %d\n", ret);
-			return ret;
-		}
+		if (ret != -ENODEV)
+			return dev_err_probe(dev, ret, "Can't probe syscfg\n");
+
 		priv->syscfg = NULL;
 	}
 
@@ -596,12 +594,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
 		priv->booster = devm_regulator_get_optional(dev, "booster");

drivers/iio/adc/stm32-adc-core.c static int stm32_adc_core_switches_probe(struct device *dev, · line 598

Quoted 10 lines
drivers/iio/adc/stm32-adc-core.c +2 -6
 		if (IS_ERR(priv->booster)) {
 			ret = PTR_ERR(priv->booster);
-			if (ret != -ENODEV) {
-				if (ret != -EPROBE_DEFER)
-					dev_err(dev, "can't get booster %d\n",
-						ret);
-				return ret;
-			}
+			if (ret != -ENODEV)
+				dev_err_probe(dev, ret, "can't get booster\n");

This tripped a warning and got the patch dropped because we no longer return on error.

Quoted 156 lines
drivers/iio/adc/stm32-adc-core.c +20 -39
+
 			priv->booster = NULL;
 		}
 	}
@@ -612,11 +607,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
 		priv->vdd = devm_regulator_get_optional(dev, "vdd");
 		if (IS_ERR(priv->vdd)) {
 			ret = PTR_ERR(priv->vdd);
-			if (ret != -ENODEV) {
-				if (ret != -EPROBE_DEFER)
-					dev_err(dev, "can't get vdd %d\n", ret);
-				return ret;
-			}
+			if (ret != -ENODEV)
+				return dev_err_probe(dev, ret, "can't get vdd\n");
+
 			priv->vdd = NULL;
 		}
 	}
@@ -669,42 +662,24 @@ static int stm32_adc_probe(struct platform_device *pdev)
 	priv->common.phys_base = res->start;
 
 	priv->vdda = devm_regulator_get(&pdev->dev, "vdda");
-	if (IS_ERR(priv->vdda)) {
-		ret = PTR_ERR(priv->vdda);
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "vdda get failed, %d\n", ret);
-		return ret;
-	}
+	if (IS_ERR(priv->vdda))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->vdda),
+				     "vdda get failed\n");
 
 	priv->vref = devm_regulator_get(&pdev->dev, "vref");
-	if (IS_ERR(priv->vref)) {
-		ret = PTR_ERR(priv->vref);
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "vref get failed, %d\n", ret);
-		return ret;
-	}
-
-	priv->aclk = devm_clk_get(&pdev->dev, "adc");
-	if (IS_ERR(priv->aclk)) {
-		ret = PTR_ERR(priv->aclk);
-		if (ret != -ENOENT) {
-			if (ret != -EPROBE_DEFER)
-				dev_err(&pdev->dev, "Can't get 'adc' clock\n");
-			return ret;
-		}
-		priv->aclk = NULL;
-	}
-
-	priv->bclk = devm_clk_get(&pdev->dev, "bus");
-	if (IS_ERR(priv->bclk)) {
-		ret = PTR_ERR(priv->bclk);
-		if (ret != -ENOENT) {
-			if (ret != -EPROBE_DEFER)
-				dev_err(&pdev->dev, "Can't get 'bus' clock\n");
-			return ret;
-		}
-		priv->bclk = NULL;
-	}
+	if (IS_ERR(priv->vref))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->vref),
+				     "vref get failed\n");
+
+	priv->aclk = devm_clk_get_optional(&pdev->dev, "adc");
+	if (IS_ERR(priv->aclk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->aclk),
+				     "Can't get 'adc' clock\n");
+
+	priv->bclk = devm_clk_get_optional(&pdev->dev, "bus");
+	if (IS_ERR(priv->bclk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->bclk),
+				     "Can't get 'bus' clock\n");
 
 	ret = stm32_adc_core_switches_probe(dev, priv);
 	if (ret)
drivers/iio/adc/stm32-adc.c +3 -7
index 3eb9ebe8372f..b3f31f147347 100644
@@ -1805,13 +1805,9 @@ static int stm32_adc_dma_request(struct device *dev, struct iio_dev *indio_dev)
 	adc->dma_chan = dma_request_chan(dev, "rx");
 	if (IS_ERR(adc->dma_chan)) {
 		ret = PTR_ERR(adc->dma_chan);
-		if (ret != -ENODEV) {
-			if (ret != -EPROBE_DEFER)
-				dev_err(dev,
-					"DMA channel request failed with %d\n",
-					ret);
-			return ret;
-		}
+		if (ret != -ENODEV)
+			return dev_err_probe(dev, ret,
+					     "DMA channel request failed with\n");
 
 		/* DMA is optional: fall back to IRQ mode */
 		adc->dma_chan = NULL;
drivers/iio/adc/stm32-dfsdm-adc.c +3 -7
index 5e10fb4f3704..c7e0109315f8 100644
@@ -1473,13 +1473,9 @@ static int stm32_dfsdm_adc_init(struct device *dev, struct iio_dev *indio_dev)
 	/* Optionally request DMA */
 	ret = stm32_dfsdm_dma_request(dev, indio_dev);
 	if (ret) {
-		if (ret != -ENODEV) {
-			if (ret != -EPROBE_DEFER)
-				dev_err(dev,
-					"DMA channel request failed with %d\n",
-					ret);
-			return ret;
-		}
+		if (ret != -ENODEV)
+			return dev_err_probe(dev, ret,
+					     "DMA channel request failed with\n");
 
 		dev_dbg(dev, "No DMA support\n");
 		return 0;
drivers/iio/adc/stm32-dfsdm-core.c +3 -6
index 26e2011c5868..0b8bea88b011 100644
@@ -243,12 +243,9 @@ static int stm32_dfsdm_parse_of(struct platform_device *pdev,
 	 * on use case.
 	 */
 	priv->clk = devm_clk_get(&pdev->dev, "dfsdm");
-	if (IS_ERR(priv->clk)) {
-		ret = PTR_ERR(priv->clk);
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Failed to get clock (%d)\n", ret);
-		return ret;
-	}
+	if (IS_ERR(priv->clk))
+		return dev_err_probe(&pdev->dev, PTR_ERR(priv->clk),
+				     "Failed to get clock\n");
 
 	priv->aclk = devm_clk_get(&pdev->dev, "audio");
 	if (IS_ERR(priv->aclk))
drivers/iio/dac/stm32-dac-core.c +1 -4
index 7e5809ba0dee..906436780347 100644
@@ -150,10 +150,7 @@ static int stm32_dac_probe(struct platform_device *pdev)
 	rst = devm_reset_control_get_optional_exclusive(dev, NULL);
 	if (rst) {
 		if (IS_ERR(rst)) {
-			ret = PTR_ERR(rst);
-			if (ret != -EPROBE_DEFER)
-				dev_err(dev, "reset get failed, %d\n", ret);
-
+			ret = dev_err_probe(dev, PTR_ERR(rst), "reset get failed\n");
 			goto err_hw_stop;
 		}
 
author maintainer
#11 lore raw

Re: [PATCH v3 08/18] iio: adc: stm32: Simplify with dev_err_probe()

Quoted 4 lines · Jonathan Cameron

On Sat, 29 Aug 2020 08:47:16 +0200
Krzysztof Kozlowski <[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

I don't have the thread to hand, but this tripped a warning next and the patch was dropped as a result. See below.

Thanks for letting me know. If you mean the warning caused by:
https://lore.kernel.org/lkml/[email protected]/
then the driver-core patch was dropped, not the iio one:
https://lore.kernel.org/linux-next/[email protected]/T/#t

So we are good here :)

Best regards,
Krzysztof

Quoted 52 lines

Jonathan

Quoted 38 lines

---

Changes since v2:
1. Wrap dev_err_probe() lines at 80 character

Changes since v1:
1. Convert to devm_clk_get_optional
2. Update also stm32-dfsdm-core and stm32-dac-core.
3. Wrap around 100 characters (accepted by checkpatch).

---
 drivers/iio/adc/stm32-adc-core.c   | 75 ++++++++++--------------------
 drivers/iio/adc/stm32-adc.c        | 10 ++--
 drivers/iio/adc/stm32-dfsdm-adc.c  | 10 ++--
 drivers/iio/adc/stm32-dfsdm-core.c |  9 ++--
 drivers/iio/dac/stm32-dac-core.c   |  5 +-
 5 files changed, 35 insertions(+), 74 deletions(-)
drivers/iio/adc/stm32-adc-core.c +3 -5
index 0e2068ec068b..3f27b4817a42 100644
@@ -582,11 +582,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
      priv->syscfg = syscon_regmap_lookup_by_phandle(np, "st,syscfg");
      if (IS_ERR(priv->syscfg)) {
              ret = PTR_ERR(priv->syscfg);
-             if (ret != -ENODEV) {
-                     if (ret != -EPROBE_DEFER)
-                             dev_err(dev, "Can't probe syscfg: %d\n", ret);
-                     return ret;
-             }
+             if (ret != -ENODEV)
+                     return dev_err_probe(dev, ret, "Can't probe syscfg\n");
+
              priv->syscfg = NULL;
      }
 
@@ -596,12 +594,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
              priv->booster = devm_regulator_get_optional(dev, "booster");

drivers/iio/adc/stm32-adc-core.c static int stm32_adc_core_switches_probe(struct device *dev, · line 598

Quoted 10 lines
drivers/iio/adc/stm32-adc-core.c +2 -6
              if (IS_ERR(priv->booster)) {
                      ret = PTR_ERR(priv->booster);
-                     if (ret != -ENODEV) {
-                             if (ret != -EPROBE_DEFER)
-                                     dev_err(dev, "can't get booster %d\n",
-                                             ret);
-                             return ret;
-                     }
+                     if (ret != -ENODEV)
+                             dev_err_probe(dev, ret, "can't get booster\n");

This tripped a warning and got the patch dropped because we no longer return on error.

#12 lore raw

Re: [PATCH v3 08/18] iio: adc: stm32: Simplify with dev_err_probe()

Hi!

Quoted 14 lines · Krzysztof Kozlowski
Quoted 4 lines · Jonathan Cameron

On Sat, 29 Aug 2020 08:47:16 +0200
Krzysztof Kozlowski <[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

I don't have the thread to hand, but this tripped a warning next and the patch was dropped as a result. See below.

Quoted 6 lines

Thanks for letting me know. If you mean the warning caused by:
https://lore.kernel.org/lkml/[email protected]/
then the driver-core patch was dropped, not the iio one:
https://lore.kernel.org/linux-next/[email protected]/T/#t

So we are good here :)

No, we are definitely not good. See below. That means "See below", and not "Please take a guess at what is being talking about".

Quoted 55 lines

Best regards,
Krzysztof

Quoted 52 lines

Jonathan

Quoted 38 lines

---

Changes since v2:
1. Wrap dev_err_probe() lines at 80 character

Changes since v1:
1. Convert to devm_clk_get_optional
2. Update also stm32-dfsdm-core and stm32-dac-core.
3. Wrap around 100 characters (accepted by checkpatch).

---
 drivers/iio/adc/stm32-adc-core.c   | 75 ++++++++++--------------------
 drivers/iio/adc/stm32-adc.c        | 10 ++--
 drivers/iio/adc/stm32-dfsdm-adc.c  | 10 ++--
 drivers/iio/adc/stm32-dfsdm-core.c |  9 ++--
 drivers/iio/dac/stm32-dac-core.c   |  5 +-
 5 files changed, 35 insertions(+), 74 deletions(-)
drivers/iio/adc/stm32-adc-core.c +3 -5
index 0e2068ec068b..3f27b4817a42 100644
@@ -582,11 +582,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
      priv->syscfg = syscon_regmap_lookup_by_phandle(np, "st,syscfg");
      if (IS_ERR(priv->syscfg)) {
              ret = PTR_ERR(priv->syscfg);
-             if (ret != -ENODEV) {
-                     if (ret != -EPROBE_DEFER)
-                             dev_err(dev, "Can't probe syscfg: %d\n", ret);
-                     return ret;
-             }
+             if (ret != -ENODEV)
+                     return dev_err_probe(dev, ret, "Can't probe syscfg\n");
+
              priv->syscfg = NULL;
      }
 
@@ -596,12 +594,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
              priv->booster = devm_regulator_get_optional(dev, "booster");

drivers/iio/adc/stm32-adc-core.c static int stm32_adc_core_switches_probe(struct device *dev, · line 598

Quoted 10 lines
drivers/iio/adc/stm32-adc-core.c +2 -6
              if (IS_ERR(priv->booster)) {
                      ret = PTR_ERR(priv->booster);
-                     if (ret != -ENODEV) {
-                             if (ret != -EPROBE_DEFER)
-                                     dev_err(dev, "can't get booster %d\n",
-                                             ret);
-                             return ret;
-                     }
+                     if (ret != -ENODEV)
+                             dev_err_probe(dev, ret, "can't get booster\n");

This tripped a warning and got the patch dropped because we no longer return on error.

As Jonathan already said, we no longer return in this hunk. I.e., you have clobbered the error path.

Cheers,
Peter

A message that is not in the archive (sent off-list or not yet received): CAHp75Vc4-zkkWtOz8w7pA0Vu1yMAVodhPSLQ1NJH4K+j9XD52g@mail.gmail.com

author maintainer
#14 lore raw

Re: [PATCH v3 08/18] iio: adc: stm32: Simplify with dev_err_probe()

Quoted 51 lines · Andy Shevchenko
Quoted 47 lines · Peter Rosin

Hi!

Quoted 14 lines · Krzysztof Kozlowski
Quoted 4 lines · Jonathan Cameron

On Sat, 29 Aug 2020 08:47:16 +0200
Krzysztof Kozlowski <[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

I don't have the thread to hand, but this tripped a warning next and the patch was dropped as a result. See below.

Quoted 6 lines

Thanks for letting me know. If you mean the warning caused by:
https://lore.kernel.org/lkml/[email protected]/
then the driver-core patch was dropped, not the iio one:
https://lore.kernel.org/linux-next/[email protected]/T/#t

So we are good here :)

No, we are definitely not good. See below. That means "See below", and not "Please take a guess at what is being talking about".

Quoted 15 lines
Quoted 15 lines

drivers/iio/adc/stm32-adc-core.c static int stm32_adc_core_switches_probe(struct device *dev, · line 598

Quoted 12 lines
drivers/iio/adc/stm32-adc-core.c +2 -6
@@ -596,12 +594,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
              priv->booster = devm_regulator_get_optional(dev, "booster");
              if (IS_ERR(priv->booster)) {
                      ret = PTR_ERR(priv->booster);
-                     if (ret != -ENODEV) {
-                             if (ret != -EPROBE_DEFER)
-                                     dev_err(dev, "can't get booster %d\n",
-                                             ret);
-                             return ret;
-                     }
+                     if (ret != -ENODEV)
+                             dev_err_probe(dev, ret, "can't get booster\n");

This tripped a warning and got the patch dropped because we no longer return on error.

Quoted 5 lines
Quoted 2 lines

As Jonathan already said, we no longer return in this hunk. I.e., you have clobbered the error path.

Exactly my point why I proposed _must_check in the first place.

That was not exactly that point as you did not mention possible errors but only "miss the opportunity to optimize". Optimization is different things than a mistake.

Best regards,
Krzysztof

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

#15 lore raw

Re: [PATCH v3 08/18] iio: adc: stm32: Simplify with dev_err_probe()

Quoted 14 lines · On Thu, 10 Sep 2020 08:58:57 +0200 Krzysztof Kozlowski <[email protected]> wrote:
Quoted 13 lines · Andy Shevchenko
Quoted 9 lines · Peter Rosin

Hi!

Quoted 5 lines · Krzysztof Kozlowski
Quoted 4 lines · Jonathan Cameron

On Sat, 29 Aug 2020 08:47:16 +0200
Krzysztof Kozlowski <[email protected]> wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

I don't have the thread to hand, but this tripped a warning next and the patch was dropped as a result. See below.

oops. That is what I get for reading an email very quickly then looking at the code a few hours later. Still a problem here we need to fix unless I'm missing something.

Quoted 34 lines
Quoted 34 lines
Quoted 32 lines
Quoted 7 lines

Thanks for letting me know. If you mean the warning caused by:
https://lore.kernel.org/lkml/[email protected]/
then the driver-core patch was dropped, not the iio one:
https://lore.kernel.org/linux-next/[email protected]/T/#t

So we are good here :)

No, we are definitely not good. See below. That means "See below", and not "Please take a guess at what is being talking about".

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/iio/adc/stm32-adc-core.c +0 -3
@@ -596,12 +594,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
              priv->booster = devm_regulator_get_optional(dev, "booster");
              if (IS_ERR(priv->booster)) {
                      ret = PTR_ERR(priv->booster);
-                     if (ret != -ENODEV) {
-                             if (ret != -EPROBE_DEFER)
-                                     dev_err(dev, "can't get booster %d\n",
Quoted 8 lines
Quoted 8 lines

drivers/iio/adc/stm32-adc-core.c static int stm32_adc_core_switches_probe(struct device *dev, · line 598

Quoted 5 lines
drivers/iio/adc/stm32-adc-core.c +2 -3
-                                             ret);
-                             return ret;
-                     }
+                     if (ret != -ENODEV)
+                             dev_err_probe(dev, ret, "can't get booster\n");  

This tripped a warning and got the patch dropped because we no longer return on error.

As Jonathan already said, we no longer return in this hunk. I.e., you have clobbered the error path.

Quoted 5 lines
Quoted 1 line

Exactly my point why I proposed _must_check in the first place.

That was not exactly that point as you did not mention possible errors but only "miss the opportunity to optimize". Optimization is different things than a mistake.

In this particular case we have introduced a bug. If the regulator returns an error other than -ENODEV we will carry on when really should error out. This includes deferred probe route in which it won't print a message but also won't actually defer.

Jonathan

Quoted 8 lines

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

author maintainer
#16 lore raw

Re: [PATCH v3 08/18] iio: adc: stm32: Simplify with dev_err_probe()

Quoted 67 lines · Jonathan Cameron
Quoted 14 lines · On Thu, 10 Sep 2020 08:58:57 +0200 Krzysztof Kozlowski <[email protected]> wrote:
Quoted 13 lines · Andy Shevchenko
Quoted 9 lines · Peter Rosin

Hi!

Quoted 5 lines · Krzysztof Kozlowski
Quoted 4 lines · Jonathan Cameron

On Sat, 29 Aug 2020 08:47:16 +0200
Krzysztof Kozlowski <[email protected]> wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

I don't have the thread to hand, but this tripped a warning next and the patch was dropped as a result. See below.

oops. That is what I get for reading an email very quickly then looking at the code a few hours later. Still a problem here we need to fix unless I'm missing something.

Quoted 36 lines
Quoted 35 lines
Quoted 30 lines
Quoted 7 lines

Thanks for letting me know. If you mean the warning caused by:
https://lore.kernel.org/lkml/[email protected]/
then the driver-core patch was dropped, not the iio one:
https://lore.kernel.org/linux-next/[email protected]/T/#t

So we are good here :)

No, we are definitely not good. See below. That means "See below", and not "Please take a guess at what is being talking about".

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +0 -3
@@ -596,12 +594,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
              priv->booster = devm_regulator_get_optional(dev, "booster");
              if (IS_ERR(priv->booster)) {
                      ret = PTR_ERR(priv->booster);
-                     if (ret != -ENODEV) {
-                             if (ret != -EPROBE_DEFER)
-                                     dev_err(dev, "can't get booster %d\n",
Quoted 8 lines
Quoted 8 lines

Review static int stm32_adc_core_switches_probe(struct device *dev, · line 598

Quoted 5 lines
(quoted diff) +2 -3
-                                             ret);
-                             return ret;
-                     }
+                     if (ret != -ENODEV)
+                             dev_err_probe(dev, ret, "can't get booster\n");

This tripped a warning and got the patch dropped because we no longer return on error.

Quoted 2 lines

As Jonathan already said, we no longer return in this hunk. I.e., you have clobbered the error path.

Exactly my point why I proposed _must_check in the first place.

Quoted 8 lines
Quoted 3 lines

That was not exactly that point as you did not mention possible errors but only "miss the opportunity to optimize". Optimization is different things than a mistake.

In this particular case we have introduced a bug. If the regulator returns an error other than -ENODEV we will carry on when really should error out. This includes deferred probe route in which it won't print a message but also won't actually defer.

Yes, I see, Peter pointed this out. The commit was actually not dropped from next so I will send a fixup.

Best regards,
Krzysztof

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

#17 lore raw

Re: [PATCH v3 08/18] iio: adc: stm32: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski
Quoted 6 lines · Krzysztof Kozlowski
Quoted 5 lines · Andy Shevchenko
Quoted 4 lines · Peter Rosin
Quoted 3 lines · Krzysztof Kozlowski
Quoted 2 lines · Jonathan Cameron

On Sat, 29 Aug 2020 08:47:16 +0200
Krzysztof Kozlowski <[email protected]> wrote:

...

Quoted 20 lines
Quoted 20 lines
Quoted 18 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
drivers/iio/adc/stm32-adc-core.c +0 -3
@@ -596,12 +594,9 @@ static int stm32_adc_core_switches_probe(struct device *dev,
              priv->booster = devm_regulator_get_optional(dev, "booster");
              if (IS_ERR(priv->booster)) {
                      ret = PTR_ERR(priv->booster);
-                     if (ret != -ENODEV) {
-                             if (ret != -EPROBE_DEFER)
-                                     dev_err(dev, "can't get booster %d\n",
Quoted 8 lines
Quoted 8 lines

drivers/iio/adc/stm32-adc-core.c static int stm32_adc_core_switches_probe(struct device *dev, · line 598

Quoted 5 lines
drivers/iio/adc/stm32-adc-core.c +2 -3
-                                             ret);
-                             return ret;
-                     }
+                     if (ret != -ENODEV)
+                             dev_err_probe(dev, ret, "can't get booster\n");

This tripped a warning and got the patch dropped because we no longer return on error.

As Jonathan already said, we no longer return in this hunk. I.e., you have clobbered the error path.

Quoted 5 lines
Quoted 1 line

Exactly my point why I proposed _must_check in the first place.

That was not exactly that point as you did not mention possible errors but only "miss the opportunity to optimize". Optimization is different things than a mistake.

Yes, and that's what happened here. You missed optimization which led to an error.

And this is a good showcase to see how dev_err_probe() may be misused because of overlooking subtle details.
Perhaps we can do

static inline __must_check dev_err_probe_ret(...)
{
return dev_err_probe(...);
}

(or other way around, introduce dev_err_probe_noret(), yes, name sucks)

Signature · 7 lines
With Best Regards,
Andy Shevchenko

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
author maintainer
#18 lore raw

PATCH v3 9/18 iio: afe: iio-rescale: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---

Changes since v2:
1. Wrap dev_err_probe() lines at 80 character

Changes since v1:
1. Wrap dev_err_probe() lines at 100 character

---
 drivers/iio/afe/iio-rescale.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/iio/afe/iio-rescale.c +3 -5
index 69c0f277ada0..e42ea2b1707d 100644
@@ -276,11 +276,9 @@ static int rescale_probe(struct platform_device *pdev)
 	int ret;
 
 	source = devm_iio_channel_get(dev, NULL);
-	if (IS_ERR(source)) {
-		if (PTR_ERR(source) != -EPROBE_DEFER)
-			dev_err(dev, "failed to get source channel\n");
-		return PTR_ERR(source);
-	}
+	if (IS_ERR(source))
+		return dev_err_probe(dev, PTR_ERR(source),
+				     "failed to get source channel\n");
 
 	sizeof_ext_info = iio_get_channel_ext_info_count(source);
 	if (sizeof_ext_info) {
Signature · 1 line
2.17.1
author maintainer
#20 lore raw

PATCH v3 10/18 iio: amplifiers: hmc425a: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---

Changes since v2:
1. Wrap dev_err_probe() lines at 80 character

Changes since v1:
1. Wrap dev_err_probe() lines at 100 character

---
 drivers/iio/amplifiers/hmc425a.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/iio/amplifiers/hmc425a.c +3 -6
index 582708924e4f..9efa692151f0 100644
@@ -201,12 +201,9 @@ static int hmc425a_probe(struct platform_device *pdev)
 	st->gain = st->chip_info->default_gain;
 
 	st->gpios = devm_gpiod_get_array(&pdev->dev, "ctrl", GPIOD_OUT_LOW);
-	if (IS_ERR(st->gpios)) {
-		ret = PTR_ERR(st->gpios);
-		if (ret != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "failed to get gpios\n");
-		return ret;
-	}
+	if (IS_ERR(st->gpios))
+		return dev_err_probe(&pdev->dev, PTR_ERR(st->gpios),
+				     "failed to get gpios\n");
 
 	if (st->gpios->ndescs != st->chip_info->num_gpios) {
 		dev_err(&pdev->dev, "%d GPIOs needed to operate\n",
Signature · 1 line
2.17.1
author maintainer
#21 lore raw

PATCH v3 11/18 iio: chemical: scd30: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---

Changes since v1:
1. Wrap dev_err_probe() lines at 100 character
2. Add Ack

---
 drivers/iio/chemical/scd30_core.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/iio/chemical/scd30_core.c +2 -7
index eac76972f83e..4d0d798c7cd3 100644
@@ -705,13 +705,8 @@ int scd30_probe(struct device *dev, int irq, const char *name, void *priv,
 	indio_dev->available_scan_masks = scd30_scan_masks;
 
 	state->vdd = devm_regulator_get(dev, "vdd");
-	if (IS_ERR(state->vdd)) {
-		if (PTR_ERR(state->vdd) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
-
-		dev_err(dev, "failed to get regulator\n");
-		return PTR_ERR(state->vdd);
-	}
+	if (IS_ERR(state->vdd))
+		return dev_err_probe(dev, PTR_ERR(state->vdd), "failed to get regulator\n");
 
 	ret = regulator_enable(state->vdd);
 	if (ret)
Signature · 1 line
2.17.1
author maintainer
#22 lore raw

PATCH v3 12/18 iio: dac: dpot-dac: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---
 drivers/iio/dac/dpot-dac.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/iio/dac/dpot-dac.c +6 -10
index be61c3b01e8b..2258535b8a42 100644
@@ -183,18 +183,14 @@ static int dpot_dac_probe(struct platform_device *pdev)
 	indio_dev->num_channels = 1;
 
 	dac->vref = devm_regulator_get(dev, "vref");
-	if (IS_ERR(dac->vref)) {
-		if (PTR_ERR(dac->vref) != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "failed to get vref regulator\n");
-		return PTR_ERR(dac->vref);
-	}
+	if (IS_ERR(dac->vref))
+		return dev_err_probe(&pdev->dev, PTR_ERR(dac->vref),
+				     "failed to get vref regulator\n");
 
 	dac->dpot = devm_iio_channel_get(dev, "dpot");
-	if (IS_ERR(dac->dpot)) {
-		if (PTR_ERR(dac->dpot) != -EPROBE_DEFER)
-			dev_err(dev, "failed to get dpot input channel\n");
-		return PTR_ERR(dac->dpot);
-	}
+	if (IS_ERR(dac->dpot))
+		return dev_err_probe(&pdev->dev, PTR_ERR(dac->dpot),
+				     "failed to get dpot input channel\n");
 
 	ret = iio_get_channel_type(dac->dpot, &type);
 	if (ret < 0)
Signature · 1 line
2.17.1
Acked-by on v3 12/18
#23 lore raw

Re: [PATCH v3 12/18] iio: dac: dpot-dac: Simplify with dev_err_probe()

Quoted 5 lines · Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

Cheers,
Peter

_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic

author maintainer
#24 lore raw

PATCH v3 13/18 iio: imu: inv_mpu6050: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +6 -14
index 3fee3947f772..18a1898e3e34 100644
@@ -1475,22 +1475,14 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
 	}
 
 	st->vdd_supply = devm_regulator_get(dev, "vdd");
-	if (IS_ERR(st->vdd_supply)) {
-		if (PTR_ERR(st->vdd_supply) != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get vdd regulator %d\n",
-				(int)PTR_ERR(st->vdd_supply));
-
-		return PTR_ERR(st->vdd_supply);
-	}
+	if (IS_ERR(st->vdd_supply))
+		return dev_err_probe(dev, PTR_ERR(st->vdd_supply),
+				     "Failed to get vdd regulator\n");
 
 	st->vddio_supply = devm_regulator_get(dev, "vddio");
-	if (IS_ERR(st->vddio_supply)) {
-		if (PTR_ERR(st->vddio_supply) != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get vddio regulator %d\n",
-				(int)PTR_ERR(st->vddio_supply));
-
-		return PTR_ERR(st->vddio_supply);
-	}
+	if (IS_ERR(st->vddio_supply))
+		return dev_err_probe(dev, PTR_ERR(st->vddio_supply),
+				     "Failed to get vddio regulator\n");
 
 	result = regulator_enable(st->vdd_supply);
 	if (result) {
Signature · 1 line
2.17.1
author maintainer
#25 lore raw

PATCH v3 14/18 iio: light: isl29018: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---
 drivers/iio/light/isl29018.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/iio/light/isl29018.c +3 -6
index ac8ad0f32689..2689867467a8 100644
@@ -746,12 +746,9 @@ static int isl29018_probe(struct i2c_client *client,
 	chip->suspended = false;
 
 	chip->vcc_reg = devm_regulator_get(&client->dev, "vcc");
-	if (IS_ERR(chip->vcc_reg)) {
-		err = PTR_ERR(chip->vcc_reg);
-		if (err != -EPROBE_DEFER)
-			dev_err(&client->dev, "failed to get VCC regulator!\n");
-		return err;
-	}
+	if (IS_ERR(chip->vcc_reg))
+		return dev_err_probe(&client->dev, PTR_ERR(chip->vcc_reg),
+				     "failed to get VCC regulator!\n");
 
 	err = regulator_enable(chip->vcc_reg);
 	if (err) {
Signature · 1 line
2.17.1
author maintainer
#26 lore raw

PATCH v3 15/18 iio: light: tsl2772: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---

Changes since v1:
1. Wrap dev_err_probe() lines at 100 character

---
 drivers/iio/light/tsl2772.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/iio/light/tsl2772.c +2 -8
index 735399405417..d79205361dfa 100644
@@ -1776,14 +1776,8 @@ static int tsl2772_probe(struct i2c_client *clientp,
 	ret = devm_regulator_bulk_get(&clientp->dev,
 				      ARRAY_SIZE(chip->supplies),
 				      chip->supplies);
-	if (ret < 0) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&clientp->dev,
-				"Failed to get regulators: %d\n",
-				ret);
-
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(&clientp->dev, ret, "Failed to get regulators\n");
 
 	ret = regulator_bulk_enable(ARRAY_SIZE(chip->supplies), chip->supplies);
 	if (ret < 0) {
Signature · 1 line
2.17.1
author maintainer
#27 lore raw

PATCH v3 16/18 iio: magnetometer: ak8974: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---

Changes since v1:
1. Wrap dev_err_probe() lines at 100 character

---
 drivers/iio/magnetometer/ak8974.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/iio/magnetometer/ak8974.c +2 -9
index cbb44e401c0a..548c686e29d6 100644
@@ -843,15 +843,8 @@ static int ak8974_probe(struct i2c_client *i2c,
 	ret = devm_regulator_bulk_get(&i2c->dev,
 				      ARRAY_SIZE(ak8974->regs),
 				      ak8974->regs);
-	if (ret < 0) {
-		if (ret != -EPROBE_DEFER)
-			dev_err(&i2c->dev, "cannot get regulators: %d\n", ret);
-		else
-			dev_dbg(&i2c->dev,
-				"regulators unavailable, deferring probe\n");
-
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(&i2c->dev, ret, "cannot get regulators\n");
 
 	ret = regulator_bulk_enable(ARRAY_SIZE(ak8974->regs), ak8974->regs);
 	if (ret < 0) {
Signature · 1 line
2.17.1
author maintainer
#28 lore raw

PATCH v3 17/18 iio: magnetometer: mag3110: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---
 drivers/iio/magnetometer/mag3110.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/iio/magnetometer/mag3110.c +6 -14
index 4d305a21c379..838b13c8bb3d 100644
@@ -476,22 +476,14 @@ static int mag3110_probe(struct i2c_client *client,
 	data = iio_priv(indio_dev);
 
 	data->vdd_reg = devm_regulator_get(&client->dev, "vdd");
-	if (IS_ERR(data->vdd_reg)) {
-		if (PTR_ERR(data->vdd_reg) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
-
-		dev_err(&client->dev, "failed to get VDD regulator!\n");
-		return PTR_ERR(data->vdd_reg);
-	}
+	if (IS_ERR(data->vdd_reg))
+		return dev_err_probe(&client->dev, PTR_ERR(data->vdd_reg),
+				     "failed to get VDD regulator!\n");
 
 	data->vddio_reg = devm_regulator_get(&client->dev, "vddio");
-	if (IS_ERR(data->vddio_reg)) {
-		if (PTR_ERR(data->vddio_reg) == -EPROBE_DEFER)
-			return -EPROBE_DEFER;
-
-		dev_err(&client->dev, "failed to get VDDIO regulator!\n");
-		return PTR_ERR(data->vddio_reg);
-	}
+	if (IS_ERR(data->vddio_reg))
+		return dev_err_probe(&client->dev, PTR_ERR(data->vddio_reg),
+				     "failed to get VDDIO regulator!\n");
 
 	ret = regulator_enable(data->vdd_reg);
 	if (ret) {
Signature · 1 line
2.17.1
author maintainer
#29 lore raw

PATCH v3 18/18 iio: multiplexer: iio-mux: Simplify with dev_err_probe()

In reply to Krzysztof Kozlowski

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

---

Changes since v2:
1. Wrap dev_err_probe() lines at 80 character

---
 drivers/iio/multiplexer/iio-mux.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/iio/multiplexer/iio-mux.c +3 -5
index 6910218fdb00..d54ae5cbe51b 100644
@@ -354,11 +354,9 @@ static int mux_probe(struct platform_device *pdev)
 		return -ENODEV;
 
 	parent = devm_iio_channel_get(dev, "parent");
-	if (IS_ERR(parent)) {
-		if (PTR_ERR(parent) != -EPROBE_DEFER)
-			dev_err(dev, "failed to get parent channel\n");
-		return PTR_ERR(parent);
-	}
+	if (IS_ERR(parent))
+		return dev_err_probe(dev, PTR_ERR(parent),
+				     "failed to get parent channel\n");
 
 	sizeof_ext_info = iio_get_channel_ext_info_count(parent);
 	if (sizeof_ext_info) {
Signature · 1 line
2.17.1
maintainer
#31 lore raw
In reply to Krzysztof Kozlowski
Quoted 5 lines · On Sat, 29 Aug 2020 08:47:09 +0200 Krzysztof Kozlowski <[email protected]> wrote:

Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value.

Series applied to the togreg branch of iio.git. I'll push that out as testing for the autobuilders to play with it sometime later today.

Thanks,

Jonathan

Quoted 36 lines
---
 drivers/iio/accel/bma180.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/iio/accel/bma180.c +8 -12
index 5b7a467c7b27..448faed001fd 100644
@@ -1000,19 +1000,15 @@ static int bma180_probe(struct i2c_client *client,
 		return ret;
 
 	data->vdd_supply = devm_regulator_get(dev, "vdd");
-	if (IS_ERR(data->vdd_supply)) {
-		if (PTR_ERR(data->vdd_supply) != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get vdd regulator %d\n",
-				(int)PTR_ERR(data->vdd_supply));
-		return PTR_ERR(data->vdd_supply);
-	}
+	if (IS_ERR(data->vdd_supply))
+		return dev_err_probe(dev, PTR_ERR(data->vdd_supply),
+				     "Failed to get vdd regulator\n");
+
 	data->vddio_supply = devm_regulator_get(dev, "vddio");
-	if (IS_ERR(data->vddio_supply)) {
-		if (PTR_ERR(data->vddio_supply) != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get vddio regulator %d\n",
-				(int)PTR_ERR(data->vddio_supply));
-		return PTR_ERR(data->vddio_supply);
-	}
+	if (IS_ERR(data->vddio_supply))
+		return dev_err_probe(dev, PTR_ERR(data->vddio_supply),
+				     "Failed to get vddio regulator\n");
+
 	/* Typical voltage 2.4V these are min and max */
 	ret = regulator_set_voltage(data->vdd_supply, 1620000, 3600000);
 	if (ret)