2020-08-26 14:54:27

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 01/16] 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/accel/bma180.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index 5b7a467c7b27..448faed001fd 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -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)
--
2.17.1


2020-08-26 14:54:38

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 02/16] 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/accel/mma8452.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 4e6e70250048..104b87b98455 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -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) {
--
2.17.1

2020-08-26 14:54:53

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 04/16] iio: adc: exynos_adc: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/adc/exynos_adc.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index 7d23b6c33284..20477b249f2a 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -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)
--
2.17.1

2020-08-26 14:55:35

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 13/16] iio: imu: inv_mpu6050: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 3fee3947f772..18a1898e3e34 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -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) {
--
2.17.1

2020-08-26 14:55:47

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 03/16] iio: adc: envelope-detector: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/adc/envelope-detector.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/adc/envelope-detector.c b/drivers/iio/adc/envelope-detector.c
index 2a4fd3bb64cf..d73eac36153f 100644
--- a/drivers/iio/adc/envelope-detector.c
+++ b/drivers/iio/adc/envelope-detector.c
@@ -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;
--
2.17.1

2020-08-26 14:56:41

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 06/16] iio: adc: meson_saradc: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/adc/meson_saradc.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 93c2252c0b89..a9d06e8a576a 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -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 =
--
2.17.1

2020-08-26 14:57:15

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 07/16] iio: adc: rcar-gyroadc: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/adc/rcar-gyroadc.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c
index d2c1419e72a0..dcaefc108ff6 100644
--- a/drivers/iio/adc/rcar-gyroadc.c
+++ b/drivers/iio/adc/rcar-gyroadc.c
@@ -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)
--
2.17.1

2020-08-26 14:57:33

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 11/16] iio: chemical: scd30: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/chemical/scd30_core.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/chemical/scd30_core.c b/drivers/iio/chemical/scd30_core.c
index eac76972f83e..92358797796d 100644
--- a/drivers/iio/chemical/scd30_core.c
+++ b/drivers/iio/chemical/scd30_core.c
@@ -705,13 +705,9 @@ 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)
--
2.17.1

2020-08-26 14:57:41

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 15/16] iio: light: tsl2772: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/light/tsl2772.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c
index 735399405417..00073346ad1e 100644
--- a/drivers/iio/light/tsl2772.c
+++ b/drivers/iio/light/tsl2772.c
@@ -1776,14 +1776,9 @@ 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) {
--
2.17.1

2020-08-26 14:58:05

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 16/16] iio: magnetometer: ak8974: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/magnetometer/ak8974.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c
index cbb44e401c0a..fa6a8e1a815c 100644
--- a/drivers/iio/magnetometer/ak8974.c
+++ b/drivers/iio/magnetometer/ak8974.c
@@ -843,15 +843,9 @@ 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) {
--
2.17.1

2020-08-26 14:58:54

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 09/16] iio: afe: iio-rescale: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/afe/iio-rescale.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/afe/iio-rescale.c b/drivers/iio/afe/iio-rescale.c
index 69c0f277ada0..e42ea2b1707d 100644
--- a/drivers/iio/afe/iio-rescale.c
+++ b/drivers/iio/afe/iio-rescale.c
@@ -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) {
--
2.17.1

2020-08-26 14:58:55

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 14/16] iio: light: isl29018: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/light/isl29018.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/light/isl29018.c b/drivers/iio/light/isl29018.c
index ac8ad0f32689..2689867467a8 100644
--- a/drivers/iio/light/isl29018.c
+++ b/drivers/iio/light/isl29018.c
@@ -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) {
--
2.17.1

2020-08-26 14:58:55

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 08/16] iio: adc: stm32: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/adc/stm32-adc-core.c | 62 ++++++++++++-------------------
drivers/iio/adc/stm32-adc.c | 10 ++---
drivers/iio/adc/stm32-dfsdm-adc.c | 10 ++---
3 files changed, 30 insertions(+), 52 deletions(-)

diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c
index 0e2068ec068b..184d5491c7ed 100644
--- a/drivers/iio/adc/stm32-adc-core.c
+++ b/drivers/iio/adc/stm32-adc-core.c
@@ -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,10 @@ 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,40 +663,32 @@ 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;
- }
+ if (IS_ERR(priv->vref))
+ return dev_err_probe(&pdev->dev, PTR_ERR(priv->vref),
+ "vref get failed\n");

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;
- }
+ if (ret != -ENOENT)
+ return dev_err_probe(&pdev->dev, ret,
+ "Can't get 'adc' clock\n");
+
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;
- }
+ if (ret != -ENOENT)
+ return dev_err_probe(&pdev->dev, ret,
+ "Can't get 'bus' clock\n");
+
priv->bclk = NULL;
}

diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index 3eb9ebe8372f..b3f31f147347 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -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;
diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
index 5e10fb4f3704..c7e0109315f8 100644
--- a/drivers/iio/adc/stm32-dfsdm-adc.c
+++ b/drivers/iio/adc/stm32-dfsdm-adc.c
@@ -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;
--
2.17.1

