]> git.baikalelectronics.ru Git - kernel.git/log
kernel.git
4 years agoiio: imu: st_lsm6dsx: enable 833Hz sample frequency for tagged sensors
Lorenzo Bianconi [Fri, 24 Apr 2020 10:44:38 +0000 (12:44 +0200)]
iio: imu: st_lsm6dsx: enable 833Hz sample frequency for tagged sensors

Enable 833Hz ODR for sensors that supports tagged hw FIFO:
- LSM6DSO/LSM6DSOX
- LSM6DSR/LSM6DSRX
- ASM330LHH

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adc: ad7476: remove redundant null check on an array
Colin Ian King [Fri, 24 Apr 2020 13:04:19 +0000 (14:04 +0100)]
iio: adc: ad7476: remove redundant null check on an array

The null check on st->chip_info->convst_channel is redundant because
convst_channel is a 2 element array of struct iio_chan_spec objects
and this can never be null. Fix this by removing the null check.

Addresses-Coverity: ("Array compared against 0")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: buffer: extend short-hand use for 'indio_dev->buffer'
Alexandru Ardelean [Fri, 24 Apr 2020 15:22:43 +0000 (18:22 +0300)]
iio: buffer: extend short-hand use for 'indio_dev->buffer'

This change is both cosmetic and a prequel to adding support for attaching
multiple buffers per IIO device.

The IIO buffer sysfs attrs are mostly designed to support only one attached
buffer, and in order to support more, we need to centralize [in each attr
function] the buffer which is being accessed.

This also makes it a bit more uniform, as in some functions there is a
short-hand 'buffer' variable and at the same time the 'indio_dev->buffer'
is still access directly.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: dac: ad5592r: Fix a typo in the name of a function
Christophe JAILLET [Sat, 25 Apr 2020 07:00:56 +0000 (09:00 +0200)]
iio: dac: ad5592r: Fix a typo in the name of a function

This module is related to AD5592R, not AD5593R, so be consistent in naming.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: dac: ad5593r: Fix a typo in MODULE_DESCRIPTION
Christophe JAILLET [Sat, 25 Apr 2020 06:56:53 +0000 (08:56 +0200)]
iio: dac: ad5593r: Fix a typo in MODULE_DESCRIPTION

This module is related to AD5593R, not AD5592R.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: st_sensors: Use get_unaligned_be24() and sign_extend32()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:35 +0000 (03:31 +0300)]
iio: st_sensors: Use get_unaligned_be24() and sign_extend32()

Use these functions instead of open-coding them.

Cc: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: temperature: max31856: Use get_unaligned_beXX()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:34 +0000 (03:31 +0300)]
iio: temperature: max31856: Use get_unaligned_beXX()

This makes the driver code slightly easier to read.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: pressure: zpa2326: Use get_unaligned_le24()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:33 +0000 (03:31 +0300)]
iio: pressure: zpa2326: Use get_unaligned_le24()

This makes the driver code slightly easier to read.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: pressure: ms5611: Use get_unaligned_be24()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:32 +0000 (03:31 +0300)]
iio: pressure: ms5611: Use get_unaligned_be24()

This makes the driver code slightly easier to read.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Tomasz Duszynski <tduszyns@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: pressure: hp206c: Use get_unaligned_be24()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:31 +0000 (03:31 +0300)]
iio: pressure: hp206c: Use get_unaligned_be24()

This makes the driver code slightly easier to read.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: magnetometer: rm3100: Use get_unaligned_be24()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:30 +0000 (03:31 +0300)]
iio: magnetometer: rm3100: Use get_unaligned_be24()

This makes the driver code slightly easier to read.

Cc: Song Qiang <songqiang1304521@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: light: zopt2201: Use get_unaligned_le24()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:29 +0000 (03:31 +0300)]
iio: light: zopt2201: Use get_unaligned_le24()

This makes the driver code slightly easier to read.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: light: si1133: Use get_unaligned_be24()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:28 +0000 (03:31 +0300)]
iio: light: si1133: Use get_unaligned_be24()

This makes the driver code slightly easier to read.

Cc: Maxime Roussin-Bélanger <maxime.roussinbelanger@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: health: afe4403: Use get_unaligned_be24()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:27 +0000 (03:31 +0300)]
iio: health: afe4403: Use get_unaligned_be24()

This makes the driver code slightly easier to read.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: gyro: adis16130: Use get_unaligned_be24()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:26 +0000 (03:31 +0300)]
iio: gyro: adis16130: Use get_unaligned_be24()

This makes the driver code slightly easier to read.

Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: dac: ad5446: Use put_unaligned_be24()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:25 +0000 (03:31 +0300)]
iio: dac: ad5446: Use put_unaligned_be24()

This makes the driver code slightly easier to read.

Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: dac: ad5624r_spi: Use put_unaligned_be24()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:24 +0000 (03:31 +0300)]
iio: dac: ad5624r_spi: Use put_unaligned_be24()

This makes the driver code slightly easier to read.

Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: dac: ltc2632: Use put_unaligned_be24()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:23 +0000 (03:31 +0300)]
iio: dac: ltc2632: Use put_unaligned_be24()

This makes the driver code slightly easier to read.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adc: ti-ads124s08: Use get_unaligned_be24()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:22 +0000 (03:31 +0300)]
iio: adc: ti-ads124s08: Use get_unaligned_be24()

This makes the driver code slightly easier to read.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adc: mpc3422: Use get_unaligned_beXX()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:21 +0000 (03:31 +0300)]
iio: adc: mpc3422: Use get_unaligned_beXX()

This makes the driver code slightly easier to read.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adc: ad_sigma_delta: Use {get,put}_unaligned_be24()
Andy Shevchenko [Tue, 21 Apr 2020 00:31:20 +0000 (03:31 +0300)]
iio: adc: ad_sigma_delta: Use {get,put}_unaligned_be24()

This makes the driver code slightly easier to read.

Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: Use an early return in iio_device_alloc to simplify code.
Jonathan Cameron [Sun, 19 Apr 2020 15:13:37 +0000 (16:13 +0100)]
iio: Use an early return in iio_device_alloc to simplify code.

Noticed whilst reviewing Alexandru's patch to the same function.
If we simply flip the logic and return NULL immediately after memory
allocation failure we reduce the indent of the following block and
end up with more 'idiomatic' kernel code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
4 years agoiio: chemical: Add OF match table for CCS811 VOC sensor
Manivannan Sadhasivam [Tue, 14 Apr 2020 18:49:30 +0000 (00:19 +0530)]
iio: chemical: Add OF match table for CCS811 VOC sensor

