linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] iio: accel: mma8452: Use dev_err_probe() to simplify error handling
@ 2020-08-11  3:43 Anson Huang
  2020-08-11  3:43 ` [PATCH 2/3] iio: light: isl29018: " Anson Huang
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Anson Huang @ 2020-08-11  3:43 UTC (permalink / raw)
  To: jic23, knaack.h, lars, pmeerw, alexandru.ardelean, hslester96,
	linux-iio, linux-kernel
  Cc: Linux-imx

dev_err_probe() can reduce code size, uniform error handling and record the
defer probe reason etc., use it to simplify the code.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
 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 ba27f86..9b5f23b 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.7.4


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

* [PATCH 2/3] iio: light: isl29018: Use dev_err_probe() to simplify error handling
  2020-08-11  3:43 [PATCH 1/3] iio: accel: mma8452: Use dev_err_probe() to simplify error handling Anson Huang
@ 2020-08-11  3:43 ` Anson Huang
  2020-08-11  3:43 ` [PATCH 3/3] iio: magnetometer: mag3110: " Anson Huang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Anson Huang @ 2020-08-11  3:43 UTC (permalink / raw)
  To: jic23, knaack.h, lars, pmeerw, alexandru.ardelean, hslester96,
	linux-iio, linux-kernel
  Cc: Linux-imx

dev_err_probe() can reduce code size, uniform error handling and record the
defer probe reason etc., use it to simplify the code.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
 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 ac8ad0f..2689867 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.7.4


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

* [PATCH 3/3] iio: magnetometer: mag3110: Use dev_err_probe() to simplify error handling
  2020-08-11  3:43 [PATCH 1/3] iio: accel: mma8452: Use dev_err_probe() to simplify error handling Anson Huang
  2020-08-11  3:43 ` [PATCH 2/3] iio: light: isl29018: " Anson Huang
@ 2020-08-11  3:43 ` Anson Huang
  2020-08-16  8:54 ` [PATCH 1/3] iio: accel: mma8452: " Jonathan Cameron
  2020-08-29 18:03 ` Jonathan Cameron
  3 siblings, 0 replies; 5+ messages in thread
From: Anson Huang @ 2020-08-11  3:43 UTC (permalink / raw)
  To: jic23, knaack.h, lars, pmeerw, alexandru.ardelean, hslester96,
	linux-iio, linux-kernel
  Cc: Linux-imx

dev_err_probe() can reduce code size, uniform error handling and record the
defer probe reason etc., use it to simplify the code.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
 drivers/iio/magnetometer/mag3110.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c
index 4d305a2..838b13c 100644
--- a/drivers/iio/magnetometer/mag3110.c
+++ b/drivers/iio/magnetometer/mag3110.c
@@ -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) {
-- 
2.7.4


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

* Re: [PATCH 1/3] iio: accel: mma8452: Use dev_err_probe() to simplify error handling
  2020-08-11  3:43 [PATCH 1/3] iio: accel: mma8452: Use dev_err_probe() to simplify error handling Anson Huang
  2020-08-11  3:43 ` [PATCH 2/3] iio: light: isl29018: " Anson Huang
  2020-08-11  3:43 ` [PATCH 3/3] iio: magnetometer: mag3110: " Anson Huang
@ 2020-08-16  8:54 ` Jonathan Cameron
  2020-08-29 18:03 ` Jonathan Cameron
  3 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2020-08-16  8:54 UTC (permalink / raw)
  To: Anson Huang
  Cc: knaack.h, lars, pmeerw, alexandru.ardelean, hslester96,
	linux-iio, linux-kernel, Linux-imx

On Tue, 11 Aug 2020 11:43:14 +0800
Anson Huang <Anson.Huang@nxp.com> wrote:

> dev_err_probe() can reduce code size, uniform error handling and record the
> defer probe reason etc., use it to simplify the code.
> 
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Hi Anson,

All look good, but will have to wait for dev_err_probe to be in my
upstream tree which hasn't quite happened yet.  Give me a poke if 
I seem to have lost these once that is true!

Thanks,

Jonathan

> ---
>  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 ba27f86..9b5f23b 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) {


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

* Re: [PATCH 1/3] iio: accel: mma8452: Use dev_err_probe() to simplify error handling
  2020-08-11  3:43 [PATCH 1/3] iio: accel: mma8452: Use dev_err_probe() to simplify error handling Anson Huang
                   ` (2 preceding siblings ...)
  2020-08-16  8:54 ` [PATCH 1/3] iio: accel: mma8452: " Jonathan Cameron
@ 2020-08-29 18:03 ` Jonathan Cameron
  3 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2020-08-29 18:03 UTC (permalink / raw)
  To: Anson Huang
  Cc: knaack.h, lars, pmeerw, alexandru.ardelean, hslester96,
	linux-iio, linux-kernel, Linux-imx

On Tue, 11 Aug 2020 11:43:14 +0800
Anson Huang <Anson.Huang@nxp.com> wrote:

> dev_err_probe() can reduce code size, uniform error handling and record the
> defer probe reason etc., use it to simplify the code.
> 
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
Sorry Anson.

You got in first, but I was working backwards through my email today and
picked up Krzysztof Kozlowski's series doing the same thing across a whole
set of drivers.

Sorry about that.

Jonathan


> ---
>  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 ba27f86..9b5f23b 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) {


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

end of thread, other threads:[~2020-08-29 18:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-11  3:43 [PATCH 1/3] iio: accel: mma8452: Use dev_err_probe() to simplify error handling Anson Huang
2020-08-11  3:43 ` [PATCH 2/3] iio: light: isl29018: " Anson Huang
2020-08-11  3:43 ` [PATCH 3/3] iio: magnetometer: mag3110: " Anson Huang
2020-08-16  8:54 ` [PATCH 1/3] iio: accel: mma8452: " Jonathan Cameron
2020-08-29 18:03 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).