From: Ben Nizette <bn@niasdigital.com>
To: Bertrand Roussel <bertrand.roussel@cor-net.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Kernel driver with multiple SPI sources
Date: Sat, 17 Oct 2009 11:34:43 +1100 [thread overview]
Message-ID: <1255739684.9801.5.camel@ben-desktop> (raw)
In-Reply-To: <a5b9b4700910160150o146a8f21n1c76c14755d64da8@mail.gmail.com>
On Fri, 2009-10-16 at 21:50 +1300, Bertrand Roussel wrote:
> _____ ______
> | | <> | ADC |
> | | |______|
> | IMU | ______ <> Bus SPI
> | | <> | MAG |
> |_____| |______|
>
> Each block correspond to a driver:
> * IMU is a basic char driver, depending on both ADC and MAG driver,
> and that register new spi_device to the spi_master
> * ADC and MAG are instances of an spi_driver, with a char driver as an interface
>
Why is the IMU part a kernel driver? Surely the kernel only needs to
know about the ADC and the MAG unit, expose interfaces for them to the
outside world and have all the IMU maths in userspace?
The ADC and MAG drivers there fit exactly in to the model of the new IIO
subsystem (industrial I/O). This subsystem is in staging/ at the moment
rather than being a first-class citizen but don't let that stop you
using it. IIO gives each device registered through it a number of sysfs
knobs to control things like sample rate etc and then a time-stamped
ring buffer holding the actual data. Your IMU then just sits in
userspace consuming that buffer, matching ADC and MAG entries with the
same (similar) timestamps and doing the maths.
And no, you certainly should not spin-wait on the data to become
available. Just set up an interrupt handler for the pin change, from
the interrupt start an spi_async transfer or spawn a workqueue to get
the data out. The async callback or workqueue then can submit the data
to IIO for buffering for userspace.
--Ben.
next prev parent reply other threads:[~2009-10-17 0:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-16 8:50 Kernel driver with multiple SPI sources Bertrand Roussel
2009-10-17 0:34 ` Ben Nizette [this message]
2009-10-17 16:05 ` 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=1255739684.9801.5.camel@ben-desktop \
--to=bn@niasdigital.com \
--cc=bertrand.roussel@cor-net.org \
--cc=linux-kernel@vger.kernel.org \
/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