From: Guenter Roeck <linux@roeck-us.net>
To: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Benoit Cousson <bcousson@baylibre.com>,
Patrick Titiano <ptitiano@baylibre.com>,
LM Sensors <lm-sensors@lm-sensors.org>
Subject: Re: [PATCH v5 1/3] hwmon: ina2xx: make shunt resistance configurable at run-time
Date: Wed, 10 Dec 2014 10:31:46 -0800 [thread overview]
Message-ID: <20141210183146.GA22847@roeck-us.net> (raw)
In-Reply-To: <CAMpxmJXp2NT+rie2d2+Z7hixKMyS+xcRNdKRNZaUSJD-aTUVVg@mail.gmail.com>
On Wed, Dec 10, 2014 at 05:46:43PM +0100, Bartosz Golaszewski wrote:
> 2014-12-10 15:20 GMT+01:00 Guenter Roeck <linux@roeck-us.net>:
> >> + case INA2XX_CALIBRATION:
> >> + if (data->regs[reg] == 0)
> >> + val = 0;
> >> + else
> >> + val = data->config->calibration_factor
> >> + / data->regs[reg];
> >> + break;
> >
> >
> > This doesn't really make sense. What you want to show is rshunt, not the
> > above.
> > I think it would be better to write a separate show function to display it.
>
> Hi Guenter,
>
> this is the only way to display values read from the chip. It also
> tells the user what the actual programmed value is. In fact it was
> your suggestion (https://lkml.org/lkml/2014/11/30/233) and I agree
> that it's a better alternative. Are you sure you don't want it done
> this way?
>
I don't really want it at all ;-). Seems to me all those options are broken
one way or another. The only real solution would be to re-instantiate the
driver if the chip was removed and re-inserted, and to provide parameters
either with platform data or with devicetree data.
On a side note, data->rshunt is not really needed anymore with your current
code. The only reason for storing it in data is to use it in
ina2xx_calibration_val(), but you could as well pass it in as parameter
to that function. Even better would be to have a function such as
ina2xx_calibrate() and let it handle the write to the calibration register.
Also, I would suggest to move the above code into its own show function.
It is probably not a good idea to have a single function for all those
conversions in the first place, and converting from 'calibration' to
rshunt goes a bit beyond the original intent to convert from one representation
to the other.
That still doesn't really solve the structural problem of having to deal with
an uninitialized chip which doesn't like to be uninitialized. But then on the
other side I guess that is really a problem with your platform, not a driver
problem.
Guenter
next prev parent reply other threads:[~2014-12-10 18:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-10 10:38 [PATCH v5 0/3] hwmon: ina2xx: new attributes Bartosz Golaszewski
2014-12-10 10:38 ` [PATCH v5 1/3] hwmon: ina2xx: make shunt resistance configurable at run-time Bartosz Golaszewski
2014-12-10 14:20 ` Guenter Roeck
2014-12-10 16:46 ` Bartosz Golaszewski
2014-12-10 18:31 ` Guenter Roeck [this message]
2014-12-11 10:26 ` Bartosz Golaszewski
2014-12-11 16:29 ` Guenter Roeck
2014-12-10 10:38 ` [PATCH v5 2/3] hwmon: ina2xx: allow to change the averaging rate " Bartosz Golaszewski
2014-12-10 10:38 ` [PATCH v5 3/3] hwmon: ina2xx: documentation update for new sysfs attributes Bartosz Golaszewski
2014-12-10 14:21 ` Guenter Roeck
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=20141210183146.GA22847@roeck-us.net \
--to=linux@roeck-us.net \
--cc=bcousson@baylibre.com \
--cc=bgolaszewski@baylibre.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--cc=ptitiano@baylibre.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox