dect
/
linux-2.6
Archived
13
0
Fork 0
Commit Graph

166 Commits

Author SHA1 Message Date
Lars-Peter Clausen 8341dc04df iio:dac: Add support for the ad5449
This patch adds support for the AD5415, AD5426, AD5429, AD5432, AD5439, AD5443
and AD5449 single and dual channel DACs.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-10-19 18:46:51 +01:00
Lars-Peter Clausen 103d9fb907 iio: Add a logarithmic fractional value type
For ADCs or DACs the denominator for fractional types often is a power of two.
In this case we can use a shift operation instead of the rather expensive 64 bit
division. This patch adds a new fractional type which expects the denominator to
be specified as the log2 of the actual denominator. E.g. for ADCs and DACs this
will usually be the number of significant bits.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-10-19 18:46:51 +01: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 4525985949 iio: at91_adc: Use devm_kcalloc to allocate arrays
Use dev_kcalloc instead of devm_kzalloc to allocate arrays since it is
semantically more appropriate.

While we are at it the patch also fixes the following coccinelle warning:
	drivers/iio/adc/at91_adc.c:277:25-31: ERROR: application of sizeof to pointer

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-By: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-10-19 18:46:37 +01:00
Lars-Peter Clausen 7737fa6d1e iio: Don't compare boolean values to true/false
Fixes the following warnings from coccicheck:
	drivers/iio/inkern.c:81:6-14: WARNING: Comparison to bool
	drivers/iio/dac/ad5686.c:191:5-11: WARNING: Comparison to bool

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-10-19 16:26:24 +01:00
Peter Meerwald ace43fcefb iio: fix spelling of Accelerometer in Kconfig
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-10-19 16:19:02 +01:00
Peter Meerwald 1217c48f51 iio: use iio_push_to_buffer() in at91 driver
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-10-19 16:18:57 +01:00
Peter Meerwald e1562ef304 iio: remove useless irq_enabled variable in at91
irq_enabled is only set, but never read

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-10-19 16:18:54 +01:00
Kim, Milo f0347c36cc iio: adc: add new lp8788 adc driver
TI LP8788 PMU provides regulators, battery charger, ADC,
 RTC, backlight driver and current sinks.

 This patch enables the LP8788 ADC functions.

 The LP8788 ADC has several ADC input selection and supports 12bit resolution.
 Internal operation of getting ADC is access to registers of LP8788.
 The LP8788 ADC uses exported functions for accessing these registers.
 (exported by LP8788 MFD device driver)

 This driver supports IIO_CHAN_INFO_RAW and SCALE.
 So the IIO consumer can calculate the value with raw and scale.
 The unit of scale is micro.

 (ADC Input Selection)

 Voltage: battery voltage (MAX 5.0, 5.5 and 6.0V)
          charger input voltage
          four general ADC inputs
          coin cell voltage
 Current: battery charging current
 Temperature: IC temperature

 (The IIO map for the IIO consumer)

 The ADC input is configurable in the platform side.
 Even though this platform data is not defined,
 the default IIO map is created for supporting the power supply driver.
 The battery voltage and temperature are used inside this driver.

 (History)

 Patch v6.
 (a) Fix scale value for each ADC input selection
 Voltage and current type are mili unit and temperature is degree.
 To calculate the IC temperature,
 temp = raw * scaleint + (raw * scalepart)/ 1000000, scaleint is always 0.
      = raw * 0.061050, raw: 0 ~ 4095
 Then range of IC temperature(ADC result) is 0 ~ 250'C

 (b) Reorganization of the IIO channel Spec
 Remove address, scan_type and scan_index and rollback the datasheet name.
 The reason why 'address' field is unnecessary is no relation with each channel.
 Moreover, to get the raw ADC value, the address info is not only one register
 but also several registers.
 Therefore specific function(lp8788_get_adc_result) is called rather than
 using one 'address' field.

 (c) Fix coding style
 Remove duplicated checking routine while unregistering the IIO map.
 Fix code for space and parenthesis.

 Patch v5.
 Fix default consumer name as 'lp8788-charger'.
 Add mutex for ADC read operation.
 Reorganization on lp8788_adc_read_raw().

 Patch v4.
 Fix adc_raw function: support RAW and SCALE channel info.
 Change LP8788 ADC platform data - iio map.
 Enables the default IIO map.

 Patch v3.
 Fix wrong size of allocating iio private data.
 Fix coding styles.

 Patch v2.
 Support RAW and SCALE interface for IIO consumer.
 Clean up the iio channel spec macro.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:29:19 +01:00