2020-08-26 15:00:47

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 05/16] iio: adc: ltc2497: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/adc/ltc2497-core.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/adc/ltc2497-core.c b/drivers/iio/adc/ltc2497-core.c
index 9b8fd9c32364..2a485c8a1940 100644
--- a/drivers/iio/adc/ltc2497-core.c
+++ b/drivers/iio/adc/ltc2497-core.c
@@ -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) {
--
2.17.1

2020-08-26 15:01:47

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 12/16] iio: dac: dpot-dac: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/dac/dpot-dac.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/dac/dpot-dac.c b/drivers/iio/dac/dpot-dac.c
index be61c3b01e8b..2258535b8a42 100644
--- a/drivers/iio/dac/dpot-dac.c
+++ b/drivers/iio/dac/dpot-dac.c
@@ -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)
--
2.17.1

2020-08-26 15:02:13

by Krzysztof Kozlowski

[permalink] [raw]
Subject: [PATCH 10/16] iio: amplifiers: hmc425a: 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.

Signed-off-by: Krzysztof Kozlowski <[email protected]>
---
drivers/iio/amplifiers/hmc425a.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/amplifiers/hmc425a.c b/drivers/iio/amplifiers/hmc425a.c
index 582708924e4f..9efa692151f0 100644
--- a/drivers/iio/amplifiers/hmc425a.c
+++ b/drivers/iio/amplifiers/hmc425a.c
@@ -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",
--
2.17.1

2020-08-26 15:49:35

by Tomasz Duszynski

[permalink] [raw]
Subject: Re: [PATCH 11/16] iio: chemical: scd30: Simplify with dev_err_probe()

On Wed, Aug 26, 2020 at 04:51:48PM +0200, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe(). Less code and also it prints the error value.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/iio/chemical/scd30_core.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/iio/chemical/scd30_core.c b/drivers/iio/chemical/scd30_core.c
> index eac76972f83e..92358797796d 100644
> --- a/drivers/iio/chemical/scd30_core.c
> +++ b/drivers/iio/chemical/scd30_core.c
> @@ -705,13 +705,9 @@ 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");

I'd say that removing like break would slightly improve readability.
Besides, staying within 100 columns seems socially acceptable now.
Otherwise,

Acked-by: Tomasz Duszynski <[email protected]>

>
> ret = regulator_enable(state->vdd);
> if (ret)
> --
> 2.17.1
>

2020-08-26 16:02:06

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 11/16] iio: chemical: scd30: Simplify with dev_err_probe()

On Wed, Aug 26, 2020 at 05:34:34PM +0200, Tomasz Duszynski wrote:
> On Wed, Aug 26, 2020 at 04:51:48PM +0200, Krzysztof Kozlowski wrote:
> > Common pattern of handling deferred probe can be simplified with
> > dev_err_probe(). Less code and also it prints the error value.
> >
> > Signed-off-by: Krzysztof Kozlowski <[email protected]>
> > ---
> > drivers/iio/chemical/scd30_core.c | 10 +++-------
> > 1 file changed, 3 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/iio/chemical/scd30_core.c b/drivers/iio/chemical/scd30_core.c
> > index eac76972f83e..92358797796d 100644
> > --- a/drivers/iio/chemical/scd30_core.c
> > +++ b/drivers/iio/chemical/scd30_core.c
> > @@ -705,13 +705,9 @@ 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");
>
> I'd say that removing like break would slightly improve readability.
> Besides, staying within 100 columns seems socially acceptable now.
> Otherwise,
>
> Acked-by: Tomasz Duszynski <[email protected]>

Indeed. Although 80 is still mentioned as preferred (in commit bdc48fa11
and in coding style) but here having longer line would be better.

I guess this could be fixed up easily when applying but if resend is
wanted, let me know.

Best regards,
Krzysztof

2020-08-26 16:19:00

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 08/16] iio: adc: stm32: Simplify with dev_err_probe()

On Wed, Aug 26, 2020 at 04:51:45PM +0200, Krzysztof Kozlowski wrote:
> Common pattern of handling deferred probe can be simplified with
> dev_err_probe(). Less code and also it prints the error value.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/iio/adc/stm32-adc-core.c | 62 ++++++++++++-------------------
> drivers/iio/adc/stm32-adc.c | 10 ++---
> drivers/iio/adc/stm32-dfsdm-adc.c | 10 ++---
> 3 files changed, 30 insertions(+), 52 deletions(-)

For this one I have a follow up - I found more of places for conversion.
I will send v2 for this one only.

Best regards,
Krzysztof

2020-08-27 12:03:25

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH 01/16] iio: accel: bma180: Simplify with dev_err_probe()

On Wed, 26 Aug 2020 16:51:38 +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.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>

Please make sure to send v2 to [email protected]

> ---
> drivers/iio/accel/bma180.c | 20 ++++++++------------
> 1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
> index 5b7a467c7b27..448faed001fd 100644
> --- a/drivers/iio/accel/bma180.c
> +++ b/drivers/iio/accel/bma180.c
> @@ -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)

2020-08-27 15:14:09

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 01/16] iio: accel: bma180: Simplify with dev_err_probe()

On Thu, Aug 27, 2020 at 12:26:05PM +0100, Jonathan Cameron wrote:
> On Wed, 26 Aug 2020 16:51:38 +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.
> >
> > Signed-off-by: Krzysztof Kozlowski <[email protected]>
>
> Please make sure to send v2 to [email protected]

Sure, my bad.

Best regards,
Krzysztof

2020-08-28 13:05:54

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 16/16] iio: magnetometer: ak8974: Simplify with dev_err_probe()

On Wed, Aug 26, 2020 at 4:53 PM 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.
>
> Signed-off-by: Krzysztof Kozlowski <[email protected]>

Acked-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij