iio: 104-quad-8: Add IIO support for the ACCES 104-QUAD-8
The ACCES 104-QUAD-8 is a general purpose quadrature encoder
counter/interface board. The 104-QUAD-8 is capable of monitoring the
outputs of eight encoders via four on-board LSI/CSI LS7266R1 24-bit
dual-axis quadrature counter chips. Core functions handled by the
LS7266R1, such as direction and total count, are available.
Performing a write to a counter's IIO_CHAN_INFO_RAW sets the counter and
also clears the counter's respective error flag. Although the counters
have a 25-bit range, only the lower 24 bits may be set, either directly
or via a counter's preset attribute. Interrupts are not supported by
this driver.
This driver adds IIO support for the ACCES 104-QUAD-8 and ACCES
104-QUAD-4. The base port addresses for the devices may be configured
via the base array module parameter.
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: Implement counter channel type and info constants
Quadrature encoders, such as rotary encoders and linear encoders, are
devices which are capable of encoding the relative position and
direction of motion of a shaft. This patch introduces several IIO
constants for supporting quadrature encoder counter devices.
IIO_COUNT: Current count (main data provided by the counter device)
IIO_INDEX: Counter device index value
Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: pressure: Add driver for Honeywell ABP family
This patch adds minimal driver for the Honeywell Amplified Basic
Pressure sensors series. Sensors are pretty simple but are
available in many variants:
- psi/mbar/kPa output,
- analog/i2c/spi,
- gage/differential measurement,
- different measure ranges etc.
Refer to datasheets for more details:
http://sensing.honeywell.com/honeywell-sensing-basic-board-mount-pressure-sensors-abp-series-datasheet-323005128-c-en.pdf
http://sensing.honeywell.com/index.php%3Fci_id%3D45841
Driver internals:
- i2c only. measure request is done by the SMBUS QUICK cmd, so if the i2c
bus doesn't support it, it is required to send a dummy byte to trigger
measurement,
- since iio sysfs expects kilopascals, mbar-variants are treated as their
respective kPa-s, hence i2c id-table has doubled entries in one line:
{ "abp060mg", ABP006KG }, { "abp006kg", ABP006KG },
- psi-variants have prescaled values in config,
- no temperature reads yet.
Work remained:
- optional temperature channel,
- SPI support,
- DT binding.
Changes since v1:
- mutex is now locked in read_raw(),
- corrected error codes,
- fixed coding style issues,
- renamed few defines and functions abp -> abp060mg
(some structs left as they were to keep the sensible meaning).
Signed-off-by: Marcin Malagowski <mrc@bourne.st> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Tue, 27 Sep 2016 00:20:20 +0000 (20:20 -0400)]
staging: iio: isl29018: check if the chip is in a suspended state
Add a check to isl29018_write_raw() to ensure that the chip is not in a
suspended state. This makes the code consistent with what is present
in isl29018_read_raw().
Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Tue, 27 Sep 2016 00:20:18 +0000 (20:20 -0400)]
staging: iio: isl29018: fixed race condition in in_illuminance_scale_available_show()
in_illuminance_scale_available_show() references the
isl29018_chip->int_time variable in three places inside a for loop.
The value of the int_time variable can be updated by the
isl29018_set_integration_time() function, which is called by the
isl29018_write_raw() function. isl29018_write_raw() locks a
mutex specific to this driver when the integration time variable is
updated.
Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Add new macros: IIO_ATTR_RO, IIO_ATTR_WO, IIO_ATTR_RW,
IIO_DEVICE_ATTR_RO, IIO_DEVICE_ATTR_WO and IIO_DEVICE_ATTR_RW to reduce
the amount of boiler plate code that is needed for creating new
attributes. This mimics the *_RO, *_WO, and *_RW macros that are found
in include/linux/device.h and include/linux/sysfs.h.
Signed-off-by: Brian Masney <masneyb@onstation.org> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Bhumika Goyal [Sat, 1 Oct 2016 09:57:18 +0000 (15:27 +0530)]
iio: Declare event_attrs field of iio_info structure as const
The event_attrs field of iio_info structure is only initialized once
whenever an object of iio_info is created. After that this field
is never modified again anywhere in the kernel. So, declare event_attrs
field of iio_info as a const struct attribute_group.
Checked for occurences throughout the kernel using grep and
coccinelle.
Signed-off-by: Bhumika Goyal <bhumirks@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Check for attribute_group structures that are only stored in the
attrs filed of iio_info structure. As the attrs field of iio_info
structures is constant, so these attribute_group structures can also be
declared constant.
Done using coccinelle
Check for attribute_group structures that are only stored in the
attrs filed of iio_info structure. As the attrs field of iio_info
structures is constant, so these attribute_group structures can also be
declared constant.
Done using coccinelle:
Brian Masney [Sun, 25 Sep 2016 11:41:06 +0000 (07:41 -0400)]
staging: iio: isl29018: made error handling consistent
Changed the processing of IIO_CHAN_INFO_INT_TIME in isl29018_write_raw()
to unlock the mutex and return at the end of the function if invalid
input is passed in. This makes the error handling code consistent with
the processing of IIO_CHAN_INFO_CALIBSCALE and IIO_CHAN_INFO_SCALE
within the same function.
Signed-off-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Add support for the AD7766, AD7766-1, AD7766-2, AD7767, AD7767-1, AD7767-2
Analog to Digital converters. It's a family of single channel 24-bit SAR
ADCs. They are all digital interface compatible and the main difference is
the internal decimation rate and analog performance. For communication with
the host processor a SPI interface is used.
In addition the part has a data ready pin that is pulsed for one MCLK cycle
when a conversion has completed and can be used as a IIO trigger.
iio:max1027: Use iio_trigger_validate_own_device() helper
Use the new iio_trigger_validate_own_device() to verify that the trigger
can only be attached to the matching IIO device rather than using a custom
variant.
While the implementation of iio_trigger_validate_own_device() and the
custom variant and are not identical their behaviour is.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio:mma8452: Use new iio_trigger_validate_own_device() helper
Use the new iio_trigger_validate_own_device() to verify that the trigger
can only be attached to the matching IIO device rather than using a custom
variant.
While the implementation of iio_trigger_validate_own_device() and the
custom variant and are not identical their behaviour is.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio:trigger: Add helper function to verify that a trigger belongs to the same device
Some triggers can only be attached to the IIO device that corresponds to
the same physical device. Currently each driver that requires this
implements its own trigger validation function.
Introduce a new helper function called iio_trigger_validate_own_device()
that can be used to do this check. Having a common implementation avoids
code duplication and unnecessary boiler-plate code.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Markus Elfring [Fri, 23 Sep 2016 20:30:32 +0000 (22:30 +0200)]
iio: Use kmalloc_array() in iio_scan_mask_set()
A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
When help ('?') option is passed to the command, the help text
printed but not from '?' switch case of getopt_long() but as a
invalid argument as below. Fix this by adding '?' to opt_String
of getopt_long().
root@am437x-evm:~# ./iio_generic_buffer -?
./iio_generic_buffer: invalid option -- '?'
Usage: generic_buffer [options]...
Capture, convert and output data from IIO device buffer
-a Auto-activate all available channels
...
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
The -Wempty-body gcc warning triggers in the newly added zpa2326 driver:
drivers/iio/pressure/zpa2326.c: In function 'zpa2326_dequeue_pressure':
drivers/iio/pressure/zpa2326.c:578:3: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
The use of an empty statement behind 'if (...)' is harmless here, but
it shows that the dev_dbg() macro is not used correctly: when the "DEBUG"
macro is not set, dev_dbg() already defaults to a no-operation, though
one that lets the compiler know that the arguments are used, and lets
it check the format string.
The newly added __sca3000_get_base_freq function handles all valid
modes of the SCA3000_REG_ADDR_MODE register, but gcc notices
that any other value (i.e. 0x00) causes the base_freq variable to
not get initialized:
drivers/staging/iio/accel/sca3000_core.c: In function 'sca3000_write_raw':
drivers/staging/iio/accel/sca3000_core.c:527:23: error: 'base_freq' may be used uninitialized in this function [-Werror=maybe-uninitialized]
This adds explicit error handling for unexpected register values,
to ensure this cannot happen.
staging: ks7010: Remove unnecessary variable used to store return value
This patch removes an unnecessary variable used to store return values
in order to reduce memory usage.
Done using coccinelle:
@@
type T;
constant C;
identifier ret;
@@
- T ret = C;
... when != ret
return
- ret
+ C
;
Remove 'x=a;' from a consecutive double assignment of the form 'x=a; x=b;'.
Issue detected by the semantic patch found here:
https://github.com/coccinelle/coccinellery/blob/master/write2/write2.cocci
staging: xgifb: Remove unused variable and if statement
Setting the variable 'refresh_rate = 60;' has no use to the rest of the
function. Hence the if statement setting it and the variable itself can be
removed. This was detected using the following Coccinelle semantic patch:
@@
type T;
identifier i;
constant C;
@@
(
extern T i;
|
- T i;
<+... when != i
- i = C;
...+>
)
staging: greybus: arche-platform: compress return logic into one line
Modify return statement to use the value being returned directly instead of
assigning it first to 'ret' and returning this variable. Coccinelle semantic
patch used:
@@
expression e;
local idexpression ret;
@@
-ret =
+return
e;
-return ret;
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Christian Gromm [Wed, 21 Sep 2016 12:49:09 +0000 (14:49 +0200)]
staging: most: clean up configuration strings
This patch adds the strings 'rx', 'tx' and 'isoc' to the list of accepted
identifiers when setting up a channel configuration. To keep consistency it
removes the prefix "dir_" from strings returned by the attributes
set_direction and available_directions and it removes the suffix "_avp"
from the string "isoc_avp" returned by the attributes set_datatype and
available_datatypes.
Signed-off-by: Christian Gromm <christian.gromm@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Christian Gromm [Wed, 21 Sep 2016 12:49:05 +0000 (14:49 +0200)]
staging: most: make function most_submit_mbo return void
Function most_submit_mbo() causes an exception only if either the pointer
mbo or mbo->context equals NULL. From the underlying architecture's point
of view both cases must _not_ come true and would happen only, if something
has tampered with the pointers. This would render runtime code unable to
recover anyway. So, instead trying to hide that things are already
critically out of control we're better off with a WARN_ON() assertion.
This patch replaces the return type of the function most_submit_mbo() with
'void' and adds a WARN_ONCE() assertion. Additionally, code calling the
function is adapted accordingly.
Signed-off-by: Christian Gromm <christian.gromm@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Being over zealous in removing unused EXPORT_SYMBOLs the function
lustre_swab_lov_mds_md exports were removed. They need to be
exported so this patch restores those EXPORT_SYMBOLS. Same
mistake was done when porting to the upstream client.
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: http://review.whamcloud.com/14545
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6486 Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com> Reviewed-by: John L. Hammond <john.hammond@intel.com> Reviewed-by: Oleg Drokin <oleg.drokin@intel.com> Signed-off-by: James Simmons <jsimmons@infradead.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: rts5208: Put constant on right side of comparison
Replaces position of constant from left to right side of a comparison.
Additionally, modifies logical continuations to be on the previous line and
fixes alignment to match open parenthesis. Issues found by checkpatch.
Instead of storing the return value into a variable and then returning it, we
can club the two into a single return statement. This change was made using
the following semantic patch by Coccinelle:
staging: media: cxd2099: replace printk with dev_info
Use dev_info() instead of printk(). Majority of the conversion was done
previously on this commit: 011b2aa [media] staging/media: Use dev_ printks in cxd2099/cxd2099.[ch]
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
staging: media: bcm2048: Merge assignment with return
Instead of storing the return value into a variable and then returning it, we
can club the two into a single return statement. This change was made using
the following semantic patch by Coccinelle:
staging: media: davinci_vpfe: Merge assignment with return
Instead of storing the return value into a variable and then returning it, we
can club the two into a single return statement. This change was made using
the following semantic patch by Coccinelle:
staging: ks7010: Remove unnecessary variable used to store return value
This patch removes an unnecessary variable used to store return values in order
to reduce memory usage.
Done using coccinelle:
@@
type T;
constant C;
identifier ret;
@@
- T ret = C;
... when != ret
return
- ret
+ C
;
Staging: octeon: Add missing of_node_put after calling of_parse_phandle.
of_node_put needs to be called when the device node which is got
from of_parse_phandle is no longer used.
This patch is found by below coccinelle script:
@@
expression e,e1,e2;
@@
*e = of_parse_phandle(...)
... when != of_node_put(e)
when != true e == NULL
when != e2 = e
e = e1