Kim, Milo 3183bac16f iio: inkern: clean up error return code
When the IIO consumer tries to get specific IIO channel,
 few error cases can be happened.
 (a) Memory allocation failure
 (b) No matched ADC channel error
 (c) Invalid input arguments
 This patch enables cleaning up error handling in case of (a) and (b).

 In error handling code,
 (a): the reference count of the IIO device should be decreased.
 (b): the allocated memory should be freed with restoring the reference count.
 Therefore iio_deivce_put() is called in both cases.
 This can be handled in the last error statement.

 Additionally, integer variable is used for stating each error case explicitly.
 Then, the error returns as ERR_PTR() with this value.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:13:33 +01:00
Kim, Milo 801c4b5ca3 iio: inkern: put the IIO device when it fails to allocate memory
The reference count of the IIO device is increased if the IIO map has
 matched consumer name.
 After then, it tries to allocate the iio_channel which is used by the consumer.
 If it fails to allocate memory, the reference count should be decreased.

 This patch enables restoring the reference count of the IIO device.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:13:32 +01:00
Dan Carpenter 369d0e2013 iio: dac/ad5755: signedness bug in ad5755_setup_pdata()
We need "ret" to be signed for the error handling to work correctly.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:09:40 +01:00
Srinivas Pandruvada f07b60b7c3 iio: hid-sensors: Prevent crash during hot-unplug
When hid sensor hub is unplugged, there is a crash in
iio_device_unregister_trigger_consumer.
In a typical IIO driver when remove is called, it will unregister and free
trigger and then it will call iio_device_free.
The function iio_trigger_free() will free the allocated memory for trigger.
If this trigger was assigned to iio_dev->trig, then it should be set to NULL.
Othewise when iio_device_free() is called later, it finally calls
iio_device_unregsister_trigger(), which checks for
       if (indio_dev->trig)
                iio_trigger_put(indio_dev->trig);
