From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Jonathan Cameron <kernel@jic23.retrosnub.co.uk>
Cc: Manuel Stahl <manuel.stahl@iis.fraunhofer.de>,
LKML <linux-kernel@vger.kernel.org>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
Jean Delvare <khali@linux-fr.org>, Greg KH <greg@kroah.com>,
Mike Frysinger <vapier.adi@gmail.com>
Subject: Re: [IIO] Proposal for sysfs attributes
Date: Mon, 6 Sep 2010 14:32:56 +0100 [thread overview]
Message-ID: <20100906143256.6b49825d@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <4C84E64D.4040600@jic23.retrosnub.co.uk>
> > Do we want to resemble the 'milli' units or should we stick to
> > standard SI units (radians, kelvin, etc.) as floating point math is
> > necessary anyway.
> I've cc'd a few people who have contributed to previous abi discussions
> for IIO in ways that make me think they may have opinions on this.
FP isn't needed you can let the drivers do fixed point quite happily -
the Intel compass driver intentionally does this.
Using milli is asking for problems. There are lots of units where "milli"
is actually quite big (millifarad, millihenry) and others where its
stupendously small (eV for example). It works for hwmon because hwmon
covers such a narrow range of devices and units.
So I'd favour FP because I think there are three choices
1. Encode the value, define the scaling factor in the ABI (not
future proof)
2. Encode the value and scaling factor as two fields in the ABI
(more future proof)
3. As 2 but use the normal encoding for this which involves
putting a "." in the right place and using one field (ie FP)
Drivers are simply going to end up doing this with sysfs values
snprintf(buf, sizeof(buf), "%d.%02d", v/100, v%100);
or similar - or in many cases
snprintf(buf, sizeof(buf), "%d0000000000", v);
neither of which is a big cost.
For a ring buffer you probably need to encode the scaling factor and
field width in some sort of interface description query and the values in
the bitstream.
Which raises an interesting question. The natural way to deal with sysfs
is decimal fixed point internally. If drivers are going to do both
sysfs and rings then really you want to be able to encode powers of 10
shifts not just bitshifts.
Alan
next prev parent reply other threads:[~2010-09-06 13:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-06 8:41 Manuel Stahl
2010-09-06 13:02 ` Jonathan Cameron
2010-09-06 13:32 ` Alan Cox [this message]
2010-09-06 14:17 ` Jonathan Cameron
2010-09-06 14:48 ` Alan Cox
2010-09-06 15:03 ` Jonathan Cameron
2010-09-18 12:25 ` 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=20100906143256.6b49825d@lxorguk.ukuu.org.uk \
--to=alan@lxorguk.ukuu.org.uk \
--cc=greg@kroah.com \
--cc=kernel@jic23.retrosnub.co.uk \
--cc=khali@linux-fr.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manuel.stahl@iis.fraunhofer.de \
--cc=vapier.adi@gmail.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
all inboxes | Powered by JetHome®