platform/kernel/linux-rpi.git
3 years agoiio: adc: ti-adc161s626: Use devm managed functions for all of probe.
Jonathan Cameron [Sun, 16 May 2021 17:25:20 +0000 (18:25 +0100)]
iio: adc: ti-adc161s626: Use devm managed functions for all of probe.

Simplifies error handling and allows us to drop remove entirely.

The regulator handling in this driver was unusual as it would try to
acquire the regulator, but if that failed with an error would continue.

We should get a stub regulator if one isn't provided in DT and an error
could indicate an actual problem preventing the device being powered
(perhaps a need to defer). So this handling is cleaned up (arguably
that might be a fix but given no one has run into it, I haven't broken
it out separately.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210516172520.1398835-9-jic23@kernel.org
3 years agoiio: adc: ti-adc108s102: Use devm managed functions for all of probe()
Jonathan Cameron [Sun, 16 May 2021 17:25:19 +0000 (18:25 +0100)]
iio: adc: ti-adc108s102: Use devm managed functions for all of probe()

Simplifies error handling and lets us drop remove() entirely.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Bogdan Pricop <bogdan.pricop@emutex.com>
Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210516172520.1398835-8-jic23@kernel.org
3 years agoiio: adc: ti-adc0832: Use devm managed functions for all of probe()
Jonathan Cameron [Sun, 16 May 2021 17:25:18 +0000 (18:25 +0100)]
iio: adc: ti-adc0832: Use devm managed functions for all of probe()

Simplifies error handling, plus allows us to drop the remove()
function entirely.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210516172520.1398835-7-jic23@kernel.org
3 years agoiio: adc: ti-adc081c: Use devm managed functions for all of probe()
Jonathan Cameron [Sun, 16 May 2021 17:25:17 +0000 (18:25 +0100)]
iio: adc: ti-adc081c: Use devm managed functions for all of probe()

Simplifies error handling and allows us to drop remove() entirely.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210516172520.1398835-6-jic23@kernel.org
3 years agoiio: adc: max1118: Avoid jumping back and forth between spi and iio structures
Jonathan Cameron [Sun, 16 May 2021 17:25:16 +0000 (18:25 +0100)]
iio: adc: max1118: Avoid jumping back and forth between spi and iio structures

Changing from passing the spi structure into various functions to
passing struct iio_dev avoids use of spi_get_drvdata and lets us
stop setting that at all.  Previous code was unnecessarily complex.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210516172520.1398835-5-jic23@kernel.org
3 years agoiio: adc: max1118: Use devm_ managed functions for all of probe
Jonathan Cameron [Sun, 16 May 2021 17:25:15 +0000 (18:25 +0100)]
iio: adc: max1118: Use devm_ managed functions for all of probe

This simplifies error handling and allows us to drop the remove
function entirely.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210516172520.1398835-4-jic23@kernel.org
3 years agoiio: adc: max11100: Use devm_ functions for rest of probe()
Jonathan Cameron [Sun, 16 May 2021 17:25:14 +0000 (18:25 +0100)]
iio: adc: max11100: Use devm_ functions for rest of probe()

By using devm_add_action_or_reset() to manage the regulator disable,
it becomes simple to use managed functions for all of remove.
This simplifies error handling and allows us to drop the remove()
function entirely.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210516172520.1398835-3-jic23@kernel.org
3 years agoiio: adc: max11100: Use get_unaligned_be16() rather than opencoding.
Jonathan Cameron [Sun, 16 May 2021 17:25:13 +0000 (18:25 +0100)]
iio: adc: max11100: Use get_unaligned_be16() rather than opencoding.

The function is more explicit in showing the intent + quicker on some
platforms.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Alexandru Ardelean <aardelean@deviqon.com>
Link: https://lore.kernel.org/r/20210516172520.1398835-2-jic23@kernel.org
3 years agoiio: chemical: sgp30: Drop use of %hx in format string.
Jonathan Cameron [Mon, 17 May 2021 12:55:54 +0000 (13:55 +0100)]
iio: chemical: sgp30: Drop use of %hx in format string.

Since:
commit cbacb5ab0aa0 ("docs: printk-formats: Stop encouraging use of
unnecessary %h[xudi] and %hh[xudi]")
use of these format strings has been discouraged.

As there are only a few such uses in IIO, lets clear them all out and
avoid chance of them getting copied into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Andreas Brauchli <andreas.brauchli@sensirion.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20210517125554.1463156-5-jic23@kernel.org
3 years agoiio: gyro: st_gyro: Support mount matrix
Linus Walleij [Tue, 18 May 2021 23:07:22 +0000 (01:07 +0200)]
iio: gyro: st_gyro: Support mount matrix

Add support to read and present the mounting matrix on ST gyroscopes.

Cc: Denis Ciocca <denis.ciocca@st.com>
Cc: Daniel Drake <drake@endlessm.com>
Cc: Stephan Gerhold <stephan@gerhold.net>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210518230722.522446-5-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: magnetometer: st_magn: Support mount matrix
Linus Walleij [Tue, 18 May 2021 23:07:21 +0000 (01:07 +0200)]
iio: magnetometer: st_magn: Support mount matrix

Add support to read and present the mounting matrix on ST magnetometers.

Cc: Denis Ciocca <denis.ciocca@st.com>
Cc: Daniel Drake <drake@endlessm.com>
Cc: Stephan Gerhold <stephan@gerhold.net>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210518230722.522446-4-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: st_sensors: Stop copying channels
Linus Walleij [Tue, 18 May 2021 23:07:20 +0000 (01:07 +0200)]
iio: accel: st_sensors: Stop copying channels

The channels were copied only so that the .ext_info member should become
assignable. We now have compile-time static assignment so drop this code.

Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Cc: Daniel Drake <drake@endlessm.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210518230722.522446-3-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: st_sensors: Support generic mounting matrix
Linus Walleij [Tue, 18 May 2021 23:07:19 +0000 (01:07 +0200)]
iio: accel: st_sensors: Support generic mounting matrix

The ST accelerators support a special type of quirky mounting matrix found
in ACPI systems, but not a generic mounting matrix such as from the device
tree.

Augment the ACPI hack to be a bit more generic and accept a mounting
matrix from device properties.

This makes it possible to fix orientation on the Ux500 HREF device.

Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Cc: Daniel Drake <drake@endlessm.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210518230722.522446-2-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: st_sensors: Create extended attr macro
Linus Walleij [Tue, 18 May 2021 23:07:18 +0000 (01:07 +0200)]
iio: st_sensors: Create extended attr macro

Extend ST_SENSORS_LSM_CHANNELS() to a version that will accept extended
attributes named ST_SENSORS_LSM_CHANNELS_EXT() and wrap the former as a
specialized version of the former.

Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Cc: Daniel Drake <drake@endlessm.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20210518230722.522446-1-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adis16136: make use of adis lock helpers
Nuno Sá [Thu, 20 May 2021 11:59:09 +0000 (13:59 +0200)]
iio: adis16136: make use of adis lock helpers

Use the adis lib lock helpers to lock the device. This makes things
consistent with other users of the library.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210520115909.466275-3-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adis16260: make use of adis lock helpers
Nuno Sá [Thu, 20 May 2021 11:59:08 +0000 (13:59 +0200)]
iio: adis16260: make use of adis lock helpers

Use the adis lib lock helpers to lock the device. This makes things
consistent with other users of the library.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210520115909.466275-2-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agostaging: iio: cdc: ad7746: use dt for capacitive channel setup.
Lucas Stankus [Sat, 1 May 2021 12:32:53 +0000 (09:32 -0300)]
staging: iio: cdc: ad7746: use dt for capacitive channel setup.

Ditch platform_data fields in favor of device tree properties for
configuring EXCA and EXCB output pins and setting the capacitive channel
excitation level.

As this covers all current use cases for the platform_data struct, remove
ad7746.h header file since it's no longer needed.

Signed-off-by: Lucas Stankus <lucas.p.stankus@gmail.com>
Link: https://lore.kernel.org/r/3e7f2a0a8960cece185f518ff2b7ceb87891edcd.1619841953.git.lucas.p.stankus@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings: staging: iio: cdc: ad7746: add binding documentation for AD7746
Lucas Stankus [Sat, 1 May 2021 12:32:31 +0000 (09:32 -0300)]
dt-bindings: staging: iio: cdc: ad7746: add binding documentation for AD7746

Add device tree binding documentation for AD7746 cdc in YAML format.

Signed-off-by: Lucas Stankus <lucas.p.stankus@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/2c2f4d486a94e0740e112bfac0d9306bdb7ea69c.1619841953.git.lucas.p.stankus@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: afe: iio-rescale: Support processed channels
Linus Walleij [Tue, 18 May 2021 09:27:41 +0000 (11:27 +0200)]
iio: afe: iio-rescale: Support processed channels

It happens that an ADC will only provide raw or processed
voltage conversion channels. (adc/ab8500-gpadc.c).
On the Samsung GT-I9070 this is used for a light sensor
and current sense amplifier so we need to think of something.

The idea is to allow processed channels and scale them
with 1/1 and then the rescaler can modify the result
on top.

Link: https://lore.kernel.org/linux-iio/20201101232211.1194304-1-linus.walleij@linaro.org/
Cc: Peter Rosin <peda@axentia.se>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Peter Rosin <peda@axentia.se>
Link: https://lore.kernel.org/r/20210518092741.403080-1-linus.walleij@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agostaging: iio: cdc: ad7746: Remove unnecessary assignment in ad7746_probe()
Tang Bin [Tue, 18 May 2021 09:56:47 +0000 (17:56 +0800)]
staging: iio: cdc: ad7746: Remove unnecessary assignment in ad7746_probe()

In the function ad7746_probe(), the initialized value of 'ret' is unused,
because it will be assigned by the function i2c_smbus_write_byte_data(),
thus remove it.

Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20210518095647.3008-1-tangbin@cmss.chinamobile.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: Drop Duplicated "mount-matrix" parameter
Andy Shevchenko [Tue, 18 May 2021 11:25:46 +0000 (14:25 +0300)]
iio: Drop Duplicated "mount-matrix" parameter

All of the users of iio_read_mount_matrix() are using the very same
property name. Moreover, the property name is hard coded in the API
documentation.

Make this clear and avoid duplication now and in the future.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210518112546.44592-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adis16480: support burst read function
Nuno Sa [Thu, 22 Apr 2021 10:37:35 +0000 (12:37 +0200)]
iio: adis16480: support burst read function

Some supported devices support burst read function. This provides a method
for reading a batch of data (status, temperature, gyroscopes,
accelerometers, time stamp/data counter, and CRC code), which does not
require a stall time between each 16-bit segment and only requires one
command on the DIN line to initiate. Devices supporting this mode
are:

 * adis16495-1
 * adis16495-2
 * adis16495-3
 * adis16497-1
 * adis16497-2
 * adis16497-3

Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20210422103735.136367-1-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: buffer: Remove redundant assignment to in_loc
Jiapeng Chong [Mon, 17 May 2021 10:11:57 +0000 (18:11 +0800)]
iio: buffer: Remove redundant assignment to in_loc

Variable in_loc is being assigned a value from a calculation
however the assignment is never read, so this redundant assignment
can be removed.

Clean up the following clang-analyzer warning:

drivers/iio/industrialio-buffer.c:929:3: warning: Value stored to
'in_loc' is never read [clang-analyzer-deadcode.DeadStores].

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Link: https://lore.kernel.org/r/1621246317-62725-1-git-send-email-jiapeng.chong@linux.alibaba.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: hid: trigger: Balance runtime pm + use pm_runtime_resume_and_get()
Jonathan Cameron [Sun, 9 May 2021 11:33:34 +0000 (12:33 +0100)]
iio: hid: trigger: Balance runtime pm + use pm_runtime_resume_and_get()

The call to pm_runtime_put_noidle() in remove() callback is not
balanced by any gets

Note this doesn't cause any problems beyond reader confusion as the runtime
pm core protects against the reference counter going negative.

Whilst here, use pm_runtiem_resume_and_get() to simplify code a little.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-9-jic23@kernel.org
3 years agoiio: adc: tsc2046: fix a warning message in tsc2046_adc_update_scan_mode()
Dan Carpenter [Sat, 15 May 2021 09:51:52 +0000 (12:51 +0300)]
iio: adc: tsc2046: fix a warning message in tsc2046_adc_update_scan_mode()

These variables are unsigned so the condition can't be less than zero
and the warning message will never be printed.

Fixes: 9374e8f5a38d ("iio: adc: add ADC driver for the TI TSC2046 controller")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YJ+ZuO43TnguY5vq@mwanda
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: light: tsl2591: delete a stray tab
Dan Carpenter [Fri, 14 May 2021 13:10:55 +0000 (16:10 +0300)]
iio: light: tsl2591: delete a stray tab

This return statement is indented one more tab than it should be.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YJ523y0dhc1IwCOB@mwanda
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: light: tsl2591: fix some signedness bugs
Dan Carpenter [Fri, 14 May 2021 13:10:07 +0000 (16:10 +0300)]
iio: light: tsl2591: fix some signedness bugs

These variables need to be int for the error handling to work.

Fixes: 2335f0d7c790 ("iio: light: Added AMS tsl2591 driver implementation")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/YJ52r1XZ44myD9Xx@mwanda
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio:adc:ad7766: Fix unnecessary check in ad7766_probe()
Tang Bin [Tue, 11 May 2021 13:47:39 +0000 (21:47 +0800)]
iio:adc:ad7766: Fix unnecessary check in ad7766_probe()

In the function ad7766_probe(), the return value of
devm_iio_device_register() can be zero or ret, Thus it
is unnecessary to repeated check here.

Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Co-developed-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Link: https://lore.kernel.org/r/20210511134739.948-1-tangbin@cmss.chinamobile.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: core: Fix an error pointer vs NULL bug in devm_iio_device_alloc()
Dan Carpenter [Sat, 15 May 2021 09:56:39 +0000 (12:56 +0300)]
iio: core: Fix an error pointer vs NULL bug in devm_iio_device_alloc()

The devm_iio_device_alloc() function is supposed to return NULL and not
error pointers.  Returning an error pointer will lead to a crash in the
callers.

Fixes: cf5724e91515 ("iio: core: simplify some devm functions")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/YJ+a1yaMu2QNATgt@mwanda
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: light: pa12203001: Use pm_runtime_resume_and_get() to replace open coding.
Jonathan Cameron [Sun, 9 May 2021 11:33:45 +0000 (12:33 +0100)]
iio: light: pa12203001: Use pm_runtime_resume_and_get() to replace open coding.

Found using coccicheck script under review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/

This is a prequel to taking a closer look at the runtime pm in IIO drivers
in general.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-20-jic23@kernel.org
3 years agoiio: potentiostat: lmp91000: Fix alignment of buffer in iio_push_to_buffers_with_time...
Jonathan Cameron [Sat, 1 May 2021 17:13:48 +0000 (18:13 +0100)]
iio: potentiostat: lmp91000: Fix alignment of buffer in iio_push_to_buffers_with_timestamp()

Add __aligned(8) to ensure the buffer passed to
iio_push_to_buffers_with_timestamp() is suitable for the naturally
aligned timestamp that will be inserted.

Here structure is not used, because this buffer is also used
elsewhere in the driver.

Fixes: 67e17300dc1d ("iio: potentiostat: add LMP91000 support")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Link: https://lore.kernel.org/r/20210501171352.512953-8-jic23@kernel.org
3 years agoiio: cros_ec_sensors: Fix alignment of buffer in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:13:47 +0000 (18:13 +0100)]
iio: cros_ec_sensors: Fix alignment of buffer in iio_push_to_buffers_with_timestamp()

The samples buffer is passed to iio_push_to_buffers_with_timestamp()
which requires a buffer aligned to 8 bytes as it is assumed that
the timestamp will be naturally aligned if present.

Fixes tag is inaccurate but prior to that likely manual backporting needed
(for anything before 4.18) Earlier than that the include file to fix is
drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.h:
commit 974e6f02e27 ("iio: cros_ec_sensors_core: Add common functions
for the ChromeOS EC Sensor Hub.") present since kernel stable 4.10.
(Thanks to Gwendal for tracking this down)

Fixes: 5a0b8cb46624c ("iio: cros_ec: Move cros_ec_sensors_core.h in /include")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org
Link: https://lore.kernel.org/r/20210501171352.512953-7-jic23@kernel.org
3 years agoiio: chemical: atlas: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:13:46 +0000 (18:13 +0100)]
iio: chemical: atlas: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

Variable location for the timestamp, so just use __aligned(8)
to ensure it is always possible to naturally align it.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes tag is not accurate, but it will need manual backporting beyond
that point if anyone cares.

Fixes: 0d15190f53b4 ("iio: chemical: atlas-ph-sensor: rename atlas-ph-sensor to atlas-sensor")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Link: https://lore.kernel.org/r/20210501171352.512953-6-jic23@kernel.org
3 years agoiio: light: tcs3472: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:21 +0000 (18:01 +0100)]
iio: light: tcs3472: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp().