If indio_dev->trig is not set to NULL, it calls iio_trigger_put on a bad
pointer causing crash.
This scenerio can happen in any driver, which is storing trigger pointer in
iio_dev structure and following current procedure during remove.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:07:34 +01:00
Greg Kroah-Hartman 8508317c96 IIO new drivers, features and rework for the 3.7 cycle, 4th set.
Here we have
 
 1) a set cleaning up and moving the ad7476 driver out of staging.
 Support for a number of additional parts is also added to that driver.
 
 2) cleanups from various people for the in kernel interface code as that
 is getting more an more real use and hence people are picking up on
 minor issues that made it through review.  Also a related useful set
 of utility functions to avoid duplicate code for converting IIO
 representations to other forms.
 
 3) a new fractional type for our read_raw / write_raw functions.
   This allows avoiding loss of accuracy via the in kernel interfaces in some
   cases as well as being rather convenient for a lot of range -> scale
   conversions.
 
 4) New AD5755 DAC driver.
 
 5) Some Blackfin timer trigger improvements including hardware pulse control
 for device triggering.
 
 6) Support for the ad7091r in the ad7476 driver.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.19 (GNU/Linux)
 
 iQIcBAABAgAGBQJQV5WKAAoJEFSFNJnE9BaIbksQAIcpGldo+clgHtLyNYdY0dsz
 CO3Ypj9CExWGLeSnUgFUf1RrevCFSaOCblxscV9S0Ms5vVCrlvg8SLX8Nm+DHS9e
 zROJMzo7mjfvoplOzuN2jXGn/T1SPPcsMBnpzJeeILVJm2G/LkUbIUU2KbCd8nBI
 xO6cehKGwg6kBz+Az8ZJXOamfr7S2THIMVDucAKNjF4Cg3lLfmKKgDqEXT2oR6xc
 yzaOnu3ObJuHi0GF6hcRFn5Q4J5MN/Lnw7M2BRQd6SazR4uLRI+17Hq7pDnXvMgJ
 QYCUUJx2uCg+5bmfYeLfgcFXUMGg6wF5Q7UO/94IiI/r5PKiNHwKwFrYMM30cZcs
 A/aRZm/YndnwpL2NUahqi/14Hoj0DnwsVSmCF2IGIzy7687xpuL4FZVuTuYc9uvX
 xlfc52stQ14xgtcsO5hpAMnTtqNiFHJHD9cCrzszGRQvqXOxMolgMOokEM02XRK9
 AUGdZjeSpE6rc6FFFgdkmElpRFLHBpiKjmq82zuMMz3kbpkQWmw5IrJNXBH65KRM
 sJUSHXZ/sXBRooDgGJej+Kg1DJzKQFxD3jB21wt0Zic3HvE73zHP0grtR5z5TnH6
 ABeMTDNkK04yGlPggJUtiT/ocdtlcvT4HzH1nKIHxLNOgYfVJabmfP1barArOc5W
 P3rBUFAbfQDTsL3aqkfu
 =BlMh
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-v3.7d' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

IIO new drivers, features and rework for the 3.7 cycle, 4th set.

Here we have

1) a set cleaning up and moving the ad7476 driver out of staging.
Support for a number of additional parts is also added to that driver.

2) cleanups from various people for the in kernel interface code as that
is getting more an more real use and hence people are picking up on
minor issues that made it through review.  Also a related useful set
of utility functions to avoid duplicate code for converting IIO
representations to other forms.

3) a new fractional type for our read_raw / write_raw functions.
  This allows avoiding loss of accuracy via the in kernel interfaces in some
  cases as well as being rather convenient for a lot of range -> scale
  conversions.

4) New AD5755 DAC driver.

5) Some Blackfin timer trigger improvements including hardware pulse control
for device triggering.

6) Support for the ad7091r in the ad7476 driver.
2012-09-17 14:42:54 -07:00
Lars-Peter Clausen 87c5b10fd9 iio: ad7476: Add support for the ad7091r
Add support for the ad7091r 12 bit ADC to the ad7476 driver. Although the
ad7091r is not really related to any of the other devices supported by this
driver, luckily for us there are not so many ways (which are not totally insane)
how sampling a single channel ADC via SPI can be implemented and support for the
ad7091r can be added to the driver with just a few adjustments.

The ad7091r requires an external "conversion start" pulse to start a sample
conversion. After the conversion has finished the result can be read via SPI. We
depend on a IIO trigger to generate this signal, as a result only sampling in
buffered mode and not in manual mode is available.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-17 22:10:00 +01:00
Lars-Peter Clausen 48e44ce0f8 iio:inkern: Add function to read the processed value
Add a function to read a processed value from a channel. The function will first
attempt to read the IIO_CHAN_INFO_PROCESSED attribute. If that fails it will
read the IIO_CHAN_INFO_RAW attribute and convert the result from a raw value to
a processed value.

The patch also introduces a function to convert raw value to a processed value
and exports it, in case a user needs or wants to do the conversion by itself.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-17 21:48:51 +01:00
Lars-Peter Clausen c499d029d8 iio:dac: Add ad5755 driver
This patch adds support for the AD5755, AD5755-1, AD5757, AD5735, AD5737 16 and
14 bit quad-channel DACs. The AD5757/AD5737 only have current outputs, but
for the AD5755/AD5757 each of the outputs can be configured to either be a
voltage or a current output. We only allow to configure this at device probe
time since usually this needs to match the external circuitry and should not be
changed on the fly.

