Commit graph

1226 commits

Author SHA1 Message Date
Lars-Peter Clausen 3fff227436 staging:iio:dummy: Fix potential NULL pointer dereference
If the config contains CONFIG_IIO_BUFFER=y and CONFIG_IIO_SIMPLE_DUMMY_BUFFER=n
iio_simple_dummy_configure_buffer() is stubbed out and iio_buffer_register() is
not. As a result we try to register a buffer which has not been configured.
This will causes a NULL pointer deref in iio_buffer_register. To solve this
issue move the iio_buffer_register() call to iio_simple_dummy_configure_buffer(),
so it will only be called if iio_simple_dummy_configure_buffer() has been called.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:55:08 +01:00
Lars-Peter Clausen 7aecec986e staging:iio:ad7780: Add support for the ad7170/ad7171
The ad7170/ad7171 have a software interface similar to the ad7780. They do not
have an external pin which allows to change the internal gain and the what is
used for the gain bit in the ad7780/ad7781 becomes part of the check pattern.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:25:32 +01:00
Lars-Peter Clausen 332ed63ee9 staging:iio:ad7780: Make powerdown GPIO optional
Some designs hardwire the PDRST pin to always on. In this case there is no GPIO
to control the mode of the device, so make the GPIO optional. Since now all of
the the platform data fields are optional now, make the platform data as a whole
optional as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:24:20 +01:00
Lars-Peter Clausen 67ad4e08dc staging:iio:sca3000: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.

The errors which the driver tries to handle in the remove function are
non-critical, so we can just ignore them and continue to free all resources and
remove the IIO device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:20:30 +01:00
Lars-Peter Clausen e71a837c81 staging:iio:lis3l02dq: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.

The errors which the driver tries to handle in the remove function are
non-critical, so we can just ignore them and continue to free all resources and
remove the IIO device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:20:11 +01:00
Lars-Peter Clausen e854bcc938 staging:iio:ade7759: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.

The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:19:57 +01:00
Lars-Peter Clausen 4922fd697a staging:iio:ade7758: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.

The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:18:42 +01:00
Lars-Peter Clausen db314a1aaa staging:iio:ade7754: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.

The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:18:25 +01:00
Lars-Peter Clausen d576c75586 staging:iio:ade7753: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.

The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:18:10 +01:00
Lars-Peter Clausen 0b4ac3dce4 staging:iio:adis16400: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.

The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:17:28 +01:00
Lars-Peter Clausen bea3e8a31f staging:iio:adis16200: Do not return a error in remove function
In the Linux device driver model the remove callback is not allowed to fail and
the device will be removed regardless of the return value of the remove
callback. So if we abort in the remove function and do not free all resources we
will create a resource leak. Also all kinds of undefined behaviour are expected
to happen since the IIO device is still there while its parent is already gone.

The error which the driver tries to handle in the remove function is
non-critical, so we can just ignore it and continue to free all resources and
remove the IIO device.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22 10:17:17 +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 587a51241c staging:iio:trigger:bfintmr Add output support
Some converters require an external signal to start the conversion. This patch
adds support to the bfintmr trigger driver to generate such a signal.

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 2aecc5b95c staging:iio:trigger:bfintmr: Only enable timer when necessary
This patch hooks up the set_trigger_state callback for the blackfin timer
trigger driver and only enables the timer when a trigger consumer requests it to
be enabled. There really is no reason to keep the timer running and generate
interrupts if nobody is listening to them.

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 37812d2e10 staging:iio:trigger:bfintmr: Avoid divide by zero
If the timer frequency has not been configured yet get_gptimer_period() will
return 0. Handle this case instead of blindly dividing by the returned value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-17 22:09:59 +01:00
Lars-Peter Clausen a0e545e0e7 staging:iio:hwmon bridge: Use iio_read_channel_processed
Use the iio_read_channel_processed function to read the sample value in the
proper unit instead of using iio_read_channel_raw and iio_read_channel_scale and
doing the unit conversion manually.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-17 21:49:49 +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
anish kumar ca7d1b32d2 iio: Documentation change for inkern interface.
This commit- 314be14bb renamed the _st_ functions to loose the bit
that was meant for staging version but forgot to change
the documentation which still have _st_ sprinkled in some of the
places.

Signed-off-by: anish kumar <anish198519851985@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-15 10:02:16 +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 610a407cdc staging:iio:ad7476: Use be16_to_cpup instead of open-coding it
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 7a28fe3c93 staging:iio:ad7476: Squash driver into a single file.
After the recent cleanups the buffer support is just a single 23 line function.
This does not really justify a file on its own, so move it to the main driver
file. And with only one source file left the header file containing the device
state struct becomes superflousious so move the content of the header
file to the main driver source file as well.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-15 10:02:13 +01:00
Lars-Peter Clausen cb093e444f staging:iio:ad7476: Rework reference voltage handling
Slightly rework the reference voltage handling for the ad7476 driver. Now the only
way to specify a external reference voltage is to use the regulator API,
previously it was possible to use either platform_data or the regulator API. The
new way is more consistent with what other drivers do.

