Some ACPI systems list 2 I2C resources for the CM3218 sensor. On these
systems the first I2cSerialBus ACPI-resource points to the SMBus Alert
Response Address (ARA, 0x0c) and the second I2cSerialBus ACPI-resource
points to the actual CM3218 sensor address:
Detect this and take the following step to deal with it:
1. When a SMBus Alert capable sensor has an Alert asserted, it will
not respond on its actual I2C address. Read a byte from the ARA
to clear any pending Alerts.
2. Create a "dummy" client for the actual I2C address and
use that client to communicate with the sensor.
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Hans de Goede [Tue, 28 Apr 2020 17:29:17 +0000 (19:29 +0200)]
iio: light: cm32181: Clean up the probe function a bit
3 small cleanups to cm32181_probe():
1. Do not log an error when we fail to allocate memory (as a general
rule drivers do not log errors for this as the kernel will already
have complained loudly that it could not alloc the mem).
2. Remove the i2c_set_clientdata() call, we never use i2c_get_clientdata()
or dev_get_drvdata() anywhere.
3. Add a dev helper variable and use it in various places instead of
&client->dev.
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Hans de Goede [Tue, 28 Apr 2020 17:29:16 +0000 (19:29 +0200)]
iio: light: cm32181: Add support for the CM3218
Add support for the CM3218 which is an older version of the
CM32181.
This is based on a newer version of cm32181.c, with a copyright of:
* Copyright (C) 2014 Capella Microsystems Inc.
* Author: Kevin Tsai <ktsai@capellamicro.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2, as published
* by the Free Software Foundation.
Which is floating around on the net in various places, but the changes
from this newer version never made it upstream.
This was tested on an Asus T100TA and an Asus T100CHI, which both come
with the CM3218 variant of the light sensor.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Hans de Goede [Tue, 28 Apr 2020 17:29:15 +0000 (19:29 +0200)]
iio: light: cm32181: Add some extra register defines
These come from a newer version of cm32181.c, which is floating around
the net, with a copyright of:
* Copyright (C) 2014 Capella Microsystems Inc.
* Author: Kevin Tsai <ktsai@capellamicro.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2, as published
* by the Free Software Foundation.
Note that this removes the bogus CM32181_CMD_ALS_ENABLE define, there
is no enable bit, only a disable bit and enabled is the absence of
being disabled.
This is a preparation patch for adding support for the older
CM3218 model of the light sensor.
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Hans de Goede [Tue, 28 Apr 2020 17:29:13 +0000 (19:29 +0200)]
iio: light: cm32181: Switch to new style i2c-driver probe function
Switch to the new style i2c-driver probe_new probe function and drop the
unnecessary i2c_device_id table (we do not have any old style board files
using this).
This is a preparation patch for adding ACPI binding support.
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
iio: hid-sensors: move triggered buffer setup into hid_sensor_setup_trigger
The main intent here is to get rid of the iio_buffer_set_attrs() helper, or
at least rework it's usage a bit.
The problem with that helper is that it needs a pointer to the buffer,
which makes supporting multiple buffers per IIO device a bit more
cumbersome.
The hid_sensor_setup_trigger() is pretty much used in the same way:
- iio_triggered_buffer_setup() gets called before
- then hid_sensor_setup_trigger() and hid_sensor_setup_batch_mode() gets
called which may attach some fifo attributes
This change merges the 2 together under the hid_sensor_setup_trigger()
function. Only the &iio_pollfunc_store_time is passed to all devices, so
it's not even required to pass it explicitly outside of the common
hid_sensor_setup_trigger() function.
Moving the devm_iio_triggered_buffer_setup/cleanup() calls into the common
place code can help the rework of the buffer code, since it is in one
place.
One detail of the change is that there are 2 drivers that use
devm_iio_triggered_buffer_setup(). That function gets implicitly
replaced with iio_triggered_buffer_setup()/cleanup(), but since all drivers
call both hid_sensor_setup_trigger9) & hid_sensor_remove_trigger() trigger,
the iio_triggered_buffer_cleanup() piggy backs on the
hid_sensor_remove_trigger() call, which should cover the cleanup.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
iio: vcnl4000: Add buffer support for VCNL4010/20.
The VCNL4010 and VCNL4020 chips are able to raise interrupts on data ready.
Use it to provide triggered buffer support for proximity data.
Those two chips also provide ambient light data. However, they are sampled
at different rate than proximity data. As this is not handled by the IIO
framework for now, and the sample frequencies of ambient light data are
very low, do add buffer support for them.
Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The VCNL4010 and VCNL4020 chips are able to raise interrupts on proximity
threshold events. Add support for threshold rising and falling events for
those two chips.
Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
iio: imu: adis16xxx: use helper to access iio core debugfs dir
The IIO core provides a iio_get_debugfs_dentry() helper.
It seems that the ADIS IMU drivers access that field directly.
This change converts them to use iio_get_debugfs_dentry() instead.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Acked-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Chris Ruehl [Mon, 20 Apr 2020 04:26:07 +0000 (12:26 +0800)]
iio: DAC extension for ltc2634-12/10/8
This patch add support for Analog Devices (Linear Technology)
LTC2634 Quad 12-/10-/8-Bit Rail-to-Rail DAC.
The SPI functionality based on them from LTC2632 therefor
add the definitions only and update the Kconfig.
Signed-off-by: Chris Ruehl <chris.ruehl@gtsys.com.hk> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The manual for the HSCDTD008A gives us a scaling for the
three axis as +/- 2.4mT (24 Gauss) per axis.
The manual for the AMI305 and AMI306 gives us a scaling
for the three axis as +/- 12 Gauss per axis.
Tests with the HSCDTD008A sensor, cat the raw values:
$ cat in_magn_*_raw
raw
45
189
-19
The scaling factor in in_magn_*_scale is 0.001464843,
which gives:
0.065 Gauss
0.277 Gauss
-0.027 Gauss
The earths magnetic field is in the range of 0.25 to 0.65
Gauss on the surface according to Wikipedia, so these
seem like reasonable values.
Again we are guessing that the AK8974 has a 12 bit ADC,
based on the similarity with AMI305 and AMI306.
Cc: Nick Reitemeyer <nick.reitemeyer@web.de> Cc: Stephan Gerhold <stephan@gerhold.net> Cc: Michał Mirosław <mirq-linux@rere.qmqm.pl> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This breaks out the measurement code to its own function
so we can handle this without swirling it up with the
big switch() statement inside ak8974_read_raw().
Keep a local s16 helper variable for the signed value
coming out of the measurement before assigning it to the
integer *val. The local variable makes the code easier
to read and the compiler will optimize it if possible.
Cc: Nick Reitemeyer <nick.reitemeyer@web.de> Cc: Stephan Gerhold <stephan@gerhold.net> Reviewed-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The HSCDTD008A has 15 bits of actual ADC valie, and the
AMI305 and AMI306 has 12 bits.
Correct this by providing an extra parameter to the channel
macro and define a separate set of channels for each variant
of the chip. The resolution is the actual resolution of the
internal ADC of the chip.
The values are stored in a S16 in 2's complement so all 16
bits are used for storing (no shifting needed).
The AMI305, AMI306 and HSCDTD008A valid bits are picked from
respective datasheet.
My best educated guess is that AK8974 is also 12 bits. The
AK8973 is an 8 bit and earlier version, and the sibling
drivers AMI305 and AMI306 are 12 bits, so it makes sense
to assume that the AK8974 is also 12 bits.
Cc: Nick Reitemeyer <nick.reitemeyer@web.de> Cc: Stephan Gerhold <stephan@gerhold.net> Cc: Michał Mirosław <mirq-linux@rere.qmqm.pl> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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".
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.
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.
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.
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.
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]
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] = {
^~~~~~~~~~~~~~~
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[] = {
^~~~~~~~~~~~~~~
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.
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.
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.
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.
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.
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.
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.
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.
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.
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().
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.
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
...
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>
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>