A few trivial formatting changes on merge.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-17 20:55:54 +01:00
Kim, Milo b2b79ffa40 iio: inkern: add error case in iio_channel_get()
The datasheet name is defined in the IIO driver.
 On the other hand, the adc_channel_label is configured in
 the platform side.
 If the datasheet name is not matched with any adc_channel_label,
 the iio_channel_get() should be returned as error for preventing
 invalid channel data access.

 This can be handled either way.
 (a) checking null data when using it : in the xxx_read_raw()
 or
 (b) error returns when the channel is requested : this patch

 The IIO consumer can't use the channel with invalid channel spec.
 Therefore case (b) is more reasonable.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-17 19:16:42 +01:00
Greg Kroah-Hartman 6a2a2cdd57 Merge 3.6-rc6 into staging-next
This pulls in the staging tree fixes in 3.6-rc6 into our branch to resolve the
merge issues.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-16 17:17:25 -07:00
Kim, Milo 2cc412b513 iio: inkern: allocate zeroed memory
Use kzalloc() rather than kmalloc() for initializing the iio_channel structure.
 This patch enables the iio_dev and iio_chan_spec are set to NULL.
 This may prevent the page fault problem because the pointer of iio_chan_spec
 is initialized as NULL.

 The iio_chan_spec is updated only in case that the IIO map has
 specific channel label.
 When the map has no ADC channel label, then the value of iio_chan_spec
 remains as invalid pointer.
 To prevent this problem, the pointer should be initialized as NULL.

Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-15 10:27:40 +01:00
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
Julia Lawall f755bbbf1f drivers/iio/adc/at91_adc.c: adjust inconsistent IS_ERR and PTR_ERR
Change the call to PTR_ERR to access the value just tested by IS_ERR.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

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

(
if (IS_ERR(e)) { ... PTR_ERR(e) ... }
|
if (IS_ERR(e=e1)) { ... PTR_ERR(e) ... }
|
*if (IS_ERR(e))
 { ...
*  PTR_ERR(e1)
   ... }
)
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27 21:15:25 +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
Jonathan Cameron 8f5879b20b IIO: Add a modifier for sqrt(x^2+y^2)
There will probably be a number of such modifiers eventually but
this one is used in the adis16204 accelerometer driver.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-06-30 10:15:22 +01:00
Jonathan Cameron 314be14bb8 iio: Rename _st_ functions to loose the bit that meant the staging version.
These were originally introduced when the plan was to have parallel
IIO cores in and out of staging with a slow move between them.
Now we have reached the point where the whole core has moved,
they need clearing up!

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-06-30 10:15:12 +01:00
Lars-Peter Clausen 6a17a0768f iio:dac:ad5064: Add support for the ad5629r and ad5669r
The ad5629r and ad5669r are the I2C variants of the ad5628 and ad5668. Since the
ad5064 driver currently only supports SPI based devices the major part of this
patch focuses on adding support for I2C based devices. Adding support for the
actual parts boils down to adding entries for them to the device id table.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-06-30 10:15:09 +01:00
Lars-Peter Clausen 8ec4cf5303 iio:adc: Add AD7265/AD7266 support
This patch adds support for the Analog Devices AD7265 and AD7266
Analog-to-Digital converters.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-06-30 10:15:07 +01:00
Lars-Peter Clausen 779c0c4619 iio:dac:ad5446: Add support for the AD5450/51/52/53
This patch adds support for the Analog Devices AD5450/51/52/53 Digital-to-Analog
converters.

