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>
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>
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>
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>
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>
-----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.
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>
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>
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>
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>
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
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>