Also do not ignore errors when requesting the regulator, since this will cope
very poorly with e.g. deferred probing.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-15 10:02:03 +01:00
Lars-Peter Clausen 93e33d7030 staging:iio:ad7476: Avoid alloc/free for each sample in buffered mode
The ad7476 driver has only support for 1 channel ADCs. So the upper limit for
the buffer size is the size of one sample plus the size of the timestamp.
Preallocate a buffer large enough to hold this to avoid having to allocate and
free a new buffer for each sample being captured.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-13 20:25:49 +01:00
Lars-Peter Clausen fcc7800b65 staging:iio:ad7476: Remove duplicated chip info entries
Some of the parts supported by this driver are software compatible. The
difference between them is only in the operating voltage range. So we do not
need extra chip info entries for them.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-13 20:25:25 +01:00
Lars-Peter Clausen cb75f2335c staging:iio:ad7476: Fix off by one error for channel shift
The datasheet is a bit confusing about this. It says that a dataword has 4
leading zeros, but the first zero is already put on the bus when CS is pulled
low and the second zero is put on the bus on the first leading edge of SCLK, so
when the first bit is sampled on the first trailing edge it will sample what the
datasheet refers to as the second leading zero. Subsequently we only see 3
leading zeros in the 16 bit dataword and the result we get is shifted to the
left by one bit. Fix this by adjusting the channel shift by 1.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-12 18:32:07 +01:00
Bryan Freed 932323b74e iio: isl29018: Support fractional ALS scaling.
The Industrial IO framework supports scaling ADC values by fractions,
but most drivers default to using whole numbers.
This change turns on fractional scaling in the isl29018 driver.