Fixes tag is not strictly accurate as prior to that patch there was
potentially an unaligned write.  However, any backport past there will
need to be done manually.

Fixes: 0624bf847dd0 ("iio:tcs3472: Use iio_push_to_buffers_with_timestamp()")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-20-jic23@kernel.org
3 years agoiio: light: tcs3414: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:20 +0000 (18:01 +0100)]
iio: light: tcs3414: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: a244e7b57f0f ("iio: Add driver for AMS/TAOS tcs3414 digital color sensor")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-19-jic23@kernel.org
3 years agoiio: light: isl29125: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:19 +0000 (18:01 +0100)]
iio: light: isl29125: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 6c25539cbc46 ("iio: Add Intersil isl29125 digital color light sensor driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-18-jic23@kernel.org
3 years agoiio: magn: bmc150: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:18 +0000 (18:01 +0100)]
iio: magn: bmc150: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: c91746a2361d ("iio: magn: Add support for BMC150 magnetometer")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-17-jic23@kernel.org
3 years agoiio: magn: hmc5843: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:17 +0000 (18:01 +0100)]
iio: magn: hmc5843: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 7247645f6865 ("iio: hmc5843: Move hmc5843 out of staging")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-16-jic23@kernel.org
3 years agoiio: prox: as3935: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:16 +0000 (18:01 +0100)]
iio: prox: as3935: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 37b1ba2c68cf ("iio: proximity: as3935: fix buffer stack trashing")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-15-jic23@kernel.org
3 years agoiio: prox: pulsed-light: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:15 +0000 (18:01 +0100)]
iio: prox: pulsed-light: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: cb119d535083 ("iio: proximity: add support for PulsedLight LIDAR")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-14-jic23@kernel.org
3 years agoiio: prox: srf08: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:14 +0000 (18:01 +0100)]
iio: prox: srf08: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 78f839029e1d ("iio: distance: srf08: add IIO driver for us ranger")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Andreas Klinger <ak@it-klinger.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-13-jic23@kernel.org
3 years agoiio: humidity: am2315: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:13 +0000 (18:01 +0100)]
iio: humidity: am2315: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 0d96d5ead3f7 ("iio: humidity: Add triggered buffer support for AM2315")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-12-jic23@kernel.org
3 years agoiio: gyro: bmg160: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:12 +0000 (18:01 +0100)]
iio: gyro: bmg160: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 13426454b649 ("iio: bmg160: Separate i2c and core driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Stephan Gerhold <stephan@gerhold.net>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-11-jic23@kernel.org
3 years agoiio: adc: vf610: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:11 +0000 (18:01 +0100)]
iio: adc: vf610: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of uses of
iio_push_to_buffers_with_timestamp()