Add devicetree OF match table support for CCS811 VOC sensor.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: chemical: Add support for external Reset and Wakeup in CCS811
Manivannan Sadhasivam [Tue, 14 Apr 2020 18:49:29 +0000 (00:19 +0530)]
iio: chemical: Add support for external Reset and Wakeup in CCS811

CCS811 VOC sensor exposes nRESET and nWAKE pins which can be connected
to GPIO pins of the host controller. These pins can be used to externally
release the device from reset and also to wake it up before any I2C
transaction. The initial driver support assumed that the nRESET pin is not
connected and the nWAKE pin is tied to ground.

This commit improves it by adding support for controlling those two pins
externally using a host controller. For the case of reset, if the hardware
reset is not available, the mechanism to do software reset is also added.

As a side effect of doing this, the IIO device allocation needs to be
slightly moved to top of probe to make use of priv data early.

Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: chemical: Add binding for CCS811 VOC sensor
Manivannan Sadhasivam [Tue, 14 Apr 2020 18:49:28 +0000 (00:19 +0530)]
dt-bindings: iio: chemical: Add binding for CCS811 VOC sensor

This commit adds devicetree binding for AMS CCS811 VOC sensor.

Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: Add adis16475 documentation
Nuno Sá [Mon, 13 Apr 2020 08:24:45 +0000 (10:24 +0200)]
dt-bindings: iio: Add adis16475 documentation

Document the ADIS16475 device devicetree bindings

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: imu: Add support for adis16475
Nuno Sá [Mon, 13 Apr 2020 08:24:44 +0000 (10:24 +0200)]
iio: imu: Add support for adis16475

Support ADIS16475 and similar IMU devices. These devices are
a precision, miniature MEMS inertial measurement unit (IMU) that
includes a triaxial gyroscope and a triaxial accelerometer. Each
inertial sensor combines with signal conditioning that optimizes
dynamic performance.

The driver adds support for the following devices:
* adis16470, adis16475, adis16477, adis16465, adis16467, adis16500,
  adis16505, adis16507.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adis: Support different burst sizes
Nuno Sá [Mon, 13 Apr 2020 08:24:43 +0000 (10:24 +0200)]
iio: adis: Support different burst sizes

Add burst_max_len to `adis_burst`. This is useful for devices which
support different burst modes with different sizes. The buffer to be
used in the spi transfer is allocated with this variable making sure
that has space for all burst modes. The spi transfer length should hold
the "real" burst length depending on the current burst mode configured
in the device.

Moreover, `extra_len` in `adis_burst` is made const and it should
contain the smallest extra length necessary for a burst transfer. In
`struct adis` was added a new `burst_extra_len` that should hold the
extra bytes needed depending on the device instance being used.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adis: Add adis_update_bits() APIs
Nuno Sá [Mon, 13 Apr 2020 08:24:42 +0000 (10:24 +0200)]
iio: adis: Add adis_update_bits() APIs

This patch adds a `regmap_update_bits()` like API to the ADIS library.
It provides locked and unlocked variant.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: imu: adis: Add irq flag variable
Nuno Sá [Mon, 13 Apr 2020 08:24:41 +0000 (10:24 +0200)]
iio: imu: adis: Add irq flag variable

There are some ADIS devices that can configure the data ready pin
polarity. Hence, we cannot hardcode our IRQ mask as IRQF_TRIGGER_RISING
since we might want to have it as IRQF_TRIGGER_FALLING.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: imu: adis: Add Managed device functions
Nuno Sá [Mon, 13 Apr 2020 08:24:40 +0000 (10:24 +0200)]
iio: imu: adis: Add Managed device functions

This patch adds support for a managed device version of
adis_setup_buffer_and_trigger. It works exactly as the original
one but it calls all the devm_iio_* functions to setup an iio
buffer and trigger. Hence we do not need to care about cleaning those
and we do not need to support a remove() callback for every driver using
the adis library.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: at91-sama5d2_adc: adjust iio_triggered_buffer_{predisable,postenable} positions
Alexandru Ardelean [Wed, 4 Mar 2020 08:42:19 +0000 (10:42 +0200)]
iio: at91-sama5d2_adc: adjust iio_triggered_buffer_{predisable,postenable} positions

The iio_triggered_buffer_{predisable,postenable} functions attach/detach
poll functions.

In most cases the iio_triggered_buffer_postenable() should be called first
to attach the poll function, and then the driver can init the data to be
triggered.
In this case it's the other way around: the DMA code should be initialized
before the attaching the poll function and the reverse should be done when
un-initializing.

To make things easier when removing the iio_triggered_buffer_postenable() &
iio_triggered_buffer_predisable() functions from the IIO core API, the DMA
code has been moved into preenable() for init, and postdisable() for
uninit.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Reviewed-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: at91-sama5d2_adc: split at91_adc_current_chan_is_touch() helper
Alexandru Ardelean [Wed, 4 Mar 2020 08:42:18 +0000 (10:42 +0200)]
iio: at91-sama5d2_adc: split at91_adc_current_chan_is_touch() helper

This change moves the logic to check if the current channel is the
touchscreen channel to a separate helper.
This reduces some code duplication, but the main intent is to re-use this
in the next patches.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Eugen Hristev <eugen.hristev@microchip.com>
Reviewed-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adc: at91-sama5d2_adc: update for other trigger usage
Eugen Hristev [Tue, 28 Jan 2020 12:57:41 +0000 (12:57 +0000)]
iio: adc: at91-sama5d2_adc: update for other trigger usage

This change will allow the at91-sama5d2_adc driver to use other triggers
than it's own.
In particular, tested with the sysfs trigger.
To be able to achieve this functionality, some changes were required:
1) Do not enable/disable channels when enabling/disabling the trigger.
This is because the trigger is enabled/disabled only for our trigger
(obviously). We need channels enabled/disabled regardless of what trigger is
being used.
2) Cope with DMA : DMA cannot be used when using another type of trigger.
Other triggers work through pollfunc, so we get polled anyway on every trigger.
Thus we have to obtain data at every trigger.
3) When to start conversion? The usual pollfunc (store time from subsystem)
would be in hard irq and this would be a good way, but current iio subsystem
recommends to have it in the threaded irq. Thus adding software start
code in this handler.
4) Buffer config: we need to setup buffer regardless of our own device's
trigger. We may get one attached later.
5) IRQ handling: we use our own device IRQ only if it's our own trigger
and we do not use DMA . If we use DMA, we use the DMA controller's IRQ.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adc: at91-sama5d2_adc: handle unfinished conversions
Eugen Hristev [Tue, 28 Jan 2020 12:57:40 +0000 (12:57 +0000)]
iio: adc: at91-sama5d2_adc: handle unfinished conversions

