All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Hugo Villeneuve <hugo@hugovil.com>
Cc: Jonathan Cameron <jic23@kernel.org>, <hvilleneuve@dimonoff.com>,
	<lars@metafoo.de>, <robh+dt@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>, <linux-iio@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] iio: adc: ti-ads7924: add Texas Instruments ADS7924 driver
Date: Fri, 13 Jan 2023 14:16:40 +0000	[thread overview]
Message-ID: <20230113141640.00006fb1@Huawei.com> (raw)
In-Reply-To: <20230112143357.6d6204f19eb622333bfd2f47@hugovil.com>


> > > +		break;
> > > +	}
> > > +	case IIO_CHAN_INFO_SCALE:
> > > +		vref_uv = regulator_get_voltage(data->vref_reg);
> > > +		if (vref_uv < 0) {
> > > +			/* dummy regulator "get_voltage" returns -EINVAL */
> > > +			ret = -EINVAL;  
> > 			return -EINVAL;  
> > > +		} else {
> > > +			*val =  vref_uv / 1000; /* Convert reg voltage to mV */
> > > +			*val2 = ADS7924_BITS;
> > > +			ret = IIO_VAL_FRACTIONAL_LOG2;  
> > 			return IIO_VAL_FR...
> >   
> > > +		}
> > > +		break;
> > > +	default:
> > > +		ret = -EINVAL;  
> > 		return -EINVAL;  
> > > +		break;
> > > +	}
> > > +
> > > +	return ret;
> > > +}  
> 
> Done. With these changes, I propose to also remove last "return ret" (like in rcar-gyroadc.c). Then, maybe also remove break statements?

Definitely to both. I was just being lazy whilst commenting ;)  No breaks after returns, and as you
have noted, the last return ret is unreachable.

> > > +
> > > +	if (num_channels > 0) {
> > > +		dev_dbg(dev, "found %d ADC channels\n", num_channels);
> > > +		return 0;
> > > +	} else {  
> > 
> > As per other review.  Give us what we expect which is error paths
> > as out of line.  
> 
> Already done as suggested by Christophe:
> 
>     if (num_channels <= 0)
>         return -EINVAL;

This is an out of line error path because it's indented more than the normal
flow.

> 
>     dev_dbg(dev, "found %d ADC channels\n", num_channels);
>     return 0;
> 
> Although I do not fully understand what you mean by "...error paths as out of line"? Do you mean to drop the debug message?
See above.

> 
> >   
> > > +		return -EINVAL;
> > > +	}
> > > +}  

  reply	other threads:[~2023-01-13 14:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-10 16:01 [PATCH v2 0/2] iio: adc: ti-ads7924: add Texas Instruments ADS7924 driver Hugo Villeneuve
2023-01-10 16:01 ` [PATCH v2 1/2] " Hugo Villeneuve
2023-01-10 18:50   ` Christophe JAILLET
2023-01-11  0:23     ` Hugo Villeneuve
2023-01-10 23:09   ` kernel test robot
2023-01-12 19:00   ` Jonathan Cameron
2023-01-12 19:33     ` Hugo Villeneuve
2023-01-13 14:16       ` Jonathan Cameron [this message]
2023-01-12 19:38   ` Hugo Villeneuve
2023-01-12 19:39   ` Hugo Villeneuve
2023-01-10 16:01 ` [PATCH v2 2/2] dt-bindings: iio: adc: add Texas Instruments ADS7924 Hugo Villeneuve
2023-01-11  1:34   ` Rob Herring
2023-01-11 23:25     ` Hugo Villeneuve
2023-01-11  9:23   ` Krzysztof Kozlowski
2023-01-12  0:11     ` Hugo Villeneuve

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230113141640.00006fb1@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=devicetree@vger.kernel.org \
    --cc=hugo@hugovil.com \
    --cc=hvilleneuve@dimonoff.com \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.