platform/kernel/linux-rpi.git
6 years agoiio: sca3000: Fix missing return in switch
Gustavo A. R. Silva [Sat, 7 Jul 2018 17:44:01 +0000 (12:44 -0500)]
iio: sca3000: Fix missing return in switch

The IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY case is missing a
return and will fall through to the default case and errorenously
return -EINVAL.

Fix this by adding in missing *return ret*.

Fixes: 626f971b5b07 ("staging:iio:accel:sca3000 Add write support to the low pass filter control")
Reported-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: ad9523: Fix displayed phase
Lars-Peter Clausen [Mon, 25 Jun 2018 08:03:07 +0000 (11:03 +0300)]
iio: ad9523: Fix displayed phase

Fix the displayed phase for the ad9523 driver. Currently the most
significant decimal place is dropped and all other digits are shifted one
to the left. This is due to a multiplication by 10, which is not necessary,
so remove it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Fixes: cd1678f9632 ("iio: frequency: New driver for AD9523 SPI Low Jitter Clock Generator")
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: adc: meson-saradc: add support for the Meson8m2 SoCs
Martin Blumenstingl [Sat, 21 Jul 2018 19:40:49 +0000 (21:40 +0200)]
iio: adc: meson-saradc: add support for the Meson8m2 SoCs