It can happen that on IRQ trigger, not all conversions are done if
we are enabling multiple channels.
The IRQ is triggered on first EOC (end of channel), but it can happen
that not all channels are done. This leads into erroneous reports to
userspace (zero values or previous values).
To solve this, in trigger handler, check if the mask of done channels
is the same as the mask of active scan channels.
If it's the same, proceed and push to buffers. Otherwise, use usleep
to sleep until the conversion is done or we timeout.
Normally, it should happen that in a short time fashion, all channels are
ready, since the first IRQ triggered.
If a hardware fault happens (for example the clock suddently dissappears),
the handler will not be completed, in which case we do not report anything to
userspace anymore.
Also, change from using the EOC interrupts to DRDY interrupt.
This helps with the fact that not 'n' interrupt statuses are enabled,
each being able to trigger an interrupt, and instead only data ready
interrupt can wake up the CPU. Like this, when data is ready, check in
handler which and how many channels are done. While the DRDY is raised,
other IRQs cannot occur. Once the channel data is being read, we ack the
IRQ and finish the conversion.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: light: vl6180: add include of mod_devicetable.h and drop of_match_ptr
Jonathan Cameron [Sun, 19 Apr 2020 15:02:06 +0000 (16:02 +0100)]
iio: light: vl6180: add include of mod_devicetable.h and drop of_match_ptr

Enables probing via ACPI PRP0001 route and removes an example of
an approach we no longer want people to copy.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
4 years agoiio: light: st_uvis25: Add mod_devicetable.h and drop of_match_ptr
Jonathan Cameron [Sun, 19 Apr 2020 15:02:05 +0000 (16:02 +0100)]
iio: light: st_uvis25: Add mod_devicetable.h and drop of_match_ptr

Enables probing via ACPI PRP0001 and removes an example that we don't
want people to cut and paste into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
4 years agoiio: light: opt3001: Add mod_devicetable.h and drop use of of_match_ptr
Jonathan Cameron [Sun, 19 Apr 2020 15:02:04 +0000 (16:02 +0100)]
iio: light: opt3001: Add mod_devicetable.h and drop use of of_match_ptr

Enables probing via ACPI PRP0001 but mostly about removing examples
that might be copied to new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
4 years agoiio: light: gp2ap020a00f: Swap of.h for mod_devicetable.h + drop of_match_ptr
Jonathan Cameron [Sun, 19 Apr 2020 15:02:03 +0000 (16:02 +0100)]
iio: light: gp2ap020a00f: Swap of.h for mod_devicetable.h + drop of_match_ptr

Also drops ifdef protections for CONFIG_OF.

Enables probing via ACPI PRP0001 and removes an example that might be
cut and paste into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
4 years agoiio: light: cm3232: Add mod_devicetable.h include and drop of_match_ptr
Jonathan Cameron [Sun, 19 Apr 2020 15:02:02 +0000 (16:02 +0100)]
iio: light: cm3232: Add mod_devicetable.h include and drop of_match_ptr

Enables ACPI probing via PRP0001 and removes an example that might
be cut and paste to a new driver.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
4 years agoiio: light: cm32181: Add mod_devicetable.h and remove of_match_ptr
Jonathan Cameron [Sun, 19 Apr 2020 15:02:01 +0000 (16:02 +0100)]
iio: light: cm32181: Add mod_devicetable.h and remove of_match_ptr

Enables probing via the ACPI PRP0001 route but more is mosty about
removing examples of this that might get copied into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
4 years agoiio: light: bh1780: use mod_devicetable.h and drop of_match_ptr macro
Jonathan Cameron [Sun, 19 Apr 2020 15:02:00 +0000 (16:02 +0100)]
iio: light: bh1780: use mod_devicetable.h and drop of_match_ptr macro

Whilst this enables ACPI binding or the device via PRP0001 the
primary aim is to remove potential for these two things to be
cut and paste into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
4 years agoiio: accel: kxsd9-i2c: Use mod_devicetable.h and drop of_match_ptr macro
Nishant Malpani [Fri, 24 Apr 2020 22:44:38 +0000 (04:14 +0530)]
iio: accel: kxsd9-i2c: Use mod_devicetable.h and drop of_match_ptr macro

Enables ACPI DSDT to probe via PRP0001 and the compatible property. Also
removes the ifdef protections for CONFIG_OF.

Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: accel: dmard06: Use mod_devicetable.h and drop of_match_ptr macro
Nishant Malpani [Fri, 24 Apr 2020 22:44:37 +0000 (04:14 +0530)]
iio: accel: dmard06: Use mod_devicetable.h and drop of_match_ptr macro

Enables ACPI DSDT to probe via PRP0001 and the compatible property.

Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: chemical: atlas-sensor: add RTD-SM module support
Matt Ranostay [Sat, 25 Apr 2020 07:25:20 +0000 (10:25 +0300)]
iio: chemical: atlas-sensor: add RTD-SM module support

Atlas Scientific RTD-SM OEM sensor reads temperature using
resistance temperature detector technology.

Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: chemical: add Atlas Scientific RTD-SM sensor docs
Matt Ranostay [Sat, 25 Apr 2020 07:25:19 +0000 (10:25 +0300)]
dt-bindings: iio: chemical: add Atlas Scientific RTD-SM sensor docs

Cc: devicetree@vger.kernel.org
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agostaging: vt6656: Use fls instead of for loop in vnt_update_top_rates
Oscar Carter [Mon, 20 Apr 2020 15:52:46 +0000 (17:52 +0200)]
staging: vt6656: Use fls instead of for loop in vnt_update_top_rates

Replace the for loops of the vnt_update_top_rates function by the fls
function.

The purpose of the two for loops is to find the most significant bit set
in a range of bits. So, they can be replace by the fls function (find
last set) with a previous mask to define the range.

This way avoid the iteration over unnecessary for loops.

The header "linux/bits.h" can be remove as it is included in the header
"linux/bitops.h".

Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
Link: https://lore.kernel.org/r/20200420155246.4925-1-oscar.carter@gmx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: vt6656: Refactor the vnt_ofdm_min_rate function
Oscar Carter [Sat, 18 Apr 2020 13:45:53 +0000 (15:45 +0200)]
staging: vt6656: Refactor the vnt_ofdm_min_rate function

