Commit graph

2849 commits

Author SHA1 Message Date
Payal Kshirsagar
e7c3d05459 staging: iio: adc: ad7816.c: Replace bit shifting with BIT macro
Challenge suggested by coccinelle.
Prefer using BIT and replace bit shifting with the BIT(x) macro.

Signed-off-by: Payal Kshirsagar <payal.s.kshirsagar.98@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-02 19:57:11 +02:00
Payal Kshirsagar
6082ac0412 staging: iio: impedance-analyzer: ad5933.c: Replace bit shifting with BIT macro
Challenge suggested by coccinelle.
Prefer using BIT and replace bit shifting with the BIT(x) macro.

Signed-off-by: Payal Kshirsagar <payal.s.kshirsagar.98@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-02 19:57:11 +02:00
Daniela Mormocea
7782c3c93d staging: iio: Line over 80 characters
Fix line over 80 characters, warning by checkpatch

Signed-off-by: Daniela Mormocea <daniela.mormocea@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-18 07:05:19 +01:00
Mircea Caprioru
7ce0f21622 staging: iio: ad7192: Fix ad7193 channel address
This patch fixes the differential channels addresses for the ad7193.

Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-09 16:55:06 +00:00
Leonard Pollak
0a8a29be49 Staging: iio: meter: fixed typo
This patch fixes an obvious typo, which will cause erroneously returning the Peak
Voltage instead of the Peak Current.

Signed-off-by: Leonard Pollak <leonardp@tr-host.de>
Cc: <Stable@vger.kernel.org>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-03-09 16:55:05 +00:00
Beniamin Bia
8e8040c52e staging: iio: frequency: ad9833: Load clock using clock framework
The clock frequency is loaded from device-tree using clock framework
instead of statically value. The change allow configuration of
the device via device-trees and better initialization sequence.
This is part of broader effort to add device-tree support to this driver
and take it out from staging.

Signed-off-by: Beniamin Bia <beniamin.bia@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-02 17:06:49 +00:00
Beniamin Bia
80109c3234 staging: iio: frequency: ad9833: Get frequency value statically
The values from platform data were replaced by statically values.
This was just a intermediate step of taking this driver out of staging and
load data from device tree.

Signed-off-by: Beniamin Bia <beniamin.bia@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-02 16:01:36 +00:00
Alexandru Ardelean
0e4c2da4f0 staging: iio: cdc: ad7152: remove driver completely
The AD7153 part has been obsoleted for some time. The AD7152 part will be
obsolete in the coming future.
Moving it out of staging doesn't make sense anymore. Which makes the driver
enter a limbo state.

This patch removes the driver completely, so that no effort is placed on
it, allowing people to focus on other parts that will still be around.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-02-02 10:01:37 +00:00
Jeremy Fertic
78accaea11 staging: iio: adt7316: fix the dac write calculation
The lsb calculation is not masking the correct bits from the user input.
Subtract 1 from (1 << offset) to correctly set up the mask to be applied
to user input.

The lsb register stores its value starting at the bit 7 position.
adt7316_store_DAC() currently assumes the value is at the other end of the
register. Shift the lsb value before storing it in a new variable lsb_reg,
and write this variable to the lsb register.

Fixes: 35f6b6b86e ("staging: iio: new ADT7316/7/8 and ADT7516/7/9 driver")
Signed-off-by: Jeremy Fertic <jeremyfertic@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-01-05 17:57:06 +00:00
Jeremy Fertic
45130fb030 staging: iio: adt7316: fix the dac read calculation
The calculation of the current dac value is using the wrong bits of the
dac lsb register. Create two macros to shift the lsb register value into
lsb position, depending on whether the dac is 10 or 12 bit. Initialize
data to 0 so, with an 8 bit dac, the msb register value can be bitwise
ORed with data.

Fixes: 35f6b6b86e ("staging: iio: new ADT7316/7/8 and ADT7516/7/9 driver")
Signed-off-by: Jeremy Fertic <jeremyfertic@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-01-05 17:55:23 +00:00
Jeremy Fertic
76b7fe8d6c staging: iio: adt7316: fix handling of dac high resolution option
The adt7316/7 and adt7516/7 have the option to output voltage proportional
to temperature on dac a and/or dac b. The default dac resolution in this
mode is 8 bits with the dac high resolution option enabling 10 bits. None
of these settings affect dacs c and d. Remove the "1 (12 bits)" output from
the show function since that is not an option for this mode. Return
"1 (10 bits)" if the device is one of the above mentioned chips and the dac
high resolution mode is enabled.

In the store function, the driver currently allows the user to write to the
ADT7316_DA_HIGH_RESOLUTION bit regardless of the device in use. Add a check
to return an error in the case of an adt7318 or adt7519. Remove the else
statement that clears the ADT7316_DA_HIGH_RESOLUTION bit. Instead, clear it
before conditionally enabling it, depending on user input. This matches the
typical pattern in the driver when an attribute is a boolean.

Fixes: 35f6b6b86e ("staging: iio: new ADT7316/7/8 and ADT7516/7/9 driver")
Signed-off-by: Jeremy Fertic <jeremyfertic@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-01-05 17:52:17 +00:00
Jeremy Fertic
e9de475723 staging: iio: adt7316: fix dac_bits assignment
The value of dac_bits is used in adt7316_show_DAC() and adt7316_store_DAC(),
and it should be either 8, 10, or 12 bits depending on the device in use. The
driver currently only assigns a value to dac_bits in
adt7316_store_da_high_resolution(). The purpose of the dac high resolution
option is not to change dac resolution for normal operation. Instead, it
is specific to an optional feature where one or two of the four dacs can
be set to output voltage proportional to temperature. If the user chooses
to set dac a and/or dac b to output voltage proportional to temperature,
the da_high_resolution attribute can optionally be enabled to use 10 bit
resolution rather than the default 8 bits. This is only available on the
10 and 12 bit dac devices. If the user attempts to read or write dacs a
or b under these settings, the driver's current behaviour is to return an
error. Dacs c and d continue to operate normally under these conditions.
With the above in mind, remove the dac_bits assignments from this function
since the value of dac_bits as used in the driver is not dependent on this
dac high resolution option.

Since the dac_bits assignments discussed above are currently the only ones
in this driver, the default value of dac_bits is 0. This results in incorrect
calculations when the dacs are read or written in adt7316_show_DAC() and
adt7316_store_DAC(). To correct this, assign a value to dac_bits in
adt7316_probe() to ensure correct operation as soon as the device is
registered and available to userspace.

Fixes: 35f6b6b86e ("staging: iio: new ADT7316/7/8 and ADT7516/7/9 driver")
Signed-off-by: Jeremy Fertic <jeremyfertic@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-01-05 17:48:39 +00:00
Stefan Popa
2985a5d884 staging: iio: adc: ad7606: Move out of staging
Move ad7606 ADC driver out of staging and into the mainline.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-01-05 16:10:59 +00:00
Stefan Popa
54160ae3b2 staging: iio: adc: ad7606: Misc style fixes (no functional change)
* Placed includes in alphabetical order
* Added brackets around num and mask through out for AD760X_CHANNEL
* Used single line comments where needed
* Removed extra lines and spaces

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-01-05 16:10:52 +00:00
Stefan Popa
cc49bd1652 staging: iio: adc: ad7606: Add support for threaded irq
This patch replaces the use of a polling ring buffer with a threaded
interrupt.

Enabling the buffer sets the CONVST signal to high. When the rising edge
of the CONVST is applied, BUSY signal goes logic high and transitions low
at the end of the entire conversion process. The falling edge of the BUSY
signal triggers the interrupt.

ad7606_trigger_handler() is used as bottom half of the poll function.
It reads data from the device and stores it in the internal buffer.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-01-05 16:10:52 +00:00
Stefan Popa
ca5b4637d7 staging: iio: adc: ad7606: Use SPDX identifier
This patch replaces the license text at the top of ad7606 driver files
and instead adds SPDX GPL-2.0 license identifier.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-01-05 16:10:51 +00:00
Stefan Popa
2bbf53e3e5 staging: iio: adc: ad7606: Simplify the Kconfing menu
There is no point in having three menu entries that can be selected
individually. Instead, the SPI and parallel interfaces should select
AD7606.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-01-05 16:10:51 +00:00
Stefan Popa
43f9b204ed staging: iio: adc: ad7606: Add OF device ID table
The driver does not have a struct of_device_id table, but supported
devices are registered via Device Trees. This patch adds and OF device
ID table.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-22 16:58:14 +00:00
Stefan Popa
6620585a0c staging: iio: adc: ad7606: Use vendor prefix for DT properties
The 'adi' vendor prefix needs to be added to conversion-start, range,
first-data and oversampling-ratio properties.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-22 16:58:13 +00:00
Stefan Popa
41f71e5e7d staging: iio: adc: ad7606: Use find_closest() macro
When looking for the available scale or oversampling ratio, it is better
to use the find_closest() macro. This simplifies the code and also does
not require an exact value to be entered from the user space.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-22 16:58:13 +00:00
Stefan Popa
c0683bfd37 staging: iio: adc: ad7606: Use devm functions in probe
Switch to devm version of request_irq, iio_triggered_buffer_setup,
iio_device_register. To avoid potential ordering issues in probe,
devm_add_action_or_reset() is used for the regulator_disable(). This
simplifies the code and decreases the chance of bugs.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-22 16:58:13 +00:00
Stefan Popa
557e585c3f staging: iio: adc: ad7606: Use wait-for-completion handler
This patch replaces the use of wait_event_interruptible() with
wait_for_completion_timeout() when reading the result of a single
conversion. In this way, if the interrupt never occurs, the program will
not remain blocked.

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-22 16:58:12 +00:00
Hardik Singh Rathore
f1b753a0f8 staging: iio: ad7816: drop unnecessary initialization of variables
Initialization is unnecessary when the variable is written before it is
read. There were some occasions in which the driver would initialize `ret'
during declaration without need.

Signed-off-by: Hardik Singh Rathore <hardiksingh.k@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:57 +00:00
Slawomir Stepien
4b6374577f staging: iio: adc: ad7280a: split ad7280_attr_init() to more functions
The ad7280_attr_init function has been split into more specific
functions to increase the code readability.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:57 +00:00
Slawomir Stepien
243c5c9d7b staging: iio: adc: ad7280a: split ad7280_channel_init() to more functions
The ad7280_channel_init function has been split into more specific
functions to increase the code readability.

The setting of channel's scan_type.shift to 0, has been removed, since
it is the default value.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:57 +00:00
Marcelo Schmitt
0e0a22aebd staging: iio: ad5933: use clock framework for clock reference
Add the option to specify the external clock (MCLK) using the clock
framework.
Also remove the old platform data structure.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Gabriel Capella <gabriel@capella.pro>
Co-developed-by: Gabriel Capella <gabriel@capella.pro>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:56 +00:00
Marcelo Schmitt
c9d07120ab staging: iio: ad5933: change regulator binging for vref
Set a single voltage regulator for all voltage references.
Remove voltage reference value from default platafrom data struct.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Gabriel Capella <gabriel@capella.pro>
Co-developed-by: Gabriel Capella <gabriel@capella.pro>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:56 +00:00
Shreeya Patel
7f6b6d553d Staging: iio: adt7316: Add all irq related code in adt7316_irq_setup()
ADT7316 driver no more uses platform data and hence use device tree
data instead of platform data for assigning irq_type field and
implement this in adt7316_irq_setup function.
Switch case figures out the type of irq and if it's the default case
then assign the default value to the irq_type i.e.
irq_type = IRQF_TRIGGER_LOW
Move devm_request_threaded_irq() and assignment of chip->config1
into the adt7316_setup_irq() to unclutter the code in probe function.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:56 +00:00
Hardik Singh Rathore
1533e45748 staging: iio: adt7316: drop unnecessary initialization of variables
Initialization is unnecessary when the variable is written before it is
read. There were some occasions in which the driver would initialize `ret'
during declaration without need.

Purely a cosmetic change with no functional impact.

Signed-off-by: Hardik Singh Rathore <hardiksingh.k@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:56 +00:00
Jeremy Fertic
618ab57f95 staging: iio: adt7316: correct spelling of ADT7316_DA_EN_VIA_DAC_LDCA
Change LDCA to LDAC.

Signed-off-by: Jeremy Fertic <jeremyfertic@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:56 +00:00
Jeremy Fertic
32f228cb2a staging: iio: adt7316: change interpretation of write to dac update mode
Based on the output of adt7316_show_all_DAC_update_modes() and
adt7316_show_DAC_update_mode(), adt7316_store_DAC_update_mode() should
expect the user to enter an integer input from 0 to 3. The user input is
currently expected to account for the actual bit positions in the register.
For example, choosing option 3 would require a write of 0x30 (actually 48
since it expects base 10). To address this inconsistency, create a shift
macro to be used in the valid input check as well as the calculation for
the register write.

Signed-off-by: Jeremy Fertic <jeremyfertic@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:56 +00:00
Jeremy Fertic
9f287a1c3f staging: iio: adt7316: remove dac vref buffer bypass from adt751x
The option to allow the external vref to bypass the reference buffer is
only available for adt7316/7/8. Remove the attributes for adt751x as
well as the chip->id checks from the show and store functions.

Signed-off-by: Jeremy Fertic <jeremyfertic@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:55 +00:00
Jeremy Fertic
10bfe7cc17 staging: iio: adt7316: allow adt751x to use internal vref for all dacs
With adt7516/7/9, internal vref is available for dacs a and b, dacs c and
d, or all dacs. The driver doesn't currently support internal vref for all
dacs. Change the else if to an if so both bits are checked rather than
just one or the other.