The SAR ADC on Meson8m2 behaves identical to the one found in the
Meson8b SoCs. Add a separate compatible string because the temperature
sensor logic (not supported yet) differs between Meson8 and Meson8m2
(however, it's the same for Meson8b and Meson8m2).

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agodt-bindings: iio: adc: add Meson8m2 support
Martin Blumenstingl [Sat, 21 Jul 2018 19:40:48 +0000 (21:40 +0200)]
dt-bindings: iio: adc: add Meson8m2 support

The Amlogic Meson SAR ADC implementation on the Meson8m2 SoC is
identical to the Meson8b variant. Add a compatible string to indicate
that we support the SAR ADC on the Meson8m2 SoC.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: adc: ti-ads7950: allow simultaneous use of buffer and direct mode
David Lechner [Sat, 21 Jul 2018 19:37:34 +0000 (14:37 -0500)]
iio: adc: ti-ads7950: allow simultaneous use of buffer and direct mode

This modifies the TI ADS7950 A/DC driver to allow the simultaneous use
of both the triggered buffer and reading channels directly (via in-
kernel API or sysfs).

The use case for this is on LEGO MINDSTORMS EV3. Two of the voltage
channels are used in-kernel by a power supply driver, which reads the
values using iio_read_channel_processed(). These channels are only read
at a slow rate (<= 1Hz).  However, we want to be able to read 12 other
channels at the same time using the triggered buffer at a high rate (>=
100Hz).

Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: adc: ti-ads7950: use SPDX-License-Identifier
David Lechner [Sat, 21 Jul 2018 19:37:33 +0000 (14:37 -0500)]
iio: adc: ti-ads7950: use SPDX-License-Identifier

This updates the ti-ads7950.c file to use SPDX-License-Identifier
instead of more verbose license text.

Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: adc: at91-sama5d2_adc: fix up casting in at91_adc_read_info_raw()
Dan Carpenter [Mon, 9 Jul 2018 11:06:59 +0000 (14:06 +0300)]
iio: adc: at91-sama5d2_adc: fix up casting in at91_adc_read_info_raw()

This code is problematic because we're supposed to be writing an int but
we instead write to only the high 16 bits.  This doesn't work on big
endian systems, and there is a potential that the bottom 16 bits are
used without being initialized.

Fixes: 23ec2774f1cc ("iio: adc: at91-sama5d2_adc: add support for position and pressure channels")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Tested-by: Eugen Hristev <eugen.hristev@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: ad9523: replace core mlock with local lock
Lars-Peter Clausen [Thu, 5 Jul 2018 12:34:22 +0000 (15:34 +0300)]
iio: ad9523: replace core mlock with local lock

This is also part of a long term effort to make the use of mlock opaque and
single purpose.

This lock is required for accessing device registers. The device may be
accessed by multiple processes at the same time, and this can result in
inconsistent data, where one device reads data before the other one has
finished writing.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: adc: xilinx: Remove dead code from xadc_zynq_setup
Manish Narani [Wed, 18 Jul 2018 11:12:09 +0000 (16:42 +0530)]
iio: adc: xilinx: Remove dead code from xadc_zynq_setup

This patch removes dead code from xadc_zynq_setup. The condition
"if (tck_rate > XADC_ZYNQ_TCK_RATE_MAX)" cannot be true at any point of
time. There is also an incompatible parameter used in the code.
This patch fixes the same reported by coverity.

Signed-off-by: Manish Narani <manish.narani@xilinx.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agodt-bindings: iio: sigma-delta-modulator: fix unit-address in example
Fabrice Gasnier [Thu, 19 Jul 2018 14:51:50 +0000 (16:51 +0200)]
dt-bindings: iio: sigma-delta-modulator: fix unit-address in example

Device tree compiler gives a warning if a device node has "@"
but no reg property.
Fix the example in iio: adc: sigma-delta-modulator.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: light: introduce si1133
Maxime Roussin-Bélanger [Thu, 19 Jul 2018 20:26:25 +0000 (16:26 -0400)]
iio: light: introduce si1133

e-mail received from Silicon Lab to confirm that the licensing
isn't a problem.

"
Dear Maxime Roussin-Belanger,

The LUX calculation code only works with Si1133.
As long as the software is used with Silicon Lab's sensor product,
I don't see any problem.

Regards,
Tony
"

Signed-off-by: Maxime Roussin-Bélanger <maxime.roussinbelanger@gmail.com>
Reviewed-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: Add modifier for DUV light
Maxime Roussin-Bélanger [Thu, 19 Jul 2018 20:26:24 +0000 (16:26 -0400)]
iio: Add modifier for DUV light

Signed-off-by: Maxime Roussin-Bélanger <maxime.roussinbelanger@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: light: isl29501: Add support for the ISL29501 ToF sensor.
Mathieu Othacehe [Fri, 20 Jul 2018 17:34:26 +0000 (19:34 +0200)]
iio: light: isl29501: Add support for the ISL29501 ToF sensor.

This patch adds support for the ISL29501 Time of Flight sensor.

Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: Add channel for Phase
Mathieu Othacehe [Fri, 20 Jul 2018 17:34:25 +0000 (19:34 +0200)]
iio: Add channel for Phase

Add new channel type support for phase.

This channel may be used by Time-of-flight sensors to express the
phase difference between emitted and received signals. Those sensor
will then use the phase shift of return signals to approximate the
distance to objects.

Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: change strncpy+truncation to strlcpy
Dominique Martinet [Fri, 13 Jul 2018 01:25:34 +0000 (03:25 +0200)]
iio: change strncpy+truncation to strlcpy

Generated by scripts/coccinelle/misc/strncpy_truncation.cocci

Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: adxl345: Add support for the ADXL375
Lars-Peter Clausen [Fri, 13 Jul 2018 11:50:44 +0000 (14:50 +0300)]
iio: adxl345: Add support for the ADXL375

The ADXL375 is fully register map compatible to the ADXL345 (including the
device ID register returning the same value ...).

The only difference is the resolution of the acceleration sensor. The
ADXL375 can measure up to +-200g of acceleration.

Datasheet:
http://www.analog.com/media/en/technical-documentation/data-sheets/ADXL375.PDF

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mircea Caprioru <mircea.caprioru@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: imu: st_lsm6dsx: add error logs to st_lsm6dsx_read_fifo()
Lorenzo Bianconi [Wed, 11 Jul 2018 22:15:12 +0000 (00:15 +0200)]
iio: imu: st_lsm6dsx: add error logs to st_lsm6dsx_read_fifo()

Add debug info to error conditions in st_lsm6dsx_read_fifo routine

Suggested-by: Jorge Ramirez-Ortiz <jramirez@baylibre.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: pressure: bmp280: remove unused options from device tree documentation
Brian Masney [Wed, 11 Jul 2018 01:33:45 +0000 (21:33 -0400)]
iio: pressure: bmp280: remove unused options from device tree documentation

There are several options in the device tree documentation that are
no longer relevant for the current in-kernel bmp280 driver so this patch
removes them.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: imu: mpu6050: add support for 6515 variant
Brian Masney [Wed, 11 Jul 2018 01:09:30 +0000 (21:09 -0400)]
iio: imu: mpu6050: add support for 6515 variant

This patch adds support for the MPU 6515 variant. Confirmed that the
driver functions correctly on a LG Nexus 5 (hammerhead) phone.

Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: hx711: fix spurious unit-address in example
Andreas Klinger [Tue, 10 Jul 2018 18:19:37 +0000 (20:19 +0200)]
iio: hx711: fix spurious unit-address in example

Device tree compiler (dtc) gives a warning if a device node has "@" with a
following number as it's name but no reg property.

Fix the example in the documentation of avia,hx711 to conform to dtc
behavior.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: hx711: add delay until DOUT is ready
Andreas Klinger [Tue, 10 Jul 2018 18:19:03 +0000 (20:19 +0200)]
iio: hx711: add delay until DOUT is ready

On a system with parasitic capacitance it turned out that DOUT is not ready
after 100 ns after PD_SCK has raised. A measurement showed almost 1000 ns
until DOUT has reached its correct value.

With this patch its now possible to wait until data is ready.

The wait time should not be higher than the maximum PD_SCK high time which
is corresponding to the datasheet 50000 ns.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: hx711: add clock-frequency property in DT
Andreas Klinger [Tue, 10 Jul 2018 18:18:31 +0000 (20:18 +0200)]
iio: hx711: add clock-frequency property in DT

Add clock-frequency property for hx711 ADC. This is the frequency of
PD_SCK.

After PD_SCK goes high DOUT is read just before PD_SCK goes down again.
This is necessary because of parasitic capacitance on the wiring.

Signed-off-by: Andreas Klinger <ak@it-klinger.de>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: accel: adxl345: add sampling frequency support
Akinobu Mita [Mon, 9 Jul 2018 15:10:08 +0000 (00:10 +0900)]
iio: accel: adxl345: add sampling frequency support

The ADXL345 provides selectable output data rate.  This adds the iio
channel information for the sampling frequency with that feature.

Cc: Eva Rachel Retuya <eraretuya@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: adc: max1363: merge calls to of_match_device and of_device_get_match_data
Julia Lawall [Mon, 21 May 2018 09:49:09 +0000 (11:49 +0200)]
iio: adc: max1363: merge calls to of_match_device and of_device_get_match_data

Drop call to of_match_device, which is subsumed by the subsequent
call to of_device_get_match_data.  The code becomes simpler, and a
temporary variable can be dropped.

The semantic match that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
local idexpression match;
identifier i;
expression x, dev, e, e1;
@@
-        match@i = of_match_device(x, dev);
-        if (match) e = of_device_get_match_data(dev);
-        else e = e1;
+        e = of_device_get_match_data(dev);
+        if (!e) e = e1;

@@
identifier r.i;
@@
- const struct of_device_id *i;
... when != i
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agodt-bindings: iio: dac: Add docs for AD5758 DAC
Stefan Popa [Wed, 4 Jul 2018 14:32:53 +0000 (17:32 +0300)]
dt-bindings: iio: dac: Add docs for AD5758 DAC

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: dac: Add AD5758 support
Stefan Popa [Wed, 4 Jul 2018 14:32:03 +0000 (17:32 +0300)]
iio: dac: Add AD5758 support

The AD5758 is a single channel DAC with 16-bit precision which uses the
SPI interface that operates at clock rates up to 50MHz.

The output can be configured as voltage or current and is available on a
single terminal.

Datasheet:
http://www.analog.com/media/en/technical-documentation/data-sheets/ad5758.pdf

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: mma8452: Mark expected switch fall-through
Gustavo A. R. Silva [Tue, 3 Jul 2018 19:44:36 +0000 (14:44 -0500)]
iio: mma8452: Mark expected switch fall-through

In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Warning level 2 was used in this case: -Wimplicit-fallthrough=2

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio:imu:adis: Mark expected switch fall-throughs
Gustavo A. R. Silva [Tue, 3 Jul 2018 19:35:50 +0000 (14:35 -0500)]
iio:imu:adis: Mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: dac: ltc2632 remove redundant pointer chip_info and spi_dev_id
Colin Ian King [Mon, 2 Jul 2018 10:13:59 +0000 (11:13 +0100)]
iio: dac: ltc2632 remove redundant pointer chip_info and spi_dev_id

Pointers chip_info and spi_dev_id are being assigned but are never used
hence they are redundant and can be removed.

Cleans up clang warning:
warning: variable 'chip_info' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: dac: ti-dac5571 remove redundant variable 'shift'
Colin Ian King [Mon, 2 Jul 2018 10:24:35 +0000 (11:24 +0100)]
iio: dac: ti-dac5571 remove redundant variable 'shift'

Variable shift is being assigned but is never used hence it is
redundant and can be removed.

Cleans up two clang warnings:
warning: variable ‘shift’ set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoIIO: st_accel_i2c.c: Use probe_new() instead of probe()
Nikolaus Voss [Tue, 3 Jul 2018 06:06:57 +0000 (08:06 +0200)]
IIO: st_accel_i2c.c: Use probe_new() instead of probe()

struct i2c_device_id argument of probe() is not used, so use probe_new()
instead.

Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoIIO: st_accel_i2c.c: Simplify access to driver data
Nikolaus Voss [Tue, 3 Jul 2018 05:41:00 +0000 (07:41 +0200)]
IIO: st_accel_i2c.c: Simplify access to driver data

Use device_get_match_data API to simplify access to driver data.
Let acpi_device_id table entries point to the same driver data as
of_device_id table entries and uniquify access to driver data by using
device_get_match_data API. Remove unused i2c_device_id .driver_data
fields.

Signed-off-by: Nikolaus Voss <nikolaus.voss@loewensteinmedical.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: adc: ina2xx: avoid kthread_stop() with stale task_struct
Akinobu Mita [Sun, 24 Jun 2018 15:05:21 +0000 (00:05 +0900)]
iio: adc: ina2xx: avoid kthread_stop() with stale task_struct

When the buffer is enabled for ina2xx driver, a dedicated kthread is
invoked to capture mesurement data.  When the buffer is disabled, the
kthread is stopped.

However if the kthread gets register access errors, it immediately exits
and when the malfunctional buffer is disabled, the stale task_struct
pointer is accessed as there is no kthread to be stopped.

A similar issue in the usbip driver is prevented by kthread_get_run and
kthread_stop_put helpers by increasing usage count of the task_struct.
This change applies the same solution.

Cc: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Fixes: c43a102e67db ("iio: ina2xx: add support for TI INA2xx Power Monitors")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: adc: Add Spreadtrum SC27XX PMICs ADC support
Freeman Liu [Thu, 21 Jun 2018 03:14:05 +0000 (11:14 +0800)]
iio: adc: Add Spreadtrum SC27XX PMICs ADC support

The Spreadtrum SC27XX PMICs ADC controller contains 32 channels,
which is used to sample voltages with 12 bits conversion.

[Baolin Wang did lots of improvements]

Signed-off-by: Freeman Liu <freeman.liu@spreadtrum.com>
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agodt-bindings: iio: Add Spreadtrum SC27XX PMICs ADC controller documentation
Baolin Wang [Thu, 21 Jun 2018 03:14:04 +0000 (11:14 +0800)]
dt-bindings: iio: Add Spreadtrum SC27XX PMICs ADC controller documentation

This patch adds the binding documentation for Spreadtrum SC27XX series
PMICs ADC controller device.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: accel: adxl345: add calibration offset support
Akinobu Mita [Mon, 25 Jun 2018 15:22:42 +0000 (00:22 +0900)]
iio: accel: adxl345: add calibration offset support

The ADXL345 provides the offset adjustment registers for each axis.
This adds the iio channel information for the calibraion offsets with
that feature.

Cc: Eva Rachel Retuya <eraretuya@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: accel: adxl345: convert address field usage in iio_chan_spec
Akinobu Mita [Mon, 25 Jun 2018 15:22:41 +0000 (00:22 +0900)]
iio: accel: adxl345: convert address field usage in iio_chan_spec

Currently the address field in iio_chan_spec is filled with an accel
data register address for the corresponding axis.

In preparation for adding calibration offset support, this sets the
address field to the index of accel data registers instead of the actual
register address.

This change makes it easier to access both accel registers and
calibration offset registers with fewer lines of code as these are
located in X-axis, Y-axis, Z-axis order.

Cc: Eva Rachel Retuya <eraretuya@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agoiio: accel: adxl345: add link to datasheet
Akinobu Mita [Mon, 25 Jun 2018 15:22:40 +0000 (00:22 +0900)]
iio: accel: adxl345: add link to datasheet

Add a link to the ADXL345 datasheet

Cc: Eva Rachel Retuya <eraretuya@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agostaging:iio:impedance-analyzer:ad5933: Macro replacement Cleanups.
Karim Eshapa [Mon, 25 Jun 2018 19:11:23 +0000 (21:11 +0200)]
staging:iio:impedance-analyzer:ad5933: Macro replacement Cleanups.

Doing some macro replacement to start an array of structures
so it can be reused by manipulating it with different values.

Signed-off-by: Karim Eshapa <karim.eshapa@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
6 years agostaging: rtl8188eu: remove whitespace - coding style
Michael Straube [Wed, 27 Jun 2018 18:47:32 +0000 (20:47 +0200)]
staging: rtl8188eu: remove whitespace - coding style

Remove unrequired whitespace in some declarations,
fix an indentation and remove unrequired blank lines.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: use mac_pton() in rtw_macaddr_cfg()
Michael Straube [Wed, 27 Jun 2018 17:36:49 +0000 (19:36 +0200)]
staging: rtl8723bs: use mac_pton() in rtw_macaddr_cfg()

Use the mac_pton() helper to convert the mac address string.

The functions key_char2num() and key_2char2num() are not used
anywhere else and can be removed.

This also has the benefit of validating the input since mac_pton()
returns false if the string is not valid.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: use ether_addr_copy() in rtw_macaddr_cfg()
Michael Straube [Wed, 27 Jun 2018 17:36:48 +0000 (19:36 +0200)]
staging: rtl8723bs: use ether_addr_copy() in rtw_macaddr_cfg()

Use ether_addr_copy() instead of memcpy() to copy the mac address.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: refactor rtw_macaddr_cfg()
Michael Straube [Wed, 27 Jun 2018 17:36:47 +0000 (19:36 +0200)]
staging: rtl8723bs: refactor rtw_macaddr_cfg()

Using is_broadcast_ether_addr() and is_zero_ether_addr() instead of
testing each byte of the mac[] array for 0xff and 0x00 shortens the
code and improves readability.

If np == NULL, of_get_property() returns NULL, hence the "np" check
is not needed.

Instead of a fixed default mac address use a random one to reduce the
likelihood of mac address collision.

Thanks to Joe Perches and Dan Carpenter.

Suggested-by: Joe Perches <joe@perches.com>
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: fix comparsion to NULL - coding style
Michael Straube [Wed, 27 Jun 2018 17:36:46 +0000 (19:36 +0200)]
staging: rtl8723bs: fix comparsion to NULL - coding style

Fix comparsion to NULL issues found by checkpatch.
Use !x instead of x == NULL.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: Convert random_ether_addr to eth_random_addr
Joe Perches [Sat, 23 Jun 2018 17:27:58 +0000 (10:27 -0700)]
staging: Convert random_ether_addr to eth_random_addr

random_ether_addr is a #define for eth_random_addr which is
generally preferred in kernel code by ~3:1

Convert the uses of random_ether_addr to enable removing the #define

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8188eu: remove blank lines
Michael Straube [Tue, 26 Jun 2018 15:38:56 +0000 (17:38 +0200)]
staging: rtl8188eu: remove blank lines

Remove unrequired blank lines after open and before close braces.
Reported by checkpatch.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wlan-ng: add parentheses to macro argument usage in prism2mgmt.c
Tim Collier [Fri, 22 Jun 2018 19:39:34 +0000 (20:39 +0100)]
staging: wlan-ng: add parentheses to macro argument usage in prism2mgmt.c

Fix two "CHECK: Macro argument 'N' may be better as '(N)' to avoid
precedence issue" messages, reported by checkpatch, by adding
parentheses around the offending macro argument references.

Signed-off-by: Tim Collier <osdevtc@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wlan-ng: replace macro with inline function in prism2mgmt.c
Tim Collier [Fri, 22 Jun 2018 19:39:33 +0000 (20:39 +0100)]
staging: wlan-ng: replace macro with inline function in prism2mgmt.c

checkpatch gives the following message for the p80211rate_to_p2bit
macro:

CHECK: Macro argument reuse 'n' - possible side-effects?

To fix the message, replace the macro with an equivalent inline
function.

Signed-off-by: Tim Collier <osdevtc@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wlan-ng: replace WLAN_CTL_FRAMELEN with inline function in p80211hdr.h
Tim Collier [Fri, 22 Jun 2018 19:39:32 +0000 (20:39 +0100)]
staging: wlan-ng: replace WLAN_CTL_FRAMELEN with inline function in p80211hdr.h

checkpatch reports a "CHECK" diagnostic for WLAN_CTL_FRAMELEN as the
macro reuses its argument, leading to possible side-effects. Avoid
this by replacing the macro with an equivalent function, named
wlan_ctl_framelen (as recommended in the coding style). All references
to the macro also updated accordingly.

Signed-off-by: Tim Collier <osdevtc@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wlan-ng: fix coding style (indentation) in prism2mib.c
Tim Collier [Fri, 22 Jun 2018 19:39:31 +0000 (20:39 +0100)]
staging: wlan-ng: fix coding style (indentation) in prism2mib.c

Fix "CHECK: Alignment should match open parenthesis" reported by
checkpatch.pl.

Signed-off-by: Tim Collier <osdevtc@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtlwifi: Fix a possible sleep-in-atomic-context bug in _is_fw_read_cmd_down()
Jia-Ju Bai [Wed, 20 Jun 2018 02:58:01 +0000 (10:58 +0800)]
staging: rtlwifi: Fix a possible sleep-in-atomic-context bug in _is_fw_read_cmd_down()

The driver may sleep with holding a spinlock.
The function call path (from bottom to top) in Linux-4.16.7 is:

[FUNC] schedule
drivers/staging/rtlwifi/halmac/rtl_halmac.c, 884:
schedule in _is_fw_read_cmd_down
drivers/staging/rtlwifi/halmac/rtl_halmac.c, 912:
_is_fw_read_cmd_down in rtl_halmac_send_h2c
drivers/staging/rtlwifi/halmac/rtl_halmac.c, 907:
_raw_spin_lock_irqsave in rtl_halmac_send_h2c

To fix this bug, schedule() is replaced with mdelay(1).

This bug is found by my static analysis tool (DSAC-2) and checked by
my code review.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wlan-ng: improved readability of function prism2_add_key
Chris Opperman [Fri, 22 Jun 2018 15:29:02 +0000 (17:29 +0200)]
staging: wlan-ng: improved readability of function prism2_add_key

Improve readability of prism2_add_key:
a) Reduce nesting and removed goto statement by using more return statements.