Replace the for loop by a ternary operator whose condition is an AND
bitmask against the priv->basic_rates variable.

The purpose of the for loop was to check if any of bits from RATE_54M to
RATE_6M was set, but it's not necessary to check every individual bit.
The same result can be achieved using only one single mask which
comprises all the commented bits.

This way avoid the iteration over an unnecessary for loop.

Also change the return type to bool because it's the type that this
function returns.

Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
Link: https://lore.kernel.org/r/20200418134553.6415-1-oscar.carter@gmx.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: gasket: Fix mapping refcnt leak when register/store fails
Xiyu Yang [Thu, 23 Apr 2020 05:15:40 +0000 (13:15 +0800)]
staging: gasket: Fix mapping refcnt leak when register/store fails

gasket_sysfs_register_store() invokes get_mapping(), which returns a
reference of the specified gasket_sysfs_mapping object to "mapping" with
increased refcnt.

When gasket_sysfs_register_store() returns, local variable "mapping"
becomes invalid, so the refcount should be decreased to keep refcount
balanced.

The reference counting issue happens in one exception handling path of
gasket_sysfs_register_store(). When gasket_dev is NULL, the function
forgets to decrease the refcnt increased by get_mapping(), causing a
refcnt leak.

Fix this issue by calling put_mapping() when gasket_dev is NULL.

Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Link: https://lore.kernel.org/r/1587618941-13718-1-git-send-email-xiyuyang19@fudan.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: gasket: Fix mapping refcnt leak when put attribute fails
Xiyu Yang [Thu, 23 Apr 2020 05:14:55 +0000 (13:14 +0800)]
staging: gasket: Fix mapping refcnt leak when put attribute fails

gasket_sysfs_put_attr() invokes get_mapping(), which returns a reference
of the specified gasket_sysfs_mapping object to "mapping" with increased
refcnt.

When gasket_sysfs_put_attr() returns, local variable "mapping" becomes
invalid, so the refcount should be decreased to keep refcount balanced.

The reference counting issue happens in one path of
gasket_sysfs_put_attr(). When mapping attribute is unknown, the function
forgets to decrease the refcnt increased by get_mapping(), causing a
refcnt leak.

Fix this issue by calling put_mapping() when put attribute fails due to
unknown attribute.

Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Link: https://lore.kernel.org/r/1587618895-13660-1-git-send-email-xiyuyang19@fudan.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: mt7621-pinctrl: Use correct pointer type argument for sizeof
Jason Yan [Mon, 20 Apr 2020 13:34:16 +0000 (21:34 +0800)]
staging: mt7621-pinctrl: Use correct pointer type argument for sizeof

Fix the following coccicheck warning:

drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c:223:14-36: WARNING: Use
correct pointer type argument for sizeof

Signed-off-by: Jason Yan <yanaijie@huawei.com>
Link: https://lore.kernel.org/r/20200420133416.3087-1-yanaijie@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: qlge: replace deprecated apis pci_dma_*
realwakka [Mon, 20 Apr 2020 15:40:09 +0000 (00:40 +0900)]
staging: qlge: replace deprecated apis pci_dma_*

Replace legacy/depreacted pci_dma_* functions to new dma_* functions.
Also replace PCI_DMA_* macro to DMA* macro.

Signed-off-by: realwakka <realwakka@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20200420154009.21161-1-realwakka@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: qlge: cleanup indent in qlge_main.c
Mathieu Dolmen [Sun, 19 Apr 2020 12:57:12 +0000 (14:57 +0200)]
staging: qlge: cleanup indent in qlge_main.c

Cleanup indentation style in qlge_main.c.
Fix 2 warnings found by checkpatch.pl.

Signed-off-by: Mathieu Dolmen <mathieu.dolmen@gmail.com>
Link: https://lore.kernel.org/r/20200419125712.27506-1-mathieu.dolmen@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: vt6656: Move vnt_get_frame_time and vnt_get_phy_field to rxtx
Malcolm Priestley [Sun, 19 Apr 2020 13:43:46 +0000 (14:43 +0100)]
staging: vt6656: Move vnt_get_frame_time and vnt_get_phy_field to rxtx

These functions are only used by rxtx so move them and their arrays
used with them abbreviating the function description.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Link: https://lore.kernel.org/r/2a4fd665-2fe1-f1ad-1e9a-1b01f698ea79@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: vt6656: call vnt_update_pre_ed_threshold from vnt_config.
Malcolm Priestley [Sun, 19 Apr 2020 11:20:52 +0000 (12:20 +0100)]
staging: vt6656: call vnt_update_pre_ed_threshold from vnt_config.

vnt_update_pre_ed_threshold needs to be updated more often so
call from vnt_config where it updated on any of config changes.

It must have maximum sensitivity when the device is off channel
or idle.

Remove all the other calls in scanning and bss.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Link: https://lore.kernel.org/r/1b00c112-347c-b0bb-61ed-a874ee448ff8@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: vt6656: Move firmware functions into main_usb.
Malcolm Priestley [Sun, 19 Apr 2020 10:26:06 +0000 (11:26 +0100)]
staging: vt6656: Move firmware functions into main_usb.

The firmware function are not that complicated so
move them into main_usb as static functions in callers
visibility

Firmware definitions moved to device.h and MODULE_FIRMWARE
move to below module_usb_driver.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Link: https://lore.kernel.org/r/7b384871-826b-9365-e3ed-5717ecefd31c@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoStaging: rtl8723bs: rtw_wlan_util: Add size check of SSID IE
Denis Straghkov [Tue, 21 Apr 2020 21:25:25 +0000 (00:25 +0300)]
Staging: rtl8723bs: rtw_wlan_util: Add size check of SSID IE

Add size check of SSID information element in incoming 802.11
frames, to prevent memcpy() of IE in array bssid->Ssid.Ssid, with
size more than 32 bytes.

Signed-off-by: Denis Straghkov <d.straghkov@ispras.ru>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200421212525.24962-1-d.straghkov@ispras.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: rtl8723bs: remove unused variable 'pregistrypriv'
YueHaibing [Tue, 21 Apr 2020 02:41:45 +0000 (10:41 +0800)]
staging: rtl8723bs: remove unused variable 'pregistrypriv'

