[PATCH v2] Re: Battery class driver.

Jean Delvare khali at linux-fr.org
Tue Oct 31 02:59:40 EST 2006


On 10/28/2006, an anonymous coward wrote:
>On 10/28/06, David Zeuthen <davidz at redhat.com> wrote:
>> What about just prepending the unit to the 'threshold' file? Then user
>> space can expect the contents of said file to be of the form "%d %s". I
>> don't think that violates the "only one value per file" sysfs mantra.
>
>The tp_smapi battery driver did just this  ("16495 mW"). But I dropped
>it in a recent version when Pavel pointed out the rest of sysfs, hwmon
>included, uses undecorated integers.
>Consistency aside, it seems reasonable and convenient. You have to
>decree that writes to the attributes (where relevant) don't include
>the units, of course, so no one will expect the kernel to parse that.

But what value should then be written? One in an absolute aribtrary unit?
That would make reads and writes to the sysfs files inconsistent, in
direct violation of the sysfs standard. Or in the same unit read from
the file? It means that userspace must first read from the file, parse
the unit, then convert the value to be written. This doesn't match my
definition of "convenient".

>There's an issue here if a drunk driver decides to specify (say)
>capacity_remaining in mWh and capacity_last_full in mAa, which will
>confuse anyone comparing those attributest. So don't do that.
>
>Jean, what's your opinion on letting hwmon-ish attributes specify
>units as "%d %s" where these are hardware-dependent?

I fail to see any benefit in doing so, while I see several problems (see
above) and potential for confusion. So my opinion is: please don't do
that.

Thanks,
--
Jean



More information about the Devel mailing list