Signed-off-by: Chris Opperman <eklikeroomys@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtsx: remove rtsx_trace() and related code
Arnd Bergmann [Mon, 18 Jun 2018 14:38:02 +0000 (16:38 +0200)]
staging: rtsx: remove rtsx_trace() and related code

The driver has rather excessive amount of tracing code, which would be
better done using ftrace. This is obviously not a main feature of the
driver, and it should work just as well without it.

Removing it saves over 1300 lines of code and likely makes the driver
a bit faster by avoiding lots of calls into the timekeeping code.

I came across this while cleaning up the last users of the deprecated
getnstimeofday64() function, of which there is one in the now-removed
get_current_time() function of the rtsx driver that was only used for
tracing.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: use BIT_ULL for NL80211_STA_INFO_* attribute types
Omer Efrat [Mon, 18 Jun 2018 14:18:11 +0000 (17:18 +0300)]
staging: use BIT_ULL for NL80211_STA_INFO_* attribute types

The BIT macro uses unsigned long which some architectures handle as 32 bit
and therefore might cause macro's shift to overflow when used on a value
equals or larger than 32 (NL80211_STA_INFO_RX_DURATION and afterwards).

Since 'filled' member in station_info changed to u64, BIT_ULL macro
should be used with all NL80211_STA_INFO_* attribute types instead of BIT
to prevent future possible bugs when one will use BIT macro for higher
attributes by mistake.

