All of lore.kernel.org
 help / color / mirror / Atom feed
From: jacopo <jacopo@jmondi.org>
To: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>,
	Jonathan Cameron <jic23@kernel.org>,
	geert@linux-m68k.org, wsa+renesas@sang-engineering.com,
	lars@metafoo.de, linux-iio@vger.kernel.org
Subject: Re: [PATCH v3 3/4] iio: adc: Add Maxim max9611 ADC driver
Date: Mon, 27 Mar 2017 10:30:29 +0200	[thread overview]
Message-ID: <20170327083029.GA21392@w540> (raw)
In-Reply-To: <alpine.DEB.2.20.1703251706420.25208@vps.pmeerw.net>

Hi Jonathan, Peter,

On Sat, Mar 25, 2017 at 05:13:38PM +0100, Peter Meerwald-Stadler wrote:
> 
> On Sat, 25 Mar 2017, Jonathan Cameron wrote:
> > > +	switch (mask) {
> > > +	case IIO_CHAN_INFO_RAW:
> > > +		mutex_lock(&dev->lock);
> > > +
> > > +		switch (chan->address) {
> > > +		case MAX9611_CHAN_TEMPERATURE:
> > > +			ret = max9611_read_single(dev, CONF_TEMP,
> > > +						  &adc_data);
> > > +			if (ret)
> > I'm not personally keen on jumping out of deep indentations like this
> > just save on repeating one line.  I'd pull the unlock back here and return
> > directly as I feel it'll improve readability.
> > Actually come to think of it, why does the lock need to be held for
> > the next line anyway?  adc_data is on the stack so doesn't matter if we
> > have concurrent readers, once the i2c transaction is finished.
> > Just unlock before checking ret.

[snip]

> > > +
> > > +			mutex_unlock(&dev->lock);
> > > +			return IIO_VAL_INT;
> > > +		}
> > > +
> 
> this falls through, no break?
> 
> I'd move
>                 mutex_unlock(&dev->lock);
>                 return IIO_VAL_INT;
> here
> 

On the two comments above: re-thinking on this a bit, the only part
that actually needs protection is gain selection routine, which
depends on consecutive reads of what is returned from the ADC bus.

All other variables (including the ones coming from outside, as val
and val2 are) are not shared and do no need protection at this level.

I should move the mutex in max9611_read_* functions (maybe even
read_single() does not need that, as I2c bus access is protected
already), and simplify the read_raw() one.
Just saying it out loud so there will be no surprises in v4.

Thanks
   j

  parent reply	other threads:[~2017-03-27  8:32 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-24 15:28 [PATCH v3 0/4] iio: adc: Maxim max9611 driver Jacopo Mondi
2017-03-24 15:28 ` Jacopo Mondi
2017-03-24 15:28 ` [PATCH v3 1/4] Documentation: dt-bindings: iio: Add max9611 ADC Jacopo Mondi
2017-03-24 15:28   ` Jacopo Mondi
2017-03-25 15:27   ` Jonathan Cameron
2017-03-25 15:27     ` Jonathan Cameron
2017-03-24 15:28 ` [PATCH v3 2/4] iio: Documentation: Add max9611 sysfs documentation Jacopo Mondi
2017-03-24 15:28   ` Jacopo Mondi
2017-03-25 16:32   ` Jonathan Cameron
2017-03-25 16:32     ` Jonathan Cameron
2017-03-26  8:38   ` Geert Uytterhoeven
2017-03-26  8:38     ` Geert Uytterhoeven
2017-03-24 15:28 ` [PATCH v3 3/4] iio: adc: Add Maxim max9611 ADC driver Jacopo Mondi
2017-03-24 15:28   ` Jacopo Mondi
2017-03-25 15:45   ` Jonathan Cameron
2017-03-25 15:45     ` Jonathan Cameron
2017-03-25 16:13     ` Peter Meerwald-Stadler
2017-03-25 16:34       ` Jonathan Cameron
2017-03-26 10:08       ` jacopo
2017-03-26 10:24         ` Jonathan Cameron
2017-03-26 10:50           ` jacopo
2017-03-27  8:30       ` jacopo [this message]
2017-03-25 17:21     ` jacopo
2017-03-25 17:21       ` jacopo
2017-03-25 17:37       ` Jonathan Cameron
2017-03-25 17:37         ` Jonathan Cameron
2017-03-26 10:02         ` jacopo
2017-03-26 10:02           ` jacopo
2017-03-26 10:23           ` Jonathan Cameron
2017-03-26 10:23             ` Jonathan Cameron
2017-03-24 15:28 ` [PATCH v3 4/4] arm64: dts: salvator-x: Add current sense amplifiers Jacopo Mondi
2017-03-24 15:28   ` Jacopo Mondi
2017-03-26  8:49   ` Geert Uytterhoeven
2017-03-26  8:49     ` Geert Uytterhoeven
2017-03-26  9:07 ` [PATCH v3 0/4] iio: adc: Maxim max9611 driver Geert Uytterhoeven
2017-03-26  9:18   ` Jonathan Cameron
2017-03-26  9:18     ` Jonathan Cameron
2017-03-27  8:53 ` Geert Uytterhoeven
2017-03-27  8:53   ` Geert Uytterhoeven

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=20170327083029.GA21392@w540 \
    --to=jacopo@jmondi.org \
    --cc=geert@linux-m68k.org \
    --cc=jacopo+renesas@jmondi.org \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=wsa+renesas@sang-engineering.com \
    /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.