Fixes: 0010d6b44406 ("iio: adc: vf610: Add IIO buffer support for Vybrid ADC")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Stefan-Gabriel Mirea <stefan-gabriel.mirea@nxp.com>
Cc: Sanchayan Maity <maitysanchayan@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-10-jic23@kernel.org
3 years agoiio: adc: ti-ads1015: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:10 +0000 (18:01 +0100)]
iio: adc: ti-ads1015: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of this function.

Fixes: ecc24e72f437 ("iio: adc: Add TI ADS1015 ADC driver support")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Daniel Baluta <daniel.baluta@nxp.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-9-jic23@kernel.org
3 years agoiio: accel: stk8ba50: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:09 +0000 (18:01 +0100)]
iio: accel: stk8ba50: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of this function.

Fixes: db6a19b8251f ("iio: accel: Add trigger support for STK8BA50")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-8-jic23@kernel.org
3 years agoiio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:08 +0000 (18:01 +0100)]
iio: accel: stk8312: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of this function.

Fixes: 95c12bba51c3 ("iio: accel: Add buffer mode for Sensortek STK8312")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-7-jic23@kernel.org
3 years agoiio: accel: mxc4005: Fix overread of data and alignment issue.
Jonathan Cameron [Sat, 1 May 2021 17:01:07 +0000 (18:01 +0100)]
iio: accel: mxc4005: Fix overread of data and alignment issue.

