Commit Graph

95 Commits

Author SHA1 Message Date
Lars-Peter Clausen
7985e7c100 iio: Introduce a new fractional value type
Currently IIO uses a decimal fixed point representations for real type numbers.
This patch introduces a new representation for rational type numbers. The number
will be expressed by specifying a numerator and denominator. For converting a
raw value to a processed value multiply it by the numerator and divide it by the
denominator.

The reasoning for introducing this new type is that for a lot of devices the
scale can be represented easily by a fractional number, but it is not possible
to represent it as fixed point number without rounding.  E.g. for a simple DAC
the scale is often the reference voltage divided by the number of possible
values (Usually 2**n_bits - 1). Each driver currently implements the conversion
of this fraction to a fixed point number on its own.

Also when it comes to the in-kernel interface this allows to directly use the
fractional factors to convert a raw value to a processed value. This should on
one hand require less instructions and on the other hand increase the
precision.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-15 10:12:22 +01:00
Lars-Peter Clausen
c26cc89e8d iio:ad7476: Add support for ad7273/ad7274/ad7276/ad7277/ad7278
The ad7276/ad7277/ad7278 are similar to the ad7476/ad7477/ad7478 but have the
same number of leading zeros as the ad7940. The ad7273/ad7274 have a extra pin
for VREF where as for the ad7276/ad7277/ad7278 VREF is taken from VDD, but
otherwise they are compatible to the ad7276/ad7277.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-15 10:02:16 +01:00
Lars-Peter Clausen
4c337de870 iio:ad7476: Add ad7940 support
The AD7940 is a single channel 14 bit ADC similar to the ADCs already supported
by the ad7476 driver, but it does have a different shift factor.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-15 10:02:15 +01:00
Lars-Peter Clausen
ac5332b147 iio:ad7476: Add ad7910/ad7920 device table entries
The ad7910/ad7920 are software compatible to the ad7467/ad7466.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-15 10:02:15 +01:00
Lars-Peter Clausen
968f3d5ba0 iio: Move ad7476 driver out of staging
The ad7476 driver is a driver for simple single channel ADCs. The driver does
not export any experimental or custom ABI files nor do the static code check
tools report any issues, so move the driver out of staging.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-15 10:02:14 +01:00
Lars-Peter Clausen
7b123c85bb staging:iio:adc: Add AD7791 driver
This patch adds support for the Analog Devices AD7787, AD7788, AD7789, AD7790
and AD7791 Sigma Delta Analog-to-Digital converters.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-08 10:20:09 +01:00
Lars-Peter Clausen
bf83238019 iio:ad5446: Add device ids for ad5301/ad5311/ad5321
The ad5301/ad5311/ad5321 are software compatible to the ad5602/ad5612/ad5622.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-08 10:14:46 +01:00
Lars-Peter Clausen
2fafbce250 iio:ad5446: Add support for the ad5300/ad5310/ad5320
The ad5300/ad5310/ad5320 is a family of single channel DACs with a SPI interface
similar to the ad5601/ad5611/ad5621 but use a different shift factor for the
data word.

While we are at it also reorder the device part numbers in the ad5446 driver
Kconfig to be ordered alphabetically.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-08 10:14:45 +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
Jonathan Cameron
a0d7bf7dd1 staging:iio: hid-sensors Use iio_push_to_buffer
Consistently use iio_push_to_buffer instead of manually calling the buffers
store_to callback.

