From: David Lechner <david@lechnology.com>
To: William Breathitt Gray <vilhelm.gray@gmail.com>
Cc: kamel.bouhara@bootlin.com, gwendal@chromium.org,
alexandre.torgue@st.com, linux-iio@vger.kernel.org,
patrick.havelange@essensium.com, alexandre.belloni@bootlin.com,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, mcoquelin.stm32@gmail.com,
syednwaris@gmail.com, linux-stm32@st-md-mailman.stormreply.com,
jic23@kernel.org
Subject: Re: [PATCH v5 3/5] counter: Add character device interface
Date: Sun, 25 Oct 2020 11:36:58 -0500 [thread overview]
Message-ID: <e616b7f5-2e58-4b61-5a13-f64875c542d6@lechnology.com> (raw)
In-Reply-To: <20201025125557.GA3458@shinobu>
>>>>> diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c
>>>>> index e66ed99dd5ea..cefef61f170d 100644
>>>>> --- a/drivers/counter/counter-sysfs.c
>>>>> +++ b/drivers/counter/counter-sysfs.c
>>>>
>>>>
>>>> Not sure why sysfs changes are in the chrdev patch. Are these
>>>> changes related somehow?
>>>
>>> Sorry, I forgot to explain this in the cover letter. The changes here
>>> are only useful for the character device interface. These changes
>>> introduce the extensionZ_name and extensionZ_width sysfs attributes.
>>>
>>> In the character device interface, extensions are selected by their id
>>> number, and the value returned depends on the type of data. The new
>>> sysfs attributes introduced here allow users to match the id of an
>>> extension with its name, as well as the bit width of the value returned
>>> so that the user knows whether to use the value_u8 or value_u64 union
>>> member in struct counter_event.
>>>
>>
>> Are we sure that all value types will always be CPU-endian unsigned
>> integers? Or should we make an enum to describe the data type instead
>> of just the width?
>
> It should be safe to assume that the character device interface will
> only ever return CPU-endian unsigned integers. The device driver should
> handle the conversion of any strange endianness from the device before
> the character device interface, while userspace is the one responsible
> for interpreting the meaning of count in the context of the application.
>
> Let's create a scenario for the sake of example. Suppose we want to use
> a counter device to track the vertical position of a component moved by
> a linear actuator. The operator considers some vertical position as the
> horizon, where anything above would be a positive position and anything
> below a negative position. The counter device stores its count in
> big-endian format; but the system CPU expects little-endian.
>
> The flow of data for this scenario would look like the following (where
> BE = big-endian, LE = little-endian):
>
> +----------+ +---------------+ +--------+
> | Raw data | - BE -> | Device driver | -> LE -> | chrdev | - u64 ->
> +----------+ +---------------+ +--------+
>
> At this point, the userspace application would read the unsigned integer
> from the character device and determine how to interpret the position --
> whether the count be converted to a signed value to represent a negative
> physical position.
>
> Whether or not a position should be considered negative is dependent on
> the user application and context. Because the character device does not
> know the context of the user application, it should only provide
> unsigned integers in order to ensure a standard interface for counter
> devices; userspace will be responsible for interpreting those counts to
> something meaningful for the context of their applications.
>
> William Breathitt Gray
>
Sounds reasonable to me.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-10-25 16:38 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-27 2:18 [PATCH v5 0/5] Introduce the Counter character device interface William Breathitt Gray
2020-09-27 2:18 ` [PATCH v5 2/5] docs: counter: Update to reflect sysfs internalization William Breathitt Gray
2020-09-27 2:18 ` [PATCH v5 3/5] counter: Add character device interface William Breathitt Gray
2020-10-14 1:40 ` David Lechner
2020-10-18 16:49 ` William Breathitt Gray
2020-10-20 15:53 ` David Lechner
2020-10-25 12:55 ` William Breathitt Gray
2020-10-25 16:36 ` David Lechner [this message]
2020-10-14 17:43 ` David Lechner
2020-10-14 19:05 ` William Breathitt Gray
2020-10-14 22:32 ` David Lechner
2020-10-14 22:40 ` David Lechner
2020-10-18 16:58 ` William Breathitt Gray
2020-10-20 16:06 ` David Lechner
2020-10-25 13:18 ` William Breathitt Gray
2020-10-25 16:34 ` David Lechner
2020-10-25 17:53 ` William Breathitt Gray
2020-09-27 2:18 ` [PATCH v5 4/5] docs: counter: Document " William Breathitt Gray
2020-10-08 8:09 ` Pavel Machek
2020-10-08 12:28 ` William Breathitt Gray
2020-10-12 17:04 ` David Lechner
2020-10-13 18:58 ` William Breathitt Gray
2020-10-13 19:08 ` David Lechner
2020-10-13 19:27 ` William Breathitt Gray
2020-09-27 2:18 ` [PATCH v5 5/5] counter: 104-quad-8: Add IRQ support for the ACCES 104-QUAD-8 William Breathitt Gray
2020-10-14 0:13 ` David Lechner
2020-10-18 14:50 ` William Breathitt Gray
2020-10-13 0:35 ` [PATCH v5 0/5] Introduce the Counter character device interface David Lechner
2020-10-18 14:14 ` William Breathitt Gray
[not found] ` <e38f6dc3a08bf2510034334262776a6ed1df8b89.1601170670.git.vilhelm.gray@gmail.com>
2020-10-13 2:15 ` [PATCH v5 1/5] counter: Internalize sysfs interface code David Lechner
2020-10-18 14:49 ` William Breathitt Gray
2020-10-20 15:38 ` David Lechner
2020-10-23 13:12 ` William Breathitt Gray
2020-10-15 1:38 ` David Lechner
2020-10-18 17:00 ` William Breathitt Gray
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=e616b7f5-2e58-4b61-5a13-f64875c542d6@lechnology.com \
--to=david@lechnology.com \
--cc=alexandre.belloni@bootlin.com \
--cc=alexandre.torgue@st.com \
--cc=gwendal@chromium.org \
--cc=jic23@kernel.org \
--cc=kamel.bouhara@bootlin.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=patrick.havelange@essensium.com \
--cc=syednwaris@gmail.com \
--cc=vilhelm.gray@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;
as well as URLs for NNTP newsgroup(s).