The bulk read size is based on the size of an array that also has
space for the timestamp alongside the channels.
Fix that and also fix alignment of the buffer passed
to iio_push_to_buffers_with_timestamp.

Found during an audit of all calls to this function.

Fixes: 1ce0eda0f757 ("iio: mxc4005: add triggered buffer mode for mxc4005")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-6-jic23@kernel.org
3 years agoiio: accel: kxcjk-1013: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:06 +0000 (18:01 +0100)]
iio: accel: kxcjk-1013: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of this function.

Fixes: 1a4fbf6a9286 ("iio: accel: kxcjk1013 3-axis accelerometer driver")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-5-jic23@kernel.org
3 years agoiio: accel: hid: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:05 +0000 (18:01 +0100)]
iio: accel: hid: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.
Note this matches what was done in all the other hid sensor drivers.
This one was missed previously due to an extra level of indirection.

Found during an audit of all calls of this function.

Fixes: a96cd0f901ee ("iio: accel: hid-sensor-accel-3d: Add timestamp")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-4-jic23@kernel.org
3 years agoiio: accel: bma220: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:04 +0000 (18:01 +0100)]
iio: accel: bma220: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of this function.

Fixes: 194dc4c71413 ("iio: accel: Add triggered buffer support for BMA220")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-3-jic23@kernel.org
3 years agoiio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp()
Jonathan Cameron [Sat, 1 May 2021 17:01:03 +0000 (18:01 +0100)]
iio: accel: bma180: Fix buffer alignment in iio_push_to_buffers_with_timestamp()

To make code more readable, use a structure to express the channel
layout and ensure the timestamp is 8 byte aligned.

Found during an audit of all calls of this function.

Fixes: b9a6a237ffc9 ("iio:bma180: Drop _update_scan_mode()")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210501170121.512209-2-jic23@kernel.org
3 years agoiio: accel: mma8452: Balance runtime pm + use pm_runtime_resume_and_get()
Jonathan Cameron [Sun, 9 May 2021 11:33:31 +0000 (12:33 +0100)]
iio: accel: mma8452: Balance runtime pm + use pm_runtime_resume_and_get()

Remove() callback calls pm_runtime_put_noidle() but there it is not
balancing a get.  No actual affect because the runtime pm core prevents
the reference count going negative.

Whilst here use pm_runtime_resume_and_get() rather than open coded version.
Again, coccinelle script missed this one due to more complex code
structure.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-6-jic23@kernel.org
3 years agoiio: light: rpr0521: Balance runtime pm + use pm_runtime_resume_and_get()
Jonathan Cameron [Sun, 9 May 2021 11:33:36 +0000 (12:33 +0100)]
iio: light: rpr0521: Balance runtime pm + use pm_runtime_resume_and_get()

Calls to pm_runtime_put_noidle in probe() error path and remove() are
not match to any get() calls.

The runtime pm core protects against negative reference counts, so this
doesn't have any visible impact beyond confusing the reader.

Whilst here use pm_runtime_resume_and_get() to replace boilerplate.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Mikko Koivunen <mikko.koivunen@fi.rohmeurope.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-11-jic23@kernel.org
3 years agoiio: magn: bmc150: Balance runtime pm + use pm_runtime_resume_and_get()
Jonathan Cameron [Sun, 9 May 2021 11:33:37 +0000 (12:33 +0100)]
iio: magn: bmc150: Balance runtime pm + use pm_runtime_resume_and_get()