drivers/staging/rtl8723bs/hal/sdio_halinit.c: In function HalRxAggr8723BSdio:
drivers/staging/rtl8723bs/hal/sdio_halinit.c:547:24: warning: variable pregistrypriv set but not used [-Wunused-but-set-variable]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Link: https://lore.kernel.org/r/20200421024145.43576-1-yuehaibing@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: rtl8723bs: remove defined but not used 'dB_Invert_Table'
Jason Yan [Fri, 17 Apr 2020 07:34:39 +0000 (15:34 +0800)]
staging: rtl8723bs: remove defined but not used 'dB_Invert_Table'

Fix the following gcc warning:

drivers/staging/rtl8723bs/hal/odm.c:10:18: warning: ‘dB_Invert_Table’
defined but not used [-Wunused-const-variable=]
 static const u16 dB_Invert_Table[8][12] = {
                  ^~~~~~~~~~~~~~~

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Link: https://lore.kernel.org/r/20200417073439.41888-1-yanaijie@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: rtl8723bs: remove some variables in hal_btcoex.c
Jason Yan [Fri, 17 Apr 2020 07:33:10 +0000 (15:33 +0800)]
staging: rtl8723bs: remove some variables in hal_btcoex.c

Fix the following gcc warning:

drivers/staging/rtl8723bs/hal/hal_btcoex.c:45:26: warning: ‘ioStaString’
defined but not used [-Wunused-const-variable=]
 static const char *const ioStaString[] = {
                          ^~~~~~~~~~~
drivers/staging/rtl8723bs/hal/hal_btcoex.c:38:26: warning:
‘h2cStaString’ defined but not used [-Wunused-const-variable=]
 static const char *const h2cStaString[] = {
                          ^~~~~~~~~~~~
drivers/staging/rtl8723bs/hal/hal_btcoex.c:33:26: warning:
‘BtLinkRoleString’ defined but not used [-Wunused-const-variable=]
 static const char *const BtLinkRoleString[] = {
                          ^~~~~~~~~~~~~~~~
drivers/staging/rtl8723bs/hal/hal_btcoex.c:23:26: warning:
‘BtSpecString’ defined but not used [-Wunused-const-variable=]
 static const char *const BtSpecString[] = {
                          ^~~~~~~~~~~~
drivers/staging/rtl8723bs/hal/hal_btcoex.c:15:26: warning:
‘BtProfileString’ defined but not used [-Wunused-const-variable=]
 static const char *const BtProfileString[] = {
                          ^~~~~~~~~~~~~~~

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
Link: https://lore.kernel.org/r/20200417073310.40893-1-yanaijie@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: drop unused attribute 'join_complete_status'
Jérôme Pouiller [Mon, 20 Apr 2020 16:03:11 +0000 (18:03 +0200)]
staging: wfx: drop unused attribute 'join_complete_status'

The field join_complete_status is never read. Drop it.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-17-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: drop unused enum wfx_state
Jérôme Pouiller [Mon, 20 Apr 2020 16:03:10 +0000 (18:03 +0200)]
staging: wfx: drop unused enum wfx_state

In former code, the field wvif->state was more or less redundant with
vif->type. With the lasts change it has become unused. It is now time to
drop it.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-16-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: simplify wfx_remove_interface()
Jérôme Pouiller [Mon, 20 Apr 2020 16:03:09 +0000 (18:03 +0200)]
staging: wfx: simplify wfx_remove_interface()

In wfx_remove_interface(), the current code differentiate AP and Station
cases. However, it is not necessary. In all cases, the only important
thing is the call to hif_reset(). We can use the same code to support
all cases.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-15-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: drop useless checks in wfx_do_unjoin()
Jérôme Pouiller [Mon, 20 Apr 2020 16:03:08 +0000 (18:03 +0200)]
staging: wfx: drop useless checks in wfx_do_unjoin()

The callers of wfx_do_unjoin() already take care of vif state.
Therefore, it is not necessary to take care of the status of the
interface.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-14-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: drop protection for asynchronous join during scan
Jérôme Pouiller [Mon, 20 Apr 2020 16:03:07 +0000 (18:03 +0200)]
staging: wfx: drop protection for asynchronous join during scan

In former code (before the inclusion of the driver in mainline kernel),
hif_join() could run asynchronously. When a join request was in
progress, it was forbidden to launch hif_scan().

Now, hif_join() is always run synchronously. There is no more reasons to
keep a protection against this case.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-13-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: keys are kept during whole firmware life
Jérôme Pouiller [Mon, 20 Apr 2020 16:03:06 +0000 (18:03 +0200)]
staging: wfx: keys are kept during whole firmware life

Keys sent to the firmware are never reset. So, it is not necessary to
re-upload them after hif_reset(). Thus, it is no more necessary to keep
a copy of the keys in struct wfx_dev.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-12-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: introduce wfx_set_default_unicast_key()
Jérôme Pouiller [Mon, 20 Apr 2020 16:03:05 +0000 (18:03 +0200)]
staging: wfx: introduce wfx_set_default_unicast_key()

Currently code handle WEP keys manually. It is far easier to use
the set_default_unicast_key() callback provided by mac80211.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-11-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: drop useless update of field basic_rate_set
Jérôme Pouiller [Mon, 20 Apr 2020 16:03:04 +0000 (18:03 +0200)]
staging: wfx: drop useless update of field basic_rate_set

Basic Rates are already set by hif_join(). hif_join() is also able to
manage possible changes after association.

Firmware also allows to change the Basic Rates with
hif_set_association_mode() but it does not bring anything in our case.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-10-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: simplify hif_set_bss_params()
Jérôme Pouiller [Mon, 20 Apr 2020 16:03:03 +0000 (18:03 +0200)]
staging: wfx: simplify hif_set_bss_params()

The structure hif_req_set_bss_params come from hardware API. It is not
intended to be manipulated in upper layers of the driver.

In add, current code for hif_req_set_bss_params() is too dumb. It should
pack data with hardware representation instead of leaving all work to
the caller.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-9-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: field operational_rate_set is ignored by firmware
Jérôme Pouiller [Mon, 20 Apr 2020 16:03:02 +0000 (18:03 +0200)]
staging: wfx: field operational_rate_set is ignored by firmware

The field bss_params.operational_rate_set is ignore by the firmware. It
is not necessary to send it. This change greatly simplify
wfx_join_finalize(). It is no more necessary to get sta and it allow to
save a RCU.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-8-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: dual CTS is never necessary
Jérôme Pouiller [Mon, 20 Apr 2020 16:03:01 +0000 (18:03 +0200)]
staging: wfx: dual CTS is never necessary

Dual CTS is only necessary when sending/receiving STBC data. However,
the chip does not support STBC, so it is never necessary to enable
double CTS.

We can simplify the code.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-7-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: also fix network parameters for IBSS networks
Jérôme Pouiller [Mon, 20 Apr 2020 16:03:00 +0000 (18:03 +0200)]
staging: wfx: also fix network parameters for IBSS networks

Current code skip some configuration during joining an IBSS network.
Indeed, it seems that this configuration is not used in IBSS. However,
it would be harmless to set them. In add, we would prefer to keep
association processes for ad-hoc and managed networks the closest as
possible. It also ensures the values of internal parameters of the
firmware.

Therefore, apply them unconditionally.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-6-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: handle firmware events synchronously
Jérôme Pouiller [Mon, 20 Apr 2020 16:02:59 +0000 (18:02 +0200)]
staging: wfx: handle firmware events synchronously

Currently, events from firmware are handled in a work queue with a
complex event queue mechanism. It is probably overkill since there is
only two events to handle: bss_loss and CQM events. Handling these
events synchronously is sufficient.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-5-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: drop useless attribute 'bss_params'
Jérôme Pouiller [Mon, 20 Apr 2020 16:02:58 +0000 (18:02 +0200)]
staging: wfx: drop useless attribute 'bss_params'

Since wfx_bss_params_work() does not exist anymore, there is no more
reason to keep a copy of bss_params in struct wfx_dev. A local instance
in wfx_join_finalize() is sufficient.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-4-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: use ieee80211_beacon_loss() provided by mac80211
Jérôme Pouiller [Mon, 20 Apr 2020 16:02:57 +0000 (18:02 +0200)]
staging: wfx: use ieee80211_beacon_loss() provided by mac80211

The firmware is able to filter beacons and send a notification if one or
multiple beacons are not received. Note that it send this notification
only once. Only if it receive beacons gain, it send a new notification.

Currently, the driver handle the connection loss itself (see
wfx_cqm_bssloss_sm()). It send null frames and watch the answers.

This patch fixes all this mess:
  - settle firmware to send a notification on the first beacon loss
  - call ieee80211_beacon_loss() and let mac80211 handle all the process
  - since we do have notification for each beacon loss, add a period
    task that call ieee80211_beacon_loss() until we receive "REGAIN"
    notification.

Thus, we can drop the ugly wfx_cqm_bssloss_sm() and
wfx_bss_params_work().

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-3-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agostaging: wfx: simplify the check if the the device is associated
Jérôme Pouiller [Mon, 20 Apr 2020 16:02:56 +0000 (18:02 +0200)]
staging: wfx: simplify the check if the the device is associated

Firmware dislikes the driver enables PS when it is not yet associated.
The current check for that condition is more complex than necessary.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20200420160311.57323-2-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 years agoMerge tag 'iio-for-5.8a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio...
Greg Kroah-Hartman [Thu, 23 Apr 2020 09:06:48 +0000 (11:06 +0200)]
Merge tag 'iio-for-5.8a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

First set of new IIO device support, features and cleanup for the 5.8 cycle

Usual mix of new drivers, new support in old drivers and lots of minor
cleanup. Yaml conversions also continue to trickle in (plenty more to go!)

New device support
* ad7476
  - Add ad7091 support (ID only)
* ad9467
  - New driver for this 200/250 MSPS adi-axi-adc and SPI attached ADC.
* adi-axi-adc
  - New driver to support ADIs generic AXI ADC IP core, used to provide
    high speed interfaces to ADCs (JESD204B/C or parallel interfaces). Usually
    paired with a device using a slow configuration interface (spi etc)
    Includes DT bindings and some fixes for fpga headers.
* bmg160
  - Add support for BMI088 (ID only)
* max1241
  - New driver for this ADC.
* st_sensors
  - Add support for LIS2HH12 accelerometer
* sx9310
  - New driver supporting sx9310 and sx9311 proximity sensors.

Yaml DT binding conversions
* rockchip-saradc (including adding some missing parts)
* stm32-dac
* tsl2563
* vcnl4000

Features
* st_lsm6dsx
  - Add LIS3MDL as a possible sensor hub device.
* vcnl4000
  - Add new concept of near level (from DT) to provide to userspace which
    often needs to have some calibrated concept of 'near'.

Cleanups, minor fixes etc.
* core
  - Use snprintf for functions where strings are built and there is
    potential for overflow.
  - Correct docs to indicate mlock should not be used directly by drivers.
  - Fix up accidental dropping of a patch to use bitmap_zalloc.
  - Stop allowing enabling of buffers with no channels enabled.
  - Drop unused 'stufftoread' from iio_buffer.
  - Drop scan_el_attrs form iio_buffer as unused.
  - Reorder sanity checks in __iio_device_register to fail earlier.
  - Drop all the devm_ runregister / free functions from IIO as they
    were never used and encourage poor design.
* dma-buffer
  - Tidy up includes.
* dma-engine-buffer
  - Provide dev-managed allocator.
  - Fix an issue with printing a size_t
* cross subsystem (kxsd9, bmg160, mpu3050, bmi160, mpu6050, bmc150)
  - Replace some unnecessary casts of error ptrs and whilst there.
    use the %pe printf parameter to print them in a more useful fashion.
* cross subsystem
  - Drop casts in calls to regmap_bulk_read as they make no sense.
  - Use devm_platform_ioremap_resource to reduce boilerplate.
  - Fix typos in Analog Devices.
* counters/104-quad
  - Add Syed Nayyar Waris as an additional maintainer.
* ad7476
  - Generate CONVST signal internally rather than requiring external
    trigger.  Add sysfs read back as can now do so.
  - use devm_add_action_or_reset to tidy up error and remove handling.
* ad7793
  - Switch to read_avail from explicit attribute. Mostly done to avoid
    confusing people with a - sign (without surounding spaces) that
    was correct but checkpatch didn't like.
* adis library
  - Add missing newlines at end of error messages.
* adis16400
  - Use DEFINE_DEBUGS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTR.
* adis16460
  - Use DEFINE_DEBUGS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTR.
* ad_sigma_delta
  - Move some channel definitions into individual drivers to avoid
    having to deal with complex options.
* ak8974
  - Silence an error on deffered probe.
* bmp280
  - Harden against IRQ before registration.
  - Convert to read_avail instead of opencoding the equivalent.
  - Explicitly mark GPIO as optional.
  - Cleanup casts.
  - Remove line breaks from strings.
* htts221
  - Replace direct access to platform_data with dev_get_platdata().
  - Use device properties rather than device tree ones to allow ACPI
    probing.
  - Casting cleanups.
* intel_mrfld_adc
  - Don't use unaligned accessor for aligned data.
* isl29125
  - Reorder buer pre and post hooks to allow for coming core rework.
* ltc2983
  - Remove comp to bool.
* max1363
  - Stop using mlock from the iio_dev directly in favour of a local lock
    with clearly defined scope.
* max30100
  - Use generic device properties to allow ACPI probe.
* mpu6050
  - Convert to i2c_new_client_device.
  - Add debugfs register access.
* st_lsm6dsx
  - Provide means of configuring full scale on slave device if supported.
  - Drop include of st_sensors header to get one value. Its not otherwise
    used by this driver.
* st-sensors
  - Replace direct access to platform_data with dev_get_platdata().
  - Casting cleanups.
  - Avoid splitting strings.
* st_uvis25
  - Casting cleanups.
* tsl2563
  - Typo fix.
* tsl2772
  - scnprintf in a non obvious string building usecase. Note also 'fixes'
    a wrong calculation of remaining space that couldn't actually cause
    any trouble as there was lots of room.
* xilinx-xadc
  - Fix Lars-Peter spelling his own name wrong :) + additional typos.

* tag 'iio-for-5.8a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (101 commits)
  iio: magnetometer: ak8974: Silence deferred-probe error
  Documentation: ABI: document IIO in_proximity_nearlevel file
  iio: vcnl4000: Export near level property for proximity sensor
  dt-bindings: iio: light: vcnl4000: Add proximity-near-level
  dt-bindings: iio: Introduce common properties for iio sensors
  dt-bindings: iio: vcnl4000: convert bindings to YAML format
  iio: Fix misspellings of "Analog Devices"
  iio: light: isl29125: fix iio_triggered_buffer_{predisable,postenable} positions
  iio: adc: fsl-imx25-gcq: Use devm_platform_ioremap_resource
  iio: adc: at91-adc: Use devm_platform_ioremap_resource
  iio: adc: sun4i-gpadc-iio: Use devm_platform_ioremap_resource
  iio:light:ltr501: Drop unnecessary cast of parameter in regmap_bulk_read
  iio:magn:mmc35240: Drop unnecessary casts of val parameter in regmap_bulk*
  iio:imu:mpu6050: Tidy up parameters to regmap_bulk functions.
  iio:chemical:bme680: Tidy up parameters to regmap_bulk_read
  iio:chemical:atlas-sensor: Drop unnecessary explicit casts in regmap_bulk_read calls
  iio:accel:mxc4005: Drop unnecessary explicit casts in regmap_bulk_read calls
  iio: imu: st_lsm6dsx: drop huge include in sensor-hub driver
  iio: buffer: drop devm_iio_kfifo_free() API call
  iio: buffer: drop devm_iio_hw_consumer_free() API call
  ...

4 years agoiio: magnetometer: ak8974: Silence deferred-probe error
Dmitry Osipenko [Sat, 18 Apr 2020 17:12:44 +0000 (20:12 +0300)]
iio: magnetometer: ak8974: Silence deferred-probe error

It's not uncommon that voltage regulator becomes available later during
kernel's boot process. This patch adds info message about unavailable
regulators in a case of the deferred-probe error and also amends the
error message with a error code.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoDocumentation: ABI: document IIO in_proximity_nearlevel file
Guido Günther [Sun, 5 Apr 2020 13:50:32 +0000 (15:50 +0200)]
Documentation: ABI: document IIO in_proximity_nearlevel file

The vcnl4000 IIO driver introduced a new attribute
"in_proximity_nearlevel".  This adds it to the list of documented ABI
for sysfs-bus-iio.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: vcnl4000: Export near level property for proximity sensor
Guido Günther [Sun, 5 Apr 2020 13:50:31 +0000 (15:50 +0200)]
iio: vcnl4000: Export near level property for proximity sensor

When an object can be considered close to the sensor is hardware
dependent. Allowing to configure the property via device tree
allows to configure this device specific value.

This is useful for e.g. iio-sensor-proxy to indicate to userspace
if an object is close to the sensor.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: light: vcnl4000: Add proximity-near-level
Guido Günther [Sun, 5 Apr 2020 13:50:30 +0000 (15:50 +0200)]
dt-bindings: iio: light: vcnl4000: Add proximity-near-level

This value indicates when userspace should consider an object
near to the sensor/device.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: Introduce common properties for iio sensors
Guido Günther [Sun, 5 Apr 2020 13:50:29 +0000 (15:50 +0200)]
dt-bindings: iio: Introduce common properties for iio sensors

Introduce a file for common properties of iio sensors. So far this
contains the new proximity-near-level property for proximity sensors
that indicates when an object should be considered near.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agodt-bindings: iio: vcnl4000: convert bindings to YAML format
Guido Günther [Sun, 5 Apr 2020 13:50:28 +0000 (15:50 +0200)]
dt-bindings: iio: vcnl4000: convert bindings to YAML format

Convert the vcnl4000 device tree bindings to the new YAML format.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: Fix misspellings of "Analog Devices"
Geert Uytterhoeven [Thu, 16 Apr 2020 10:30:56 +0000 (12:30 +0200)]
iio: Fix misspellings of "Analog Devices"

According to https://www.analog.com/, the company name is spelled
"Analog Devices".

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: light: isl29125: fix iio_triggered_buffer_{predisable,postenable} positions
Alexandru Ardelean [Wed, 4 Mar 2020 08:24:25 +0000 (10:24 +0200)]
iio: light: isl29125: fix iio_triggered_buffer_{predisable,postenable} positions

The iio_triggered_buffer_{predisable,postenable} functions attach/detach
the poll functions.

For the predisable hook, the disable code should occur before detaching
the poll func, and for the postenable hook, the poll func should be
attached before the enable code.

This change reworks the predisable/postenable hooks so that the pollfunc is
attached/detached in the correct position.
It also balances the calls a bit, by grouping the preenable and the
iio_triggered_buffer_postenable() into a single
isl29125_buffer_postenable() function.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adc: fsl-imx25-gcq: Use devm_platform_ioremap_resource
Aishwarya Ramakrishnan [Sun, 12 Apr 2020 13:50:20 +0000 (19:20 +0530)]
iio: adc: fsl-imx25-gcq: Use devm_platform_ioremap_resource

Use the helper function that wraps the calls to
platform_get_resource() and devm_ioremap_resource()
together. It reduces boilerplate and suggested by coccinelle.

Signed-off-by: Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adc: at91-adc: Use devm_platform_ioremap_resource
Aishwarya Ramakrishnan [Sun, 12 Apr 2020 13:56:42 +0000 (19:26 +0530)]
iio: adc: at91-adc: Use devm_platform_ioremap_resource

Use the helper function that wraps the calls to
platform_get_resource() and devm_ioremap_resource()
together. It reduces boilerplate and suggested by coccinelle.

Signed-off-by: Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: adc: sun4i-gpadc-iio: Use devm_platform_ioremap_resource
Aishwarya Ramakrishnan [Sun, 12 Apr 2020 14:32:18 +0000 (20:02 +0530)]
iio: adc: sun4i-gpadc-iio: Use devm_platform_ioremap_resource

Use the helper function that wraps the calls to platform_get_resource()
and devm_ioremap_resource() together.  Reduces boilerplate and suggested
by coccinelle.

Signed-off-by: Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio:light:ltr501: Drop unnecessary cast of parameter in regmap_bulk_read
Jonathan Cameron [Sun, 5 Apr 2020 18:03:21 +0000 (19:03 +0100)]
iio:light:ltr501: Drop unnecessary cast of parameter in regmap_bulk_read

This only occurs once in the driver and isn't needed in this case either,
so drop it.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
4 years agoiio:magn:mmc35240: Drop unnecessary casts of val parameter in regmap_bulk*
Jonathan Cameron [Sun, 5 Apr 2020 18:03:20 +0000 (19:03 +0100)]
iio:magn:mmc35240: Drop unnecessary casts of val parameter in regmap_bulk*

Given the parameter is void *, casting to u8 * is unnecessary.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
4 years agoiio:imu:mpu6050: Tidy up parameters to regmap_bulk functions.
Jonathan Cameron [Sun, 5 Apr 2020 18:03:19 +0000 (19:03 +0100)]
iio:imu:mpu6050: Tidy up parameters to regmap_bulk functions.

A mixture of:
* Casts to u8 * for the val parameter which is void * and so needs no cast.
* Explicit sizes when we can use sizeof on the destination / source variable.

Not broken in anyway, I'm just trying to tidy up the is in the subsystem to
avoid it getting cut and paste into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
4 years agoiio:chemical:bme680: Tidy up parameters to regmap_bulk_read
Jonathan Cameron [Sun, 5 Apr 2020 18:03:18 +0000 (19:03 +0100)]
iio:chemical:bme680: Tidy up parameters to regmap_bulk_read

A mixture of:
* Unnecessary casts of val parameter to u8 * which makes little sense as
  the function take a void *.
* Explicit sizes where we can use the destination type to define that.
  Note that's not true in all cases as we do read 3 bytes into 4 byte
  destinations.

Note that noting was broken here, I'm just trying to ensure this doesn't
get cut and paste into more drivers so cleaning these out subsystem wide.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Himanshu Jha <himanshujha199640@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
4 years agoiio:chemical:atlas-sensor: Drop unnecessary explicit casts in regmap_bulk_read calls
Jonathan Cameron [Sun, 5 Apr 2020 18:03:17 +0000 (19:03 +0100)]
iio:chemical:atlas-sensor: Drop unnecessary explicit casts in regmap_bulk_read calls

regmap_bulk_read takes a void * for its val parameter. It certainly
makes no sense to cast to a (u8 *) + no need to explicitly cast
at all when converting another pointer type to void *.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
4 years agoiio:accel:mxc4005: Drop unnecessary explicit casts in regmap_bulk_read calls
Jonathan Cameron [Sun, 5 Apr 2020 18:03:16 +0000 (19:03 +0100)]
iio:accel:mxc4005: Drop unnecessary explicit casts in regmap_bulk_read calls

regmap_bulk_read takes a void * for its val parameter. It certainly
makes no sense to cast to a (u8 *) + no need to explicitly cast
at all when converting another pointer type to void *.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
4 years agoiio: imu: st_lsm6dsx: drop huge include in sensor-hub driver
Lorenzo Bianconi [Mon, 6 Apr 2020 19:00:25 +0000 (21:00 +0200)]
iio: imu: st_lsm6dsx: drop huge include in sensor-hub driver

st_lsm6dsx is a standalone driver for STM IMU sensors and does not rely
on st_sensor common framework, so it does not include st_sensor common
definitions.
In st_lsm6dsx_shub driver st_sensors.h is used just to introduce the
default wai address for LIS3MDL sensor.
Drop this largely unconnected include file and introduce the default wai
address for LIS3MDL in st_lsm6dsx_ext_dev_settings register map

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: buffer: drop devm_iio_kfifo_free() API call
Alexandru Ardelean [Thu, 27 Feb 2020 13:52:27 +0000 (15:52 +0200)]
iio: buffer: drop devm_iio_kfifo_free() API call

It's unused so far, so it can be removed. Also makes sense to remove it
to discourage weird uses of this call during review.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: buffer: drop devm_iio_hw_consumer_free() API call
Alexandru Ardelean [Thu, 27 Feb 2020 13:52:26 +0000 (15:52 +0200)]
iio: buffer: drop devm_iio_hw_consumer_free() API call

It's unused so far, so it can be removed. Also makes sense to remove it
to discourage weird uses of this call during review.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: inkern: drop devm_iio_channel_release{_all} API calls
Alexandru Ardelean [Thu, 27 Feb 2020 13:52:25 +0000 (15:52 +0200)]
iio: inkern: drop devm_iio_channel_release{_all} API calls

It's unused so far, so it can be removed. Also makes sense to remove it
to discourage weird uses of this call during review.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: core: drop devm_iio_trigger_free() API call
Alexandru Ardelean [Thu, 27 Feb 2020 13:52:24 +0000 (15:52 +0200)]
iio: core: drop devm_iio_trigger_free() API call

It's unused so far, so it can be removed. Also makes sense to remove it
to discourage weird uses of this call during review.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
4 years agoiio: core: drop devm_iio_trigger_unregister() API call
Alexandru Ardelean [Thu, 27 Feb 2020 13:52:23 +0000 (15:52 +0200)]
iio: core: drop devm_iio_trigger_unregister() API call

It's unused so far, so it can be removed. Also makes sense to remove it
to discourage weird uses of this call during review.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>