This commit cleans up all usages of BIT macro with the above field
in cfg80211 by changing it to BIT_ULL instead.

Signed-off-by: Omer Efrat <omer.efrat@tandemg.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: most: fix sparse warning Using plain integer as NULL pointer
Marcin Ciupak [Fri, 15 Jun 2018 14:21:09 +0000 (14:21 +0000)]
staging: most: fix sparse warning Using plain integer as NULL pointer

This patch fixes following sparse warning:
Using plain integer as NULL pointer
in drivers/staging/most/dim2/dim2.c

Signed-off-by: Marcin Ciupak <marcin.s.ciupak@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: remove rtw_set_tx_chksum_offload()
Michael Straube [Mon, 25 Jun 2018 14:50:25 +0000 (16:50 +0200)]
staging: rtl8723bs: remove rtw_set_tx_chksum_offload()

The function rtw_set_tx_chksum_offload() has empty definition.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Fix comment on variable init
Henriette Hofmeier [Fri, 22 Jun 2018 14:01:59 +0000 (16:01 +0200)]
staging: rtl8723bs: Fix comment on variable init

Change comment from 'local variable' to 'global variables'
and change style to comply with coding-style.

Signed-off-by: Henriette Hofmeier <passt@h-hofmeier.de>
Signed-off-by: Florian Harbecke <florian.harbecke@fau.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Remove unnecessary initializations
Henriette Hofmeier [Fri, 22 Jun 2018 14:01:58 +0000 (16:01 +0200)]
staging: rtl8723bs: Remove unnecessary initializations

