linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] Add support for Counter array components
@ 2022-08-29 15:17 William Breathitt Gray
  2022-08-29 15:17 ` [RFC PATCH 1/2] counter: Consolidate Counter extension sysfs attribute creation William Breathitt Gray
  2022-08-29 15:17 ` [RFC PATCH 2/2] counter: Introduce the COUNTER_COMP_ARRAY_U64 component type William Breathitt Gray
  0 siblings, 2 replies; 5+ messages in thread
From: William Breathitt Gray @ 2022-08-29 15:17 UTC (permalink / raw)
  To: linux-iio
  Cc: linux-kernel, mranostay, jpanis, fabien.lahoudere, gwendal,
	enric.balletbo, bleung, groeck, jic23, david, robertcnelson,
	William Breathitt Gray

The COUNTER_COMP_ARRAY_U64 Counter component type is introduced to
enable support for Counter array components. With Counter array
components, exposure for buffers on counter devices can be defined via
new Counter array component macros. This should simplify code for driver
authors who would otherwise need to define individual Counter components
for each array element.

For example, suppose a driver wants to expose a Count's read-only
capture buffer of four elements using a callback `foobar_read()`::

        COUNTER_COMP_COUNT_ARRAY_U64("capture", foobar_read, NULL, 4)

Respective sysfs attributes for each array element would appear for the
respective Count:

* /sys/bus/counter/devices/counterX/countY/capture0
* /sys/bus/counter/devices/counterX/countY/capture1
* /sys/bus/counter/devices/counterX/countY/capture2
* /sys/bus/counter/devices/counterX/countY/capture3

If a user tries to read _capture2_ for example, `idx` will be `2` when
passed to the `foobar_read()` callback, and thus the driver knows which
array element to handle.

Currently, only u64 arrays are supported. One thing to consider is
whether it would make sense to support arrays of other types. This would
allow support for arrays that don't necessarily correlate to a buffer on
the device, but rather serve as logical groupings of components.

For example, if a Signal has four polarity modes, a driver author can
define a Counter array component to handle the exposure of all four
together rather than defining individual components for each one. This
is the reason I've chosen the more generic "array" terminology for this
feature rather than "buffer".

William Breathitt Gray (2):
  counter: Consolidate Counter extension sysfs attribute creation
  counter: Introduce the COUNTER_COMP_ARRAY_U64 component type

 drivers/counter/counter-sysfs.c | 210 ++++++++++++++++++++++++--------
 include/linux/counter.h         |  78 ++++++++++++
 2 files changed, 239 insertions(+), 49 deletions(-)


base-commit: a12224997bec72d231a8dd642876e6364decdc45
-- 
2.37.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-10 23:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-29 15:17 [RFC PATCH 0/2] Add support for Counter array components William Breathitt Gray
2022-08-29 15:17 ` [RFC PATCH 1/2] counter: Consolidate Counter extension sysfs attribute creation William Breathitt Gray
2022-08-29 15:17 ` [RFC PATCH 2/2] counter: Introduce the COUNTER_COMP_ARRAY_U64 component type William Breathitt Gray
2022-09-06 14:41   ` Julien Panis
2022-09-10 23:40     ` William Breathitt Gray

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).