probe() error paths after runtime pm is enabled, should disable it.
remove() should not call pm_runtime_put_noidle() as there is no
matching get() to have raised the reference count.  This case
has no affect a the runtime pm core protects against going negative.

Whilst here use pm_runtime_resume_and_get() to tidy things up a little.
coccicheck script didn't get this one due to complex code structure so
found by inspection.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-12-jic23@kernel.org
3 years agoiio: accel: bmi088: Balance runtime pm + use pm_runtime_resume_and_get()
Jonathan Cameron [Sun, 9 May 2021 11:33:38 +0000 (12:33 +0100)]
iio: accel: bmi088: Balance runtime pm + use pm_runtime_resume_and_get()

The call to pm_runtime_put_noidle() in remove() is not balanced by a get so
drop it.

Using pm_runtime_resume_and_get() allows for simple introduction of
error handling to allow for runtime resume failing.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Mike Looijmans <mike.looijmans@topic.nl>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-13-jic23@kernel.org
3 years agoiio: light: vcnl4035: Use pm_runtime_resume_and_get() to replace open coding.
Jonathan Cameron [Sun, 9 May 2021 11:33:48 +0000 (12:33 +0100)]
iio: light: vcnl4035: Use pm_runtime_resume_and_get() to replace open coding.

Found using coccicheck script under review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/

This is a prequel to taking a closer look at the runtime pm in IIO drivers
in general.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Parthiban Nallathambi <pn@denx.de>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-23-jic23@kernel.org
3 years agoiio: light: vcnl4000: Use pm_runtime_resume_and_get() to replace open coding.
Jonathan Cameron [Sun, 9 May 2021 11:33:47 +0000 (12:33 +0100)]
iio: light: vcnl4000: Use pm_runtime_resume_and_get() to replace open coding.

Found using coccicheck script under review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/

This is a prequel to taking a closer look at the runtime pm in IIO drivers
in general.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Mathieu Othacehe <m.othacehe@gmail.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-22-jic23@kernel.org
3 years agoiio: proximity: srf04: Use pm_runtime_resume_and_get() and handle error
Jonathan Cameron [Sun, 9 May 2021 11:33:51 +0000 (12:33 +0100)]
iio: proximity: srf04: Use pm_runtime_resume_and_get() and handle error

Previously this driver used pm_runtime_sync_get() and did not handle any
errors that occurred.  Moving to the new pm_runtime_resume_and_get() +
handle errors.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Andreas Klinger <ak@it-klinger.de>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-26-jic23@kernel.org
3 years agoiio: adc: rcar-gyroadc: Use pm_runtime_resume_and_get() and check in probe()
Jonathan Cameron [Sun, 9 May 2021 11:33:54 +0000 (12:33 +0100)]
iio: adc: rcar-gyroadc: Use pm_runtime_resume_and_get() and check in probe()

1 instance found using coccicheck script under review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/
The other instance changed did not check for failure of the
pm_runtime_get_sync() so that is added.

Note the remaining pm_runtime_get_sync() call is left alone because it
is not obvious what to do on failure to power up in remove()

This is a prequel to taking a closer look at the runtime pm in IIO drivers
in general.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Marek Vasut <marek.vasut@gmail.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-29-jic23@kernel.org
3 years agoiio: temp: mlx90614: Handle failure in pm_runtime_resume_and_get()
Jonathan Cameron [Sun, 9 May 2021 11:33:50 +0000 (12:33 +0100)]
iio: temp: mlx90614: Handle failure in pm_runtime_resume_and_get()

Converts from using pm_runtime_get_sync() with no error handling over
to pm_runtime_resume_and_get() which will ensure we don't end up
holding a reference.  Ensure this error return is then handled at
calls to mlx90614_power_get(). These are all direct returns.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-25-jic23@kernel.org
3 years agoiio: light: us5182: Use pm_runtime_resume_and_get() to replace open coding.
Jonathan Cameron [Sun, 9 May 2021 11:33:46 +0000 (12:33 +0100)]
iio: light: us5182: Use pm_runtime_resume_and_get() to replace open coding.

Found using coccicheck script under review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/

This is a prequel to taking a closer look at the runtime pm in IIO drivers
in general.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-21-jic23@kernel.org
3 years agoiio: dac: stm32-dac: Use pm_runtime_resume_and_get() to replace open coding.
Jonathan Cameron [Sun, 9 May 2021 11:33:42 +0000 (12:33 +0100)]
iio: dac: stm32-dac: Use pm_runtime_resume_and_get() to replace open coding.

Found using coccicheck script under review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/

This is a prequel to taking a closer look at the runtime pm in IIO drivers
in general

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-17-jic23@kernel.org
3 years agoiio: adc: stm32-dfsdm: Use pm_runtime_resume_and_get() to replace open coding.
Jonathan Cameron [Sun, 9 May 2021 11:33:41 +0000 (12:33 +0100)]
iio: adc: stm32-dfsdm: Use pm_runtime_resume_and_get() to replace open coding.

Found using coccicheck script under review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/

This is a prequel to taking a closer look at the runtime pm in IIO drivers
in general.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-16-jic23@kernel.org
3 years agoiio: adc: stm32-adc: Use pm_runtime_resume_and_get() to replace open coding.
Jonathan Cameron [Sun, 9 May 2021 11:33:40 +0000 (12:33 +0100)]
iio: adc: stm32-adc: Use pm_runtime_resume_and_get() to replace open coding.

Found using coccicheck script under review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/

This is a prequel to taking a closer look at the runtime pm in IIO drivers
in general.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-15-jic23@kernel.org
3 years agoiio: imu: kmx61: Balance runtime pm + use pm_runtime_resume_and_get()
Jonathan Cameron [Sun, 9 May 2021 11:33:35 +0000 (12:33 +0100)]
iio: imu: kmx61: Balance runtime pm + use pm_runtime_resume_and_get()

No point in calling pm_runtime_put_noidle() that isn't balancing a get.
Note no actual impact because the runtime pm core protects against
a negative reference counter.

For the pm_runtime_resume_and_get() main interest is in clearing
out this old pattern to avoid it getting coppied into new submissions.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-10-jic23@kernel.org
3 years agoiio: accel: kxcjk-1013: Balance runtime pm + use pm_runtime_resume_and_get()
Jonathan Cameron [Sun, 9 May 2021 11:33:33 +0000 (12:33 +0100)]
iio: accel: kxcjk-1013: Balance runtime pm + use pm_runtime_resume_and_get()

