2021-09-28 01:40:21

by Cai,Huoqing

[permalink] [raw]
Subject: [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.

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/iio/dac/ad8801.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/dac/ad8801.c b/drivers/iio/dac/ad8801.c
index 6354b7c8f052..8acb9fee273c 100644
--- a/drivers/iio/dac/ad8801.c
+++ b/drivers/iio/dac/ad8801.c
@@ -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;
}

--
2.25.1


2021-09-28 01:40:34

by Cai,Huoqing

[permalink] [raw]
Subject: [PATCH v2 5/8] iio: dac: max5821: 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.

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/iio/dac/max5821.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/dac/max5821.c b/drivers/iio/dac/max5821.c
index bd0b7f361154..7da4710a6408 100644
--- a/drivers/iio/dac/max5821.c
+++ b/drivers/iio/dac/max5821.c
@@ -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) {
--
2.25.1

2021-09-28 01:40:43

by Cai,Huoqing

[permalink] [raw]
Subject: [PATCH v2 6/8] iio: dac: mcp4922: 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.

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/iio/dac/mcp4922.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/dac/mcp4922.c b/drivers/iio/dac/mcp4922.c
index c4e430b4050e..0ae414ee1716 100644
--- a/drivers/iio/dac/mcp4922.c
+++ b/drivers/iio/dac/mcp4922.c
@@ -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) {
--
2.25.1

2021-09-28 01:40:48

by Cai,Huoqing

[permalink] [raw]
Subject: [PATCH v2 7/8] iio: dac: stm32-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.

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/iio/dac/stm32-dac-core.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/iio/dac/stm32-dac-core.c b/drivers/iio/dac/stm32-dac-core.c
index 9a6a68b11b2a..bd7a3b20e645 100644
--- a/drivers/iio/dac/stm32-dac-core.c
+++ b/drivers/iio/dac/stm32-dac-core.c
@@ -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);
--
2.25.1

2021-09-28 01:41:27

by Cai,Huoqing

[permalink] [raw]
Subject: [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.

Signed-off-by: Cai Huoqing <[email protected]>
---
v1->v2: Remove the separate line of PTR_ERR().

drivers/iio/dac/lpc18xx_dac.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/dac/lpc18xx_dac.c b/drivers/iio/dac/lpc18xx_dac.c
index 9e38607a189e..afb37647b035 100644
--- a/drivers/iio/dac/lpc18xx_dac.c
+++ b/drivers/iio/dac/lpc18xx_dac.c
@@ -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;
--
2.25.1

2021-09-28 01:41:34

by Cai,Huoqing

[permalink] [raw]
Subject: [PATCH v2 4/8] iio: dac: ds4424: 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.

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/iio/dac/ds4424.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c
index 79527fbc250a..5a5e967b0be4 100644
--- a/drivers/iio/dac/ds4424.c
+++ b/drivers/iio/dac/ds4424.c
@@ -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);
--
2.25.1

2021-09-28 01:42:06

by Cai,Huoqing

[permalink] [raw]
Subject: [PATCH v2 8/8] iio: dac: ti-dac7311: 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.

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/iio/dac/ti-dac7311.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/dac/ti-dac7311.c b/drivers/iio/dac/ti-dac7311.c
index 9d0b253be841..09218c3029f0 100644
--- a/drivers/iio/dac/ti-dac7311.c
+++ b/drivers/iio/dac/ti-dac7311.c
@@ -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) {
--
2.25.1

2021-09-28 01:56:31

by Cai,Huoqing

[permalink] [raw]
Subject: [PATCH v2 3/8] iio: dac: ltc1660: 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.

Signed-off-by: Cai Huoqing <[email protected]>
---
drivers/iio/dac/ltc1660.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/dac/ltc1660.c b/drivers/iio/dac/ltc1660.c
index dc10188540ca..f6ec9bf5815e 100644
--- a/drivers/iio/dac/ltc1660.c
+++ b/drivers/iio/dac/ltc1660.c
@@ -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) {
--
2.25.1

2021-10-01 08:14:43

by Marcus Folkesson

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

Hi,

On Tue, Sep 28, 2021 at 09:38:56AM +0800, Cai Huoqing 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.
>
> Signed-off-by: Cai Huoqing <[email protected]>

Reviewed-by: Marcus Folkesson <[email protected]>


Attachments:
(No filename) (448.00 B)
signature.asc (849.00 B)
Download all attachments

2021-10-07 17:24:10

by Jonathan Cameron

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

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.
>
> Signed-off-by: Cai Huoqing <[email protected]>
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

> ---
> drivers/iio/dac/ti-dac7311.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iio/dac/ti-dac7311.c b/drivers/iio/dac/ti-dac7311.c
> index 9d0b253be841..09218c3029f0 100644
> --- a/drivers/iio/dac/ti-dac7311.c
> +++ b/drivers/iio/dac/ti-dac7311.c
> @@ -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) {

2021-10-07 20:49:24

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v2 1/8] iio: dac: ad8801: Make use of the helper function dev_err_probe()

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.
>
> Signed-off-by: Cai Huoqing <[email protected]>

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

> ---
> drivers/iio/dac/ad8801.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/dac/ad8801.c b/drivers/iio/dac/ad8801.c
> index 6354b7c8f052..8acb9fee273c 100644
> --- a/drivers/iio/dac/ad8801.c
> +++ b/drivers/iio/dac/ad8801.c
> @@ -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);
This last change is unconnected to the rest of the patch. I've dropped it whilst
applying.

> goto error_disable_vrefh_reg;
> }
>