These crossed with Lars-Peter's patch set doing every other case.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
2012-09-07 19:09:20 +01:00
srinivas pandruvada
ed5514c925 iio: hid-sensors: Added ALS
Added usage id processing for ALS. This uses IIO
interfaces for triggered buffer to present data to user
mode.This uses HID sensor framework for registering callback
events from the sensor hub.

Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-06 19:24:15 +01:00
srinivas pandruvada
bc1d57ba06 iio: hid-sensors: Added Compass/Magnetometer 3D
Added usage id processing for Compass 3D. This uses IIO
interfaces for triggered buffer to present data to user
mode.This uses HID sensor framework for registering callback
events from the sensor hub.

Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-06 19:22:32 +01:00
srinivas pandruvada
c5bdbef704 iio: hid-sensors: Added Gyroscope 3D
Added usage id processing for Gyroscope 3D. This uses IIO
interfaces for triggered buffer to present data to user
mode.This uses HID sensor framework for registering callback
events from the sensor hub.

Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-06 19:21:40 +01:00
srinivas pandruvada
45fe6f7d00 iio: hid-sensors: Added accelerometer 3D
Added usage id processing for Accelerometer 3D.This uses IIO
interfaces for triggered buffer to present data to user
mode.This uses HID sensor framework for registering callback
events from the sensor hub.

Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-06 19:21:09 +01:00
srinivas pandruvada
73c6768b71 iio: hid-sensors: Common attribute and trigger
This patch contains the common code, which is used by all HID sensors.
There are some common set of attributes, which every hid sensor
needs it. This patch contains all such attributes processing.
Also the trigger interface is common among all HID sensors. This
patch contains common trigger functions utilized by all HID sensors.

Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-06 19:20:11 +01:00
srinivas pandruvada
7c9ab035ac iio: core: Add hysteresis in channel spec
Added hysteresis to the list of channel info enumeration, shared
/separate bit defines and to postfix channel info strings.

Signed-off-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-06 19:04:45 +01:00
Jonathan Cameron
c8b95952e7 IIO: Update email address for Jonathan Cameron.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03 20:26:46 +01:00
Jean-Francois Dagenais
2e15c903c1 iio:ad5446: get rid of private header file
Most of the defines in there were not even used, and the structs left are
private to the .c file. Makes the driver more in line with most of the
kernel drivers.

Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03 20:26:45 +01:00
Jean-Francois Dagenais
3ec36a2cf0 iio:ad5446: Add support for I2C based DACs
This patch adds support for I2C based single channel DACs to the ad5446
driver. Specifically AD5602, AD5612 and AD5622.

V1: from Lars-Peter Clausen <lars@metafoo.de>
V2: Split the device IDs into two enums and move them to the c file.

Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03 20:26:45 +01:00
Peter Meerwald
e58bf5332d iio: fix spelling of subsystem
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03 20:26:44 +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
Peter Meerwald
d25b3808db iio: fix typos
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03 20:26:43 +01:00
Julia Lawall
00062a9c2e drivers/iio/adc/at91_adc.c: use clk_prepare_enable and clk_disable_unprepare
Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and
clk_enable, and clk_disable and clk_unprepare.  They make the code more
concise, and ensure that clk_unprepare is called when clk_enable fails.

A simplified version of the semantic patch that introduces calls to these
functions is as follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e;
@@

- clk_prepare(e);
- clk_enable(e);
+ clk_prepare_enable(e);

@@
expression e;
@@

- clk_disable(e);
- clk_unprepare(e);
+ clk_disable_unprepare(e);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03 20:26:42 +01:00
Jonathan Cameron
7c388ec1d4 iio: kfifo - add poll support.
This buffer implementation was missing poll support.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Tested-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: srinivas pandruvada <srinivas.pandruvada@intel.com>
2012-08-27 18:58:37 +01:00
Jonathan Cameron
08ce9b44b5 iio:kfifo_buf improve error handling in read_first_n.
These two elements were originally in the patch
iio:kfifo_buf  Take advantage of the fixed record size used in IIO
but Lars-Peter Clausen pointed out they should not have been
so here they are.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Tested-by: Lars-Peter Clausen <lars@metafoo.de>
2012-08-27 18:58:36 +01:00
Jonathan Cameron
c559afbfb0 iio:kfifo_buf Take advantage of the fixed record size used in IIO
By bypassing the standard macros for setting up the kfifo we can
take advantage of the fixed record size implementation without
having to have a type to pass in (from which the size of an element
is normally established).

