linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] staging: iio: adc: ad7192: Fix identation
@ 2019-03-15 11:14 Mircea Caprioru
  2019-03-15 11:14 ` [PATCH 2/2] staging: iio: adc: ad7192: Report error directly in ad7192_setup Mircea Caprioru
  2019-03-16 16:39 ` [PATCH 1/2] staging: iio: adc: ad7192: Fix identation Jonathan Cameron
  0 siblings, 2 replies; 5+ messages in thread
From: Mircea Caprioru @ 2019-03-15 11:14 UTC (permalink / raw)
  To: jic23
  Cc: Michael.Hennerich, lars, gregkh, linux-kernel, linux-iio,
	Mircea Caprioru

This patch fixes the odd indentation inside function ad7192_calibrate_all.

Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
---
 drivers/staging/iio/adc/ad7192.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index acdbc07fd259..ebab75bdeed7 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -216,8 +216,8 @@ static const struct ad_sd_calib_data ad7192_calib_arr[8] = {
 
 static int ad7192_calibrate_all(struct ad7192_state *st)
 {
-		return ad_sd_calibrate_all(&st->sd, ad7192_calib_arr,
-				ARRAY_SIZE(ad7192_calib_arr));
+	return ad_sd_calibrate_all(&st->sd, ad7192_calib_arr,
+				   ARRAY_SIZE(ad7192_calib_arr));
 }
 
 static inline bool ad7192_valid_external_frequency(u32 freq)
-- 
2.17.1


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

* [PATCH 2/2] staging: iio: adc: ad7192: Report error directly in ad7192_setup
  2019-03-15 11:14 [PATCH 1/2] staging: iio: adc: ad7192: Fix identation Mircea Caprioru
@ 2019-03-15 11:14 ` Mircea Caprioru
  2019-03-16 16:45   ` Jonathan Cameron
  2019-03-16 16:39 ` [PATCH 1/2] staging: iio: adc: ad7192: Fix identation Jonathan Cameron
  1 sibling, 1 reply; 5+ messages in thread
From: Mircea Caprioru @ 2019-03-15 11:14 UTC (permalink / raw)
  To: jic23
  Cc: Michael.Hennerich, lars, gregkh, linux-kernel, linux-iio,
	Mircea Caprioru

This patch removes the goto out statement thus ensuring that an error is
report as soon as it occurs. This gives more information and improves
readability.

Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
---
 drivers/staging/iio/adc/ad7192.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
index ebab75bdeed7..27f962b8c4ef 100644
--- a/drivers/staging/iio/adc/ad7192.c
+++ b/drivers/staging/iio/adc/ad7192.c
@@ -236,13 +236,13 @@ static int ad7192_setup(struct ad7192_state *st,
 	/* reset the serial interface */
 	ret = ad_sd_reset(&st->sd, 48);
 	if (ret < 0)
-		goto out;
+		return ret;
 	usleep_range(500, 1000); /* Wait for at least 500us */
 
 	/* write/read test for device presence */
 	ret = ad_sd_read_reg(&st->sd, AD7192_REG_ID, 1, &id);
 	if (ret)
-		goto out;
+		return ret;
 
 	id &= AD7192_ID_MASK;
 
@@ -310,15 +310,15 @@ static int ad7192_setup(struct ad7192_state *st,
 
 	ret = ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, st->mode);
 	if (ret)
-		goto out;
+		return ret;
 
 	ret = ad_sd_write_reg(&st->sd, AD7192_REG_CONF, 3, st->conf);
 	if (ret)
-		goto out;
+		return ret;
 
 	ret = ad7192_calibrate_all(st);
 	if (ret)
-		goto out;
+		return ret;
 
 	/* Populate available ADC input ranges */
 	for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) {
@@ -332,9 +332,6 @@ static int ad7192_setup(struct ad7192_state *st,
 	}
 
 	return 0;
-out:
-	dev_err(&st->sd.spi->dev, "setup failed\n");
-	return ret;
 }
 
 static ssize_t
-- 
2.17.1


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

* Re: [PATCH 1/2] staging: iio: adc: ad7192: Fix identation
  2019-03-15 11:14 [PATCH 1/2] staging: iio: adc: ad7192: Fix identation Mircea Caprioru
  2019-03-15 11:14 ` [PATCH 2/2] staging: iio: adc: ad7192: Report error directly in ad7192_setup Mircea Caprioru
@ 2019-03-16 16:39 ` Jonathan Cameron
  1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2019-03-16 16:39 UTC (permalink / raw)
  To: Mircea Caprioru; +Cc: Michael.Hennerich, lars, gregkh, linux-kernel, linux-iio

On Fri, 15 Mar 2019 13:14:24 +0200
Mircea Caprioru <mircea.caprioru@analog.com> wrote:

> This patch fixes the odd indentation inside function ad7192_calibrate_all.
> 
> Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Applied to the togreg branch of iio.git and pushed out as testing
Thanks.

Jonathan

> ---
>  drivers/staging/iio/adc/ad7192.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
> index acdbc07fd259..ebab75bdeed7 100644
> --- a/drivers/staging/iio/adc/ad7192.c
> +++ b/drivers/staging/iio/adc/ad7192.c
> @@ -216,8 +216,8 @@ static const struct ad_sd_calib_data ad7192_calib_arr[8] = {
>  
>  static int ad7192_calibrate_all(struct ad7192_state *st)
>  {
> -		return ad_sd_calibrate_all(&st->sd, ad7192_calib_arr,
> -				ARRAY_SIZE(ad7192_calib_arr));
> +	return ad_sd_calibrate_all(&st->sd, ad7192_calib_arr,
> +				   ARRAY_SIZE(ad7192_calib_arr));
>  }
>  
>  static inline bool ad7192_valid_external_frequency(u32 freq)


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

* Re: [PATCH 2/2] staging: iio: adc: ad7192: Report error directly in ad7192_setup
  2019-03-15 11:14 ` [PATCH 2/2] staging: iio: adc: ad7192: Report error directly in ad7192_setup Mircea Caprioru
@ 2019-03-16 16:45   ` Jonathan Cameron
  2019-03-16 16:52     ` Jonathan Cameron
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2019-03-16 16:45 UTC (permalink / raw)
  To: Mircea Caprioru; +Cc: Michael.Hennerich, lars, gregkh, linux-kernel, linux-iio

On Fri, 15 Mar 2019 13:14:25 +0200
Mircea Caprioru <mircea.caprioru@analog.com> wrote:

> This patch removes the goto out statement thus ensuring that an error is
> report as soon as it occurs. This gives more information and improves
> readability.
No problem with the patch, but I'm not sure why it gives more information?
Gone from printing an useless error message to printing none.

I'll just drop that bit of the description in favour of code readability.
Hope you don't mind!

Jonathan
> 
> Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
> ---
>  drivers/staging/iio/adc/ad7192.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
> index ebab75bdeed7..27f962b8c4ef 100644
> --- a/drivers/staging/iio/adc/ad7192.c
> +++ b/drivers/staging/iio/adc/ad7192.c
> @@ -236,13 +236,13 @@ static int ad7192_setup(struct ad7192_state *st,
>  	/* reset the serial interface */
>  	ret = ad_sd_reset(&st->sd, 48);
>  	if (ret < 0)
> -		goto out;
> +		return ret;
>  	usleep_range(500, 1000); /* Wait for at least 500us */
>  
>  	/* write/read test for device presence */
>  	ret = ad_sd_read_reg(&st->sd, AD7192_REG_ID, 1, &id);
>  	if (ret)
> -		goto out;
> +		return ret;
>  
>  	id &= AD7192_ID_MASK;
>  
> @@ -310,15 +310,15 @@ static int ad7192_setup(struct ad7192_state *st,
>  
>  	ret = ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, st->mode);
>  	if (ret)
> -		goto out;
> +		return ret;
>  
>  	ret = ad_sd_write_reg(&st->sd, AD7192_REG_CONF, 3, st->conf);
>  	if (ret)
> -		goto out;
> +		return ret;
>  
>  	ret = ad7192_calibrate_all(st);
>  	if (ret)
> -		goto out;
> +		return ret;
>  
>  	/* Populate available ADC input ranges */
>  	for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) {
> @@ -332,9 +332,6 @@ static int ad7192_setup(struct ad7192_state *st,
>  	}
>  
>  	return 0;
> -out:
> -	dev_err(&st->sd.spi->dev, "setup failed\n");
> -	return ret;
>  }
>  
>  static ssize_t


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

* Re: [PATCH 2/2] staging: iio: adc: ad7192: Report error directly in ad7192_setup
  2019-03-16 16:45   ` Jonathan Cameron
@ 2019-03-16 16:52     ` Jonathan Cameron
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2019-03-16 16:52 UTC (permalink / raw)
  To: Mircea Caprioru; +Cc: Michael.Hennerich, lars, gregkh, linux-kernel, linux-iio

On Sat, 16 Mar 2019 16:45:19 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Fri, 15 Mar 2019 13:14:25 +0200
> Mircea Caprioru <mircea.caprioru@analog.com> wrote:
> 
> > This patch removes the goto out statement thus ensuring that an error is
> > report as soon as it occurs. This gives more information and improves
> > readability.  
> No problem with the patch, but I'm not sure why it gives more information?
> Gone from printing an useless error message to printing none.
> 
> I'll just drop that bit of the description in favour of code readability.
> Hope you don't mind!
Patch is also wrong as that out is used by other gotos...

I guess this is because it's dependent on the patch you sent later on Friday.
I'll reorder, but please be careful of this in future.

If patches are in separate series posted as the same time they really 
need to be independent.

Jonathan

> 
> Jonathan
> > 
> > Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
> > ---
> >  drivers/staging/iio/adc/ad7192.c | 13 +++++--------
> >  1 file changed, 5 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
> > index ebab75bdeed7..27f962b8c4ef 100644
> > --- a/drivers/staging/iio/adc/ad7192.c
> > +++ b/drivers/staging/iio/adc/ad7192.c
> > @@ -236,13 +236,13 @@ static int ad7192_setup(struct ad7192_state *st,
> >  	/* reset the serial interface */
> >  	ret = ad_sd_reset(&st->sd, 48);
> >  	if (ret < 0)
> > -		goto out;
> > +		return ret;
> >  	usleep_range(500, 1000); /* Wait for at least 500us */
> >  
> >  	/* write/read test for device presence */
> >  	ret = ad_sd_read_reg(&st->sd, AD7192_REG_ID, 1, &id);
> >  	if (ret)
> > -		goto out;
> > +		return ret;
> >  
> >  	id &= AD7192_ID_MASK;
> >  
> > @@ -310,15 +310,15 @@ static int ad7192_setup(struct ad7192_state *st,
> >  
> >  	ret = ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, st->mode);
> >  	if (ret)
> > -		goto out;
> > +		return ret;
> >  
> >  	ret = ad_sd_write_reg(&st->sd, AD7192_REG_CONF, 3, st->conf);
> >  	if (ret)
> > -		goto out;
> > +		return ret;
> >  
> >  	ret = ad7192_calibrate_all(st);
> >  	if (ret)
> > -		goto out;
> > +		return ret;
> >  
> >  	/* Populate available ADC input ranges */
> >  	for (i = 0; i < ARRAY_SIZE(st->scale_avail); i++) {
> > @@ -332,9 +332,6 @@ static int ad7192_setup(struct ad7192_state *st,
> >  	}
> >  
> >  	return 0;
> > -out:
> > -	dev_err(&st->sd.spi->dev, "setup failed\n");
> > -	return ret;
> >  }
> >  
> >  static ssize_t  
> 


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

end of thread, other threads:[~2019-03-16 16:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-15 11:14 [PATCH 1/2] staging: iio: adc: ad7192: Fix identation Mircea Caprioru
2019-03-15 11:14 ` [PATCH 2/2] staging: iio: adc: ad7192: Report error directly in ad7192_setup Mircea Caprioru
2019-03-16 16:45   ` Jonathan Cameron
2019-03-16 16:52     ` Jonathan Cameron
2019-03-16 16:39 ` [PATCH 1/2] staging: iio: adc: ad7192: Fix identation 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).