Remove initializations of global variables with 0.
Criticized by checkpatch.

Signed-off-by: Henriette Hofmeier <passt@h-hofmeier.de>
Signed-off-by: Florian Harbecke <florian.harbecke@fau.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Move definition open brace
Henriette Hofmeier [Fri, 22 Jun 2018 14:01:57 +0000 (16:01 +0200)]
staging: rtl8723bs: Move definition open brace

Move open braces of definitions to the next line
to comply with codestyle.
Criticized by checkpatch.

Signed-off-by: Henriette Hofmeier <passt@h-hofmeier.de>
Signed-off-by: Florian Harbecke <florian.harbecke@fau.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Fix two possible sleep-in-atomic-context bugs in translate_scan()
Jia-Ju Bai [Wed, 20 Jun 2018 09:50:16 +0000 (17:50 +0800)]
staging: rtl8723bs: Fix two possible sleep-in-atomic-context bugs in translate_scan()

The driver may sleep with holding a spinlock.
The function call paths (from bottom to top) in Linux-4.16.7 are:

[FUNC] kzalloc(GFP_KERNEL)
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 323:
kzalloc in translate_scan
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 1554:
translate_scan in rtw_wx_get_scan
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 1533:
spin_lock_bh in rtw_wx_get_scan

[FUNC] kzalloc(GFP_KERNEL)
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 455:
kzalloc in translate_scan
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 1554:
translate_scan in rtw_wx_get_scan
drivers/staging/rtl8723bs/os_dep/ioctl_linux.c, 1533:
spin_lock_bh in rtw_wx_get_scan