In IIO we have variable 'scans' as our records in which any element
can be present or not.  They do not however vary when we are
actually filling or reading from the buffer.  Thus we have a fixed
record size whenever we are actually running.  As setup and tear
down are not in the fast path we can take the overhead of reinitializing
the kfifo every time.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Tested-by: Lars-Peter Clausen <lars@metafoo.de>
2012-08-27 18:58:30 +01:00
Kim, Milo
d965a8bc0c iio: use IIO_CHAN_INFO_RAW rather than 0
(a) For better readability, replace 0 with IIO_CHAN_INFO_RAW.
(b) Make same line-format as other apis()
    : iio_read_channel_scale() and iio_read_channel_offset()

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27 18:24:45 +01:00
Lars-Peter Clausen
af3008485e iio:adc: Add common code for ADI Sigma Delta devices
Most devices from the Analog Devices Sigma Delta family use a similar scheme for
communication with the device. This includes register access, as well as trigger
handling. But each device sub-family has different features and different
register layouts (some even have no registers at all) and thus it is impractical
to try to support all of the devices by the same driver. This patch adds a
common base library for Sigma Delta converter devices. It will be used by
individual drivers.

This code is mostly based on the three existing Sigma Delta drivers the AD7192,
AD7780 and AD7793, but has been improved for more robustness and flexibility.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27 17:53:12 +01:00
Greg Kroah-Hartman
8f8b77bfdc Merge 3.6-rc3 into staging-next
This picks up fixes we want in this branch to allow us to properly test.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-27 07:10:40 -07:00
Axel Lin
95d1c8c7e2 iio: lm3533-als: Fix build warnings
Fix below build warnings:
  CC [M]  drivers/iio/light/lm3533-als.o
drivers/iio/light/lm3533-als.c:667:8: warning: initialization from incompatible pointer type [enabled by default]
drivers/iio/light/lm3533-als.c:667:8: warning: (near initialization for 'dev_attr_in_illuminance0_thresh_either_en.show') [enabled by default]
drivers/iio/light/lm3533-als.c:667:8: warning: initialization from incompatible pointer type [enabled by default]
drivers/iio/light/lm3533-als.c:667:8: warning: (near initialization for 'dev_attr_in_illuminance0_thresh_either_en.store') [enabled by default]

Signed-off-by: Axel Lin <axel.lin@gmail.com>
2012-08-16 20:24:38 +01:00
Alexey Khoroshilov
1c795ebd00 iio/adjd_s311: Fix potential memory leak in adjd_s311_update_scan_mode()
Do not leak memory by updating pointer with potentially NULL realloc return value.
There is no need to preserve data in the buffer,
so replace krealloc() by kfree()-kmalloc() pair.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16 20:24:33 +01:00
Michael Hennerich
8857df3ace iio: frequency: ADF4350: Fix potential reference div factor overflow.
With small channel spacing values and high reference frequencies it is
possible to exceed the range of the 10-bit counter.
Workaround by checking the range and widening some constrains.

We don't use the REG1_PHASE value in this case the datasheet recommends to set
it to 1 if not used.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16 20:24:33 +01:00
Julia Lawall
390d75c128 drivers/iio/adc/at91_adc.c: use devm_ functions
The various devm_ functions allocate memory that is released when a driver
detaches.  This patch uses these functions for data that is allocated in
the probe function of a platform device and is only freed in the remove
function.

The call to platform_get_resource(pdev, IORESOURCE_MEM, 0) is moved coser
to the call to devm_request_and_ioremap, which is th first use of the
result of platform_get_resource.

This does not use devm_request_irq to ensure that free_irq is executed
before its idev argument is freed.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16 20:03:19 +01:00
Peter Meerwald
795876238f iio: fix pointer cast warning
fix compile warning reported by Fengguang Wu:

drivers/iio/light/adjd_s311.c: In function 'adjd_s311_trigger_handler':
drivers/iio/light/adjd_s311.c:188:12: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
drivers/iio/light/adjd_s311.c:188:4: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

   185              }
   186
   187              if (indio_dev->scan_timestamp)
 > 188                      *(s64 *)((phys_addr_t)data->buffer + ALIGN(len, sizeof(s64)))
   189                              = time_ns;
   190              iio_push_to_buffer(buffer, (u8 *)data->buffer, time_ns);
   191

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-15 17:33:17 +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
Greg Kroah-Hartman
fc6ed2c641 Various minor IIO fixes for staging-next.
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.19 (GNU/Linux)
 
 iQIcBAABAgAGBQJP/x8tAAoJEFSFNJnE9BaI8OIP/AxZKFDFdVV/yPFwfVVY/Hig
 HuhXSxRbEx70ck0gkTTtD2dZGTtBQsJy4uOlOncG4OpEnu22AlI/tr5cEohuzV8F
 4Vqx6kZoxtMZgoKzA1cE7u7F3753+cWeWC6Z0/45pqU4Oc4X4igi1/4LesxH+2Ct
 lmv/KnCsjxkb6aByp9Hz9xADBfDdsQ5fe1kxMx1Oj6jLqzFXnsqbUQ6Oj0NjSWUK
 NSaKiKUCGEVRBj6uT0ajzVTghZ4iCSW4mNfoln7LYUYdH3pEZ4VVwiu3/PnlnxTR
 SqxTj4ldsgIn471bmVQV0LdaNHf9dtO1br1l7AOEnzv1ah2XyxGhmq2IdshVbf/y
 g2eTreGln/fJt9h+r124m3gxC/FsHYiK3+ax2KW4SB0oRGiqXV8Q6QqmNGhhXOW+
 DBZDZez+5mdNYn2M8p017OAsgDeH+ra1LZ1N8dvIw7FZhXFSLjYLFp0Fpgfmkc0G
 sed13A72HqWkbqQjih2V1OYcsyVcfxtOqXmXfakju+utsgjb0awIt7fvUTLOxphK
 VMUBN96rAhGwZ260Dpf1TEY5iVQ3SpN8hzX+eAObtBolBVtUEMqfAqcagdRBWK3B
 ZELZ31HKAsOA+E+mX6KU75Oe474ARfXZB/DSX5I78rJSKHZ4LEhSNAsoiAwpoch0
 8CMyF2hPAEKH1BgB5VdJ
 =UMCQ
 -----END PGP SIGNATURE-----

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

Various minor IIO fixes for staging-next.
2012-07-12 12:26:33 -07:00
Dan Carpenter
e59b9afecf iio: double unlock on error path
We should be holding the mutex when we goto error_free_chans.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-12 20:00:20 +01:00
Gerard Snitselaar
21fa54e401 iio: dac: ad5064: fix section mismatch in ad5064_init() in linux-next
ad5064_init() calls ad5064_spi_unregister_driver() which is annotated
__exit.

Signed-off-by: Gerard Snitselaar <dev@snitselaar.org>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-12 20:00:08 +01:00
Lars-Peter Clausen
9660ac704e iio: ad5064: Move bus write callbacks to #if protected sections
Move the SPI and I2C specific write callbacks to the respective
"#if IS_ENABLED(CONFIG_SPI_MASTER)" and "#if IS_ENABLED(CONFIG_I2C)"
protected sections of the code.

This fixes the following warning which occurs if CONFIG_I2C is not set:
	drivers/iio/dac/ad5064.c: In function ‘ad5064_i2c_write’:
	drivers/iio/dac/ad5064.c:132: error: implicit declaration of function ‘i2c_master_send’

And the follwing warning which occurs when CONFIG_SPI_MASTER is not set:
	drivers/iio/dac/ad5064.c:137: warning: ‘ad5064_spi_write’ defined but not used

Reported-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-12 17:57:16 +01:00
Peter Meerwald
bbdb822c4c iio: add adjd_s311 I2C digital color sensor driver
sensor has 4 channels (10-bit each, R/G/B and clear), sensitivity
and gain is controlled in the driver by ext_info integration_time
and CHAN_INFO_HARDWAREGAIN

driver supports triggered buffer and IIO_CHAN_INFO_RAW to get the
sensor data

v5: address comments by Jonathan Cameron
* use macro for channel declaration
* get timestamp right before measurement
* cleanups

v4: address comments by Lars-Peter Clausen
* make sure trigger handler is exited with iio_trigger_notify_done()
  and IRQ_HANDLED
* kfree()/kalloc() -> krealloc()

v3:
* fix warnings

v2: address comments by Lars-Peter Clausen
* buffer allocation now in update_scan_mode instead of in trigger
  handler