Signed-off-by: Bryan Freed <bfreed@chromium.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-08 10:25:10 +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
Lars-Peter Clausen 00176b360c staging:iio: Use iio_push_to_buffer
Consistently use iio_push_to_buffer instead of manually calling the buffers
store_to callback.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-06 22:05:36 +01:00
Lars-Peter Clausen f38bc926d0 staging:iio:sysfs-trigger: Use irq_work to properly active trigger
Since iio_trigger_poll() calls generic_handle_irq() it need to be called from
hardirq context. The sysfs trigger is kicked from userspace, so it is obviously
not possible to fulfill this requirement by calling iio_trigger_poll directly.
As a workaround commit 1f785681 ("staging:iio:trigger sysfs userspace trigger
rework.") added iio_trigger_poll_chained() which uses handle_nested_irq instead
of generic_handle_irq. This in itself is a hack and only works by chance.
handle_nested_irq is intended to be called from the threaded interrupt handler
of the parent IRQ. Using handle_nested_irq is also problematic since it will
only call the threaded handler of the IRQ. But quite a few IIO drivers rely on
their hardirq handler being called or undefined behaviour will occur.

This patch uses the irq_work framework to schedule the call to
iio_trigger_poll() from hardirq context, which fixes the issues described above.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-06 22:00:28 +01:00
Jonathan Cameron 0f8c962004 staging:iio: Update email address for Jonathan Cameron.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03 20:26:46 +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
Julia Lawall f5ed9c35bd drivers/staging/iio/adc/spear_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>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03 20:26:41 +01:00
Peter Meerwald 91b4171f4e staging iio: lis3l02dq cleanup
fixes some typos, whitespace, comments

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03 20:26:40 +01:00
Peter Meerwald d1dc9c1276 staging iio: fix potential memory leak in lis3l02dq_ring.c
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27 19:09:25 +01:00
Dan Carpenter 50d4b3062d staging:iio: prevent divide by zero bugs
"val" is used as a divisor later, so we should check for zero here to
avoid a division by zero.

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-08-27 19:00:51 +01:00
Lars-Peter Clausen 8e82875268 staging:iio: Add missing __devinit and __devexit annotations
Autogenerated using the following coccinelle semantic patch:

// <smpl>
@r1@
identifier driver;
identifier fn;
position p;
type T;
@@
T driver = {
 .remove =
(
 fn@p
|
 __devexit_p(fn@p)
)
};

@r2@
identifier r1.fn;
position p != r1.p;
@@
fn@p

@r3@
identifier r1.fn;
position r1.p;
@@
(
 __devexit_p(fn@p)
|
-fn@p
+__devexit_p(fn)
)

@depends on !r2@
identifier r1.fn;
@@
 static
-int fn
+int __devexit fn
 (...) { ... }

@r11@
identifier driver;
identifier fn;
position p;
type T;
@@
T driver = {
	.probe = fn@p
};

@r12@
identifier r11.fn;
position p != r11.p;
@@
fn@p

@depends on !r12@
identifier r11.fn;
@@
 static
-int fn
+int __devinit fn
 (...) { ... }
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27 18:58:11 +01:00
Lars-Peter Clausen 8c29ecd362 staging:iio:ad7793: Add ad7785 support
The ad7785 is similar to the ad7792/ad7793, but has 20 bit wide data samples.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27 18:10:55 +01:00
Lars-Peter Clausen 525e643e48 staging:iio:ad7793: Add support for ad7794/ad7795
The ad7794/ad7795 are similar to the ad7792/ad7793, but have 6 channels instead
of 3.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27 18:10:42 +01:00
Lars-Peter Clausen 3f7c3306cf staging:iio:ad7192: Use common Sigma Delta library
Convert the ad7192 driver to make use of the new common code for devices from
the Analog Devices Sigma Delta family.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27 18:10:40 +01:00
Lars-Peter Clausen 1abec6ac69 staging:iio:ad7793: Use common Sigma Delta library
Convert the ad7793 driver to make use of the new common code for devices from
the Analog Devices Sigma Delta family.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27 18:10:36 +01:00
Lars-Peter Clausen 32e0e7e08c staging:iio:ad7780: Use common Sigma Delta library
Convert the ad7780 driver to make use of the new common code for devices from
the Analog Devices Sigma Delta family.

As a bonus the ad7780 driver gains support for buffered mode. Although this is a
bit tricky. The ad7780 reports in the lower 4 unused bits of the data word the
internal gain used. The driver will update the scale attribute value depending
on the gain accordingly, but obviously this will only work if the gain does not
change while sampling. This is not perfect, but since we store the raw value in
the buffer an application which is aware of this can extract the gain factor
from the buffer as well an apply it accordingly.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27 17:53:24 +01:00
Lars-Peter Clausen 49f8812e4d staging:iio:ad7192: Remove unused platform_data from device state struct
The platform data for the device is only used from within the drivers probe
callback, so there is no need to keep it around in the devices state struct.

While we are at it mark the platform data struct as const.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27 17:47:35 +01:00
Lars-Peter Clausen c8c194d5c2 staging:iio:ad7793: Remove unused platform_data from device state struct
The platform data for the device is only used from within the drivers probe
callback, so there is no need to keep it around in the devices state struct.

While we are at it mark the platform data struct as const.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27 17:46:49 +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
Lars-Peter Clausen 70e01880a9 staging:iio:ad7780: Mark channels as unsigned
The values reported by the AD7780 are unsigned with a binary offset:

	0x000000 is negative fullscale
	0x800000 is zeroscale
	0xffffff is positive fullscale

So mark the channel in the channel spec as unsigned rather than signed.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16 20:24:37 +01:00
Lars-Peter Clausen 4fcbcf95b7 staging:iio:ad7192: Report offset and scale for temperature channel
The temperature channel reports values in degree Kelvin with sensitivity of 5630
codes per degree. If the chip is configured in bipolar mode there is an
additional binary offset of 0x800000 and the sensitivity is divided by two.

Currently the driver does the mapping from the raw value to degree Celsius when
doing a manual conversion. This has several disadvantages, the major one being
that it does not work for buffered mode, also by doing the division by the
sensitivity in the driver the precession of the reported value is needlessly
reduced.

Furthermore the current calculation only works in bipolar mode and the current
scale is of by a factor of 1000.

This patch modifies the driver to report correct offset and scale values in
both unipolar and bipolar mode and to report the raw temperature value
for manual conversions.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16 20:24:37 +01:00
Lars-Peter Clausen 58cdff6ee7 staging:iio:ad7192: Report channel offset
In bipolar mode there is a a binary offset of 2**(N-1) (with N being the number
of bits) on the reported value. Currently this value is subtracted when doing a
manual read. While this works for manual channel readings it does not work for
buffered mode. So report the offset in the channels offset property, which will
work in both modes.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-08-16 20:24:37 +01:00
Lars-Peter Clausen a684a0c711 staging:iio:ad7192: Mark channels as unsigned
The values reported by the AD7793 are unsigned.
	In uniploar mode:
			0x000000 is zeroscale
			0xffffff is fullscale
	In bipolar mode:
			0x000000 is negative fullscale
			0x800000 is zeroscale
			0xffffff is positive fullscale

In bipolar mode there is a binary offset, but the values are still unsigned.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16 20:24:36 +01:00
Lars-Peter Clausen 74aa933894 staging:iio:ad7192: Fix setting ACX
Write to the correct register when setting the ACX bit.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16 20:24:35 +01:00
Lars-Peter Clausen f09906f43b staging:iio:ad7192: Add missing break in switch statement
Without the break statement we fall right through to the default case and return
an error value.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16 20:24:35 +01:00