This driver alls pm_runtime_put_noidle() in it's remove function, but there
is no matching get call.  This isn't a bug as runtime pm will not allow
the reference counter to go negative, but it is missleading so lets remove
it.

Whilst here use pm_runtime_resume_and_get() to tidy up some boilerplate.
The coccicheck script didn't get this one due to the less obvious
structure. Found by inspection.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-8-jic23@kernel.org
3 years agoiio: accel: mma9551/3: Balance untime pm + use pm_runtime_resume_and_get()
Jonathan Cameron [Sun, 9 May 2021 11:33:32 +0000 (12:33 +0100)]
iio: accel: mma9551/3: Balance untime pm + use pm_runtime_resume_and_get()

Both these drivers call pm_runtime_put_no_idle() when the reference
count should already be zero as there is no matching get()

Whilst here use pm_runtime_resume_and_get() rather than open coding.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-7-jic23@kernel.org
3 years agoiio: accel: bmc150-accel: Balanced runtime pm + use pm_runtime_resume_and_get()
Jonathan Cameron [Sun, 9 May 2021 11:33:30 +0000 (12:33 +0100)]
iio: accel: bmc150-accel: Balanced runtime pm + use pm_runtime_resume_and_get()

A call to pm_runtime_put_noidle() doesn't match any call that would
result in a get().  It is safe because runtime pm core protects against
the reference counter going 0, but it makes it harder to understand the
code.

Whilst here use pm_runtime_resume_and_get() to tidy things up.
The Coccinelle script didn't get this one due to more complex code
structure.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-5-jic23@kernel.org
3 years agoiio: light: tsl2583: Balance runtime pm + use pm_runtime_resume_and_get()
Jonathan Cameron [Sun, 9 May 2021 11:33:29 +0000 (12:33 +0100)]
iio: light: tsl2583: Balance runtime pm + use pm_runtime_resume_and_get()