The AD5452 and AD5453 are software compatible to the existing AD5444 and AD5446.
The AD5450 and AD5451 are similar but have a smaller resolution.

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-26 14:57:30 -07:00
Lars-Peter Clausen 90e6dc7c27 iio:adc:at91: Relase mutex on error path in at91_adc_read_raw
This issue was reported by the mini_lock.cocci coccinelle semantic patch.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-26 14:57:30 -07:00
Greg Kroah-Hartman bcc66c0b88 Merge 3.5-rc4 into staging-next
This picks up the staging changes made in 3.5-rc4 so that everyone can sync up
properly.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-25 09:31:00 -07:00
Lars-Peter Clausen 971ff1db41 iio:trigger: Use to_iio_trigger() instead of dev_get_drvdata()
Use to_iio_trigger(dev) instead of dev_get_drvdata(dev). Both will return the
trigger which belongs to the device, but the the first on is a bit more
lightweight.

Since this is the last location where we used dev_get_drvdata() for retrieving
the trigger there is no need anymore to assign the the trigger to the devices
drvdata, so we can remove that as well.

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-22 21:08:11 -07:00
Peter Meerwald 62a1efb9f8 iio: add vcnl4000 combined ALS and proximity sensor
minimal driver, no IR current control and proximity/event
handling yet

v5:
* checkpatch warnings
* increase msleep() to 20 ms when waiting for data ready as
  measurement/conversion can take up to 100 ms, 1 ms is too short

v4 (address comments by Jonathan Cameron)
* remove SENSORS_ prefix in Kconfig
* change from IIO_INTENSITY to IIO_LIGHT
* move from staging

v3 (address comments by Shubhrajyoti Datta)
* cleanup Kconfig entry
* call I2C read/write functions directly

v2 (address comments by Lars-Peter Clausen and Jonathan Cameron)
* unify code for reading PS and AL data into
  parameterized _measure() function
* limit wait for data to become ready within 20 tries
* drop IIO_LIGHT channel, add SCALE to IIO_INTENSITY
* drop extra string arguments used for logging purpose only

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-20 16:12:46 -07:00
Lars-Peter Clausen 90032e4e9c iio:adc:at91: Use new triggered buffer setup helper
Use the new triggered buffer setup helper function to allocate and register
buffer and pollfunc.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-18 17:26:09 -07:00
Lars-Peter Clausen 23f2d735a9 iio: Add helper function for initializing triggered buffers
Add a helper function for executing the common tasks which are usually involved
in setting up a simple software ringbuffer. It will allocate the buffer,
allocate the pollfunc and register the buffer.

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 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
Axel Lin d03fcfe626 iio: dac: Convert ad5380 to devm_regmap_* APIs
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-15 14:36:25 -07:00
Jiri Kosina a529ae4ba3 iio: drop wrong reference from Kconfig
The documentation lives in drivers/staging/iio/Documentation, but
according to Jonathan it's obsolete and needs fixing.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-14 17:28:46 -07:00
Greg Kroah-Hartman 89a86a2da3 Merge branch 'staging-linus' into staging-next
We need this for the pstore fixes that went into the staging-linus branch, so
that things apply properly for the pstore/android code merge.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-13 16:57:09 -07:00
Michael Hennerich 011c10c351 iio: ad9523: Fix argument type mismatch
drivers/iio/frequency/ad9523.c:378 ad9523_vco_out_map()
	 warn: value 2 can't fit into 1 'out'

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12 14:50:51 -07:00
Peter Meerwald cf35ad61ac iio: add mcp4725 I2C DAC driver
v5:
* fix warnings (Jonathan Cameron)

v4:
* remove unused indio_dev pointer in mcp4725_data (Jonathan Cameron)
* use u16 instead of unsigned short in mcp4725_data (Jonathan Cameron)
* #include mcp4725.h from linux/iio/dac/

v3:
* move from staging to drivers/iio
* switch to chan_spec
* dev_get_drvdata() -> dev_to_iio_dev()
* annotate probe() and remove() with __devinit and __devexit