To fix these bugs, GFP_KERNEL is replaced with GFP_ATOMIC.

These bugs are found by my static analysis tool (DSAC-2) and checked by
my code review.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: remove get_monotonic_boottime()
Arnd Bergmann [Mon, 18 Jun 2018 15:06:50 +0000 (17:06 +0200)]
staging: rtl8723bs: remove get_monotonic_boottime()

get_monotonic_boottime() is deprecated because it uses the
old 'timespec' structure. This replaces one of the last callers
with a call to ktime_get_boottime, which also simplifies it
a bit by avoiding a double conversion.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Add missing curly braces on else statement.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:40 +0000 (22:30 -0700)]
staging: rtl8723bs: Add missing curly braces on else statement.

Fix 'braces {} should be used on all arms of this statement' coding
style problem in 'phy_get_tx_pwr_lmt()'.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Merge workaround conditionals into single else-if.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:39 +0000 (22:30 -0700)]
staging: rtl8723bs: Merge workaround conditionals into single else-if.

The if conditionals used to work around wrong TX power limit indices
can be condensed into a single if/else-if statement for more concise
expression.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Merge conditionals with similar bodies.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:38 +0000 (22:30 -0700)]
staging: rtl8723bs: Merge conditionals with similar bodies.

Two conditionals that set 'channel' based on 'band_type' in
'phy_get_tx_pwr_lmt()' can be simplified into one single-line conditional.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Fix spelling mistake in comment.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:37 +0000 (22:30 -0700)]
staging: rtl8723bs: Fix spelling mistake in comment.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Move bandwidth index lookup to new function.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:36 +0000 (22:30 -0700)]
staging: rtl8723bs: Move bandwidth index lookup to new function.

Factoring out the conditional lookup of bandwidth index into the power
limit table into it's own function simplifies the logic of
'phy_get_tx_pwr_lmt()'.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Move rate section index lookup to new function.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:35 +0000 (22:30 -0700)]
staging: rtl8723bs: Move rate section index lookup to new function.

The rate section lookup is a large switch statement in the middle of
'phy_get_tx_pwr_lmt()'; refactor this statement into it's own function
for increased readability.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Remove empty else-if conditional.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:34 +0000 (22:30 -0700)]
staging: rtl8723bs: Remove empty else-if conditional.

This else-if conditional block does nothing; remove it.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Combine if statements with equivalent body.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:33 +0000 (22:30 -0700)]
staging: rtl8723bs: Combine if statements with equivalent body.

Two if statements that carry out the same operation can be combined with
a logical OR.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Fix camel-case names in phy_get_tx_pwr_lmt().
Quytelda Kahja [Sun, 17 Jun 2018 05:30:32 +0000 (22:30 -0700)]
staging: rtl8723bs: Fix camel-case names in phy_get_tx_pwr_lmt().

Change camel-case names to snake-case names; to avoid variable name
conflicts, rename table index variables to idx_*.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Rename PHY_GetTxPowerLimit().
Quytelda Kahja [Sun, 17 Jun 2018 05:30:31 +0000 (22:30 -0700)]
staging: rtl8723bs: Rename PHY_GetTxPowerLimit().

Rename camel-case 'PHY_GetTxPowerLimit()' to 'phy_get_tx_pwr_lmt()'.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()'.
Quytelda Kahja [Sun, 17 Jun 2018 05:30:30 +0000 (22:30 -0700)]
staging: rtl8723bs: Clean up whitespace in 'PHY_GetTxPowerLimit()'.

Wrap lines longer than 80 characters where possible, delete double
newlines, and fix alignment per the kernel coding style guidelines.

Signed-off-by: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: pi433: cleanup comments in rf69.h
Valentin Vidic [Mon, 25 Jun 2018 12:04:41 +0000 (14:04 +0200)]
staging: pi433: cleanup comments in rf69.h

Fixes checkpatch warning:

  WARNING: line over 80 characters

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: pi433: add SPDX-License-Identifier tag
Valentin Vidic [Mon, 25 Jun 2018 11:52:23 +0000 (13:52 +0200)]
staging: pi433: add SPDX-License-Identifier tag

Use GPL-2.0+ based on the license text in each of the files.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: pi433: replace simple switch statements
Valentin Vidic [Sun, 24 Jun 2018 16:31:38 +0000 (18:31 +0200)]
staging: pi433: replace simple switch statements

Use const array to map switch cases to resulting values.

Signed-off-by: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Reviewed-by: Marcus Wolf <Marcus.Wolf@Wolf-Entwicklungen.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: pi433: fix race condition in pi433_open
Hugo Lefeuvre [Wed, 20 Jun 2018 13:37:19 +0000 (09:37 -0400)]
staging: pi433: fix race condition in pi433_open

The device structure contains a useless non-atomic users counter which
is subject to race conditions. It has probably been created to handle
the case where remove is executed while operations are still executing
on open fds but this will never happen because of reference counts.

Drop the users counter and move rx buffer {de,}allocation to probe()
and remove(). Remove associated dead code from open() and release().
Remove related TODO entry from ioctl().

Signed-off-by: Hugo Lefeuvre <hle@owl.eu.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: android/vsoc: stop using 'timespec'
Arnd Bergmann [Mon, 18 Jun 2018 15:09:09 +0000 (17:09 +0200)]
staging: android/vsoc: stop using 'timespec'