* simplify trigger code (assume active_scan_mask is not empty, use
  for_each_set_bit, use iio_push_to_buffer)
* reorder entry in Makefile and Kconfig
* fix remove

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-12 17:45:34 +01:00
Jon Brenner
21cd1fab05 IIO channel type and modifiers for CCT and RGBC data
Add iio channel type and modifiers for Correlated Color Temperature (CCT)
and RGBC (red/green/blue/clear) data.
Add CCT and RGBC descriptions to documentation.

Changes:
Revised/condensed RGBC descriptions.

Merge and trivial fix done by Jonathan Cameron.

Signed-off-by: Jon Brenner <jbrenner@taosinc.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-10 18:49:26 +01:00
Greg Kroah-Hartman
f12db36d3f Mixed back of updates and trivial examples fixes.
Nothing terribly interesting in this one.
 
 8 July 2012
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.19 (GNU/Linux)
 
 iQIcBAABAgAGBQJP+d34AAoJEFSFNJnE9BaIJtMQAI3LR9H/WW00adqHZuRf1bZe
 +24h/yrrLuWx3KxyzHDh+AQwhFdRMUaWSme4K8wn9p4K0qVQXmY2XWE1pPk5OzdC
 LnXVl+QT8Ij+hz02Gl2GEiraAvSWVgR8jxZBfRBQtpfrsDFgyaDaq0+MlfT8W7O+
 5sF/OcraYqeaE+jx3Y1kZwgcpo4b2zd4R70HCJNxLCGEV9xC7tMDeCs7PzOwgM1B
 65/hw7EAFvDaq+xzpV+W0fmvbSnWhoYtSHSYPg5gZB0N38gYWay5fOJv3TB+4TWM
 vDxbWVfFx+qFFyOhCWXnezhnlIpt/+HLiJo/9WHma8Nonao6Dly++nYeHizVbeMc
 yk/fR7DuNKRjw5EbwNj+i9mIBnjtREGI8JSVqc9QQxuIvvXIh52Fmf0nXlFt1P/a
 yjzj1kycmWJ4P3Mll2xXlnOqE0VpHp645rbdfOz2Ix8q0LlByeRN736mlfpSrv1l
 vP9QZecufpeUvIM5z7kS/RWFZAC8wYIJVQkFHm56LrKXTec/OS7TO9g/nx8rGlzu
 eP5XfPpwUUw4BXQSRHZBY3rFhrF+p3mx5WFlQeCie/eDPgGJ1yHoCZUCc7tMRLwR
 So+7SRIoJYF6OWRkyZQE1VjiMpuHrmFG5WIKv9WuzSzyZloRZYyAD6yx4dJAz9z2
 CwzEn+/tbrwu8+8hdZSb
 =ihIe
 -----END PGP SIGNATURE-----

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

Mixed back of updates and trivial examples fixes.
Nothing terribly interesting in this one.

8 July 2012
2012-07-09 13:39:08 -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
Jonathan Cameron
7b7627410e iio: Fix inkern remove incorrect put of device
The device_get is after this point so on error we should not be
removing it.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-08 20:02:31 +01:00
Sascha Hauer
46b24311cc iio: Fix unitialized use of list
The dev_attr list is initialized in __iio_add_event_config_attrs which
is called only when indio_dev->channels is true. Nevertheless the list
is used unconditionally later in iio_device_register_eventset which
results in a NULL pointer exception. To fix this unconditionally
initialize the list in iio_device_register_eventset.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-08 20:02:24 +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
6d459aa011 iio:trigger: Register sysfs file statically
The name sysfs attribute is the same for all triggers, so there is no need to
register them dynamically at runtime. Create a attribute group for it and set it
up for the bus attribute group. This also avoids a possible race condition
where the uevent for the device is sent before the name sysfs attribute has been
added.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-08 10:39:58 +01:00
Peter Meerwald
034bd7b5d9 iio: fix spelling of detach in static func
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-07 16:52:22 +01:00
Jonathan Cameron
cf82cb8128 IIO: Add a modifier for x^2+y^2+z^2
There will probably be a number of such modifiers eventually but
this one is used in the adis16240 accelerometer driver.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-06-30 10:15:28 +01:00