From: Jonathan Cameron <jic23@cam.ac.uk>
To: Ben Dooks <ben-linux@fluff.org>
Cc: Jonathan Cameron <Jonathan.Cameron@gmail.com>,
mgross@linux.intel.com, Dmitry Torokhov <dtor@mail.ru>,
LKML <linux-kernel@vger.kernel.org>,
LM Sensors <lm-sensors@lm-sensors.org>,
David Brownell <david-b@pacbell.net>,
hmh@hmh.eng.br, Jean Delvare <khali@linux-fr.org>,
spi-devel-general@lists.sourceforge.net,
Ben Nizette <bn@niasdigital.com>
Subject: Re: [spi-devel-general] [Patch 1/4] Industrialio Core
Date: Thu, 24 Jul 2008 11:33:15 +0100 [thread overview]
Message-ID: <48885A6B.6080905@cam.ac.uk> (raw)
In-Reply-To: <20080723194230.GE26938@trinity.fluff.org>
Hi Ben,
Firstly thanks for taking a look at this.
Ben Dooks wrote:
>> +/* The actual event being pushed ot userspace */
>> +struct iio_event_data {
>> + int id;
>> + s64 timestamp;
>> +};
>
> So is this an header for an event? Where is the data in this, this
> is confusing... Also, should we have a framework to produce an
> key/pair data, so that an single event can export multiple values
> from one event...
>
> ie:
>
> struct event_header {
> unsigned int id;
> unsigned int nr_data; /* number of event_data after */
> s64 timestamp;
>
> struct event {
> struct event_header header;
> struct event_data data[0];
> };
At the current time at least the purpose of events in this subsystem is rather
different from those in say the input system. So far they have all
corresponded to things that don't actually have any data associated with them.
The list so far is:
Ring bufer 50% full, Ring buffer 75% full (due to the support for escalating
events, only the highest of these will ever be in the queue).
Motion detected, device dependent on whether this is for specific axis.
Thresholds breached.
Tap detection (common on accelerometers)
Anyhow I did originally start our with a similar layout to you have suggested
(based in input subsystem) but removed it for now as it is currently unecessary.
> the naming of these structures is rather long.
>
>> +/* Requires high resolution timers */
>> +/* TODO - provide alternative if not available? */
>> +static inline s64 iio_get_time_ns(void)
>> +{
>> + struct timespec ts;
>> + ktime_get_ts(&ts);
>> + return timespec_to_ns(&ts);
>> +}
>
> do we really need something that accurate? we should at-least have
> the option to remove the timestamp or choose something of lower
> accuracy?
Not necessarily, hence the TODO. I've been wondering about using an approach
similar to the 'scan' modes seen in the max1363 driver in which the time stamp
will simply be another 'input' recorded to the ring buffer as necessary. Within
the event structure, this is certainly something that needs to be configurable.
>> +
>> +#define INIT_IIO_SW_RING_BUFFER(ring, _bytes_per_datum, _length) { \
>> + INIT_IIO_RING_BUFFER(&(ring)->buf, \
>> + _bytes_per_datum, \
>> + _length); \
>> + (ring)->read_p = 0; \
>> + (ring)->write_p = 0; \
>> + (ring)->last_written_p = 0; \
>> + (ring)->data = kmalloc(_length*(ring)->buf.size, \
>> + GFP_KERNEL); \
>> + (ring)->use_count = 0; \
>> + (ring)->use_lock = __SPIN_LOCK_UNLOCKED((ring)->use_lock); \
>> + }
>
> these should be inlined functions.
Oops, I'll clean them up. Thanks for pointing that out.
>> +
>> +int iio_request_sw_ring_buffer(int bytes_per_datum,
>> + int length,
>> + struct iio_sw_ring_buffer **ring,
>> + int id,
>> + struct module *owner,
>> + struct device *dev);
>> +
>
> how about tying this to a driver, where you already know the owner
> and the dev?
Good point.
>> +
>> +struct iio_work_cont {
>> + struct work_struct ws;
>> + struct work_struct ws_nocheck;
>> + int address;
>> + int mask;
>> + void *st;
>> +};
>> +#define INIT_IIO_WORK_CONT(cont, _checkfunc, _nocheckfunc, _add, _mask, _st)\
>> + do { \
>> + INIT_WORK(&(cont)->ws, _checkfunc); \
>> + INIT_WORK(&(cont)->ws_nocheck, _nocheckfunc); \
>> + (cont)->address = _add; \
>> + (cont)->mask = _mask; \
>> + (cont)->st = _st; \
>> + } while (0)
>
> more nasty macros.
Yes, definitely need to get rid of most of them.
[ring buffer code]
> Nice idea, I just don't get what is actually going on in
> here. This needs more planning.
I definitely should have put together some more explanatory documents explaining
the aims and approach taken for the ring buffer handling. I'll get some initial
stuff writen and posted here shortly.
Thanks for taking a look and your suggestions,
--
Jonathan Cameron
next prev parent reply other threads:[~2008-07-24 10:33 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-23 17:00 [Patch 0/4] IndustrialIO subsystem (ADCs, accelerometers etc) Jonathan Cameron
2008-07-23 17:08 ` [Patch 1/4] Industrialio Core Jonathan Cameron
2008-07-23 18:31 ` Anton Vorontsov
2008-07-24 10:12 ` [spi-devel-general] " Jonathan Cameron
2008-07-23 19:42 ` Ben Dooks
2008-07-24 10:33 ` Jonathan Cameron [this message]
2008-07-24 9:01 ` Eric Piel
2008-07-24 11:56 ` [spi-devel-general] " Jonathan Cameron
2008-07-23 17:11 ` [Patch 2/4] Max1363 (and similar) ADCs Jonathan Cameron
2008-07-23 17:14 ` [Patch 3/4] ST LIS3L02DQ accelerometer Jonathan Cameron
2008-07-23 17:07 ` Alan Cox
2008-07-23 17:44 ` Jonathan Cameron
2008-07-23 17:17 ` [Patch 4/4] VTI SCA3000 Series accelerometer driver Jonathan Cameron
2008-07-23 17:48 ` [Patch 0/4] IndustrialIO subsystem (ADCs, accelerometers etc) Henrique de Moraes Holschuh
2008-07-24 9:44 ` Eric Piel
2008-07-24 10:08 ` Ben Dooks
2008-07-24 12:20 ` [spi-devel-general] " Jonathan Cameron
2008-07-24 12:13 ` Jonathan Cameron
2008-07-24 12:37 ` Eric Piel
2008-07-24 12:45 ` Jonathan Cameron
2008-07-24 13:26 ` Dmitry Torokhov
2008-07-24 13:39 ` Jonathan Cameron
2008-07-23 18:36 ` David Brownell
2008-07-23 19:19 ` [spi-devel-general] " Ben Dooks
2008-07-24 7:41 ` Hans J. Koch
2008-07-24 9:19 ` Alan Cox
2008-07-24 12:28 ` Jonathan Cameron
2008-07-24 10:01 ` Ben Dooks
2008-07-24 15:38 ` Hans J. Koch
2008-07-24 16:11 ` Jonathan Cameron
2008-07-24 12:32 ` Jonathan Cameron
2008-07-23 19:33 ` Ben Dooks
2008-07-24 17:57 ` [Patch 5/4] IndustrialIO subsystem very early cut of documentation + userspace demo Jonathan Cameron
2008-07-24 22:25 ` [Patch 0/4] IndustrialIO subsystem (ADCs, accelerometers etc) Jan Engelhardt
2008-07-25 11:12 ` Jonathan Cameron
2008-07-25 11:28 ` Anton Vorontsov
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=48885A6B.6080905@cam.ac.uk \
--to=jic23@cam.ac.uk \
--cc=Jonathan.Cameron@gmail.com \
--cc=ben-linux@fluff.org \
--cc=bn@niasdigital.com \
--cc=david-b@pacbell.net \
--cc=dtor@mail.ru \
--cc=hmh@hmh.eng.br \
--cc=khali@linux-fr.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lm-sensors@lm-sensors.org \
--cc=mgross@linux.intel.com \
--cc=spi-devel-general@lists.sourceforge.net \
/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