The timespec structure suffers from the y2038 overflow and should not
be used. This changes handle_vsoc_cond_wait() to use ktime_t directly.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Martijn Coenen <maco@android.com>
Tested-by: Alistair Strachan <astrachan@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: android: ashmem: Fix mmap size validation
Alistair Strachan [Wed, 20 Jun 2018 00:57:35 +0000 (17:57 -0700)]
staging: android: ashmem: Fix mmap size validation

The ashmem driver did not check that the size/offset of the vma passed
to its .mmap() function was not larger than the ashmem object being
mapped. This could cause mmap() to succeed, even though accessing parts
of the mapping would later fail with a segmentation fault.

Ensure an error is returned by the ashmem_mmap() function if the vma
size is larger than the ashmem object size. This enables safer handling
of the problem in userspace.

Cc: Todd Kjos <tkjos@android.com>
Cc: devel@driverdev.osuosl.org
Cc: linux-kernel@vger.kernel.org
Cc: kernel-team@android.com
Cc: Joel Fernandes <joel@joelfernandes.org>
Signed-off-by: Alistair Strachan <astrachan@google.com>
Acked-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Reviewed-by: Martijn Coenen <maco@android.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: android: ashmem: Remove use of unlikely()
Alistair Strachan [Wed, 20 Jun 2018 00:57:34 +0000 (17:57 -0700)]
staging: android: ashmem: Remove use of unlikely()

There is no speed difference, and it makes the code harder to read.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arve Hjønnevåg <arve@android.com>
Cc: Todd Kjos <tkjos@android.com>
Cc: Martijn Coenen <maco@android.com>
Cc: devel@driverdev.osuosl.org
Cc: linux-kernel@vger.kernel.org
Cc: kernel-team@android.com
Cc: Joel Fernandes <joel@joelfernandes.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Alistair Strachan <astrachan@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: updated TODO file
Ajay Singh [Tue, 26 Jun 2018 06:07:14 +0000 (11:37 +0530)]
staging: wilc1000: updated TODO file

Item [1] in TODO list is already addressed, so removed it from TODO file.

[1]. Move handling for each individual members of 'union message_body' out
into a separate 'struct work_struct' and completely remove the
multiplexerthat is currently part of host_if_work(), allowing movement
of the implementation of each message handler into the callsite of the
function that currently queues the 'host_if_msg'.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: avoid use of static variable 'rssi'
Ajay Singh [Tue, 26 Jun 2018 06:07:13 +0000 (11:37 +0530)]
staging: wilc1000: avoid use of static variable 'rssi'

Instead of static variable now allocating the data and passing to
handle_get_rssi() to fill the rssi information.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: avoid use of static variable 'inactive_time'
Ajay Singh [Tue, 26 Jun 2018 06:07:12 +0000 (11:37 +0530)]
staging: wilc1000: avoid use of static variable 'inactive_time'

Avoided the use of static variable 'inactive_time' and move it as part of
'sta_inactive_t' structure.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: handle freeing of 'key' & 'seq' data in wilc_add_rx_gtk()
Ajay Singh [Tue, 26 Jun 2018 06:07:11 +0000 (11:37 +0530)]
staging: wilc1000: handle freeing of 'key' & 'seq' data in wilc_add_rx_gtk()

Handle freeing of memory allocated to keep 'key' & 'seq' in wilc_add_rx_gtk().
Once completion event is received, free the memory allocated for
to avoid missing of free in work function.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: handle freeing of key data in wilc_add_ptk()
Ajay Singh [Tue, 26 Jun 2018 06:07:10 +0000 (11:37 +0530)]
staging: wilc1000: handle freeing of key data in wilc_add_ptk()

Handle freeing of memory allocated to store the 'key' in wilc_add_ptk()
function. Once work completion notification is received, free the
memory allocated to avoid missing of free in work function sepecially
for error scenario.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: handle freeing of key data in wep add key
Ajay Singh [Tue, 26 Jun 2018 06:07:09 +0000 (11:37 +0530)]
staging: wilc1000: handle freeing of key data in wep add key

Modified the code to free the allocated memory, used to store the key in
wilc_add_wep_key_bss_sta() and wilc_add_wep_key_bss_ap().
After work completion notification is received, free the
memory allocated to avoid missing of free in work function.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: rename wilc_enqueue_cmd() to wilc_enqueue_work()
Ajay Singh [Tue, 26 Jun 2018 06:07:08 +0000 (11:37 +0530)]
staging: wilc1000: rename wilc_enqueue_cmd() to wilc_enqueue_work()

Rename wilc_enqueue_cmd() to wilc_enqueue_work() because its used to
enqueue the work queue. Also removed the function header comment for
wilc_enqueue_cmd() as its not correct.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: remove 'hif_thread_comp' completions
Ajay Singh [Tue, 26 Jun 2018 06:07:07 +0000 (11:37 +0530)]
staging: wilc1000: remove 'hif_thread_comp' completions

Remove 'hif_thread_comp' completions as its not required after adding
completion event as part work data to handle each sync call.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: added 'work_comp' completion as part of host_if_msg
Ajay Singh [Tue, 26 Jun 2018 06:07:06 +0000 (11:37 +0530)]
staging: wilc1000: added 'work_comp' completion as part of host_if_msg

Added 'work_comp' completion in 'host_if_msg'. It allows handling the
sync call to wait for sepecific completion event.
The commands can be run in sync way waiting for their specific
completion event.
Added is_sync flag in wilc_create_work_queue() to handle the sync call to
host interface.