Error paths in read_raw() and write_raw() callbacks failed to perform and
type of runtime pm put().  Remove called pm_runtime_put_noidle()
but there is no equivalent get (this is safe because the reference
count is protected against going below zero, but it is misleading.

Whilst here use pm_runtime_resume_and_get() to replace boilerplate.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Brian Masney <masneyb@onstation.org>
Reviewed-by: Brian Masney <masneyb@onstation.org>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-4-jic23@kernel.org
3 years agoiio: light: isl29028: Balance runtime pm + use pm_runtime_resume_and_get()
Jonathan Cameron [Sun, 9 May 2021 11:33:28 +0000 (12:33 +0100)]
iio: light: isl29028: Balance runtime pm + use pm_runtime_resume_and_get()

In remove this driver called pm_runtime_put_noidle() but there is
no matching get operation.  This does not cause any problems because
the reference counter will not change if already zero, but it
does make the code harder to reason about so should be dropped.

Whilst we are here, use pm_runtime_resume_and_get() to replace open
coded version.
Found using coccicheck script under review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-3-jic23@kernel.org
3 years agoiio: gyro: fxa21002c: Balance runtime pm + use pm_runtime_resume_and_get().
Jonathan Cameron [Sun, 9 May 2021 11:33:27 +0000 (12:33 +0100)]
iio: gyro: fxa21002c: Balance runtime pm + use pm_runtime_resume_and_get().

In both the probe() error path and remove() pm_runtime_put_noidle()
is called which will decrement the runtime pm reference count.
However, there is no matching function to have raised the reference count.
Not this isn't a fix as the runtime pm core will stop the reference count
going negative anyway.

An alternative would have been to raise the count in these paths, but
it is not clear why that would be necessary.

Whilst we are here replace some boilerplate with pm_runtime_resume_and_get()
Found using coccicheck script under review at:
https://lore.kernel.org/lkml/20210427141946.2478411-1-Julia.Lawall@inria.fr/

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/20210509113354.660190-2-jic23@kernel.org
3 years agoiio: accel: kxcjk-1013: Add support for KX023-1025
Stephan Gerhold [Tue, 11 May 2021 14:24:02 +0000 (16:24 +0200)]
iio: accel: kxcjk-1013: Add support for KX023-1025

The KX023-1025 accelerometer [1] seems to be some mixture of
KXCJK and KXTF9. It has the motion interrupt functionality from KXCJK
but also the tap detection from KXTF9, and a lot more functionality.

The configuration register map seems fairly different at first,
but actually all register bits used by the kxcjk-1013 driver are
available at the same bit positions on KX023-1025. It's just quite
misleading because:

  1. The registers have entirely different names and are at different
     addresses, but the bits are mostly named the same (and mean the same).
  2. There are many more registers and bits used that are reserved on KXCJK
     to enable additional functionality.

Ignoring all additionally available functionality for now, the KX023
works just fine after setting up the struct with the correct register
addresses. The only difference that needs to be handled additionally
is that the KX023 supports two configurable interrupt lines (INT1/2).

For now only INT1 is supported so we route all interrupts used by
the driver there.

[1]: https://kionixfs.azureedge.net/en/datasheet/KX023-1025%20Specifications%20Rev%2012.0.pdf

Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: kxcjk-1013: Refactor configuration registers into struct
Stephan Gerhold [Tue, 11 May 2021 14:24:01 +0000 (16:24 +0200)]
iio: accel: kxcjk-1013: Refactor configuration registers into struct

Most Kionix accelerometers seem to use fairly consistent register bits,
but the register addresses are not necessarily the same. This is already
partially the case for the KXTF9 (added in commit 1540d0106bcb
("iio: accel: kxcjk1013: add support for KXTF9")), which has some
registers at different addresses.

However, it's even much worse for the KX023-1025. All register bits
used by the kxcjk-1013 driver seem to be fully compatible with KX023,
but it has most registers at totally different addresses.

In preparation to add support for KX023-1025, move the fixed register
addresses into a struct so we can change them for KX023 more easily.

Cc: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings: iio: kionix,kxcjk1013: Document kionix,kx023-1025
Stephan Gerhold [Tue, 11 May 2021 14:24:00 +0000 (16:24 +0200)]
dt-bindings: iio: kionix,kxcjk1013: Document kionix,kx023-1025

The KX023-1025 accelerometer uses similar register bits as kxcjk1023,
so it can make use of the same driver. Document the new kionix,kx023-1025
compatible that is also supported by the kxcjk-1013 driver now.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: adc: Add missing MODULE_DEVICE_TABLE
Chunyan Zhang [Wed, 12 May 2021 09:38:44 +0000 (17:38 +0800)]
iio: adc: Add missing MODULE_DEVICE_TABLE

MODULE_DEVICE_TABLE is used to extract the device information out of the
driver and builds a table when being compiled. If using this macro,
kernel can find the driver if available when the device is plugged in,
and then loads that driver and initializes the device.

Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings: iio: afe: current-sense-shunt: add io-channel-cells
Krzysztof Kozlowski [Thu, 6 May 2021 15:06:37 +0000 (11:06 -0400)]
dt-bindings: iio: afe: current-sense-shunt: add io-channel-cells

The current-sense-shunt is an IIO provider thus can be referenced by IIO
consumers (via "io-channels" property in consumer device node).
Such provider is required to describe number of cells used in phandle
lookup with "io-channel-cells" property.  This also fixes dtbs_check
warnings like:

  arch/arm/boot/dts/s5pv210-fascinate4g.dt.yaml: current-sense-shunt:
    '#io-channel-cells' does not match any of the regexes: 'pinctrl-[0-9]+'

Fixes: ce66e52b6c16 ("dt-bindings:iio:afe:current-sense-shunt: txt to yaml conversion.")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: ep93xx: Remove redundant error printing in ep93xx_adc_probe()
Zhen Lei [Tue, 11 May 2021 11:39:12 +0000 (19:39 +0800)]
iio: ep93xx: Remove redundant error printing in ep93xx_adc_probe()

When devm_ioremap_resource() fails, a clear enough error message will be
printed by its subfunction __devm_ioremap_resource(). The error
information contains the device name, failure cause, and possibly resource
information.

Therefore, remove the error printing here to simplify code and reduce the
binary size.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: fxls8962af: fix errata bug E3 - I2C burst reads
Sean Nyekjaer [Thu, 6 May 2021 07:09:40 +0000 (09:09 +0200)]
iio: accel: fxls8962af: fix errata bug E3 - I2C burst reads

When flushing the hw fifo there is a bug in the I2C that prevents burst
reads of more than one sample pair.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: fxls8962af: add hw buffered sampling
Sean Nyekjaer [Thu, 6 May 2021 07:09:39 +0000 (09:09 +0200)]
iio: accel: fxls8962af: add hw buffered sampling

When buffered sampling is enabled, the accelerometer will dump data into
the internal fifo and interrupt at watermark. Then the driver flushes
all data to the iio buffer.
As the accelerometer doesn't have internal timestamps, they are
approximated between the current and last interrupt.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: fxls8962af: add interrupt support
Sean Nyekjaer [Thu, 6 May 2021 07:09:38 +0000 (09:09 +0200)]
iio: accel: fxls8962af: add interrupt support

Preparation commit for the next that adds hw buffered sampling.
Adds the interrupt function and reads the devicetree for which
interrupt pin that is used.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: fxls8962af: add set/get of samplerate
Sean Nyekjaer [Thu, 6 May 2021 07:09:37 +0000 (09:09 +0200)]
iio: accel: fxls8962af: add set/get of samplerate

This adds support for setting de accelerometers output data rate.
Primarily used for hardware buffered reads.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings: iio: accel: fxls8962af: add bindings
Sean Nyekjaer [Thu, 6 May 2021 07:09:36 +0000 (09:09 +0200)]
dt-bindings: iio: accel: fxls8962af: add bindings

Add devicetree binding for the NXP FXLS8962AF/FXLS8964AF
accelerometer sensor.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: add support for FXLS8962AF/FXLS8964AF accelerometers
Sean Nyekjaer [Thu, 6 May 2021 07:09:35 +0000 (09:09 +0200)]
iio: accel: add support for FXLS8962AF/FXLS8964AF accelerometers

Add basic support for NXP FXLS8962AF/FXLS8964AF Automotive
accelerometers.
It will allow setting up scale/gain and reading x,y,z
axis.

Datasheet: https://www.nxp.com/docs/en/data-sheet/FXLS8962AF.pdf
Datasheet: https://www.nxp.com/docs/en/data-sheet/FXLS8964AF.pdf
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: imu: st_lsm6dsx: correct ODR in header
Sean Nyekjaer [Fri, 7 May 2021 10:31:49 +0000 (12:31 +0200)]
iio: imu: st_lsm6dsx: correct ODR in header

Fix wrongly stated 13 Hz ODR for accelerometers, the correct ODR is 12.5 Hz

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: bme680_i2c: Remove acpi_device_id table
Guenter Roeck [Thu, 6 May 2021 03:43:32 +0000 (20:43 -0700)]
iio: bme680_i2c: Remove acpi_device_id table

With CONFIG_ACPI=n and -Werror, 0-day reports:

drivers/iio/chemical/bme680_i2c.c:46:36: error:
'bme680_acpi_match' defined but not used

Apparently BME0680 is not a valid ACPI ID. Remove the ID.

Note the driver will still work with ACPI bindings that use the PRP0001
mechanism as that uses the of_device_id table instead.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: bme680_spi: Remove acpi_device_id table
Guenter Roeck [Thu, 6 May 2021 13:31:45 +0000 (06:31 -0700)]
iio: bme680_spi: Remove acpi_device_id table

BME0680 is not an official ACPI ID, so let's remove it before someone
starts using it.

Note that ACPI can still be used with this driver via the PRP0001 method
which will use the of_device_id table to match.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio:accel:stk8312: Remove acpi_device_id table
Guenter Roeck [Thu, 6 May 2021 03:56:59 +0000 (20:56 -0700)]
iio:accel:stk8312: Remove acpi_device_id table

With CONFIG_ACPI=n, W=1 and -Werror, 0-day reports:

drivers/iio/accel/stk8312.c:644:36: error:
'stk8312_acpi_id' defined but not used

Apparently STK8312 is not a valid ACPI ID. Remove the ID table
as this is the only entry.  If ACPI support is desired an explicit
of_device_id table should be added (rather than relying on the fallback
to the existing ID table).

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: am2315: Remove acpi_device_id table
Guenter Roeck [Tue, 4 May 2021 15:37:46 +0000 (08:37 -0700)]
iio: am2315: Remove acpi_device_id table

With CONFIG_ACPI=n and -Werror, 0-day reports:

drivers/iio/humidity/am2315.c:259:36: error:
'am2315_acpi_id' defined but not used

According to Andy Shevchenko, the ACPI ID used in this driver is fake
and does not really exist. Remove it and with it ACPI support from
the driver.

Note that, if an explicit of_device_id table is added to the driver
it could support the PRP0001 based ACPI approach.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agodt-bindings:iio:dac:ad5755: txt to yaml format conversion.
Jonathan Cameron [Sat, 24 Apr 2021 17:30:15 +0000 (18:30 +0100)]
dt-bindings:iio:dac:ad5755: txt to yaml format conversion.

Straight forward conversion.  Only fiddly bit is the XOR of
spi-cpol and spi-cpha.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
Link: https://lore.kernel.org/r/20201031184854.745828-40-jic23@kernel.org
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210424173015.534941-1-jic23@kernel.org
3 years agodt-bindings: iio: st,st-sensors: Add LSM9DS0 compatible string
Andy Shevchenko [Wed, 14 Apr 2021 19:54:54 +0000 (22:54 +0300)]
dt-bindings: iio: st,st-sensors: Add LSM9DS0 compatible string

Enumerate LSM9DS0 (accelerometer and magnetometer parts) via
'st,lsm9ds0-imu' compatible string.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20210414195454.84183-7-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: st_sensors: Add lsm9ds0 IMU support
Andy Shevchenko [Wed, 14 Apr 2021 19:54:53 +0000 (22:54 +0300)]
iio: st_sensors: Add lsm9ds0 IMU support

We can utilize separate drivers for accelerometer and magnetometer,
so here is the glue driver to enable LSM9DS0 IMU support.

The idea was suggested by Crestez Dan Leonard in [1]. The proposed change
was sent as RFC due to race condition concerns, which are indeed possible.

In order to amend the initial change, I went further by providing a specific
multi-instantiate probe driver that reuses existing accelerometer and
magnetometer.

[1]: https://lore.kernel.org/patchwork/patch/670353/

Suggested-by: Crestez Dan Leonard <leonard.crestez@intel.com>
Cc: mr.lahorde@laposte.net
Cc: Matija Podravec <matija_podravec@fastmail.fm>
Cc: Sergey Borishchenko <borischenko.sergey@gmail.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210414195454.84183-6-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: st_sensors: Make accel, gyro, magn and pressure probe shared
Andy Shevchenko [Wed, 14 Apr 2021 19:54:52 +0000 (22:54 +0300)]
iio: st_sensors: Make accel, gyro, magn and pressure probe shared

Some IMUs may utilize existing library code for STMicro accelerometer,
gyroscope, magnetometer and pressure. Let's share them via st_sensors.h.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210414195454.84183-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: st_sensors: Call st_sensors_power_enable() from bus drivers
Andy Shevchenko [Wed, 14 Apr 2021 19:54:51 +0000 (22:54 +0300)]
iio: st_sensors: Call st_sensors_power_enable() from bus drivers

In case we would initialize two IIO devices from one physical device,
we shouldn't have a clash on regulators. That's why move
st_sensors_power_enable() call from core to bus drivers.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210414195454.84183-4-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: magnetometer: st_magn: Provide default platform data
Andy Shevchenko [Wed, 14 Apr 2021 19:54:50 +0000 (22:54 +0300)]
iio: magnetometer: st_magn: Provide default platform data

Provide default platform data for magnetometer in case it supports DRDY.

One case is LSM9DS0 IMU, on which it is the case. Since accelerometer
is using INT1, default magnetometer to INT2.

While at it, update description of the drdy_int_pin field.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210414195454.84183-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: gyro: st_gyro: Move platform data from header to C file
Andy Shevchenko [Wed, 14 Apr 2021 19:54:49 +0000 (22:54 +0300)]
iio: gyro: st_gyro: Move platform data from header to C file

Platform data is solely used by one file. Don't share it with others.

While at it, drop unneeded anymore __maybe_unused and fix kernel doc
to avoid warning:

  st_gyro_core.c:366: error: Cannot parse struct or union!

by converting to a simple comment. It is described at the declaration.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210414195454.84183-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: accel: st_accel: Move platform data from header to C file
Andy Shevchenko [Wed, 14 Apr 2021 19:54:48 +0000 (22:54 +0300)]
iio: accel: st_accel: Move platform data from header to C file

Platform data is solely used by one file. Don't share it with others.

While at it, drop unneeded anymore __maybe_unused and fix kernel doc
to avoid warning:

  st_accel_core.c:1079: error: Cannot parse struct or union!

by converting to a simple comment. It is described at the declaration.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210414195454.84183-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
3 years agoiio: core: move @clock_id from struct iio_dev to struct iio_dev_opaque
Jonathan Cameron [Mon, 26 Apr 2021 17:49:11 +0000 (18:49 +0100)]
iio: core: move @clock_id from struct iio_dev to struct iio_dev_opaque

There is already an acessor function used to access it, making this
move straight forward.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-10-jic23@kernel.org
3 years agoiio: core: move @flags from struct iio_dev to struct iio_dev_opaque
Jonathan Cameron [Mon, 26 Apr 2021 17:49:10 +0000 (18:49 +0100)]
iio: core: move @flags from struct iio_dev to struct iio_dev_opaque

No reason any driver should ever need access to this field, so hide it.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-9-jic23@kernel.org
3 years agoiio: core: move @chrdev from struct iio_dev to struct iio_dev_opaque
Jonathan Cameron [Mon, 26 Apr 2021 17:49:09 +0000 (18:49 +0100)]
iio: core: move @chrdev from struct iio_dev to struct iio_dev_opaque

No reason for this to be exposed to the drivers, so lets move it to the
opaque structure.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-8-jic23@kernel.org