Граф коммитов

17 Коммитов

Автор SHA1 Сообщение Дата
Peter Meerwald 9572588c91 iio: Minor cleanups of industrialio-buffer
adding one return value check
fix one kerneldoc

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-18 21:44:13 +01:00
Lars-Peter Clausen 5d65d92045 iio: iio_push_to_buffers(): Change type of 'data' to const void *
Change the type of the 'data' parameter for iio_push_to_buffers() from 'u8 *' to
'const void *'. Drivers typically use the correct type (e.g. __be16 *) for their
data buffer. When passing the buffer to iio_push_to_buffers() it needs to be
cast to 'u8 *' for the compiler to not complain (and also having to add __force
if we want to keep sparse happy as well). Since the buffer implementation should
not care about the data layout (except the size of one sample) using a void
pointer is the correct thing to do. Also make it const as the buffer
implementations are not supposed to modify it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-15 19:02:07 +01:00
Jonathan Cameron 3704432fb1 iio: refactor info mask and ext_info attribute creation.
Introduce an enum to specify whether the attribute is separate or
shared.

Factor out the bitmap handling for loop into a separate function.

Tidy up error handling and add a NULL assignment to squish a false
positive warning from GCC.

Change ext_info shared type from boolean to enum and update in all
drivers.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2013-09-15 17:43:20 +01:00
Lars-Peter Clausen 705ee2c98a iio:buffer: Simplify iio_buffer_is_active()
We can skip having to loop through all the device's buffers to see if a certain
buffer is active, if we let the buffer's list head point to itself when the
buffer is inactive.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-15 17:35:31 +01:00
Michał Mirosław bec1889d24 iio: buffer: cleanup messages in iio_update_buffers()
1. make messages grepable (in one line)
2. include returned errno in them

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-05-22 22:16:47 +01:00
Jonathan Cameron 84b36ce5f7 staging:iio: Add support for multiple buffers
Route all buffer writes through the demux.
Addition or removal of a buffer results in tear down and
setup of all the buffers for a given device.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Tested-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
2012-11-10 10:17:21 +00:00
Lars-Peter Clausen 948ad20504 iio: Use strict_strtouint instead of kstrtoul
strict_strto* has been deprecated in favor of kstrto*. Use strict_strtouint
respective strict_strtoint, since that is what the functions we pass the
converted values to expect.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-10-19 18:46:50 +01:00
Lars-Peter Clausen ce56ade6ae iio: Drop timestamp parameter from buffer store_to callback
Drop timestamp parameter from buffer store_to callback and subsequently from
iio_push_to_buffer. The timestamp parameter is unused and it seems likely that
it will stay unused in the future, so it should be safe to remove it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-08 10:14:34 +01:00
Peter Meerwald 99698b4567 iio: whitespace cleanup and removal of semicolon after functions
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03 20:26:43 +01:00
Greg Kroah-Hartman bd972ff317 One new driver and a couple of nice cleanups.
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.19 (GNU/Linux)
 
 iQIcBAABAgAGBQJP/x5IAAoJEFSFNJnE9BaI4a8QALxYb9a+CU248/fz987hxA6d
 Ajqw2uo0sUUkeap03yjlJRCDvlyhnbinytJx/RJANRqhF4+p5Y9gMmudupnkQFlD
 qTEo3odQ7RvjcK6HURz8OKnwGMoiXpZkmcIuFyg3spIe33DonycB/O2AAvAb69LJ
 pQZoCTRNRJEK0PFbcum1vX9pNhfvnSFCVOXywBaEhZhBE03vqlgMjhnGbaoT9qLL
 ItjFCZd22JarpDZkY01PTtAVU2J6WPIvwoh585EjF1aZYV/YUrDfyqM6yAUqP01y
 YcnvMe0imwKwhubq9lfT9zphXWD4rzV/Ajr/uD0qMXmzAufBia3R74nIQ26XTlTm
 KY5dEcCTy4TJrQPxmdl2hJvWvyJ2mnJQGyfnCHpTnCWyj2jCRzXAleTbCt0QFYOB
 5tgJg8QCO3M/ZNBe+D9I5KO3JtDLMiBboeVVxPrWEVT4XyO3vQOxgzVirvXoSJID
 c64EXJFIi9PRlEXyCBB8xAyH8BS5wuAJbYdXrOzovU9nBwj18tWWY4M7NOb1bSry
 1RiLzw0mulYj59UeuyXqe2ydCOWyNw8S8XnGVgQB5Nw7WeUL4OilrwYixDiLW5qS
 ZBHgu0L37FPW1AT57lnifqAz6uGIKERqQsbJzBWz4E39uU8DXLBMLDRNiLlLeH3Z
 z3mtd7bNn8ow04rBVd9F
 =5L5b
 -----END PGP SIGNATURE-----