After adding completion as part of host_if_msg now
below completion are not required
 comp_test_key_block;
 comp_test_disconn_block
 comp_get_rssi
 comp_inactive_time
 hif_wait_response

Modified wilc_get_statistics() API to handle get statistic in sync &
async way.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: move the allocation of cmd out of wilc_enqueue_cmd()
Ajay Singh [Tue, 26 Jun 2018 06:07:05 +0000 (11:37 +0530)]
staging: wilc1000: move the allocation of cmd out of wilc_enqueue_cmd()

Instead of allocating the host_if_cmd in wilc_enqueue_cmd() now moved
the allocation of cmd in the caller. Added the NULL check for
'hif_workqueue' before posting the work queue in wilc_enqueue_cmd().

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: remove unused marco related to HIF commands
Ajay Singh [Tue, 26 Jun 2018 06:07:04 +0000 (11:37 +0530)]
staging: wilc1000: remove unused marco related to HIF commands

After removing the multiplexing of hif commands in hif_if_work()
macros prefix with 'HOST_IF_MSG_' are not required. Also 'id' field in
host_if_msg is not required anymore.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: remove host_if_work() to handle TODO list issue
Ajay Singh [Tue, 26 Jun 2018 06:07:03 +0000 (11:37 +0530)]
staging: wilc1000: remove host_if_work() to handle TODO list issue

Remove multiplexing of command at host_if_work().
Make use of function pointer instead of command ID to track individual
work_struct separately.

Modified the handler function to take work_struct pointer as argument
and its return type is changes to void. Now prototype of 'handle_'
function is same work_struct i.e. 'void (*fun)(struct struct *)' to
register with work_queue.
Removed host_if_work() because its not required now.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: wilc1000: Use common structs to parse ip packets
Thibaut Robert [Tue, 19 Jun 2018 18:44:19 +0000 (20:44 +0200)]
staging: wilc1000: Use common structs to parse ip packets

Use structs ethhdr, iphdr and tcphdr instead of manual parsing in
tcp_process.
This commit fix handling of ip packets containing options.
It also fixes the following sparse warning:

drivers/staging/wilc1000//wilc_wlan.c:201:19: warning: cast to restricted __be16

Signed-off-by: Thibaut Robert <thibaut.robert@gmail.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: avoid use banks in device tree
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:20 +0000 (11:36 +0200)]
staging: mt7621-gpio: avoid use banks in device tree

Banks shouldn't be defined in DT if number of resources
per bank is not variable. We actually know that this SoC
has three banks so take that into account in order to don't
overspecify the device tree. Device tree will only have one
node making it simple. Update device tree, binding doc and
code accordly.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: update Kconfig with SoC details
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:19 +0000 (11:36 +0200)]
staging: mt7621-gpio: update Kconfig with SoC details

Kconfig is using a generic 'Mediatek GPIO Support' in
description and help which is not specific at all about
the current SoC which is MT7621. Update it.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: avoid long line in a comment
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:18 +0000 (11:36 +0200)]
staging: mt7621-gpio: avoid long line in a comment

Checkpatch script is complaining about a comment line
which exceeds 80 characteres. Just silence it.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: set different names for each gpio_chip and irq_chip
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:17 +0000 (11:36 +0200)]
staging: mt7621-gpio: set different names for each gpio_chip and irq_chip

Currently the driver defines 3 gpiochips, one for each bank.

/sys/class/gpio/gpiochip416/label:1e000600.gpio
/sys/class/gpio/gpiochip448/label:1e000600.gpio
/sys/class/gpio/gpiochip480/label:1e000600.gpio

Unfortunately they all have the same label

Interrupts from /proc/interrupt show the same name which is
confusing:

/proc/interrupts:

17: 0  0  0  0  MIPS GIC  19  mt7621, mt7621, mt7621

which is the interrupt from the GPIO controller.
It is a little weird that all three banks are named "mt7621"
here. We also have:

26: 0  0  0  0  GPIO  18  reset

which is the interrupt from GPIO which provides the "reset"
button. I suspect that if I had interrupts form two different
banks they would both be called "GPIO" which would be a little
confusing.

In order to unify all of this set different names for each chip
Use a 'bank-based' name instead the same for all: 'mt7621-bank[0-2]'.
Create a new 'mediatek_gpio_bank_name' function which return the
name depending on the bank number. This function is allways called
with a valid index 0, 1 or 2.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: avoid one level indentation in interrupt handler
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:16 +0000 (11:36 +0200)]
staging: mt7621-gpio: avoid one level indentation in interrupt handler

There is no need to check for 'pending' before loop over the
interrupts using 'for_each_set_bit' if nothing is set the
return values will be the same so just avoid this check avoiding
also one level intentation and improving readability.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: avoid to set up irqs if not defined in dts
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:15 +0000 (11:36 +0200)]
staging: mt7621-gpio: avoid to set up irqs if not defined in dts

If there is no interrupt defined in the dts 'irq_of_parse_and_map'
returns 0 and we should't set up interrupts for each gpio chip in
that case.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: avoid check for NULL in 'to_mediatek_gpio' calls
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:14 +0000 (11:36 +0200)]
staging: mt7621-gpio: avoid check for NULL in 'to_mediatek_gpio' calls

Function 'to_mediatek_gpio' cannot return NULL, so this NULL
checkings are pointless.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years agostaging: mt7621-gpio: align indentation for all defines
Sergio Paracuellos [Mon, 18 Jun 2018 09:36:13 +0000 (11:36 +0200)]
staging: mt7621-gpio: align indentation for all defines

There was two remaining defines which weren't properly
aligned with the rest. Align them improving readability.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>