v2 (based on comments from Jonathan Cameron and Lars-Peter Clausen):
* did NOT switch to chan_spec yet
* rebase to staging-next tree, update iio header locations
* dropped dac.h #include, not needed
* strict_strtol() -> kstrtol()
* call iio_device_unregister() in remove()
* everything in one patch

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12 14:50:51 -07:00
Dan Carpenter 1a135d1ab5 iio: frequency: adf4350: using an uninitialized variable
GCC complains that we use an uninitialized variable if the user passes
an invalid parameter to adf4350_read().  I decided that we should return
-EINVAL instead in that case.

However, when I looked up at adf4350_write() it returned -ENODEV for
that condition.  In the end, I decided the -EINVAL was the right thing
and I change adf4350_write() to match.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12 14:48:39 -07:00
Dan Carpenter e86ee142a2 iio: frequency: adf4350: fix an initialization
Sparse complains about this:
drivers/iio/frequency/adf4350.c:58:29: warning: Initializer entry defined twice
drivers/iio/frequency/adf4350.c:59:10:   also defined here

It looks like '|' was intended here instead of ','.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12 14:47:03 -07:00
Peter Meerwald f9eb89e97d iio: max517: mark probe() and remove() with __devinit and __devexit
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Roland Stigge <stigge@antcom.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12 14:45:16 -07:00
Peter Meerwald 227d5e0040 iio: remove indio_dev pointer from max517_data
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Roland Stigge <stigge@antcom.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12 14:45:16 -07:00
Dan Carpenter 17c88eb6a0 iio: frequency: ad9523: unlock on error in ad9523_reg_access()
There was a return path which got missed accidentally.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-12 14:45:16 -07:00
Lars-Peter Clausen 74dcd439bf iio: iio_enum_available_read: Prevent possible buffer overflow
Use scnprint instead of snprintf, because snprintf returns the number of bytes
that would have been written to the buffer if there was enough space, and as a
result writing to buf[len-1] might cause a access beyond the buffers limits.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
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-07 14:26:29 +09:00
Michael Hennerich a21e6bfeb4 iio: adf4350: fix compiler warning [-Wuninitialized]
drivers/iio/frequency/adf4350.c:316:32: warning: ‘val’ may be used uninitialized in this function
[-Wuninitialized]

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-07 14:26:28 +09:00
Lars-Peter Clausen dbdc025bb2 staging:iio: Move DAC drivers out of staging
The IIO DAC drivers are in a reasonably good shape. They all make use of channel
spec and non of them provides non-documented sysfs attributes. Code style should
be OK as well, both checkpatch and coccicheck only report trivial issues.

So lets move the whole folder out of staging.

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-05 14:02:25 +09:00
Lars-Peter Clausen 5212cc8a9d iio: Add helper functions for enum style channel attributes
We often have the case were we do have a enum style channel attribute. These
attributes have in common that they are a list of string values which usually
map in a 1-to-1 fashion to integer values.

This patch implements some common helper code for implementing enum style
channel attributes using extended channel attributes. The helper functions take
care of converting between the string and integer values, as well providing a
function for "_available" attributes which list all available enum items.

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-05 13:47:29 +09:00
Lars-Peter Clausen 1875ffd218 iio:inkern: Use iio_device_{get,put}
Use iio_device_get and iio_device_put instead of open-coding it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-04 21:21:29 -07:00
Michael Hennerich e31166f0fd iio: frequency: New driver for Analog Devices ADF4350/ADF4351 Wideband Synthesizers
Changes since V1:
Apply Jonathan's review feedback:
    Introduce and use IIO_ALTVOLTAGE.
    Fix up comments and documentation.
    Remove dead code.
    Reorder some code fragments.
    Add missing iio_device_free.

Convert to new API.
Fix-up out of staging includes.
Removed pll_locked attribute.

Changes since V2:
Use module_spi_driver.
adf4350_remove: move gpio_free after regulator.
target patch to drivers/iio

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-04 21:19:40 -07:00