Signed-off-by: Jeremy Fertic <jeremyfertic@gmail.com>
Fixes: 35f6b6b86e ("staging: iio: new ADT7316/7/8 and ADT7516/7/9 driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:55 +00:00
Jeremy Fertic
5107d16e0a staging: iio: adt7316: use correct variable in DAC_internal_Vref read
The dac internal vref settings are part of the ldac config register rather
than the dac config register. Change the variable being used so the read
returns the correct result.

Whilst a fix, it is for a driver in heavy churn so do not backport
to stable without taking considerable care and testing.

Signed-off-by: Jeremy Fertic <jeremyfertic@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:55 +00:00
Jeremy Fertic
85a1c11913 staging: iio: adt7316: invert the logic of the check for an ldac pin
ADT7316_DA_EN_VIA_DAC_LDCA is set when the dac and ldac registers are being
used to update the dacs instead of the ldac pin. ADT7516_SEL_AIN3 is an adc
input that shares the ldac pin. Only set these bits if an ldac pin is not
being used.

This could be backported to stable, but note there are various
other bugs that probably make that a waste of time.

Signed-off-by: Jeremy Fertic <jeremyfertic@gmail.com>
Fixes: 35f6b6b86e ("staging: iio: new ADT7316/7/8 and ADT7516/7/9 driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:55 +00:00
Jeremy Fertic
53a6f022b4 staging: iio: adt7316: fix register and bit definitions
Change two register addresses and one bit definition to match the
datasheet.

Note that there are many issues in this driver so I would
not suggest backporting these fixes to stable trees.

Signed-off-by: Jeremy Fertic <jeremyfertic@gmail.com>
Fixes: 35f6b6b86e ("staging: iio: new ADT7316/7/8 and ADT7516/7/9 driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-16 14:05:55 +00:00
Jeremy Fertic
5c608d4dd4 Revert "Staging: iio: adt7316: Add an extra check for 'ret' equals to 0"
This reverts commit 00426e9978.

i2c_smbus_read_byte() returns 0 when a byte with the value 0 is read from
the device. This is a valid read so revert the check for 0.

Signed-off-by: Jeremy Fertic <jeremyfertic@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-08 11:15:54 +00:00
Slawomir Stepien
794e20ee03 staging: iio: adc: ad7280a: fix overwrite of the returned value
The ret returned from ad7280_chain_setup() is needed to initialize the
slave_num. Don't overwrite it with call to devm_add_action_or_reset().

Fixes: cc9c58ef6e ("staging: iio: adc: ad7280a: use devm_* APIs")
Signed-off-by: Slawomir Stepien <sst@poczta.fm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-02 15:36:28 +00:00
Nicholas Mc Guire
53e8785c24 staging: iio: adc: ad7280a: check for devm_kasprint() failure
devm_kasprintf() may return NULL on failure of internal allocation thus
the assignments to  attr.name  are not safe if not checked. On error
ad7280_attr_init() returns a negative return so -ENOMEM should be
OK here (passed on as return value of the probe function). To make the
error case more readable a temporary  iio_attr  is introduced and the code
refactored.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: 2051f25d2a ("iio: adc: New driver for AD7280A Lithium Ion Battery Monitoring System2")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-01 16:35:14 +00:00
Matheus Tavares
9564c7a492 staging:iio:ad2s90: Move out of staging
Move ad2s90 resolver driver out of staging to the main tree.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Victor Colombo <victorcolombo@gmail.com>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-01 15:40:39 +00:00
Victor Colombo
3a1203bfa4 staging:iio:ad2s90: Add comment to device state mutex
Fix the checkpatch.pl issue:
"CHECK: struct mutex definition without comment".

Signed-off-by: Victor Colombo <victorcolombo@gmail.com>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-01 15:40:22 +00:00
Matheus Tavares
07e00822cc staging:iio:ad2s90: Replace license text w/ SPDX identifier
This patch removes the license boilerplate text at the top of ad2s90.c
and, instead, adds the SPDX GPL-2.0 license identifier, which solves the
checkpatch.pl warning:
"WARNING: Missing or malformed SPDX-License-Identifier tag in line 1".

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-01 15:38:01 +00:00
Alexandru Ardelean
11d509adfb staging:iio:ad2s90: Add max frequency check at probe
This patch adds a max frequency check at the beginning of ad2s90_probe
function so that when it is set to a value above 0.83Mhz, dev_err is
called with an appropriate message and -EINVAL is returned.

The defined limit is 0.83Mhz instead of 2Mhz, which is the chip's max
frequency as specified in the datasheet, because, as also specified in
the datasheet, a 600ns delay is expected between the application of a
logic LO to CS and the application of SCLK. Since the delay is not
implemented in the spi code, to satisfy it, SCLK's period should be at
most 2 * 600ns, so the max frequency should be 1 / (2 * 6e-7), which
gives roughly 830000Hz.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-01 15:35:33 +00:00
Matheus Tavares
a996590bad staging:iio:ad2s90: Remove spi setup that should be done via dt
The ad2s90 driver currently sets some spi settings (max_speed_hz and
mode) at ad2s90_probe. Since the maximum frequency is a required element
in DT binding for spi slave devices and because the spi mode for the
device can be either (0,0) or (1,1), these settings should be handled
via device tree, not in the driver's code. This patch removes them from
the probe function.

Note: The way in which the mentioned spi settings need to be specified
on the ad2s90's node of a device tree will be documented in the future
patch "dt-bindings:iio:resolver: Add docs for ad2s90".

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-01 15:35:25 +00:00
Matheus Tavares
f116914dca staging:iio:ad2s90: Add device tree support
This patch adds device tree support to ad2s90 with standard
device tree id table.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-12-01 15:35:18 +00:00
Shreeya Patel
c3d8360deb Staging: iio: adt7316: Change the name from irq_flags to irq_type
Most of the drivers in IIO uses irq_type as the name for
storing the interrupt type and hence change the name from
irq_flags to irq_type for maintaining the consistency.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-25 11:52:19 +00:00
Shreeya Patel
3310280830 Staging: iio: adt7316: Switch irq_flags to a local variable
There is no need to store irq_flags into the structure as it
is always set to the same thing. Hence switch irq_flags to a
local variable.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-25 11:49:33 +00:00
Shreeya Patel
c63460c429 Staging: iio: adt7316: Use device tree data to set ldac_pin
Make the driver use device tree instead of the platform data.
Hence, use devm_gpiod_get_optional function to get the data from
device tree for ldac-pin and accordingly make the needed changes
in the driver.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-25 11:48:57 +00:00
Shreeya Patel
f8f612530e Staging: iio: adt7316: Add of_device_id table
When the kernel starts up, it kicks off compiled-in drivers
that match “compatible” entries it finds in the device tree.
At a later stage (when /lib/modules is available), all kernel modules
that match “compatible” entries in the device tree are loaded.

But if there is no dt table then there should be a fall back path
with which desired kernel modules can be loaded. Hence, add
of_device_id table in the i2c driver to be able to use when there
is no dt table.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-25 11:43:47 +00:00
Marcelo Schmitt
bac257b0d2 staging: iio: ad5933: add device tree support
Add a of_device_id struct variable and subsequent call to
MODULE_DEVICE_TABLE macro to complete device tree support.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-25 09:58:08 +00:00
Greg Kroah-Hartman
7c0bc65c84 First set of new device support, features and cleanups for IIO in the 4.21 cycle
Along with the headline feature of 5 new drivers, we have the
 substantial addition of auxilliary sensor support on the lsm6sdx
 parts for ST.  There has also been a good set of staging cleanup
 in this period with more underway.
 
 An ever increasing number of devices supported with just a new
 ID which is a good sign that at least some manufacturers are
 continuing to stabilise their interfaces.
 
 New device support,
 * ad7124
   - New driver supporting Analog Devices' ad7124-4 and ad7124-8 parts
     with the inevitable DT binding.
 * ad7949
   - New driver supporting Analog Devices' ad7949, AD7682 and AD7689 ADCs.
 * rm3100
   - New driver supporting PNIs RM3100 magnometer with bindings and
     vendor prefix.
 * ti-dac7311
   - New driver supporting DAC7311, DAC6311 and DAC5311 TI DACs, with
     DT bindings.
 * vcnl5035
   - New driver supporting the light sensor part of the VCNL4035, with
     DT bindings
 
 Features,
 * bindings
   - Add a generic ADC channel binding as we keep reinventing this
     wheel.
 * adc128s052
   - Add IDs for additional pin compatible parts.
   - Add APCI ID seen on E3940 UP squared boards.
 * ad_sigma_delta
   - Allow for custom data register overiding default.
 * kxcjk1013
   - Add KIOX0009 ACPI ID as seen on the Acer One 10.
 * lsm6dsx
   - Rework leading to...
   - External sensor support using the built in I2C master.
   - Initial support for a slave lis2mdl magnetometer.
 * meson-saradc
   - Add temperature sensor support and bindings.
 * st_magn
   - New ID for lsm9dsl_magn with bindings
   - New ID for lis3de accelerometer
 * tpl0102
   - Add supprot for IIO_AVAIL_RANGE to report the range available
     from this device to userspace and in kernel users.
 
 Cleanups and minor fixes
 * tools
   - Allow outside specification of CFLAGS
 * ad2s90
   - Handle and spi_read error.
   - Handle spi_setup failure
   - Drop a pointless assignment.
   - Prevent a potentail race by moving device registration to after
     all other setup.
   - Add missing scale attribute.
   - Add a sanity check on channel type before trying to read it.
 * ad2s1210
   - Move to modern gpio descriptors.
   - Drop a gpioin flag which made no sense as far as we can tell.
   - Add dt table (bindings doc to follow when this is ready for
     moving out of staging).
 * ad5933
   - Drop camel-case naming of ext_clk_hz.
   - White space fixes.
 * ad7150
   - Local variable to shorten overly long line.
   - Alignment and line break fixes.
 * ad7280a
   - Handle an error path that was previously ignored.
   - Use crc8.h to build the crc table replacing custom code.
   - Avoid unecessary cast.
   - Power down the device if an error happens in probe
   - Use devm routines to simplify probe and remove.
 * ad7606
   - Alignment fixes.
 * ad7780
   - This worked as long as by coincidence an uninitialized value
     was 0.  Lets not rely on that.
   - Ensure gain update is only used with the ad778x chips that
     actually support it.
   - Tidy up pattern mask generation.
   - Read regulator when scale is requested (which should be infrequent)
     as it might have changed from initialization.
 * ad7816
   - Move to modern gpio descriptors
   - Don't use a busy_pin for ad7818 as there isn't one.
   - Ensure RD/WR and CONVST pins are outputs (previously they
     were brought up as inputs which doesn't seem to make any sense)
   - DT id table.
 * adc128s052
   - SPDX
 * adt7316
   - Alignment fix.
   - Fix data reading.  When using I2C the driver never actually
     used the value read.  This has been broken a very long time
     hence no rush to fix it now + the driver is undergoing a lot
     of cleanup.
   - Sanity check that the i2c read didn't fail to actually read
     anything.
 * dpot-dac
   - Mark a switch full through with slightly different text so that
     gcc doesn't warn on it.
 * gyro-adc
   - Fix a wrong file in the MAINTAINERS entry and add binding doc to the
     listed files.
 * ina2xx
   - Add some early returns to clarify error paths in switch.
 * lsm6dsx
   - MAINTAINERS entry.
 * max11100
   - SPDX
 * max9611
   - SPDX
 * mcp4131
   - use of_device_get_match_data in preference to spi_get_device_id
     approach.
 * rcar-adc
   - SPDX
 * sc27xx
   - Add ADC conversion timeout support to avoid possible fault.
 * ssp_sensors
   - Don't free managed resources manually.
 * st-magn
   - Add a comment to avoid future confusion over when to use -magn
     postfix (on multi chip in package parts)
   - Add BDU register for LIS3MDL where it seems to have been missed.
 * st-sensors
   - Minor spelling, grammar etc fixes.
 * tpl0102
   - Use a pointer rather than an index of an array to improve conciseness.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlv1wDARHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Fohf9Q//fzNk9RoY98awaEmHRW7PLnHe1WKyQTV5
 M13EaFwm/NeWfT1kaNd/heZDnwucB34ONrcueNcM8MfwzPwWaL9UvSqEnSWIuTae
 hKdn/BMTfy168xhu95YPjHw4X42HwcXYlHL9XFsA0WERgaWsQu2EwIy1/3XRgIrt
 QPQVyJNUkLZmBuGcd2UhxzdTiLuh/hs7FFBg037hxaR77slWYKqAzwVa6eyz/jvo
 tRT9RE50O1FT3eDkBSw91nkamFcmFyyA2j4HQ33Aitjs5O1ML95xEJ0tMAznZfKn
 zAGCCUJjFYBvWPOpQ8xBA3tplFRGIyVhPJ5ZU+B2vZcxVXQ3IFZNqKRXfrUkAXpf
 PK2+05+HjHk1g7Ms1Tj4lF5AtP/nEQ8dvmGk6/nDU7Gt4Ytrpb0DhAuMGmN4S5ih
 zwwh+c6fLGCMz7KE8AoegOn3WF/FW1ZppTRjOWgqt7OP6lgoChPuTV5HGzxiZgr+
 MzY/fytbXTnmfTL1ZvZYPdOSjkHcS9+8rwu1Jirmb1Y5Qt3qpNAUsdsnt965mQaE
 bHmuqw8QJN31goTEsqvjnsFhH57dJ1HbmG0MSrF8XB0bQB5Xzbkd+RV4fls1J+SG
 XwpIzQLhPxF5da6G+I/SIgLX6nASacJp9hHEN/ZuM3IKr2UW8FCpCH6JmyX0i6OU
 dPjHsXrGTuI=
 =78Y3
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.21a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-testing

Jonathan writes:

First set of new device support, features and cleanups for IIO in the 4.21 cycle

Along with the headline feature of 5 new drivers, we have the
substantial addition of auxilliary sensor support on the lsm6sdx
parts for ST.  There has also been a good set of staging cleanup
in this period with more underway.

An ever increasing number of devices supported with just a new
ID which is a good sign that at least some manufacturers are
continuing to stabilise their interfaces.

New device support,
* ad7124
  - New driver supporting Analog Devices' ad7124-4 and ad7124-8 parts
    with the inevitable DT binding.
* ad7949
  - New driver supporting Analog Devices' ad7949, AD7682 and AD7689 ADCs.
* rm3100
  - New driver supporting PNIs RM3100 magnometer with bindings and
    vendor prefix.
* ti-dac7311
  - New driver supporting DAC7311, DAC6311 and DAC5311 TI DACs, with
    DT bindings.
* vcnl5035
  - New driver supporting the light sensor part of the VCNL4035, with
    DT bindings

Features,
* bindings
  - Add a generic ADC channel binding as we keep reinventing this
    wheel.
* adc128s052
  - Add IDs for additional pin compatible parts.
  - Add APCI ID seen on E3940 UP squared boards.
* ad_sigma_delta
  - Allow for custom data register overiding default.
* kxcjk1013
  - Add KIOX0009 ACPI ID as seen on the Acer One 10.
* lsm6dsx
  - Rework leading to...
  - External sensor support using the built in I2C master.
  - Initial support for a slave lis2mdl magnetometer.
* meson-saradc
  - Add temperature sensor support and bindings.
* st_magn
  - New ID for lsm9dsl_magn with bindings
  - New ID for lis3de accelerometer
* tpl0102
  - Add supprot for IIO_AVAIL_RANGE to report the range available
    from this device to userspace and in kernel users.

Cleanups and minor fixes
* tools
  - Allow outside specification of CFLAGS
* ad2s90
  - Handle and spi_read error.
  - Handle spi_setup failure
  - Drop a pointless assignment.
  - Prevent a potentail race by moving device registration to after
    all other setup.
  - Add missing scale attribute.
  - Add a sanity check on channel type before trying to read it.
* ad2s1210
  - Move to modern gpio descriptors.
  - Drop a gpioin flag which made no sense as far as we can tell.
  - Add dt table (bindings doc to follow when this is ready for
    moving out of staging).
* ad5933
  - Drop camel-case naming of ext_clk_hz.
  - White space fixes.
* ad7150
  - Local variable to shorten overly long line.
  - Alignment and line break fixes.
* ad7280a
  - Handle an error path that was previously ignored.
  - Use crc8.h to build the crc table replacing custom code.
  - Avoid unecessary cast.
  - Power down the device if an error happens in probe
  - Use devm routines to simplify probe and remove.
* ad7606
  - Alignment fixes.
* ad7780
  - This worked as long as by coincidence an uninitialized value
    was 0.  Lets not rely on that.
  - Ensure gain update is only used with the ad778x chips that
    actually support it.
  - Tidy up pattern mask generation.
  - Read regulator when scale is requested (which should be infrequent)
    as it might have changed from initialization.
* ad7816
  - Move to modern gpio descriptors
  - Don't use a busy_pin for ad7818 as there isn't one.
  - Ensure RD/WR and CONVST pins are outputs (previously they
    were brought up as inputs which doesn't seem to make any sense)
  - DT id table.
* adc128s052
  - SPDX
* adt7316
  - Alignment fix.
  - Fix data reading.  When using I2C the driver never actually
    used the value read.  This has been broken a very long time
    hence no rush to fix it now + the driver is undergoing a lot
    of cleanup.
  - Sanity check that the i2c read didn't fail to actually read
    anything.
* dpot-dac
  - Mark a switch full through with slightly different text so that
    gcc doesn't warn on it.
* gyro-adc
  - Fix a wrong file in the MAINTAINERS entry and add binding doc to the
    listed files.
* ina2xx
  - Add some early returns to clarify error paths in switch.
* lsm6dsx
  - MAINTAINERS entry.
* max11100
  - SPDX
* max9611
  - SPDX
* mcp4131
  - use of_device_get_match_data in preference to spi_get_device_id
    approach.
* rcar-adc
  - SPDX
* sc27xx
  - Add ADC conversion timeout support to avoid possible fault.
* ssp_sensors
  - Don't free managed resources manually.
* st-magn
  - Add a comment to avoid future confusion over when to use -magn
    postfix (on multi chip in package parts)
  - Add BDU register for LIS3MDL where it seems to have been missed.
* st-sensors
  - Minor spelling, grammar etc fixes.
* tpl0102
  - Use a pointer rather than an index of an array to improve conciseness.

* tag 'iio-for-4.21a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (80 commits)
  Staging: iio: adt7316: Add an extra check for 'ret' equals to 0
  Staging: iio: adt7316: Fix i2c data reading, set the data field
  dt-bindings: iio: adc: Add docs for ad7124
  iio: adc: Add ad7124 support
  dt-bindings: iio: adc: Add common ADCs properties to a separate file
  iio: ad_sigma_delta: Allow to provide custom data register address
  staging: iio: ad7816: Add device tree table.
  iio: imu: st_lsm6dsx: add entry in MAINTAINERS file
  iio: potentiometer: mcp4131: use of_device_get_match_data()
  staging: iio: adc: ad7280a: use devm_* APIs
  staging: iio: adc: ad7280a: power down the device on error in probe
  dt-bindings: iio: imu: st_lsm6dsx: add support to i2c pullup resistors
  iio: imu: st_lsm6dsx: add hw FIFO support to i2c controller
  iio: imu: st_lsm6dsx: add st_lsm6dsx_push_tagged_data routine
  iio: imu: st_lsm6dsx: add i2c embedded controller support
  iio: imu: st_lsm6dsx: introduce st_lsm6dsx_sensor_set_enable routine
  iio: imu: st_lsm6dsx: introduce ST_LSM6DSX_ID_EXT sensor ids
  iio: imu: st_lsm6dsx: remove static from st_lsm6dsx_set_watermark
  iio: imu: st_lsm6dsx: reload trimming parameter at bootstrap
  iio: imu: st_lsm6dsx: introduce locked read/write utility routines
  ...
2018-11-22 09:39:45 +01:00
Shreeya Patel
00426e9978 Staging: iio: adt7316: Add an extra check for 'ret' equals to 0
ret = 0 indicates a case of no error but no data read from
the bus which is an invalid case. This case doesn't ever happen
in reality. It should perhaps be handled for correctness though.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-17 16:59:56 +00:00
Shreeya Patel
688cd642ba Staging: iio: adt7316: Fix i2c data reading, set the data field
adt7316_i2c_read function nowhere sets the data field.
It is necessary to have an appropriate value for it.
Hence, assign the value stored in 'ret' variable to data field.

This is an ancient bug, and as no one seems to have noticed,
probably no sense in applying it to stable.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-17 16:57:09 +00:00
Nishad Kamdar
c24a4173f6 staging: iio: ad7816: Add device tree table.
Add device tree table for matching vendor ID.

Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:36 +00:00
Slawomir Stepien
cc9c58ef6e staging: iio: adc: ad7280a: use devm_* APIs
devm_* APIs are device managed and make code simpler.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:35 +00:00
Slawomir Stepien
9829f9e541 staging: iio: adc: ad7280a: power down the device on error in probe
Power down the device if anything goes wrong after the SPI has been
setup correctly in the probe function.

Existing code that toggles the AD7280A_CTRL_LB_SWRST bit inside
ad7280_chain_setup function is responsible for powering up the device.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:35 +00:00
Renato Lui Geh
befa9f6a3e staging: iio: ad7780: remove unnecessary stashed voltage value
This patch removes the unnecessary field int_vref_mv in ad7780_state
referring to the device's voltage.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:31 +00:00
Renato Lui Geh
336650c785 staging: iio: ad7780: update voltage on read
The ad7780 driver previously did not read the correct device output, as
it read an outdated value set at initialization. It now updates its
voltage on read.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:31 +00:00
Giuliano Belinassi
c036a324c0 staging: iio: ad7780: generates pattern_mask from PAT bits
Previously, all pattern_masks and patterns in the chip_info table were
hardcoded. Now they are generated using the PAT macros, as described in
the datasheets.

Signed-off-by: Giuliano Belinassi <giuliano.belinassi@usp.br>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:26 +00:00
Giuliano Belinassi
23da6a1511 staging: iio: ad7780: check if ad778x before gain update
Only the ad778x have the 'gain' status bit. Check it before updating
through a new variable is_ad778x in chip_info.

Signed-off-by: Giuliano Belinassi <giuliano.belinassi@usp.br>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-16 18:32:17 +00:00
Nishad Kamdar
72e3a5248d staging: iio: ad7816: Set RD/WR pin and CONVST pin as outputs.
The RD/WR pin and CONVST pin are logical inputs to the AD78xx
chip as per the datasheet. Hence convert them to outputs.

Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-11 15:29:50 +00:00
Nishad Kamdar
06c77f564d staging: iio: ad7816: Do not use busy_pin in case of AD7818
AD7818 does not support busy_pin functionality as per datasheet.
Hence drop busy_pin when AD7818 is used.

Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-11 15:29:50 +00:00
Matheus Tavares
addacf3b49 staging:iio:ad2s90: Check channel type at read_raw
This patch adds a channel type check at the beginning of the
ad2s90_read_raw function. Since ad2s90 has only one channel, it just
checks if the given channel is the expected one and if not, return
-EINVAL.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-11 15:29:49 +00:00
Victor Colombo
ccba40e9f7 staging:iio:ad2s90: Add IIO_CHAN_INFO_SCALE to channel spec and read_raw
This patch adds the IIO_CHAN_INFO_SCALE mask to ad2s90_chan and
implements the relative read behavior at ad2s90_read_raw.

Signed-off-by: Victor Colombo <victorcolombo@gmail.com>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-11 15:29:48 +00:00
Matheus Tavares
f14a283c2d staging:iio:ad2s90: Move device registration to the end of probe
Previously, devm_iio_device_register was being called before the
spi_setup call and the spi_device's max_speed_hz and mode assignments.
This could lead to a race condition since the driver was still being
set up after it was already made ready to use. To fix it, this patch
moves the device registration to the end of ad2s90_probe.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-11 15:29:48 +00:00
Matheus Tavares
addb2ebe4a staging:iio:ad2s90: Remove always overwritten assignment
This patch removes an initial assignment to the variable ret at probe,
that was always overwritten.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-11 15:29:48 +00:00
Matheus Tavares
b3a3eafeef staging:iio:ad2s90: Make probe handle spi_setup failure
Previously, ad2s90_probe ignored the return code from spi_setup, not
handling its possible failure. This patch makes ad2s90_probe check if
the code is an error code and, if so, do the following:

- Call dev_err with an appropriate error message.
- Return the spi_setup's error code.

Note: The 'return ret' statement could be out of the 'if' block, but
this whole block will be moved up in the function in the patch:
'staging:iio:ad2s90: Move device registration to the end of probe'.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-11 15:29:47 +00:00
Matheus Tavares
070e8c7da1 staging:iio:ad2s90: Make read_raw return spi_read's error code
Previously, when spi_read returned an error code inside ad2s90_read_raw,
the code was ignored and IIO_VAL_INT was returned. This patch makes the
function return the error code returned by spi_read when it fails.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-11 15:29:47 +00:00
Renato Lui Geh
5ccc612b83 staging: iio: ad7780: fix offset read value
Variable val subtracted an uninitialized value on IIO_CHAN_INFO_OFFSET.
This was fixed by assigning the correct value instead.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Acked-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-11 15:29:46 +00:00
Nishad Kamdar
382c7fce70 staging: iio: ad2s1210: Add device tree table.
Add device tree table for matching vendor ID.

Note that as the driver is still heavily in flux and there are some
non obvious aspects to a comprehensive binding, that binding will
be submitted at a later date (before leaving staging!)

Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-11 15:29:46 +00:00
Nishad Kamdar
66dd9e3d5e staging: iio: ad2s1210: Drop the gpioin flag.
Drop gpioin flag which decides how the GPIOs
are controlled as the GPIOs must be outputs
for the host as per the datasheet.

Removes need for platform data so that is dropped as well.

Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-11 15:29:46 +00:00
Nishad Kamdar
f356dc6ec2 staging: iio: ad2s1210: Switch to the gpio descriptor interface
Use the gpiod interface instead of the deprecated old non-descriptor
interface.

Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-11 15:29:45 +00:00
Slawomir Stepien
fdee2ca14b staging: iio: adc: ad7280a: don't cast type inside switch expression
The type promotion will kick in, so the comparison will work.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-11 15:29:43 +00:00
Victor Colombo
3138bbc129 staging: iio: ad5933: Remove unnecessary blank line
This patch fixes the checkpatch.pl warning:

WARNING: Blank lines aren't necessary before a close brace '}'

Signed-off-by: Victor Colombo <victorcolombo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-03 09:44:34 +00:00
Victor Colombo
e147791fa1 staging: iio: ad5933: Remove unnecessary space on casting
This patch fixes the checkpatch.pl warning:

WARNING: No space is necessary after a cast

Signed-off-by: Victor Colombo <victorcolombo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-11-03 09:44:33 +00:00
Linus Torvalds
738b04fba1 Staging/IIO patches for 4.20-rc1
Here is the big staging and IIO driver pull request for 4.20-rc1.
 
 There are lots of things here, we ended up adding more lines than
 removing, thanks to a large influx of Comedi National Instrument device
 support.  Someday soon we need to get comedi out of staging...
 
 Other than the comedi drivers, the "big" things here are:
   - new iio drivers
   - delete dgnc driver (no one used it and no one had the hardware
     anymore)
   - vbox driver updates and fixes
   - erofs fixes
   - tons and tons of tiny checkpatch fixes for almost all staging
     drivers
 
 All of these have been in linux-next, with the last few happening a bit
 "late" due to them getting stuck on my laptop during travel to the
 Mantainers summit.
 
 When merging with your tree, there will be 2 merge conflicts, both files
 will be simple to resolve, just delete them :)
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCW9bSGA8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+yk5eACfYp73m9tLO22rnBcXJ73bWAYSTOMAn2GEL4Nc
 LZBXs8QvvJIwfqmi7ofn
 =UWJn
 -----END PGP SIGNATURE-----

Merge tag 'staging-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging/IIO driver updates from Greg KH:
 "Here is the big staging and IIO driver pull request for 4.20-rc1.

  There are lots of things here, we ended up adding more lines than
  removing, thanks to a large influx of Comedi National Instrument
  device support. Someday soon we need to get comedi out of staging...

  Other than the comedi drivers, the "big" things here are:

   - new iio drivers

   - delete dgnc driver (no one used it and no one had the hardware
     anymore)

   - vbox driver updates and fixes

   - erofs fixes

   - tons and tons of tiny checkpatch fixes for almost all staging
     drivers

  All of these have been in linux-next, with the last few happening a
  bit "late" due to them getting stuck on my laptop during travel to the
  Mantainers summit"

* tag 'staging-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (690 commits)
  staging: gasket: Fix sparse "incorrect type in assignment" warnings.
  staging: gasket: remove debug logs for callback invocation
  staging: gasket: remove debug logs in page table mapping calls
  staging: rtl8188eu: core: Use sizeof(*p) instead of sizeof(struct P) for memory allocation
  staging: ks7010: Remove extra blank line
  staging: gasket: Remove extra blank line
  staging: media: davinci_vpfe: Fix spelling mistake in enum
  staging: speakup: Add a pair of braces
  staging: wlan-ng: Replace long int with long
  staging: MAINTAINERS: remove obsolete IPX staging directory
  staging: MAINTAINERS: remove NCP filesystem entry
  staging: rtl8188eu: cleanup comparsions to false
  staging: gasket: Update device virtual address comment
  staging: gasket: sysfs: fix attribute release comment
  staging: gasket: apex: fix sysfs_show
  staging: gasket: page_table: simplify gasket_components_to_dev_address
  staging: gasket: page_table: fix comment in components_to_dev_address
  staging: gasket: page table: fixup error path allocating coherent mem
  staging: gasket: page_table: rearrange gasket_page_table_entry
  staging: gasket: page_table: remove unnecessary PTE status set to free
  ...
2018-10-29 10:38:10 -07:00
Nishad Kamdar
073a391ca0 staging: iio: ad7816: Switch to the gpio descriptor interface
Use the gpiod interface for rdwr_pin, convert_pin and busy_pin
instead of the deprecated old non-descriptor interface.

Note that Phil Reid identified that some of this code would never
have worked.  A follow up patch can fix that as this is just
a direct change of interface.

Signed-off-by: Nishad Kamdar <nishadkamdar@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-10-21 15:51:56 +01:00
Marcelo Schmitt
e480490c90 Staging:iio:adc:ad7606: Match parenthesis alignment
Change close parenthesis alignment to match respective open parenthesis at
iio/drivers/staging/iio/adc/ad7606.c line 379.
This makes the file more compliant with the preferred coding style for the
linux kernel.

Signed-of-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-10-21 15:38:10 +01:00
Slawomir Stepien
4cd62a5425 staging: iio: adc: ad7280a: use crc8.h API to build crc table
The custom build function ad7280_crc8_build_table is not needed. The
crc8_populate_msb function from linux/crc8.h will build the same crc
table.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-10-21 14:30:56 +01:00
Slawomir Stepien
0559ef7fde staging: iio: adc: ad7280a: handle error from __ad7280_read32()
Inside __ad7280_read32(), the spi_sync_transfer() can fail with negative
error code. This change will ensure that this error is being passed up
in the call stack, so it can be handled.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-10-21 14:17:06 +01:00
Renato Lui Geh
a476e20c30 staging: iio: adt7316: fix parenthesis alignment
This patch fixes most "Alignment should match open parenthesis" check
warnings found by checkpatch.pl in the addac/adt7316 driver.

Signed-off-by: Renato Lui Geh <renatogeh@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-10-14 18:01:38 +01:00
Matheus Tavares
5c93f3ce98 staging: iio: ad2s1210: fix 'assignment operator' style checks
This patch fixes all "Assignment operator '=' should be on the previous
line" checks found in ad2s1210.c with checkpatch.pl.

Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-10-08 21:20:55 +01:00
Slawomir Stepien
2e00b53352 staging: iio: cdc: ad7150: fix misaligned lines
These lines were misaligned, but the checkpatch.pl didn't indicate them
as such.

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-10-07 20:08:04 +01:00
Slawomir Stepien
4bb199e51d staging: iio: cdc: ad7150: use value copy to shorten the line length
By using the copy of channel attribute, we can now make the lines short
enough to eliminate the checkpatch.pl problem:

    CHECK: Alignment should match open parenthesis

Signed-off-by: Slawomir Stepien <sst@poczta.fm>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-10-07 20:06:41 +01:00
Alexandru Ardelean
1afacfb0df staging: iio: ad5933: rename ext_clk_Hz -> ext_clk_hz
The checkpatch script doesn't like camel-case names.
Renamed the variable.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-10-07 16:52:41 +01:00
Alexandru Ardelean
bb9fc6adac staging:iio:ad7606: Add support for the ad7605-4
Add support for the AD7605-4 to the AD7606 driver. The AD7605-4 is mostly
interface compatible to the AD7606-6 with the only difference being not
having support for oversampling.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-09-22 16:42:57 +01:00
Alexandru Ardelean
7c2d53700c staging:iio:ad7606: update structs with doc annotations
The current structs are only partially documented via annotations. This
change updates annotations for all structs in the ad7606.h file.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-09-22 14:45:40 +01:00
Alexandru Ardelean
c8d5b99696 staging:iio:ad7606: Remove incorrect kernel doc annotations
The ad7606_chip_info struct does not have the lock & name fields. Remove
the kernel documentation annotations for it.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-09-16 12:18:36 +01:00
Alexandru Ardelean
4ee033301c staging:iio:ad7606: fix voltage scales
Fixes commit 17be2a2905 ("staging: iio:
ad7606: replace range/range_available with corresponding scale").

The AD7606 devices don't have a 2.5V voltage range, they have 5V & 10V
voltage range, which is selectable via the `gpio_range` descriptor.

The scales also seem to have been miscomputed, because when they were
applied to the raw values, the results differ from the expected values.
After checking the ADC transfer function in the datasheet, these were
re-computed.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-09-16 12:18:20 +01:00
Janusz Krzysztofik
77588c14ac gpiolib: Pass array info to get/set array functions
In order to make use of array info obtained from gpiod_get_array() and
speed up processing of arrays matching single GPIO chip layout, that
information must be passed to get/set array functions.  Extend the
functions' API with that additional parameter and update all users.
Pass NULL if a user builds an array itself from single GPIOs.

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Peter Korsgaard <peter.korsgaard@barco.com>
Cc: Peter Rosin <peda@axentia.se>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Rojhalat Ibrahim <imr@rtschenk.de>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Russell King <rmk+kernel@armlinux.org.uk>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Yegor Yefremov <yegorslists@googlemail.com>
Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-13 11:16:54 +02:00
Janusz Krzysztofik
b9762bebc6 gpiolib: Pass bitmaps, not integer arrays, to get/set array
Most users of get/set array functions iterate consecutive bits of data,
usually a single integer, while processing array of results obtained
from, or building an array of values to be passed to those functions.
Save time wasted on those iterations by changing the functions' API to
accept bitmaps.

All current users are updated as well.

More benefits from the change are expected as soon as planned support
for accepting/passing those bitmaps directly from/to respective GPIO
chip callbacks if applicable is implemented.

Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Miguel Ojeda Sandonis <miguel.ojeda.sandonis@gmail.com>
Cc: Sebastien Bourdelin <sebastien.bourdelin@savoirfairelinux.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Peter Korsgaard <peter.korsgaard@barco.com>
Cc: Peter Rosin <peda@axentia.se>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Rojhalat Ibrahim <imr@rtschenk.de>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Russell King <rmk+kernel@armlinux.org.uk>
Cc: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.com>
Cc: Yegor Yefremov <yegorslists@googlemail.com>
Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-13 11:15:30 +02:00
Michael Hennerich
9920ed25ec drivers: iio: Update MODULE AUTHOR email address
no functional changes

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-08-19 17:23:39 +01:00
Karim Eshapa
c6988eb0e7 staging:iio:impedance-analyzer:ad5933: Macro replacement Cleanups.
Doing some macro replacement to start an array of structures
so it can be reused by manipulating it with different values.

Signed-off-by: Karim Eshapa <karim.eshapa@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-06-30 18:21:17 +01:00
Karim Eshapa
5f1d651fbf staging:iio:accel:adis16240: sign extend function replace hard code duplication
Use sign_extend32 kernel function instead of code duplication,
Safe also for 16 bit. and remove declaration of bits variable not needed.

Signed-off-by: Karim Eshapa <karim.eshapa@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-06-24 14:45:06 +01:00
Karim Eshapa
c660abab5c staging:iio:accel:adis16203: sign extend function rather code duplication
Use sign_extend32 kernel function instead of code duplication.
This function is also safe for 16 bits.

Signed-off-by: Karim Eshapa <karim.eshapa@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-06-16 19:04:53 +01:00
Giulio Benetti
727198f99e staging: iio: adc: ad7606: fix function pointer parameter names missing.
Checkpatch.pl complains about function pointer parameter names missing.

Add parameter names.

Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com>
Reviewed-by: Martin Kelly <mkelly@xevo.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-06-10 14:44:00 +01:00
Jonathan Cameron
adca2d68d7 staging: iio: Drop ADIS16060 driver from staging
This part has been declared "not for new designs". It is now
difficult to obtain and we have had no-one come forward with hardware
making it difficult to proceed with the necessary work to move this
driver out of staging.

The device uses two separate chip selects and would require locking
between them which is thought to be difficult to enforce without
non trivial changes in the SPI subsystem.  This work simply isn't worth
doing given the status of the part and the fact no one seems to have
gone for a similar hardware design since this one.

If anyone does have access to one of these and is willing to contribute
the time necessary then we can reevaluate dropping the driver.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-06-10 11:52:31 +01:00
Jonathan Cameron
be3be7814a staging:iio:meter: Drop ADE7759 driver
I announced the intent to drop some of these meter drivers
on the IIO list last cycle. This device is obsolete and not easily
obtained.  No one has come forward with suitable test hardware and
the driver would need a lot of work to move out of staging.

As such I am dropping it.  We can always bring it back again
if a user / tester emerges in the future.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 12:21:54 +01:00
Jonathan Cameron
1f31ee3508 staging:iio:meter: Drop ADE7758 driver
I announced the intent to drop some of these meter drivers
on the IIO list last cycle. This device is obsolete and not easily
obtained.  No one has come forward with suitable test hardware and
the driver would need a lot of work to move out of staging.

As such I am dropping it.  We can always bring it back again
if a user / tester emerges in the future.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 12:21:42 +01:00
Jonathan Cameron
d15d4be9da staging:iio:meter: Drop ADE7754 driver
I announced the intent to drop some of these meter drivers
on the IIO list last cycle. This device is obsolete and not easily
obtained.  No one has come forward with suitable test hardware and
the driver would need a lot of work to move out of staging.

As such I am dropping it.  We can always bring it back again
if a user / tester emerges in the future.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 12:21:26 +01:00
Jonathan Cameron
cfbcdb6a98 staging:iio:meter: Drop ADE7753 driver
I announced the intent to drop some of these meter drivers
on the IIO list last cycle. This device is obsolete and not easily
obtained.  No one has come forward with suitable test hardware and
the driver would need a lot of work to move out of staging.

As such I am dropping it.  We can always bring it back again
if a user / tester emerges in the future.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 12:20:26 +01:00
David Veenstra
ad28d31554 staging: iio: ad2s1200: Move driver out of staging
Move the iio driver for the ad2s1200 and ad2s1205 resolver-to-digital
converter out of staging, into mainline iio subsystems.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 12:17:48 +01:00
David Veenstra
9c3e81ab74 staging: iio: ad2s1200: Add copyright
Add David Veenstra as a copyright holders and as an author,
for all of the staging clean ups of the ad2s1200 driver.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 12:10:58 +01:00
David Veenstra
f9db7370be staging: iio: ad2s1200: Add scaling factor for angle channel
A scaling factor of approximately 2 * Pi / (2^12 -1) is added,
to scale the 12-bits angular position to radians.

A return type of IIO_VAL_INT_PLUS_NANO is used, so that the scale of
both the angle channel and angular velocity channel has 7 significant
digits.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 12:09:47 +01:00
David Veenstra
d3e6ed8416 staging: iio: ad2s1200: Add scaling factor for angular velocity channel
The sysfs iio ABI states radians per second is expected as the unit for
angular velocity, but the 12-bit angular velocity register has
revolution per seconds as its unit. So a scaling factor of approximately
2 * Pi is added to the angular velocity channel.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 12:07:29 +01:00
David Veenstra
2363c010ce staging: iio: ad2s1200: Add dt table
Add device tree table for matching with the vendor ID.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 12:02:17 +01:00
David Veenstra
1946980b8f staging: iio: ad2s1200: Replace platform data with dt bindings
Remove usage of platform data, and replace it with device tree
facilities.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 12:00:17 +01:00
David Veenstra
5af93e6aa7 staging: iio: ad2s1200: Replace legacy gpio API with modern API
The legacy, integer based gpio API is replaced with the modern
descriptor based API.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 11:57:27 +01:00
David Veenstra
94cdefa81b staging: iio: ad2s1200: Setup spi before iio device register
The spi should be set up before the device is registered as an iio
device.

This patch moves the setup to before the device registration.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 11:54:43 +01:00
David Veenstra
bc683b47c3 staging: iio: ad2s1200: Add kernel docs to driver state
Add missing kernel docs to the ad2s1200 driver state.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 11:53:45 +01:00
David Veenstra
c1b6a7d72d staging: iio: ad2s1200: Remove unneeded initializations
Remove 2 initializations which are unneeded, because the
initialized values are never used.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 11:52:49 +01:00
David Veenstra
c8e97b62e1 staging: iio: ad2s1200: Remove unneeded newline in license
Remove unneeded newline in license, as it does not improve readability.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-20 11:51:30 +01:00
Brian Masney
c06c4d7935 staging: iio: tsl2x7x/tsl2772: move out of staging
Move the tsl2772 driver out of staging and into mainline.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-12 12:40:04 +01:00
Brian Masney
4e24c1719f staging: iio: tsl2x7x: rename driver to tsl2772
This patch renames this driver from tsl2x7x to tsl2772 since it is
highly likely that additional devices will be added to this driver that
do not match that wildcard. The tsl2772 driver name was selected since
that is currently the device with the most features that are supported
by this driver.

This patch also adds Brian Masney's copyright to tsl2772.h for all of
the work that has been done to move this driver out of staging.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-12 12:24:29 +01:00
Brian Masney
da18e89062 staging: iio: tsl2x7x: add range checking to tsl2x7x_write_raw
The CALIBBIAS and INT_TIME masks in tsl2x7x_write_raw did not have any
range checking in place so this patch adds the appropriate range
checking. The defines TSL2X7X_ALS_GAIN_TRIM_{MIN,MAX} are also
introduced by this patch.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-12 12:23:06 +01:00
Brian Masney
9861d2daaf staging: iio: tsl2x7x: correct IIO_EV_INFO_PERIOD values
The thresh periods assumed an integration time of 3ms. This patch adds
support for the correct integration time (2.72ms or 2.73ms). The code
had the ALS filter values as going up to 15, however the values actually
went up to 60 since the values scaled in increments of 5 once the
persistence value went above 3.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-12 12:21:27 +01:00
Brian Masney
77b69a0e67 staging: iio: tsl2x7x: convert to use read_avail
Make the sysfs attributes in_proximity0_calibscale_available, and
in_intensity0_{calibscale,integration_time}_available be created
using info_mask_separate_available on the channel configuration.

The driver assumed that the ALS increment was 2.72 ms, and the upper
range was 696 ms. Some other supported devices use 2.73 ms - 699 ms.
This patch adds support for the multiple ranges.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-12 12:19:27 +01:00
Brian Masney
bfdf7f1024 staging: iio: tsl2x7x: use macro to populate tsl2X7X_device_info
This patch creates a macro that populates the tsl2X7X_device_info
structure to reduce duplicated code in the driver.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-12 12:17:49 +01:00
Brian Masney
cc566e90cb staging: iio: tsl2x7x: turn chip off if IIO device registration fails
This patch turns the chip off if IIO device registration fails so that
the error handling mirrors the device remove to make review easier in
preparation for moving this driver out of staging.

This patch also adds a missing error check in the call to
tsl2x7x_chip_on() in tsl2x7x_probe().

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-12 12:16:39 +01:00
Brian Masney
7b4db2e3e6 staging: iio: tsl2x7x: use direct returns
This patch changes the functions tsl2x7x_read_event_value() and
tsl2x7x_read_raw() to use direct returns to simplify the code.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-12 12:15:47 +01:00
Brian Masney
5cf05135b0 staging: iio: tsl2x7x: remove unnecessary whitespace
This patch removes unnecessary whitespace in preparation for moving this
driver out of staging.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-12 12:14:38 +01:00
Greg Kroah-Hartman
6a8b25abf1 1st round of IIO new device support, features and cleanup for the 4.18 cycle
A nice mix this time of excellent cleanups (many to send drivers
 speeding toward staging graduations) and new drivers / device support.
 A good part of this is Brian Masney's never ending task on the tsl2x7x
 driver.  The end is in sight so hopefully we'll get that one out of
 staging very soon!
 
 New device support
 * AD5686
   - Support AD5685R (was wrongly present as AD5685)
   - Support AD5672R, AD5676, AD5676, AD5684R and AD5686R 4 and 8 channel
     SPI DACs with various precisions.
   - Support AD5671R, AD5675R, AD5694, AD5694R, AD5695R, AD5696 and AD5696R
     I2C DACs with various percisions and numbers of channels.
 * Analog front end rescale driver - New driver.
   - Support current sensing usings a shunt resistor.
   - Support simple voltage dividers.
   - support simple current sense amplifiers.
 * TI dac5571
   - New driver and device bindings supporting:
     dac5571, dac6571, dac7571, dac5574, dac6574, dac7574,
     dac5573, dac6573 and dac7573
 * Meson-adc
   - Support for Meson AXG with DT bindings.
 * mpu6050
   - Support the mpu9255 which only requires additional WHOAMI entry and
     compatible string.
 * st_lsm6dsx
   - Support for lsm330dlc combinded accelerometer and gyro sensors with
     DT bindings.
 * stm32_adc
   - Add support for STM32MP1 with bindings.
 
 Staging graduations
 * adis16201 after some excelent cleanup by Himanshu Jha.
 * adis16029 after some excelent cleanup by Shreeya Patel.
 
 New features:
 * ABI docs
   - Add core ABI docs for angle channels.
 * inv_mpu6050
   - Provide support for the full range of interrupts the device
     supports.
 * st_accel
   - Add SMO8840 ACPI ID seen in the wild on some Lenovo machines.
 * stx104
   - Provide a multiple gpio get function.
 
 Cleanups / Minor fixes
 * core
   - Use new nested structure support to improve kernel-doc.
 * ad2s1200
   - Use be16_to_cpup instead of opencoding.
 * ad5686
   - Indentation tidy up.
   - Switch to SPDX
   - Refactor to allow various numbers of channels.
   - Refactor to separate core and SPI specific support, prior to
     addition of i2c equivalent devices.
 * ad7606
   - Use drvdata directly from device rather than boucing via the
     platform_device structure.
 * ad7746
   - Replace opencoded byte swapped i2c calls with _swapped variants.
   - White space and line break readability improvements.
   - Reorder includes and variable declarations where appropriate.
 * ad7791
   - Changes to the AD ADC library used by this driver took in the
     sampling frequency.  This lead to be the wrong path being the one
     tied to the resulting attribute, so it didn't work, and a warning
     to be printed.
 * ad7780
   - Remove apparent support for sampling frequency control on devices
     that don't support changing the sampling attributes.
 * ade7854
   - Fix a read of the wrong number of bits.
   - Improve error handling on i2c read/write errors.
   - Rework i2c and spi code to reduce duplication.
 * adis16201 (staging)
   - Improve meaning inherent in some macro names by adding units etc
     where relevant.
   - Adjust comments to improve detail and drop the irrelevant.
   - Rename register address definitions definitions to add a _REG
     postfix, clearly separating them from field definitions. Reorganize
     the definitions to group register address and fields.
   - Use sign_extend32 rather than open coding.
   - Reverse Xmas tree ordering where appropriate and align function args.
   - Remove unused headers.
   - Use GENMASK where appropriate instead of open coding.
 * adis16209 (staging)
   - Indent field definitions to visually separate them from
     register address definitions.
   - Use reverse xmas tree ordering where appropriate.
   - Add some whitespace where it will help readability.
   - Drop some unused headers.
   - Use GENMASK where appropriate.
 * ad2s1200
   - Drop unnecessary includes and reorder alphabetically.
   - Reverse xmas tree and blank line cleanups.
 * atlas-ph-sensor
   - Use msleep instead of usleep_range where the precise value doesn't
     matter and the delays are long.
 * bcm150
   - Drop transaction splitting as core now handles it.
 * cros_ec
   - Move the shared header to the include/iio/common directory.
     This brings it inline with the other multiple type devices.
   - Use drvdata directly from device rather than boucing via the
     platform_device structure.
 * hid-sensors
   - Use drvdata directly from device rather than boucing via the
     platform_device structure.
 * inv_mpu6050
   - Clear out a second function definition for the same function.
   - Don't flush fifo when the iio buffer is full but just drop excess
     data.
   - Tidy up set_power_itg and ensure it is used in the right places.
   - Use set_power_itg rather than opencoding it again in the i2c mux
     control.
   - Make sure error paths disable the power if undoing power on.
   - Used managed devm_ functions during probe. Delete remove function.
   - Refactor to pull raw data read out of read_raw function.
   - Simplify data reading error paths.
   - Only enable the i2c mux for chips with the i2c aux bus (not icm20608)
   - Fix a potential deadlock due to varying lock ordering.
   - Fix an issue where first sample from gyro after enabling is unstable
     by dropping the first sample.
   - Fix an issue where the user_ctrl register is incorrectly overwritten.
   - Tidy up some grammar and spelling minor issus.
 * mcp320x
   - Use vendor compatible strings.
 * mcp4018
   - Switch to using i2c .probe_new.
 * mcp4351
   - switch to using i2c .probe_new.
 * meson-adc
   - rework handing on common ADC platform data so it can be shared
     across multiple families of SoCs.
 * sca3000
   - Fix an error handling path if the ring configure fails.
 * st_lsm6dsx
   - Fix a wrong fifo threshold mask (no actual effect)
 * stm32-dfsdm
   - Style fixes and cleanups.
   - Check filter ID is in range and check spi-max-frequency.
 * tsl2x7x (staging)
   - Drop some unnecessary function calls, unused variables and
     unnecessary local variables.
   - Fix wrong interrupt type.
   - Avoid unnecessary double clear of interrupt.
   - Simplify proximity calibration call which did various things
     unrelated to actually calibrating.
   - Separate control of the proximity and ALS interrupts.
   - Improve consistency of logging.
   - Separate ALS and proximity persistence settings as they have
     separate hardware controls.
   - Tidy up variable ordering.
   - Add Brian to copyright notice given consider work on this driver.
   - Take advantage of hardware support for I2C address auto increment.
   - Combine individuaal enable and period attributes for the two
     directions on the threshold events into a single value as the
     hardware doesn't separate them.
   - Move integration_time* attributes from light channel to
     intensity value as they effect the intensity readings directly
     and the light reading only indirectly.  Hence this better
     reflects reality. Also move the calibscale_available.
   - Avoid returning an error in the IRQ handler.
   - Hard code the reg value in _clear_interrupts as it only takes
     one value in the code.   Result is the function has little
     purpose so opencode the two remaining i2c_smbus_write_byte
     calls.
   - Drop some unnecessary checking of the chip status register.
   - Tidy up return path in _write_interrupt_config.
   - Tidy up the ID verification code.
   - Move the power and diode settings defines into the header as these
     are needed for platform data configuration.
   - Various renames and comment cleanups for consistency and clarity.
   - Use actual device defaults for default startup settings.
   - SPDX
   - Add some range sanity checking to sysfs attribute writes.
   - Don't provide event interfaces if the interrupt line isn't available.
   - Use IIO_CONST_ATTR macro for calibscale_available as it's a constant
     string.
   - Fix the integration time and lux equations.
   - Make device IDs explicit index values in the device_channel_config array.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlr0uigRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FoiRhw//bIv57xenV6WV3+7Xmrp/rG4OBVzt8riD
 d9HczYKZE8/tqfB9cjF5e/xOpfin99eXBqEMWecidh3BxMNKXgnbvvCYCXF+m47D
 3cYlWvGbyZ2lbvqwbYCkk4xKfPNbRHBo5NX9TB08wf7DrAjmaudxmxDSFrRYQCho
 3Z3H2o54z1i/iJud61TApEONxr7H5oFdeb6uwNB5UVlG7XING9mfWbmlSzdlxW4X
 lHG4hC1/Pz/F4WjiLvNKccjhuq1f60CwSppKvfihq1IZKYKyHvSWjOicwrNb3QB2
 Kr0dT8yDqNKcKU1tsfgfR+YFeLKq52Ik4whulk8mkL7E4IWVIkGbL0ewkPwZ0YqO
 Cj9Nv52vzYS7x9Dj7R6f23Lwq30a19WKXixybjdo9zV14S0XKfzTmU7xC/4yhEjh
 yUg9QPjWxE5rAUTSjNF0C6tv786Y3aVYBp2jscIroSutipa6cUyc2rOKssM6GTZs
 vyRElGiUEXbg7uI7GrwN4PJszho47ptkFGn/o88Sy90KjUJ0mP15NTlp4IeSiVc/
 sM4YHHQ7tldcKqsaKeGbH8JwJNvzj9Kh20zniYd9lSZkeZusSkZUvd1FgB5uUocb
 ZZEG2IzCLM/utH49yXyaUkRS/lqoGCcObDkIHbsE1OM8q2bnZxaUYEMumxIpAs7l
 W2LBlr3vGF4=
 =egCX
 -----END PGP SIGNATURE-----

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

Jonathan writes:

1st round of IIO new device support, features and cleanup for the 4.18 cycle

A nice mix this time of excellent cleanups (many to send drivers
speeding toward staging graduations) and new drivers / device support.
A good part of this is Brian Masney's never ending task on the tsl2x7x
driver.  The end is in sight so hopefully we'll get that one out of
staging very soon!

New device support
* AD5686
  - Support AD5685R (was wrongly present as AD5685)
  - Support AD5672R, AD5676, AD5676, AD5684R and AD5686R 4 and 8 channel
    SPI DACs with various precisions.
  - Support AD5671R, AD5675R, AD5694, AD5694R, AD5695R, AD5696 and AD5696R
    I2C DACs with various percisions and numbers of channels.
* Analog front end rescale driver - New driver.
  - Support current sensing usings a shunt resistor.
  - Support simple voltage dividers.
  - support simple current sense amplifiers.
* TI dac5571
  - New driver and device bindings supporting:
    dac5571, dac6571, dac7571, dac5574, dac6574, dac7574,
    dac5573, dac6573 and dac7573
* Meson-adc
  - Support for Meson AXG with DT bindings.
* mpu6050
  - Support the mpu9255 which only requires additional WHOAMI entry and
    compatible string.
* st_lsm6dsx
  - Support for lsm330dlc combinded accelerometer and gyro sensors with
    DT bindings.
* stm32_adc
  - Add support for STM32MP1 with bindings.

Staging graduations
* adis16201 after some excelent cleanup by Himanshu Jha.
* adis16029 after some excelent cleanup by Shreeya Patel.

New features:
* ABI docs
  - Add core ABI docs for angle channels.
* inv_mpu6050
  - Provide support for the full range of interrupts the device
    supports.
* st_accel
  - Add SMO8840 ACPI ID seen in the wild on some Lenovo machines.
* stx104
  - Provide a multiple gpio get function.

Cleanups / Minor fixes
* core
  - Use new nested structure support to improve kernel-doc.
* ad2s1200
  - Use be16_to_cpup instead of opencoding.
* ad5686
  - Indentation tidy up.
  - Switch to SPDX
  - Refactor to allow various numbers of channels.
  - Refactor to separate core and SPI specific support, prior to
    addition of i2c equivalent devices.
* ad7606
  - Use drvdata directly from device rather than boucing via the
    platform_device structure.
* ad7746
  - Replace opencoded byte swapped i2c calls with _swapped variants.
  - White space and line break readability improvements.
  - Reorder includes and variable declarations where appropriate.
* ad7791
  - Changes to the AD ADC library used by this driver took in the
    sampling frequency.  This lead to be the wrong path being the one
    tied to the resulting attribute, so it didn't work, and a warning
    to be printed.
* ad7780
  - Remove apparent support for sampling frequency control on devices
    that don't support changing the sampling attributes.
* ade7854
  - Fix a read of the wrong number of bits.
  - Improve error handling on i2c read/write errors.
  - Rework i2c and spi code to reduce duplication.
* adis16201 (staging)
  - Improve meaning inherent in some macro names by adding units etc
    where relevant.
  - Adjust comments to improve detail and drop the irrelevant.
  - Rename register address definitions definitions to add a _REG
    postfix, clearly separating them from field definitions. Reorganize
    the definitions to group register address and fields.
  - Use sign_extend32 rather than open coding.
  - Reverse Xmas tree ordering where appropriate and align function args.
  - Remove unused headers.
  - Use GENMASK where appropriate instead of open coding.
* adis16209 (staging)
  - Indent field definitions to visually separate them from
    register address definitions.
  - Use reverse xmas tree ordering where appropriate.
  - Add some whitespace where it will help readability.
  - Drop some unused headers.
  - Use GENMASK where appropriate.
* ad2s1200
  - Drop unnecessary includes and reorder alphabetically.
  - Reverse xmas tree and blank line cleanups.
* atlas-ph-sensor
  - Use msleep instead of usleep_range where the precise value doesn't
    matter and the delays are long.
* bcm150
  - Drop transaction splitting as core now handles it.
* cros_ec
  - Move the shared header to the include/iio/common directory.
    This brings it inline with the other multiple type devices.
  - Use drvdata directly from device rather than boucing via the
    platform_device structure.
* hid-sensors
  - Use drvdata directly from device rather than boucing via the
    platform_device structure.
* inv_mpu6050
  - Clear out a second function definition for the same function.
  - Don't flush fifo when the iio buffer is full but just drop excess
    data.
  - Tidy up set_power_itg and ensure it is used in the right places.
  - Use set_power_itg rather than opencoding it again in the i2c mux
    control.
  - Make sure error paths disable the power if undoing power on.
  - Used managed devm_ functions during probe. Delete remove function.
  - Refactor to pull raw data read out of read_raw function.
  - Simplify data reading error paths.
  - Only enable the i2c mux for chips with the i2c aux bus (not icm20608)
  - Fix a potential deadlock due to varying lock ordering.
  - Fix an issue where first sample from gyro after enabling is unstable
    by dropping the first sample.
  - Fix an issue where the user_ctrl register is incorrectly overwritten.
  - Tidy up some grammar and spelling minor issus.
* mcp320x
  - Use vendor compatible strings.
* mcp4018
  - Switch to using i2c .probe_new.
* mcp4351
  - switch to using i2c .probe_new.
* meson-adc
  - rework handing on common ADC platform data so it can be shared
    across multiple families of SoCs.
* sca3000
  - Fix an error handling path if the ring configure fails.
* st_lsm6dsx
  - Fix a wrong fifo threshold mask (no actual effect)
* stm32-dfsdm
  - Style fixes and cleanups.
  - Check filter ID is in range and check spi-max-frequency.
* tsl2x7x (staging)
  - Drop some unnecessary function calls, unused variables and
    unnecessary local variables.
  - Fix wrong interrupt type.
  - Avoid unnecessary double clear of interrupt.
  - Simplify proximity calibration call which did various things
    unrelated to actually calibrating.
  - Separate control of the proximity and ALS interrupts.
  - Improve consistency of logging.
  - Separate ALS and proximity persistence settings as they have
    separate hardware controls.
  - Tidy up variable ordering.
  - Add Brian to copyright notice given consider work on this driver.
  - Take advantage of hardware support for I2C address auto increment.
  - Combine individuaal enable and period attributes for the two
    directions on the threshold events into a single value as the
    hardware doesn't separate them.
  - Move integration_time* attributes from light channel to
    intensity value as they effect the intensity readings directly
    and the light reading only indirectly.  Hence this better
    reflects reality. Also move the calibscale_available.
  - Avoid returning an error in the IRQ handler.
  - Hard code the reg value in _clear_interrupts as it only takes
    one value in the code.   Result is the function has little
    purpose so opencode the two remaining i2c_smbus_write_byte
    calls.
  - Drop some unnecessary checking of the chip status register.
  - Tidy up return path in _write_interrupt_config.
  - Tidy up the ID verification code.
  - Move the power and diode settings defines into the header as these
    are needed for platform data configuration.
  - Various renames and comment cleanups for consistency and clarity.
  - Use actual device defaults for default startup settings.
  - SPDX
  - Add some range sanity checking to sysfs attribute writes.
  - Don't provide event interfaces if the interrupt line isn't available.
  - Use IIO_CONST_ATTR macro for calibscale_available as it's a constant
    string.
  - Fix the integration time and lux equations.
  - Make device IDs explicit index values in the device_channel_config array.
2018-05-11 09:50:04 +02:00
Brian Masney
9701b6e2c5 staging: iio: tsl2x7x: add device ids for code readability
This patch adds the device IDs to the device_channel_config array to
improve code readability.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-06 19:25:21 +01:00
Brian Masney
498efcd081 staging: iio: tsl2x7x: correct integration time and lux equation
The integration_time sysfs attribute did not report the correct
time. Changing the integration time would cause the reported lux to
change wildly. Once the integration time was corrected, all of the
equations, and lux tables needed to be corrected to match what the
data sheets expected. This patch corrects all of this, and adds some
more comments about how some of the constants were derived. Here are
the results from testing a TSL2772 hooked up to a Raspberry Pi 2:

# cat in_intensity0_integration_time
0.002730
# watch -n .1 cat in_illuminance0_input
; Lux hovers around 55
# echo 0.65 > in_intensity0_integration_time
# cat in_intensity0_integration_time
0.649740
# watch -n .1 cat in_illuminance0_input
; Lux hovers around 55 with noticeable lag to lux changes in watch
; process.

; Now test the ALS calibration routine.
# cat in_intensity0_calibbias
1000
# cat in_illuminance0_target_input
150
# echo 1 > in_illuminance0_calibrate
# cat in_intensity0_calibbias
2777
# watch -n .1 cat in_illuminance0_input
; Lux now hovers around 150-155

The returned lux values were tested on a TSL2772 in various lighting
conditions and the results are within the lux ranges described at
https://en.wikipedia.org/wiki/Lux.

The driver was primarily tested using a TSL2772, however some quick tests
were also ran against the devices TSL2771, TSL2572, and TMD2772.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-06 19:10:36 +01:00
Brian Masney
11031d7df0 staging: iio: tsl2x7x: use IIO_CONST_ATTR for calibscale_available
The in_intensity0_calibscale_available sysfs attribute has code that
checks the device type to determine which calibration scales are
available. This check is not necessary since all of the supported
ALS device types use the scales 1 8 16 120. This patch converts the
sysfs attribute to use IIO_CONST_ATTR. The following device datasheets
were checked: tsl2571, tsl2771, tmd2771, tsl2572, tsl2772, tmd2772.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-06 19:06:46 +01:00
Brian Masney
7775e1d1e7 staging: iio: tsl2x7x: move calibscale_available attribute to IIO_INTENSITY channel
The calibscale_available attribute is currently associated with the
IIO_LIGHT channel but should be associated with the IIO_INTENSITY
channel. This patch corrects that association and it also corrects
lines that were unnecessarily split for the
in_intensity0_integration_time sysfs attribute.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-06 19:05:37 +01:00
Brian Masney
95d22154d6 staging: iio: tsl2x7x: don't setup event handlers if interrupts are not configured
The driver would expose to userspace the events directory even if the
interrupts were not configured. This patch changes the driver so that
the events directory is not exposed to user space if interrupts are
not configured. This patch also corrects the indentation of the
chan_table_elements and info structure members.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-06 19:05:00 +01:00
Brian Masney
2a74090249 staging: iio: tsl2x7x: add range checking to three sysfs attributes
The sysfs attributes in_illuminance0_target_input,
in_illuminance0_calibrate, and in_proximity0_calibrate did not have
proper range checking in place so this patch adds the correct range
checks.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-06 19:01:14 +01:00
Brian Masney
5a1f2de133 staging: iio: tsl2x7x: use GPL-2.0+ SPDX license identifier
The summary text for the GPL is not needed since the SPDX identifier
is a legally binding shorthand that can be used instead.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-05-06 18:57:57 +01:00
David Veenstra
0bd3d338f6 staging: iio: ad2s1200: Improve readability with be16_to_cpup
The manual states that the data is contained in the upper 12 bits
of the 16 bits read by spi. The code that extracts these 12 bits
is correct for both be and le machines, but this is not clear
from a first glance.

To improve readability the relevant expressions are replaced
with equivalent expressions that use be16_to_cpup.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 18:12:03 +01:00
David Veenstra
d99066e60c staging: iio: ad2s1200: Add blank lines
Add blank lines to improve readability.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
David Veenstra
0598225542 staging: iio: ad2s1200: Reverse Christmas tree ordering
Reorders the variable declarations to prefer a reverse Christmas tree
order to improve readability.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
David Veenstra
972c0c3a73 staging: iio: ad2s1200: Sort includes alphabetically
This patches sorts all the includes in alphabetic order.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
David Veenstra
0c261a912b staging: iio: ad2s1200: Remove unneeded include
This patches removes unneeded slab.h header.

Signed-off-by: David Veenstra <davidjulianveenstra@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
Brian Masney
e1f3592634 staging: iio: tsl2x7x: rename prox_config to als_prox_config
The configuration register on the device is represented with the
prox_config member on the tsl2x7x_settings structure. According to the
TSL2772 data sheet, this register can hold: 1) the proximity drive
level, 2) ALS/Proximity long wait, and 3) the ALS gain level. This
patch renames prox_config to als_prox_config since ALS settings can
be stored here as well.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
Brian Masney
ffb036a083 staging: iio: tsl2x7x: various comment cleanups
This patch removes several unnecessary comments, changes some comments
so that the use as much of the allowable 80 characters as possible, adds
the proper whitespace, removes some structure members from the kernel
docs that are no longer present, and improves the existing kernel doc
information for some existing structure members.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
Brian Masney
09d0bfae7b staging: iio: tsl2x7x: use device defaults for als_time, prox_time and wait_time
This patch changes the defaults of the als_time, prox_time and
wait_time to match the defaults according to the TSL2772 datasheet.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
Brian Masney
dc6ebdd347 staging: iio: tsl2x7x: rename prx to prox for consistency
The driver mostly uses the 'prox' naming convention for most of the
proximity settings, however prx_time and tsl2x7x_prx_gain was present.
This patch renames these to prox_time and tsl2x7x_prox_gain for
consistency with everything else in the driver.

The kernel documentation for prx_gain is corrected to prox_gain so that
it matches what is actually in the structure.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
Brian Masney
96c44e2e61 staging: iio: tsl2x7x: move power and diode settings into header file
The power and diode defines are needed for the platform data so this
patch moves the defines out of the .c file and into the header file. A
comment for the diode is also cleaned up while this code is touched.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
Brian Masney
dbc6cd1b0b staging: iio: tsl2x7x: simplify device id verification
This patch renames tsl2x7x_device_id() to tsl2x7x_device_id_verif(),
removes the unnecessary pointer on the id parameter, and only calls
the verification function once.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
Brian Masney
8d0cc09058 staging: iio: tsl2x7x: simplify tsl2x7x_write_interrupt_config return
tsl2x7x_write_interrupt_config() has an unnecessary return value check
at the end of the function. This patch changes the function to just
return the value from the call to tsl2x7x_invoke_change().

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
Brian Masney
0ba50bef8f staging: iio: tsl2x7x: remove unnecessary chip status checks in suspend/resume
tsl2x7x_suspend() and tsl2x7x_resume() both check to see what the
current chip status is. These checks are not necessary so this patch
removes those checks.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
Brian Masney
d8e24a31cc staging: iio: tsl2x7x: simplify tsl2x7x_clear_interrupts function
tsl2x7x_clear_interrupts() takes a reg argument but there are only
two callers to this function and both callers pass the same value.
Since this function was introduced, interrupts are now working
properly for this driver, and several unnecessary calls to
tsl2x7x_clear_interrupts() were removed. This patch removes the
tsl2x7x_clear_interrupts() function and replaces the two callers
with the i2c_smbus_write_byte() call instead.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
Brian Masney
3605dfb851 staging: iio: tsl2x7x: don't return error in IRQ handler
tsl2x7x_event_handler() could return an error and this could cause the
interrupt to remain masked. We shouldn't return an error in the
interrupt handler so this patch always returns IRQ_HANDLED. An error
will be logged if one occurs.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
Brian Masney
2f58efa963 staging: iio: tsl2x7x: move integration_time* attributes to IIO_INTENSITY channel
The integration_time* attributes are currently associated with the
IIO_LIGHT channel but should be associated with the IIO_INTENSITY
channel. Directory listing of the sysfs attributes for a TSL2772
with this patch applied:

dev
events
in_illuminance0_calibrate
in_illuminance0_calibscale_available
in_illuminance0_input
in_illuminance0_lux_table
in_illuminance0_target_input
in_intensity0_calibbias
in_intensity0_calibscale
in_intensity0_integration_time
in_intensity0_integration_time_available
in_intensity0_raw
in_intensity1_raw
in_proximity0_calibrate
in_proximity0_calibscale
in_proximity0_calibscale_available
in_proximity0_raw
name
of_node
power
subsystem
uevent

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
Wolfram Sang
dae013afa7 staging: iio: adc: simplify getting .drvdata
We should get drvdata from struct device directly. Going via
platform_device is an unneeded step back and forth.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-28 16:17:59 +01:00
Linus Walleij
1be5b22e1d staging: iio: Augment TODO file with GPIO work item
To make sure that these drivers do not leave staging before they
are properly converted to use the new GPIO descriptor API,
augment the TODO file with this work item.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-04-23 14:36:10 +02:00
Hernán Gonzalez
2c97342164 staging: iio: ad7746: Fix bound checkings
Also remove unnecessary parenthesis

Signed-off-by: Hernán Gonzalez <hernan@vanguardiasur.com.ar>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-21 15:38:38 +01:00
Hernán Gonzalez
afcd0b22e3 staging: iio: ad7746: Reorder variable declarations
Reorder some variable declarations in an inverse-pyramid scheme.

Signed-off-by: Hernán Gonzalez <hernan@vanguardiasur.com.ar>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-15 16:09:52 +01:00
Hernán Gonzalez
7adedec254 staging: iio: ad7746: Reorder includes alphabetically
Signed-off-by: Hernán Gonzalez <hernan@vanguardiasur.com.ar>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-15 16:08:37 +01:00
Hernán Gonzalez
c9aff39fa1 staging: iio: ad7746: Fix multiple line dereference
Clear checkpatch.pl WARNING about multiple line derefence but creates a
new one of line over 80 characters. In my opinion, it improves
readability.

Signed-off-by: Hernán Gonzalez <hernan@vanguardiasur.com.ar>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-15 16:06:38 +01:00
Hernán Gonzalez
2470bf57fc staging: iio: ad7746: Adjust arguments to match open parenthesis
Clear a couple more checkpatch.pl CHECKS.

Signed-off-by: Hernán Gonzalez <hernan@vanguardiasur.com.ar>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-15 16:02:48 +01:00
Hernán Gonzalez
95302e54d2 staging: iio: ad7746: Automatically swap values in readings/writings
Data to read or write was being handled with the swab16() macro instead
of using i2c_smbus_{read,write}_swapped.

Signed-off-by: Hernán Gonzalez <hernan@vanguardiasur.com.ar>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-04-15 16:00:28 +01:00
Linus Torvalds
df34df483a Staging/IIO patches for 4.17-rc1
Here is the big set of Staging/IIO driver patches for 4.17-rc1.
 
 It is a lot, over 500 changes, but not huge by previous kernel release
 standards.  We deleted more lines than we added again (27k added vs. 91k
 remvoed), thanks to finally being able to delete the IRDA drivers and
 networking code.
 
 We also deleted the ccree crypto driver, but that's coming back in
 through the crypto tree to you, in a much cleaned-up form.
 
 Added this round is at lot of "mt7621" device support, which is for an
 embedded device that Neil Brown cares about, and of course a handful of
 new IIO drivers as well.
 
 And finally, the fsl-mc core code moved out of the staging tree to the
 "real" part of the kernel, which is nice to see happen as well.
 
 Full details are in the shortlog, which has all of the tiny cleanup
 patches described.
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWsSnAA8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+yn60ACgxKvU/5XBP14hBkBpAcD0Q43OHe0AniEti65M
 Kw03GWK3NNM3pzk49BjZ
 =sj3K
 -----END PGP SIGNATURE-----

Merge tag 'staging-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging/IIO updates from Greg KH:
 "Here is the big set of Staging/IIO driver patches for 4.17-rc1.

  It is a lot, over 500 changes, but not huge by previous kernel release
  standards. We deleted more lines than we added again (27k added vs.
  91k remvoed), thanks to finally being able to delete the IRDA drivers
  and networking code.

  We also deleted the ccree crypto driver, but that's coming back in
  through the crypto tree to you, in a much cleaned-up form.

  Added this round is at lot of "mt7621" device support, which is for an
  embedded device that Neil Brown cares about, and of course a handful
  of new IIO drivers as well.

  And finally, the fsl-mc core code moved out of the staging tree to the
  "real" part of the kernel, which is nice to see happen as well.

  Full details are in the shortlog, which has all of the tiny cleanup
  patches described.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'staging-4.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (579 commits)
  staging: rtl8723bs: Remove yield call, replace with cond_resched()
  staging: rtl8723bs: Replace yield() call with cond_resched()
  staging: rtl8723bs: Remove unecessary newlines from 'odm.h'.
  staging: rtl8723bs: Rework 'struct _ODM_Phy_Status_Info_' coding style.
  staging: rtl8723bs: Rework 'struct _ODM_Per_Pkt_Info_' coding style.
  staging: rtl8723bs: Replace NULL pointer comparison with '!'.
  staging: rtl8723bs: Factor out rtl8723bs_recv_tasklet() sections.
  staging: rtl8723bs: Fix function signature that goes over 80 characters.
  staging: rtl8723bs: Fix lines too long in update_recvframe_attrib().
  staging: rtl8723bs: Remove unnecessary blank lines in 'rtl8723bs_recv.c'.
  staging: rtl8723bs: Change camel case to snake case in 'rtl8723bs_recv.c'.
  staging: rtl8723bs: Add missing braces in else statement.
  staging: rtl8723bs: Add spaces around ternary operators.
  staging: rtl8723bs: Fix lines with trailing open parentheses.
  staging: rtl8723bs: Remove unnecessary length #define's.
  staging: rtl8723bs: Fix IEEE80211 authentication algorithm constants.
  staging: rtl8723bs: Fix alignment in rtw_wx_set_auth().
  staging: rtl8723bs: Remove braces from single statement conditionals.
  staging: rtl8723bs: Remove unecessary braces from switch statement.
  staging: rtl8723bs: Fix newlines in rtw_wx_set_auth().
  ...
2018-04-04 18:56:27 -07:00
Shreeya Patel
524c762844 Staging: iio: adis16209: Move adis16209 driver out of staging
Move the adis16209 driver out of staging directory and merge to the
mainline IIO subsystem.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-30 13:50:36 +01:00
Shreeya Patel
abb07089b5 Staging: iio: adis16209: Use GENMASK
Use GENMASK to improve readability and remove the local
variables used to store intermediate data.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-30 13:50:35 +01:00
Shreeya Patel
11b2ffbbc3 Staging: iio: adis16209: Remove unused headers
Remove few unused header files since the adis core handles
the sysfs and buffer support.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-30 13:50:35 +01:00
Shreeya Patel
ec4187783f Staging: iio: adis16209: Add a blank line after return statements
Add a blank line after return statements to improve the code
readability.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-30 13:50:34 +01:00
Shreeya Patel
0a9d5dce5b Staging: iio: adis16209: Prefer reverse christmas tree ordering
Prefer reverse christmas tree ordering of declarations to
improve readability.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-30 13:50:33 +01:00
Shreeya Patel
55cdd2ecf6 Staging: iio: adis16209: Indent the field definitions
Have indentation in field definitions to make them
clearly different from the register addresses.

Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-30 13:50:32 +01:00
Arnd Bergmann
04b0297863 staging: iio: remove iio-trig-bfin-timer driver
The blackfin architecture is getting removed, so the timer trigger
driver is now obsolete. Since this is the last remaining iio trigger
driver in staging, I'm removing the entire directory.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Aaron Wu <aaron.wu@analog.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2018-03-26 15:57:27 +02:00
Brian Masney
a2fdb4e1a6 staging: iio: tsl2x7x: use either direction for IIO_EV_INFO_{ENABLE,PERIOD}
The events IIO_EV_INFO_VALUE and IIO_EV_INFO_ENABLE currently have a
falling and rising direction configured. There does not need to be a
separate distinction so this patch changes these to use the
either direction. Directory listing of event sysfs attributes for a
TSL2772 with this patch applied:

in_intensity0_thresh_either_en
in_intensity0_thresh_either_period
in_intensity0_thresh_falling_value
in_intensity0_thresh_rising_value
in_proximity0_thresh_either_en
in_proximity0_thresh_either_period
in_proximity0_thresh_falling_value
in_proximity0_thresh_rising_value

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-25 18:19:10 +01:00
Brian Masney
19422bde04 staging: iio: tsl2x7x: use auto increment I2C protocol
The hardware supports 16-bit ALS and proximity readings, however the
datasheet recommends using the I2C auto increment protocol so that the
correct high and low bytes are read even if the integration cycle ends
between reading the lower and upper registers.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-25 18:08:42 +01:00
Himanshu Jha
591298e54c Staging: iio: accel: adis16201: Move adis16201 driver out of staging
Move adis16201 driver out of staging and merge into mainline
IIO subsystem.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 14:26:19 +00:00
Himanshu Jha
6988a80ae8 Staging: iio: accel: adis16201: Fix 80 character line limit
Split the line over 80 characters limit to fix checkpatch
warning.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 14:20:13 +00:00
Himanshu Jha
15e374daf9 Staging: iio: accel: adis16201: Use GENMASK
Use GENMASK to improve readability and remove the local variables used to
store intermediate data.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 14:20:13 +00:00
Himanshu Jha
d8a6fc1813 Staging: iio: accel: adis16201: Remove unused headers
Remove few unused headers files since the adis core handles the buffer and
sysfs support.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 14:15:01 +00:00
Brian Masney
d15052bdb7 staging: iio: tsl2x7x: add copyright
Add Brian Masney's copyright and to the list of module authors for all
of the staging cleanups. This patch also update's Jon Brenner's current
work email address since AMS now owns TAOS.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:44:40 +00:00
Brian Masney
c9a6efd2c9 staging: iio: tsl2x7x: put local variables in reverse Christmas tree order
This patch ensures that all of the local variable declarations are in
reverse Christmas tree order where possible to increase code
readability.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:43:34 +00:00
Brian Masney
2130e243c4 staging: iio: tsl2x7x: remove ch0 and ch1 variables from tsl2x7x_get_lux()
Remove the ch0 and ch1 variables from tsl2x7x_get_lux() and
write those values directly into the chip->als_cur_info.als_ch0
and chip->als_cur_info.als_ch01 variables.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:43:04 +00:00
Brian Masney
96e6a016d7 staging: iio: tsl2x7x: remove unused variables from tsl2x7x_get_lux()
tsl2x7x_get_lux() has a ch0lux and ch1lux variables that are not used
so this patch removes them.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:40:59 +00:00
Brian Masney
490941db55 staging: iio: tsl2x7x: split out als and prox persistence settings
The struct tsl2x7x_settings contained a persistence member that
contained both the ALS and proximity persistence fields. This patch
splits this out into two separate fields so that the bitmasks in
several parts of the code are no longer necessary.

The default persistence settings are also changed by this patch from:

- Proximity: 0 (Every proximity cycle generates an interrupt)
- ALS: 255 (60 consecutive values out of range)

to something a little more reasonable based on my testing:

- Proximity: 1 (1 proximity value out of range)
- ALS: 1 (1 value outside of threshold range)

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:40:20 +00:00
Brian Masney
8bf09ec4dc staging: iio: tsl2x7x: make logging consistent and correct newlines
This patch updates all of the logging commands so that they are
consistent with the other messages, includes __func__ in the message,
and all of the messages include newlines. This patch also removes some
debug log messages.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:38:05 +00:00
Brian Masney
4123e69af2 staging: iio: tsl2x7x: split out als and prox interrupt settings
The struct tsl2x7x_settings contained an interrupts_en member that was
a bitmask for which interrupts are enabled. This required having
bitmasks in several parts of the code. This patch splits this field
out into two booleans to remove most of the bitmasks in the code.

This patch also fixes a bug where if an interrupt pin was configured,
but proximity interrupts were disabled, then the proximity value could
not be polled.

This patch also removes an unnecessary second call to writing the
control register in tsl2x7x_chip_on().

Driver tested using a TSL2772 hooked up to a Raspberry Pi 2.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:36:29 +00:00
Brian Masney
bce075d0ec staging: iio: tsl2x7x: simplify tsl2x7x_prox_cal()
tsl2x7x_prox_cal() would set the interrupt flag, and reset the device to
start doing the calibration routine. However, this did not actually
affect the readings since they are polled. This patch drops the interrupt
code.

This patch also drops the function tsl2x7x_prox_calculate() and removes
support for the standard deviation and min sample since those values
were not used.

Driver was tested using a TSL2772 hooked up to a Raspberry Pi 2. I
performed the following testing at various distances:

- Put hand in front of sensor and keep the sensor and hand stationary.
- Perform calibration routine.
- Run iio_event_monitor.
- Verify that a proximity event is triggered when my hand comes
  anywhere between the sensor and where I performed the calibration
  routine.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:35:15 +00:00
Brian Masney
85a7d0f7db staging: iio: tsl2x7x: no need to clear interrupt flag when getting lux
tsl2x7x_get_lux() does not need to clear the interrupt flag when
querying the ALS. The interrupt flag is cleared in
tsl2x7x_event_handler(). This patches removes the unnecessary code.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:34:09 +00:00
Brian Masney
9e4701eaef staging: iio: tsl2x7x: correct interrupt handler trigger
tsl2x7x_event_handler() was not called as expected when the device was
asserting a hardware interrupt. This patch changes the interrupt line
trigger from rising to falling.

The driver was tested on a TSL2772 hooked up to a Raspberry Pi 2. The
interrupt pin also had a 10K pull-up resistor per the requirements from
the datasheet. The relevant device tree binding:

&i2c1 {
	tsl2772@39 {
		compatible = "amstaos,tsl2772";
		reg = <0x39>;
		interrupt-parent = <&gpio>;
		interrupts = <22 0x2>;
	};
};

With this patch, iio_event_monitor now shows the events when the
channels are outside the defined interrupt thresholds.

$ sudo ./iio_event_monitor tsl2772
Found IIO device with name tsl2772 with device number 0
Event: time: 1478193460053760446, type: proximity, channel: 0, evtype:
thresh, direction: either
...
Event: time: 1478193463020270185, type: illuminance, channel: 0, evtype:
thresh, direction: either
...

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:32:40 +00:00
Brian Masney
c7bd25e8e2 staging: iio: tsl2x7x: remove unnecessary code
As a follow up to the work in commit a0722d05a1 ("staging: iio:
tsl2x7x: convert mutex_trylock() to mutex_lock()"), this patch removes
the unnecessary calls to tsl2x7x_get_prox() and tsl2x7x_get_lux() in
tsl2x7x_event_handler(). Previously, these functions were locked with
mutex_trylock(), but that is no longer the case. This patch also removes
a comment that is no longer relevant about returning the last sample.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:31:40 +00:00
Rodrigo Siqueira
8ea0fa7cd4 staging:iio:ade7854: Remove read_reg_* duplications
The original code had a read function per data size; after updates, all
read functions tasks were centralized in a single function, but the old
signature was kept to maintain the module working without problems. This
patch removes a set of duplications associated with read_reg_*, and
update the areas that calling the old interface by the new one.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:28:05 +00:00
Rodrigo Siqueira
e6182b2d8a staging:iio:ade7854: Rework SPI read function
Rework read SPI function to reduce the code duplication and centralizes
all the task in a single function.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:27:21 +00:00
Rodrigo Siqueira
5d55dcbc31 staging:iio:ade7854: Rework I2C read function
The read operation for the I2C function has many duplications that can
be generalized into a single function. This patch reworks the read
operation for I2C to centralizes all similar code in a single function.

It is possible to remove all the old interface to use the new one,
however, for keeping the things simple and working this patch maintain
legacy interface.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:26:45 +00:00
Rodrigo Siqueira
259a8202b6 staging:iio:ade7854: Remove write_reg_* duplications
This patch removes code duplications related to the write_reg_*
functions and centralizes them in a single function. Also, it eliminates
the legacy functions and replaces them by a unique signature that is
used by SPI and I2C.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:25:59 +00:00
Rodrigo Siqueira
418bbb6e6b staging:iio:ade7854: Rework SPI write function
The write operation using SPI has a many code duplications (similar to
I2C) and four different interfaces per data size. This patch introduces
a single function that centralizes the main task related to SPI.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:25:06 +00:00
Rodrigo Siqueira
e4c771d3a5 staging:iio:ade7854: Rework I2C write function
The write operation using I2C has many code duplications and four
different interfaces per data size. This patch introduces a single
function that centralizes the main tasks.

The central function inserted by this patch can easily replace all the
four functions related to the data size. However, this patch does not
remove any code signature for keeping the meter module work and make
easier to review this patch.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 13:24:21 +00:00
John Syne
6cef2ab016 staging:iio:ade7854: Fix the wrong number of bits to read
Fixes: correctly handle the data size in the read operation for I2C

The function ade7854_i2c_read_reg_32() have to invoke the
i2c_master_recv() for read 32 bits values, however, the counter is set
to 3 which means 24 bits. This patch fixes the wrong size of 24 bits, to
32 bits.

Signed-off-by: John Syne <john3909@gmail.com>
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Fixes: 8d97a5877 ("staging: iio: meter: new driver for ADE7754 devices")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 12:42:26 +00:00
John Syne
4297b23d92 staging:iio:ade7854: Fix error handling on read/write
The original code does not correctly handle the error related to I2C
read and write. This patch fixes the error handling related to all
read/write functions for I2C.

Signed-off-by: John Syne <john3909@gmail.com>
Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Fixes: 8d97a5877 ("staging: iio: meter: new driver for ADE7754 devices")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-24 12:37:02 +00:00
Himanshu Jha
211d71af69 Staging: iio: accel: adis16201: Adjust argument to match open parentheses
In adis16201_read_raw() adjust an argument to match an open parentheses
using tabs and spaces.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-18 08:35:09 +00:00
Himanshu Jha
58f368f509 Staging: iio: accel: adis16201: Prefer reverse christmas tree ordering
Prefer reverse christmas tree ordering of declarations to improve
readability.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-18 08:33:46 +00:00
Himanshu Jha
e7f3bfb7eb Staging: iio: accel: adis16201: Use sign_extend32 function
Use sign_extned32() for 32 bit sign extending rather than hard coding.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-18 08:33:00 +00:00
Himanshu Jha
57f9386405 Staging: iio: accel: adis16201: Add comments about units in read_raw()
Clarify the conversion and formation of resultant data in the
adis16201_read_raw() with sufficient comments and remove the unnecessary
comments.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-18 08:31:40 +00:00
Himanshu Jha
0d0f97d896 Staging: iio: accel: adis16201: Group register definitions
Group register definitions with its register field bits to improve
readability and easy identification. A small comment is also added to
denote the purpose/functionality of the grouped register definitions.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-18 08:29:26 +00:00
Himanshu Jha
a58efed313 Staging: iio: accel: adis16201: Add _REG suffix to registers
Add a _REG suffix to distinguish between registers and the register bit
fileds.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-18 08:24:11 +00:00
Himanshu Jha
395f42cb38 Staging: iio: accel: adis16201: Remove unnecessary comments
Remove few unnecessary comments since the macro definitions clearly
justify their purpose.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-18 08:21:51 +00:00
Himanshu Jha
241b91aee5 Staging: iio: accel: adis16201: Rename few macro definitions
Rename the macro definitions with suitable names specifying their
purpose.

* ADIS16201_STARTUP_DELAY_MS: Remove the comment specifying the delay in
  microseconds and rename it with addtition of _MS suffix.

* ADIS16201_MSC_CTRL_ACTIVE_DATA_RDY_HIGH: Rename the macro to make it
  similar to other misc control registers which denotes the data ready
  polarity.

* ADIS16201_DIAG_STAT_FLASH_UPT_FAIL_BIT: Rename to denote it is a
  failure bit.

* ADIS16201_GLOB_CMD_FACTORY_RESET: Remove ambiguous _CAL suffix and add
  _RESET suffix instead to denote factory reset command.

Signed-off-by: Himanshu Jha <himanshujha199640@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-18 08:09:00 +00:00
Alexandru Ardelean
192af06a28 iio: adc: ad7780: remove IIO_CHAN_INFO_SAMP_FREQ support
The `ad7780` driver does not implement setting/getting the sampling
frequency.
For the ad7780/ad7781 devices, the control is done via an external pin,
and the ad7170/ad7171 devices have a fixed sampling rate (so, no control).

For these devices, and similar other that may be added later on,
a AD_SD_CHANNEL_NO_SAMPLE_FREQ() macro has been added, which doesn't set
the IIO_CHAN_INFO_SAMP_FREQ flag.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-17 20:50:26 +00:00
Greg Kroah-Hartman
6761f0ac66 Second set of new device support, features and cleanup for IIO in the 4.17 cycle
The uptick in staging cleanup is partly due to GSoC Applications
 process being underway and one of Daniel's tasks being to try
 cleaning up an IIO driver to move out of staging.
 Naturally there is some normal staging cleanup progress in here
 as well.
 
 New device support
 * Microchip mcp4018
   - New driver supproting MCP4017, MCP4018 and MCP4019 digital pots.
 * On Semiconductor lv0104cs
   - New driver to support this ambient light sensor.
 
 Cleanup
 * axp20x_adc
   - remove a !! in favour of clear ternary operator.
 * ad2s1210 (staging cleanup)
   - Reorganise to avoid ending a line with [
   - Remove some unnecessary defines.
   - Remove unsed variable.
 * ad5380
   - Replace magic 0 with IIO_CHAN_INFO_RAW
 * ad5764
   - Replace magic 0 with IIO_CHA_INFO_RAW
 * ad7150 (staging cleanup)
   - Align arguements with parenthesis.
 * ad7152 (staging cleanup)
   - Align arguements.
 * ad7746 (staging cleanup)
   - Align arguements.
 * ad7816
   - Remove pointless void pointer cast.
 * ade7753
   - Replace IIO_DEV_ATTR_CH_OFF with equivalent to avoid confusing
     checkpatch (this macro didn't really help anyway).  Also drop the
     macro from the meter.h header.
 * ade7754 (staging cleanup)
   - Add names to funciton definition arguements.
   - Align arguements with open parenthesis where possible.
 * ade7758 (staging cleanup)
   - Remove __func__ from dev_dbg statements as provided by dynamic
     debug anyway.
   - Align arguements with open parenthesis where possible.
 * ade7759 (staging cleanup)
   - Replace IIO_DEV_ATTR_CH_OFF with equiavalent to avoid confusing
     checkpatch.
 * adis16201 (staging cleanup)
   - Headers in alphabetical order.
   - Blank lines before returns.
 * adis16209 (staging cleanup)
   - Headers in alphabetical order
   - Change some definition names to make them more meaningful (2 rounds
     of this).
   - Add explicit _REG prefix to register names to make them
     obviously different from fields within those registers.
   - Remove some superflous comments and group definitions better.
   - Use a switch statement to make it semantically obvious that we
     only have two options (rather than an unlimited 'else').
   - Use sign_extent32 instead of open coding.
 * adt7316 (staging cleanup)
   - Move an export next to symbol.
 * bmc150
   - drop redundant __func__ in dynamic debug.
 * ccs811
   - Rename varaible to better reflect what it does.
 * cros_ec
   - Reduce sampling frequency before suspending to avoid preventing
     suspend.
 * dummy
   - Correct whitespace in Kconfig.
   - Add extra description in Kconfig.
 * ds1803
   - Remove a VLA which we always know is 2 long.
 * hid-sensor-accel
   - Replace magic number 0 by IIO_CHAN_INFO_RAW.
 * hid-sensor-gyro
   - Replace magic number 0 by IIO_CHAN_INFO_RAW.
 * hid-sensor-light
   - Replace magic number 0 by IIO_CHAN_INFO_RAW.
 * hid-sensor-magn
   - Replace magic number 0 by IIO_CHAN_INFO_RAW.
 * lm3533
   - Replace magic number 0 by IIO_CHAN_INFO_RAW
 * mlx90632
   - Squash a smatch warning - no runtime effect.
 * stm32_dfsdm:
   - Cleanup the dt bindings.
 * sx9500
   - Add GPIO ACPI mapping table to behave correctly when firmware
     doesn't provide the mapping.
 * tsl2x7x (staging cleanup)
   - Fix the proximity sensor functionality.
   - Remove platform data provided power functions.  There are much
     better ways to do this these days.
   - Introduce some common functions to avoid various repititions.
   - Stop using mutex_trylock when mutex_lock and wait a bit is fine.
   - Improve error handling in various places.
   - Drop some 'Camel case' (which wasn't actually strickly camel case
     but was a bit odd.
   - Drop some _available sysfs attributes for things that don't exist
     (for particular supported parts).
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAlqlObQRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FoissQ/+IQjcyxNdtOhHagvRgZ5z+6GYj6JzIX8s
 Qqnep34sc6yUaygbJBXdcBQ5qdnPjrTk2CD3VYANOdC1bqXa80yuTGCGN6lBIBEr
 /qBso6UbUiobA1PXektUj7Qel5HfVfYCyQ4NssSwKbdza6pyqoZA+iPzwiztWAwE
 JsU5EdsTVxB/39kMOnoQJM6l5Lc5Ljg5pS3Du++3U49neiDk1Z/+VXsimFSPK3zt
 FrSmMehNRYr0iFPwi7IZf8beG5ixmpRyY+KZzdM45Gm4hrpgE9ZIMd7A8B+ypx5N
 WM1HJxu3PC6xHc7DIbcJG82sQ9DDrIeCkN4wN29ESE0JUt/GPvySSFZRAhsVp+xO
 8rObv0r9Va+ones5WhZeAx/x3FowommZ2Jn+0FpX5H0X0mgi34au4YiOOAhg2gz5
 9fnj39k7WarYozn1VVY8D8copO6C7j/UQVup/qfjmufkc7bDrQMml3rBWZbNxSUC
 0TfZZJ9k+bxw2fvIedrjU/CFYbJJSpkRF/Sm3TZW28OMpxt/3qmAECtREOXVLyl2
 cJnJpw8ERWbyeHJxhULurc2ekJVFeOS1sZ+sWU7P0LFt+J3dkOgZP1GJpXXhCWQa
 GmgIm7vYYtAsVjDZ+FwH4ir/wSUeufscFEHs1oVhmIRh7jRCaJWycgLKZcK+rVRK
 docrwE4wGrk=
 =6eOr
 -----END PGP SIGNATURE-----

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

Jonathan writes:

Second set of new device support, features and cleanup for IIO in the 4.17 cycle

The uptick in staging cleanup is partly due to GSoC Applications
process being underway and one of Daniel's tasks being to try
cleaning up an IIO driver to move out of staging.
Naturally there is some normal staging cleanup progress in here
as well.

New device support
* Microchip mcp4018
  - New driver supproting MCP4017, MCP4018 and MCP4019 digital pots.
* On Semiconductor lv0104cs
  - New driver to support this ambient light sensor.

Cleanup
* axp20x_adc
  - remove a !! in favour of clear ternary operator.
* ad2s1210 (staging cleanup)
  - Reorganise to avoid ending a line with [
  - Remove some unnecessary defines.
  - Remove unsed variable.
* ad5380
  - Replace magic 0 with IIO_CHAN_INFO_RAW
* ad5764
  - Replace magic 0 with IIO_CHA_INFO_RAW
* ad7150 (staging cleanup)
  - Align arguements with parenthesis.
* ad7152 (staging cleanup)
  - Align arguements.
* ad7746 (staging cleanup)
  - Align arguements.
* ad7816
  - Remove pointless void pointer cast.
* ade7753
  - Replace IIO_DEV_ATTR_CH_OFF with equivalent to avoid confusing
    checkpatch (this macro didn't really help anyway).  Also drop the
    macro from the meter.h header.
* ade7754 (staging cleanup)
  - Add names to funciton definition arguements.
  - Align arguements with open parenthesis where possible.
* ade7758 (staging cleanup)
  - Remove __func__ from dev_dbg statements as provided by dynamic
    debug anyway.
  - Align arguements with open parenthesis where possible.
* ade7759 (staging cleanup)
  - Replace IIO_DEV_ATTR_CH_OFF with equiavalent to avoid confusing
    checkpatch.
* adis16201 (staging cleanup)
  - Headers in alphabetical order.
  - Blank lines before returns.
* adis16209 (staging cleanup)
  - Headers in alphabetical order
  - Change some definition names to make them more meaningful (2 rounds
    of this).
  - Add explicit _REG prefix to register names to make them
    obviously different from fields within those registers.
  - Remove some superflous comments and group definitions better.
  - Use a switch statement to make it semantically obvious that we
    only have two options (rather than an unlimited 'else').
  - Use sign_extent32 instead of open coding.
* adt7316 (staging cleanup)
  - Move an export next to symbol.
* bmc150
  - drop redundant __func__ in dynamic debug.
* ccs811
  - Rename varaible to better reflect what it does.
* cros_ec
  - Reduce sampling frequency before suspending to avoid preventing
    suspend.
* dummy
  - Correct whitespace in Kconfig.
  - Add extra description in Kconfig.
* ds1803
  - Remove a VLA which we always know is 2 long.
* hid-sensor-accel
  - Replace magic number 0 by IIO_CHAN_INFO_RAW.
* hid-sensor-gyro
  - Replace magic number 0 by IIO_CHAN_INFO_RAW.
* hid-sensor-light
  - Replace magic number 0 by IIO_CHAN_INFO_RAW.
* hid-sensor-magn
  - Replace magic number 0 by IIO_CHAN_INFO_RAW.
* lm3533
  - Replace magic number 0 by IIO_CHAN_INFO_RAW
* mlx90632
  - Squash a smatch warning - no runtime effect.
* stm32_dfsdm:
  - Cleanup the dt bindings.
* sx9500
  - Add GPIO ACPI mapping table to behave correctly when firmware
    doesn't provide the mapping.
* tsl2x7x (staging cleanup)
  - Fix the proximity sensor functionality.
  - Remove platform data provided power functions.  There are much
    better ways to do this these days.
  - Introduce some common functions to avoid various repititions.
  - Stop using mutex_trylock when mutex_lock and wait a bit is fine.
  - Improve error handling in various places.
  - Drop some 'Camel case' (which wasn't actually strickly camel case
    but was a bit odd.
  - Drop some _available sysfs attributes for things that don't exist
    (for particular supported parts).
2018-03-14 12:32:11 +01:00
Rodrigo Siqueira
9aa5134ac4 staging:iio:ad2s1210: Remove old_data from ad2s1210_state
The variable old_data is a bool type, which only receives the value
'true' in the function ad2s1210_config_write and ad2s1210_config_read.
There is no other use for this variable. This patch removes old_data
from the ad2s1210_state and from all the function that use it.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-10 17:21:23 +00:00
Rodrigo Siqueira
a8cf0d829a staging:iio:ad2s1210: Remove unused #define directive
This patch removes some #define directives not used in the code.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-10 17:20:18 +00:00
Rodrigo Siqueira
23c537ae0e staging:iio:ad2s1210: Remove end of line with '['
This patch fixes the checkpatch.pl check:

iio/resolver/ad2s1210.c:202: CHECK: Lines should not end with a '['

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-10 16:41:09 +00:00
Tom Lebreux
6e2e828de0 staging:iio:ad7150: Align arguments to match open parenthesis
This fixes the following checkpatch.pl CHECK: Alignment should match
open parenthesis

Signed-off-by: Tom Lebreux <tomlebreux@cock.li>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-03-10 16:18:14 +00:00