Merge tag 'togreg-3.6a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

IIO: One new driver and a couple of nice cleanups.
2012-07-12 12:29:44 -07:00
Lars-Peter Clausen 8163663205 iio: Introduce iio_validate_scan_mask_onehot
Add a helper function for validating a scan mask for devices where exactly one
channel must be selected during sampling. This is a common case among devices
which have scan mask restrictions so it makes sense to provide this function in
the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-09 18:18:15 +01:00
Lars-Peter Clausen 939546d1a9 iio: Add callback to check whether a scan mask is valid
This is useful for cases where the number of valid scan masks grows
exponentially, but it is rather easy to check whether a mask is valid or not
programmatically.

An example of such a case is a device with multiple ADCs where each ADC has a
upstream MUX, which allows to select from a number of physical channels.

  +-------+   +-------+
  |       |   |       | --- Channel 1
  | ADC 1 |---| MUX 1 | ---   ...
  |       |   |       | --- Channel M
  +-------+   +-------+

     .            .            .
     .            .            .
     .            .            .

  +-------+   +-------+
  |       |   |       | --- Channel M * N + 1
  | ADC N |---| MUX N | ---       ...
  |       |   |       | --- Channel M * N + M
  +-------+   +-------+

The number of necessary scan masks for this case is (M+1)**N - 1, on the other
hand it is easy to check whether subsets for each ADC of the scanmask have only
one bit set.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-09 18:18:15 +01:00
Lars-Peter Clausen e1dc7bee74 iio: iio_buffer_register: Use correct channel when calculating masklength
The channel set assigned to the iio device is not necessarily the same has the
channel set passed to iio_buffer_register. So to avoid possible complications
always work with the channel set pass to iio_buffer_register and ignore the
channel set assigned to the iio device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-08 20:02:23 +01:00
Lars-Peter Clausen f5b81ddd12 iio: iio_buffer_register: Skip channels with negative scan index
It is not always the case that all channels can be used in buffered mode. This
patch allows channels, which can not be used in buffered mode, to set their scan
index to a negative number, which will cause iio_buffer_register to ignore the
channel.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-18 17:26:09 -07:00
Lars-Peter Clausen aff1eb4e3d iio: buffer: Fix NULL pointer deref caused by empty scan mask
iio_scan_mask_match() returns NULL if the passed in scan mask is empty. This
will happen if no channel has been selected and buffer is enabled.
iio_sw_buffer_preenable() will assign NULL to indio_dev->active_scan_mask in
this case. As a result iio_update_demux() will cause a NULL pointer deref,
because it expects active_scan_mask to be non-NULL.

Since it does not make much sense to start data capture if there is no data to
capture this patch updates the code to fail gracefully in iio_scan_mask_match()
instead of crashing the kernel.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-15 14:39:19 -07:00
Lars-Peter Clausen e53f5ac52e iio: Use dev_to_iio_dev()
Replace open-coded instances of getting a iio_dev struct from a device struct
with dev_to_iio_dev().

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-14 13:37:45 -07:00
Jonathan Cameron a980e04609 IIO: Move the core files to drivers/iio
Take the core support + the kfifo buffer implentation out of
staging.  Whilst we are far from done in improving this subsystem
it is now at a stage where the userspae interfaces (provided by
the core) can be considered stable.

Drivers will follow over a longer time scale.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-25 11:11:38 -07:00