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>
Subject: Re: [PATCH 1/5] hwmon: ina2xx: bail-out from ina2xx_probe() in case of configuration errors
Date: Tue, 25 Nov 2014 09:59:08 -0800 [thread overview]
Message-ID: <5474C36C.1020004@roeck-us.net> (raw)
In-Reply-To: <CAMpxmJVGE444t3gE-=u8kuK_B9rJ=0fw9ZYVuYgQRPdswiPj7Q@mail.gmail.com>
On 11/25/2014 09:50 AM, Bartosz Golaszewski wrote:
> 2014-11-25 17:59 GMT+01:00 Guenter Roeck <linux@roeck-us.net>:
>> The new functions _might_ make a bit more sense if you would
>> implement the necessary calculations in the functions, but you are
>> not doing that. Instead, in the next patch, you introduce yet
>> another function to do the calibration calculation, just to add it
>> as parameter to the actual calibration function whenever you call it.
>
> This wasn't my intention, but I'll keep that in mind for the next version.
>
>> - I don't accept unnecessary ( ).
>> - I don't accept unnecessary typecasts.
>> - If you don't accept negative values, use kstrtoul().
>> - kstrtol can at least in theory return other errors besides -EINVAL.
>
> I'll fix those in the next version.
>
>> - Locking should be done in the calling code. It is not needed during
>> probe and more appropriate in set functions.
>
> I don't use locks in probe - they're used directly in
> ina2xx_set_value() or indirectly in ina226_update_avg(), but these
> functions are never called from probe.
>
>> - Any reason for selecting "rshunt" as sysfs attribute name instead
>> of, say, shunt-resistor or maybe shunt_resistor ?
>
> I'll change it to shunt_resistor for more readability.
>
>> - Returning -ENODEV from a set function doesn't make much sense.
>
> It does make sense in case of ACME (http://baylibre.com/acme/) - a
> probe can be disconnected at run-time, which, even without these
> patches, would cause ina2xx_update_device() to error out when called
> by ina2xx_show_value():
>
It seems to me this is a problem of your architecture. That doesn't
make it a generic problem. Your architecture should detect that a
probe was disconnected and de-instantiate the device automatically
if so, and re-instantiate it if it is re-inserted. Ultimately this
should be done with, for example, devicetree overlays.
Even worse, the remove/reinsertion sequence results in a non-initialized
chip.
This makes me wonder: Is the shunt resistor value set by software,
or by replacing one probe with another ?
Guenter
> 231 int rv = i2c_smbus_read_word_swapped(client, i);
> 232 if (rv < 0) {
> 233 ret = ERR_PTR(rv);
> 234 goto abort;
>
> I just reproduced this behavior in ina2xx_set_value().
>
>> - We don't overwrite error codes except in probe functions.
>
> I'll fix that too.
>
> Bart
>
next prev parent reply other threads:[~2014-11-25 17:59 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-25 15:46 [PATCH 0/5] hwmon: ina2xx: fixes & extensions Bartosz Golaszewski
2014-11-25 15:46 ` [PATCH 1/5] hwmon: ina2xx: bail-out from ina2xx_probe() in case of configuration errors Bartosz Golaszewski
2014-11-25 15:58 ` Guenter Roeck
2014-11-25 16:25 ` Bartosz Golaszewski
2014-11-25 16:59 ` Guenter Roeck
2014-11-25 17:50 ` Bartosz Golaszewski
2014-11-25 17:59 ` Guenter Roeck [this message]
2014-11-25 18:22 ` Bartosz Golaszewski
2014-11-25 18:30 ` Guenter Roeck
2014-11-26 3:05 ` Guenter Roeck
2014-11-26 9:13 ` Bartosz Golaszewski
2014-11-26 9:38 ` Benoit Cousson
2014-11-26 19:04 ` [lm-sensors] [PATCH 1/5] hwmon: ina2xx: bail-out from ina2xx_probe() in case of configuration er Guenter Roeck
2014-11-26 19:04 ` [PATCH 1/5] hwmon: ina2xx: bail-out from ina2xx_probe() in case of configuration errors Guenter Roeck
2014-11-27 10:18 ` [lm-sensors] [PATCH 1/5] hwmon: ina2xx: bail-out from ina2xx_probe() in case of configuration er Jean Delvare
2014-11-27 10:18 ` [PATCH 1/5] hwmon: ina2xx: bail-out from ina2xx_probe() in case of configuration errors Jean Delvare
2014-11-25 15:47 ` [PATCH 2/5] hwmon: ina2xx: make shunt resistance configurable at run-time Bartosz Golaszewski
2014-11-25 15:59 ` Guenter Roeck
2014-11-25 16:09 ` Bartosz Gołaszewski
2014-11-25 15:47 ` [PATCH 3/5] hwmon: ina2xx: allow to change the averaging rate " Bartosz Golaszewski
2014-11-25 16:01 ` Guenter Roeck
2014-11-25 15:47 ` [PATCH 4/5] hwmon: ina2xx: change hex constants to lower-case Bartosz Golaszewski
2014-11-25 15:47 ` [PATCH 5/5] hwmon: ina2xx: documentation update for new sysfs attributes Bartosz Golaszewski
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=5474C36C.1020004@roeck-us.net \
--to=linux@roeck-us.net \
--cc=bcousson@baylibre.com \
--cc=bgolaszewski@baylibre.com \
--cc=linux-kernel@vger.kernel.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 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.