linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Renato Lui Geh <renatogeh@gmail.com>
Cc: lars@metafoo.de, Michael.Hennerich@analog.com, knaack.h@gmx.de,
	pmeerw@pmeerw.net, gregkh@linuxfoundation.org,
	alexandru.Ardelean@analog.com, stefan.popa@analog.com,
	giuliano.belinassi@usp.br, linux-iio@vger.kernel.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	kernel-usp@googlegroups.com
Subject: Re: [PATCH v2 1/2] staging: iio: ad7780: update voltage on read
Date: Sun, 28 Oct 2018 18:58:03 +0000	[thread overview]
Message-ID: <20181028185803.6dc8bb57@archlinux> (raw)
In-Reply-To: <20181028165231.2det3cq3u7r6qoxj@renatolg>

On Sun, 28 Oct 2018 13:52:32 -0300
Renato Lui Geh <renatogeh@gmail.com> wrote:

> Hi Jonathan,
> 
> Thank you for the review.
> 
> >> +		voltage_uv = regulator_get_voltage(st->reg);
> >> +		if (voltage_uv)
> >> +			st->int_vref_mv = voltage_uv/1000;
> >>  		*val = st->int_vref_mv * st->gain;  
> >Is there actually a reason (now) to have the stashed value
> >of int_vref_mv in the state structure?  
> 
> From probe:
> 
> if (voltage_uv)
> 	st->int_vref_mv = voltage_uv / 1000;
> else
> 	dev_warn(&spi->dev, "Reference voltage unspecified\n");
> 
> So the idea was to, when voltage_uv = 0, return the previous voltage.
> Should I instead handle this as an error the same way as in probe?
> 
I would return it as an error.  I can't really see how we would get
this to occur if the bindings are all correct and appropriate driver
support is there for the regulator to actually let us use it.

If we wanted to handle the case of no regulator having been provided
cleanly then we should it using an optional regulator get, and
not provide the scale attribute at all if we can't know what it will
read.  This is a weird enough corner case though that I just wouldn't 
bother handling it as anything other than an error.

> Thanks,
> Renato
Thanks,

Jonathan

  reply	other threads:[~2018-10-28 18:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25 22:29 [PATCH v2 0/2] staging: iio: ad7780: correct driver read Renato Lui Geh
2018-10-25 22:30 ` [PATCH v2 1/2] staging: iio: ad7780: update voltage on read Renato Lui Geh
2018-10-28 15:56   ` Jonathan Cameron
2018-10-28 16:52     ` Renato Lui Geh
2018-10-28 18:58       ` Jonathan Cameron [this message]
2018-10-25 22:30 ` [PATCH v2 2/2] staging: iio: ad7780: fix offset read value Renato Lui Geh
2018-10-28 15:58   ` Jonathan Cameron

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=20181028185803.6dc8bb57@archlinux \
    --to=jic23@kernel.org \
    --cc=Michael.Hennerich@analog.com \
    --cc=alexandru.Ardelean@analog.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=giuliano.belinassi@usp.br \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-usp@googlegroups.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=renatogeh@gmail.com \
    --cc=stefan.popa@analog.com \
    --subject='Re: [PATCH v2 1/2] staging: iio: ad7780: update voltage on read' \
    /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

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).