]> www.infradead.org Git - users/jedix/linux-maple.git/log
users/jedix/linux-maple.git
8 months agoiio: iio-mux: kzalloc instead of devm_kzalloc to ensure page alignment
Matteo Martelli [Mon, 2 Dec 2024 15:11:08 +0000 (16:11 +0100)]
iio: iio-mux: kzalloc instead of devm_kzalloc to ensure page alignment

During channel configuration, the iio-mux driver allocates a page with
devm_kzalloc(PAGE_SIZE) to read channel ext_info. However, the resulting
buffer points to an offset of the page due to the devres header sitting
at the beginning of the allocated area. This leads to failure in the
provider driver when sysfs_emit* helpers are used to format the ext_info
attributes.

Switch to plain kzalloc version. The devres version is not strictly
necessary as the buffer is only accessed during the channel
configuration phase. Rely on __free cleanup to deallocate the buffer.
Also, move the ext_info handling into a new function to have the page
buffer definition and assignment in one statement as suggested by
cleanup documentation.

Signed-off-by: Matteo Martelli <matteomartelli3@gmail.com>
Fixes: 7ba9df54b091 ("iio: multiplexer: new iio category and iio-mux driver")
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20241202-iio-kmalloc-align-v1-2-aa9568c03937@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: adc: ad7625: Add ending newlines to error messages
Uwe Kleine-König [Mon, 30 Dec 2024 15:10:31 +0000 (16:10 +0100)]
iio: adc: ad7625: Add ending newlines to error messages

Error messages passed to dev_err_probe() are supposed to end in "\n".
Fix accordingly.

Fixes: b7ffd0fa65e9 ("iio: adc: ad7625: add driver")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Tested-by: Trevor Gamblin <tgamblin@baylibre.com>
Link: https://patch.msgid.link/20241230151030.3207529-2-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: accel: adxl345: complete the list of defines
Lothar Rubusch [Sat, 28 Dec 2024 23:29:49 +0000 (23:29 +0000)]
iio: accel: adxl345: complete the list of defines

Having interrupts events and FIFO available allows to evaluate the
sensor events. Cover the list of interrupt based sensor events. Keep
them in the header file for readability.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20241228232949.72487-5-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: accel: adxl345: add FIFO with watermark events
Lothar Rubusch [Sat, 28 Dec 2024 23:29:48 +0000 (23:29 +0000)]
iio: accel: adxl345: add FIFO with watermark events

Add a basic setup for FIFO with configurable watermark. Add a handler
for watermark interrupt events and extend the channel for the
scan_index needed for the iio channel. The sensor is configurable to use
a FIFO_BYPASSED mode or a FIFO_STREAM mode. For the FIFO_STREAM mode now
a watermark can be configured, or disabled by setting 0. Further features
require a working FIFO setup.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20241228232949.72487-4-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: accel: adxl345: initialize FIFO delay value for SPI
Lothar Rubusch [Sat, 28 Dec 2024 23:29:47 +0000 (23:29 +0000)]
iio: accel: adxl345: initialize FIFO delay value for SPI

Add the possibility to delay FIFO access when SPI is used. According to
the datasheet this is needed for the adxl345. When initialization
happens over SPI the need for delay is to be signalized, and the delay
will be used.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20241228232949.72487-3-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: accel: adxl345: introduce interrupt handling
Lothar Rubusch [Sat, 28 Dec 2024 23:29:46 +0000 (23:29 +0000)]
iio: accel: adxl345: introduce interrupt handling

Add the possibility to claim an interrupt. Init the state structure
with an interrupt line obtained from the DT. The adxl345 can use
two different interrupt lines for event handling. Only one is used.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20241228232949.72487-2-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: light: veml3235: fix scale to conform to ABI
Javier Carrasco [Mon, 30 Dec 2024 15:13:53 +0000 (16:13 +0100)]
iio: light: veml3235: fix scale to conform to ABI

The current scale is not ABI-compliant as it is just the sensor gain
instead of the value that acts as a multiplier to be applied to the raw
value (there is no offset).

Use the iio-gts helpers to obtain the proper scale values according to
the gain and integration time to match the resolution tables from the
datasheet. When at it, use 'scale' instead of 'gain' consistently for
the get/set functions to avoid misunderstandings.

Fixes: c5a23f80c164 ("iio: light: add support for veml3235")
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20241230-veml3235_scale-v3-2-48a5795e2f64@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: gts-helper: add helpers to ease searches of gain_sel and new_gain
Javier Carrasco [Mon, 30 Dec 2024 15:13:52 +0000 (16:13 +0100)]
iio: gts-helper: add helpers to ease searches of gain_sel and new_gain

This helper functions reduce the burden in the drivers that want to
fetch a gain and time selector for a given scale or a new optimal gain.

The former is currently achieved by calling
iio_gts_find_gain_sel_for_scale_using_time() for the current time
selector, and then iterating over the rest of time selectors if the
gain selector was not found.

The latter requires a combination of multiple iio-gts helpers to find
the new gain, look for an optimal gain if there was no exact match, and
set a minimum gain if the optimal gain is not in the range of available
gains.

Provide simpler workflows by means of functions that address common
patterns in the users of the iio-gts helpers.

Acked-by: Matti Vaittinen <mazziesaccount@gmail.com>
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20241230-veml3235_scale-v3-1-48a5795e2f64@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: light: veml3235: extend regmap to add cache
Javier Carrasco [Tue, 24 Dec 2024 10:59:02 +0000 (11:59 +0100)]
iio: light: veml3235: extend regmap to add cache

The configuration and ID registers are not volatile and are not affected
by read operations (i.e. not precious), making them suitable to be
cached in order to reduce the number of accesses to the device.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20241224-veml3235_scale-v2-3-2e1286846c77@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: light: veml3235: fix code style
Javier Carrasco [Tue, 24 Dec 2024 10:59:01 +0000 (11:59 +0100)]
iio: light: veml3235: fix code style

Trivial fixes to drop double spacings.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20241224-veml3235_scale-v2-2-2e1286846c77@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agodt-bindings: iio: accel: adxl345: add interrupt-names
Lothar Rubusch [Wed, 25 Dec 2024 18:13:34 +0000 (18:13 +0000)]
dt-bindings: iio: accel: adxl345: add interrupt-names

Add interrupt-names INT1 and INT2 for the two interrupt lines of the
sensor.

When one of the two interrupt lines is connected, the interrupt as its
interrupt-name, need to be declared in the devicetree. The driver then
configures the sensor to indicate its events on either INT1 or INT2.

If no interrupt is configured, then no interrupt-name should be
configured, and vice versa. In this case the sensor runs in FIFO BYPASS
mode. This allows sensor measurements, but none of the sensor events.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20241225181338.69672-4-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agodt-bindings: iio: accel: adxl345: make interrupts not a required property
Lothar Rubusch [Wed, 25 Dec 2024 18:13:33 +0000 (18:13 +0000)]
dt-bindings: iio: accel: adxl345: make interrupts not a required property

Remove interrupts from the list of required properties. The ADXL345
does not need interrupts for basic accelerometer functionality.

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20241225181338.69672-3-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agodt-bindings: iio: imu: bmi323: add boolean type for drive-open-drain
Vasileios Amoiridis [Thu, 19 Dec 2024 23:47:45 +0000 (00:47 +0100)]
dt-bindings: iio: imu: bmi323: add boolean type for drive-open-drain

Add missing type description "boolean" for the drive-open-drain property.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/20241219234745.58723-4-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agodt-bindings: iio: imu: bmi270: add boolean type for drive-open-drain
Vasileios Amoiridis [Thu, 19 Dec 2024 23:47:44 +0000 (00:47 +0100)]
dt-bindings: iio: imu: bmi270: add boolean type for drive-open-drain

Add missing type description "boolean" for the drive-open-drain property.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Reviewed-by: Alex Lanzano <lanzano.alex@gmail.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/20241219234745.58723-3-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agodt-bindings: iio: imu: bmi160: add boolean type for drive-open-drain
Vasileios Amoiridis [Thu, 19 Dec 2024 23:47:43 +0000 (00:47 +0100)]
dt-bindings: iio: imu: bmi160: add boolean type for drive-open-drain

Add missing type description "boolean" for the drive-open-drain property.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/20241219234745.58723-2-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: adc: meson: simplify MESON_SAR_ADC_REG11 register access
Martin Blumenstingl [Tue, 24 Dec 2024 14:29:41 +0000 (15:29 +0100)]
iio: adc: meson: simplify MESON_SAR_ADC_REG11 register access

Simply check the max_register value to decide whether
MESON_SAR_ADC_REG11 is present on the current IP revision. This allows
dropping two additional bool fields from struct meson_sar_adc_param
which previously had to be manually kept in sync. No functional changes
intended.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://patch.msgid.link/20241224142941.97759-4-martin.blumenstingl@googlemail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: adc: meson: use tabs instead of spaces for some REG11 bit fields
Martin Blumenstingl [Tue, 24 Dec 2024 14:29:40 +0000 (15:29 +0100)]
iio: adc: meson: use tabs instead of spaces for some REG11 bit fields

This makes them consistent with the rest of the driver. No functional
changes.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://patch.msgid.link/20241224142941.97759-3-martin.blumenstingl@googlemail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: adc: meson: fix voltage reference selection field name typo
Martin Blumenstingl [Tue, 24 Dec 2024 14:29:39 +0000 (15:29 +0100)]
iio: adc: meson: fix voltage reference selection field name typo

The field should be called "vref_voltage", without a typo in the word
voltage. No functional changes intended.

Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://patch.msgid.link/20241224142941.97759-2-martin.blumenstingl@googlemail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: adc: rockchip: correct alignment of timestamp
Jonathan Cameron [Sun, 15 Dec 2024 18:29:11 +0000 (18:29 +0000)]
iio: adc: rockchip: correct alignment of timestamp

I assume this device is only used on architectures where a 8 byte
integer type is always 8 byte aligned.  However, I would prefer IIO
drivers to never make that assumption as the code gets copied into
new drivers which are not so tightly couple to one driver and those
can run on architectures that align these types to only 4 bytes in which
case this structure may be 4 byte to small leading to a buffer overrun.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-21-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: imu: inv_icm42600: switch timestamp type from int64_t __aligned(8) to aligned_s64
Jonathan Cameron [Sun, 15 Dec 2024 18:29:09 +0000 (18:29 +0000)]
iio: imu: inv_icm42600: switch timestamp type from int64_t __aligned(8) to aligned_s64

The vast majority of IIO drivers use aligned_s64 for the type of the
timestamp field.  It is not a bug to use int64_t and until this series
iio_push_to_buffers_with_timestamp() took and int64_t timestamp, it
is inconsistent.  This change is to remove that inconsistency and
ensure there is one obvious choice for future drivers.

Acked-by: Jean-Baptiste Maneyrol <jean-baptiste.maneyrol@tdk.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-19-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: chemical: scd4x: switch timestamp type from int64_t __aligned(8) to aligned_s64
Jonathan Cameron [Sun, 15 Dec 2024 18:29:08 +0000 (18:29 +0000)]
iio: chemical: scd4x: switch timestamp type from int64_t __aligned(8) to aligned_s64

The vast majority of IIO drivers use aligned_s64 for the type of the
timestamp field.  It is not a bug to use int64_t and until this series
iio_push_to_buffers_with_timestamp() took and int64_t timestamp, it
is inconsistent.  This change is to remove that inconsistency and
ensure there is one obvious choice for future drivers.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-18-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: adc: ti-lmp92064: Switch timestamp type from int64_t __aligned(8) to aligned_s64
Jonathan Cameron [Sun, 15 Dec 2024 18:29:07 +0000 (18:29 +0000)]
iio: adc: ti-lmp92064: Switch timestamp type from int64_t __aligned(8) to aligned_s64

The vast majority of IIO drivers use aligned_s64 for the type of the
timestamp field.  It is not a bug to use int64_t and until this series
iio_push_to_buffers_with_timestamp() took and int64_t timestamp, it
is inconsistent.  This change is to remove that inconsistency and
ensure there is one obvious choice for future drivers.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-17-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: accel: bma220: Use aligned_s64 instead of open coding alignment.
Jonathan Cameron [Sun, 15 Dec 2024 18:29:05 +0000 (18:29 +0000)]
iio: accel: bma220: Use aligned_s64 instead of open coding alignment.

Use this new type to both slightly simplify the code and avoid
confusing static analysis tools. Mostly this series is about consistency
to avoid this code pattern getting copied into more drivers.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-15-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: adc: Use aligned_s64 instead of open coding alignment.
Jonathan Cameron [Sun, 15 Dec 2024 18:29:04 +0000 (18:29 +0000)]
iio: adc: Use aligned_s64 instead of open coding alignment.

Use this new type to both slightly simplify the code and avoid
confusing static analysis tools. Mostly this series is about consistency
to avoid this code pattern getting copied into more drivers.

Acked-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-14-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: chemical: Use aligned_s64 instead of open coding alignment.
Jonathan Cameron [Sun, 15 Dec 2024 18:29:03 +0000 (18:29 +0000)]
iio: chemical: Use aligned_s64 instead of open coding alignment.

Use this new type to both slightly simplify the code and avoid
confusing static analysis tools. Mostly this series is about consistency
to avoid this code pattern getting copied into more drivers.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-13-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: gyro: Use aligned_s64 instead of open coding alignment.
Jonathan Cameron [Sun, 15 Dec 2024 18:29:02 +0000 (18:29 +0000)]
iio: gyro: Use aligned_s64 instead of open coding alignment.

Use this new type to both slightly simplify the code and avoid
confusing static analysis tools. Mostly this series is about consistency
to avoid this code pattern getting copied into more drivers.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-12-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: humidity: Use aligned_s64 instead of open coding alignment.
Jonathan Cameron [Sun, 15 Dec 2024 18:29:01 +0000 (18:29 +0000)]
iio: humidity: Use aligned_s64 instead of open coding alignment.

Use this new type to both slightly simplify the code and avoid
confusing static analysis tools. Mostly this series is about consistency
to avoid this code pattern getting copied into more drivers.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-11-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: imu: Use aligned_s64 instead of open coding alignment.
Jonathan Cameron [Sun, 15 Dec 2024 18:29:00 +0000 (18:29 +0000)]
iio: imu: Use aligned_s64 instead of open coding alignment.

Use this new type to both slightly simplify the code and avoid
confusing static analysis tools. Mostly this series is about consistency
to avoid this code pattern getting copied into more drivers.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-10-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: light: Use aligned_s64 instead of open coding alignment.
Jonathan Cameron [Sun, 15 Dec 2024 18:28:59 +0000 (18:28 +0000)]
iio: light: Use aligned_s64 instead of open coding alignment.

Use this new type to both slightly simplify the code and avoid
confusing static analysis tools. Mostly this series is about consistency
to avoid this code pattern getting copied into more drivers.

Acked-By: Matti Vaittinen <mazziesaccount@gmail.com> #For bu27034, rpr0521
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-9-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: magnetometer: Use aligned_s64 instead of open coding alignment.
Jonathan Cameron [Sun, 15 Dec 2024 18:28:58 +0000 (18:28 +0000)]
iio: magnetometer: Use aligned_s64 instead of open coding alignment.

Use this new type to both slightly simplify the code and avoid
confusing static analysis tools. Mostly this series is about consistency
to avoid this code pattern getting copied into more drivers.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-8-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: pressure: Use aligned_s64 instead of open coding alignment.
Jonathan Cameron [Sun, 15 Dec 2024 18:28:57 +0000 (18:28 +0000)]
iio: pressure: Use aligned_s64 instead of open coding alignment.

Use this new type to both slightly simplify the code and avoid
confusing static analysis tools. Mostly this series is about consistency
to avoid this code pattern getting copied into more drivers.

Acked-By: Matti Vaittinen <mazziesaccount@gmail.com> #for the BD1390
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-7-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: proximity: Use aligned_s64 instead of open coding alignment.
Jonathan Cameron [Sun, 15 Dec 2024 18:28:56 +0000 (18:28 +0000)]
iio: proximity: Use aligned_s64 instead of open coding alignment.

Use this new type to both slightly simplify the code and avoid
confusing static analysis tools. Mostly this series is about consistency
to avoid this code pattern getting copied into more drivers.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-6-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: resolver: ad2s1210: Use aligned_s64 instead of open coding alignment.
Jonathan Cameron [Sun, 15 Dec 2024 18:28:55 +0000 (18:28 +0000)]
iio: resolver: ad2s1210: Use aligned_s64 instead of open coding alignment.

Use this new type to both slightly simplify the code and avoid
confusing static analysis tools. Mostly this series is about consistency
to avoid this code pattern getting copied into more drivers.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-5-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: temperature: tmp006: Use aligned_s64 instead of open coding alignment.
Jonathan Cameron [Sun, 15 Dec 2024 18:28:54 +0000 (18:28 +0000)]
iio: temperature: tmp006: Use aligned_s64 instead of open coding alignment.

Use this new type to both slightly simplify the code and avoid
confusing static analysis tools. Mostly this series is about consistency
to avoid this code pattern getting copied into more drivers.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-4-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoio: adc: ina2xx-adc: Fix sign and use aligned_s64 for timestamp.
Jonathan Cameron [Sun, 15 Dec 2024 18:28:53 +0000 (18:28 +0000)]
io: adc: ina2xx-adc: Fix sign and use aligned_s64 for timestamp.

Whilst it doesn't actually make any difference because the code
that fills this field doesn't care, timestamps are all signed.
Use the new aligned_s64 instead of open coding alignment to avoid
confusing static analyzers and give slightly cleaner code.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-3-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: adc: ad7944: Fix sign and use aligned_s64 for timestamp.
Jonathan Cameron [Sun, 15 Dec 2024 18:28:52 +0000 (18:28 +0000)]
iio: adc: ad7944: Fix sign and use aligned_s64 for timestamp.

Whilst it doesn't actually make any difference because the code
that fills this field doesn't care, timestamps are all signed.
Use the new aligned_s64 instead of open coding alignment to avoid
confusing static analyzers and give slightly cleaner code.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20241215182912.481706-2-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: ABI: combine current input sections
David Lechner [Thu, 19 Dec 2024 19:25:23 +0000 (13:25 -0600)]
iio: ABI: combine current input sections

Combine two duplicate sections describing in_currentY_raw.

This went unnoticed until we renamed in_currentX_raw to in_currentY_raw
and the kernel test robot found the duplication.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202412200256.OB5Hmw5Q-lkp@intel.com/
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20241219-iio-abi-combine-current-input-sections-v1-1-8dcd8221d469@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: trigger: stm32-timer: add support for stm32mp25
Fabrice Gasnier [Fri, 20 Dec 2024 09:59:21 +0000 (10:59 +0100)]
iio: trigger: stm32-timer: add support for stm32mp25

Add support for STM32MP25 SoC. Use newly introduced compatible to handle
this new HW variant. Add TIM20 trigger definitions that can be used by
the stm32 analog-to-digital converter. Use compatible data to identify
it.
As the counter framework is now superseding the deprecated IIO counter
interface (IIO_COUNT), don't support it. Only register IIO trigger
devices for ADC usage. So, make the valids_table a cfg option.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://patch.msgid.link/20241220095927.1122782-4-fabrice.gasnier@foss.st.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: proximity: hx9023s: Added firmware file parsing functionality
Yasin Lee [Mon, 16 Dec 2024 07:59:40 +0000 (15:59 +0800)]
iio: proximity: hx9023s: Added firmware file parsing functionality

Configuration information is now prioritized from the firmware file.
If the firmware file is missing or fails to parse, the driver falls
back to using the default configuration list for writing the settings.

Signed-off-by: Yasin Lee <yasin.lee.x@gmail.com>
Link: https://patch.msgid.link/20241216-hx9023s-firmware-20241209-v2-1-ce1b0a1121d0@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoMAINTAINERS: Add maintainer for ROHM BD79703
Matti Vaittinen [Thu, 19 Dec 2024 11:39:55 +0000 (13:39 +0200)]
MAINTAINERS: Add maintainer for ROHM BD79703

Add undersigned as a maintainer for the ROHM BD79703 DAC driver.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/5e99d4153b61a0d62174b8bde2ba6ae49da1e970.1734608215.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: dac: Support ROHM BD79703 DAC
Matti Vaittinen [Thu, 19 Dec 2024 11:39:37 +0000 (13:39 +0200)]
iio: dac: Support ROHM BD79703 DAC

The ROHM BD79703 is a 6 channel digital to analog converter.

Based on the data-sheet examples the hardware would support setting the
DAC word without changing the actual output. The data-sheet is not too
specific on how the enabling the output of new voltage set by DAC
should be done - hence this is not implemented by the driver.

The BD79703 would also support two specific "PULL_DOWN" modes. These
aren't currently supported by the driver either.

Add a very basic support for controlling the channel outputs one-by-one.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/bc77d7b979ca28408a216f597082fcd94ec63be7.1734608215.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agodt-bindings: Add ROHM BD79703
Matti Vaittinen [Thu, 19 Dec 2024 11:39:11 +0000 (13:39 +0200)]
dt-bindings: Add ROHM BD79703

The ROHM BD79703 is a 8-bit, 6 channel DAC.

Describe the dt-bindings.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/51ed31c494ea7385940b59500e8592d12558e291.1734608215.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: imu: bno055: constify 'struct bin_attribute'
Thomas Weißschuh [Sun, 15 Dec 2024 15:21:24 +0000 (16:21 +0100)]
iio: imu: bno055: constify 'struct bin_attribute'

The sysfs core now allows instances of 'struct bin_attribute' to be
moved into read-only memory. Make use of that to protect them against
accidental or malicious modifications.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://patch.msgid.link/20241215-sysfs-const-bin_attr-iio-v1-1-a5801212482e@weissschuh.net
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: core: mark scan_timestamp as __private
Vasileios Amoiridis [Sat, 14 Dec 2024 19:14:21 +0000 (20:14 +0100)]
iio: core: mark scan_timestamp as __private

Since there are no more direct accesses to the indio_dev->scan_timestamp
value, it can be marked as __private and use the macro ACCESS_PRIVATE()
in order to access it. Like this, static checkers will be able to inform
in case someone tries to either write to the value, or read its value
directly.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20241214191421.94172-5-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: common: ssp_sensors: drop conditional optimization for simplicity
Vasileios Amoiridis [Sat, 14 Dec 2024 19:14:20 +0000 (20:14 +0100)]
iio: common: ssp_sensors: drop conditional optimization for simplicity

Drop conditional in favor of always calculating the timestamp value.
This simplifies the code and allows to drop usage of internal private
variable "scan_timestamp" of the struct iio_dev.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20241214191421.94172-4-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: adc: max1363: Use a small fixed size buffer to replace dynamic allocation
Vasileios Amoiridis [Sat, 14 Dec 2024 19:14:19 +0000 (20:14 +0100)]
iio: adc: max1363: Use a small fixed size buffer to replace dynamic allocation

Drop the recurrent allocation of the data buffer from the trigger
handler and put it in the iio_priv(). This way, the maximum amount of
channels is always allocated in favor of simpler code and drop
of usage of the internal private variable "scan_timestamp" of the
struct iio_dev.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20241214191421.94172-3-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: adc: dln2-adc: zero full struct instead of just the padding
Vasileios Amoiridis [Sat, 14 Dec 2024 19:14:18 +0000 (20:14 +0100)]
iio: adc: dln2-adc: zero full struct instead of just the padding

Drop a minor optimization of zeroing the padding between data and
timestamp and zero the whole structure. This is done in favor of
simpler code, and in order to drop the usage of the internal private
variable "scan_timestamp" of the struct iio_dev.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20241214191421.94172-2-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: ABI: document in_illuminance_hardwaregain
Javier Carrasco [Sun, 15 Dec 2024 21:18:21 +0000 (22:18 +0100)]
iio: ABI: document in_illuminance_hardwaregain

This attribute is used for the vl6180 (see vl6180.c), but it is still
not documented. Add it to the _hardwaregain list.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20241215-iio_abi_in_illuminance_hardwaregain-v1-1-d94a59efb937@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: dac: ad7293: enable power before reset
David Lechner [Mon, 16 Dec 2024 21:44:03 +0000 (15:44 -0600)]
iio: dac: ad7293: enable power before reset

Change the order of regulator enable and reset so that power supplies
are turned on before touching the reset line. Generally, chips should
have the VDRIVE supply enabled before applying voltage on any pins.

While we are at it, remove the voltage level checks. If the power
supplies are not supplying the correct voltage, this is a hardware
design problem, not a software problem.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20241216-iio-regulator-cleanup-round-6-v2-1-9482164b68cb@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: ABI: use Y consistently as channel number
David Lechner [Mon, 16 Dec 2024 23:29:36 +0000 (17:29 -0600)]
iio: ABI: use Y consistently as channel number

Change X to Y when referring to channel number in the ABI documentation.
There were only a few cases using X (and one using Z). By far, most
documented attributes are using Y for the channel number placeholder.
For consistency, we should follow the same convention throughout.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20241216-doc-iio-use-voltagey-consistently-v1-1-9e34a72133bc@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: dac: ad5624r: Drop docs of missing members
Matti Vaittinen [Wed, 18 Dec 2024 08:17:15 +0000 (10:17 +0200)]
iio: dac: ad5624r: Drop docs of missing members

The documentation for struct ad5624r_state contains members that are (no
longer?) part of the structure.

Remove unnecessary docs.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/Z2KFC7ZBwmM69Qb4@mva-rohm
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: light: Add support for TI OPT4060 color sensor
Per-Daniel Olsson [Wed, 18 Dec 2024 10:48:36 +0000 (11:48 +0100)]
iio: light: Add support for TI OPT4060 color sensor

Add support for Texas Instruments OPT4060 RGBW Color sensor.

Signed-off-by: Per-Daniel Olsson <perdaniel.olsson@axis.com>
Link: https://patch.msgid.link/20241218104836.2784523-3-perdaniel.olsson@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agodt-bindings: iio: light: Document TI OPT4060 RGBW sensor
Per-Daniel Olsson [Wed, 18 Dec 2024 10:48:35 +0000 (11:48 +0100)]
dt-bindings: iio: light: Document TI OPT4060 RGBW sensor

Add devicetree bindings for the OPT4060 RGBW color sensor.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Per-Daniel Olsson <perdaniel.olsson@axis.com>
Link: https://patch.msgid.link/20241218104836.2784523-2-perdaniel.olsson@axis.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: adc: ad_sigma_delta: Use `unsigned int` instead of plain `unsigned`
Uwe Kleine-König [Wed, 18 Dec 2024 11:48:09 +0000 (12:48 +0100)]
iio: adc: ad_sigma_delta: Use `unsigned int` instead of plain `unsigned`

This fixes a checkpatch warning:

WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
#70: FILE: drivers/iio/adc/ad_sigma_delta.c:253:
+ unsigned status_reg;

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/20241218114809.1378063-2-u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agodt-bindings: iio: pressure: bmp085: Add SPI interface
Vasileios Amoiridis [Mon, 9 Dec 2024 23:38:45 +0000 (00:38 +0100)]
dt-bindings: iio: pressure: bmp085: Add SPI interface

The BMP{2,3,5}80 and BME280 devices have an SPI interface, so include it
in the device-tree.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20241209233845.29539-2-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
8 months agoiio: accel: adxl345: add function to switch measuring mode
Lothar Rubusch [Fri, 13 Dec 2024 21:19:03 +0000 (21:19 +0000)]
iio: accel: adxl345: add function to switch measuring mode

Replace the powerup / powerdown functions by a generic function to put
the sensor in STANDBY, or MEASURE mode. When configuring the FIFO for
several features of the accelerometer, it is recommended to put
measuring in STANDBY mode.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20241213211909.40896-2-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad-sigma-delta: Document ABI for sigma delta adc
Guillaume Ranquet [Mon, 2 Dec 2024 10:09:53 +0000 (11:09 +0100)]
iio: adc: ad-sigma-delta: Document ABI for sigma delta adc

Add common calibration nodes for sigma delta adc.

Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>
Link: https://patch.msgid.link/20241202-ad411x_calibration-v3-2-beb6aeec39e2@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad7173: add calibration support
Guillaume Ranquet [Mon, 2 Dec 2024 10:09:52 +0000 (11:09 +0100)]
iio: adc: ad7173: add calibration support

The ad7173 family of chips has up to four calibration modes.

Internal zero scale: removes ADC core offset errors.
Internal full scale: removes ADC core gain errors.
System zero scale: reduces offset error to the order of channel noise.
System full scale: reduces gain error to the order of channel noise.

All voltage channels will undergo an internal zero/full scale
calibration at bootup.

System zero/full scale can be done after bootup using the newly created
iio interface 'sys_calibration' and 'sys_calibration_mode'

Signed-off-by: Guillaume Ranquet <granquet@baylibre.com>
Link: https://patch.msgid.link/20241202-ad411x_calibration-v3-1-beb6aeec39e2@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad4000: Add support for PulSAR devices
Marcelo Schmitt [Mon, 2 Dec 2024 14:08:30 +0000 (11:08 -0300)]
iio: adc: ad4000: Add support for PulSAR devices

The ADI PulSAR series of single-channel devices comprises differential and
pseudo-differential ADCs that don't require any input data from the host
controller. By not requiring a data input line, PulSAR devices can operate
with a 3-wire only data bus in some setups.

The AD4000 series and the single-channel PulSAR series of devices have
similar SPI transfer specifications and wiring configurations.
Single-channel PulSAR devices are slower than AD4000 and don't have a
configuration register. That taken into account, single-channel PulSARs can
be supported by the ad4000 driver without any increase in code complexity.

Extend the AD4000 driver to also support single-channel PulSAR devices.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://patch.msgid.link/2bfb904e29914c3dc4905e1c87fcc735575f330d.1733147444.git.marcelo.schmitt@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad4000: Use device specific timing for SPI transfers
Marcelo Schmitt [Mon, 2 Dec 2024 14:08:13 +0000 (11:08 -0300)]
iio: adc: ad4000: Use device specific timing for SPI transfers

The SPI transfers for AD4020, AD4021, and AD4022 have slightly different
timing specifications. Use device specific timing constraints to set SPI
transfer parameters. While tweaking time constraints, remove time related
defines including unused AD4000_TQUIET1_NS.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/a36fcf44cc00b2a498170e2ae3f005829d516266.1733147444.git.marcelo.schmitt@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad4000: Add timestamp channel
Marcelo Schmitt [Mon, 2 Dec 2024 14:07:56 +0000 (11:07 -0300)]
iio: adc: ad4000: Add timestamp channel

The ADC data is pushed to the IIO buffer along with timestamp but no
timestamp channel was provided to retried the time data.
Add a timestamp channel to provide sample capture time.

Suggested-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Link: https://patch.msgid.link/d1f1bb1b726b90a3a7c1148c65d2f7fe073e2b15.1733147444.git.marcelo.schmitt@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agodt-bindings: iio: adc: adi,ad4000: Add PulSAR
Marcelo Schmitt [Mon, 2 Dec 2024 14:07:38 +0000 (11:07 -0300)]
dt-bindings: iio: adc: adi,ad4000: Add PulSAR

Extend the AD4000 series device tree documentation to also describe
PulSAR devices.

The single-channel series of PulSAR devices is similar to the AD4000 series
except PulSAR devices sample at slower rates and don't have a
configuration register. Because PulSAR devices don't have a configuration
register, they don't support all features of AD4000 devices and thus fewer
interfaces are provided to user space. Also, while AD4000 may have their
SDI pin connected to SPI host MOSI line, PulSAR SDI pin is never connected
to MOSI.

Some devices within the PulSAR series are just faster versions of others.
>From fastest to slowest, AD7980, AD7988-5, AD7686, AD7685, and AD7988-1 are
all 16-bit pseudo-differential pin-for-pin compatible ADCs. Devices that
only vary on the sample rate are documented with a common fallback
compatible.

Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/cc05f1471c409ab38722cd0e80fd5857ff9ce5db.1733147444.git.marcelo.schmitt@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: consumers: ensure read buffers for labels and ext_info are page aligned
Matteo Martelli [Mon, 2 Dec 2024 15:11:07 +0000 (16:11 +0100)]
iio: consumers: ensure read buffers for labels and ext_info are page aligned

Attributes of iio providers are exposed via sysfs. Typically, providers
pass attribute values to the iio core, which handles formatting and
printing to sysfs. However, some attributes, such as labels or extended
info, are directly formatted and printed to sysfs by provider drivers
using sysfs_emit() and sysfs_emit_at(). These helpers assume the read
buffer, allocated by sysfs fop, is page-aligned. When these attributes
are accessed by consumer drivers, the read buffer is allocated by the
consumer and may not be page-aligned, leading to failures in the
provider's callback that utilizes sysfs_emit*.

Add a check to ensure that read buffers for labels and external info
attributes are page-aligned. Update the prototype documentation as well.

Signed-off-by: Matteo Martelli <matteomartelli3@gmail.com>
Link: https://patch.msgid.link/20241202-iio-kmalloc-align-v1-1-aa9568c03937@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: pressure: bmp280: Make time vars intuitive and move to fsleep
Vasileios Amoiridis [Mon, 2 Dec 2024 18:19:07 +0000 (19:19 +0100)]
iio: pressure: bmp280: Make time vars intuitive and move to fsleep

Move sleep functions to the new fsleep() implementation. While at it,
add time unit abbreviation as a suffix of time describing variables to
make them more intuitive.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20241202181907.21471-4-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: pressure: bmp280: Use sizeof() for denominator
Vasileios Amoiridis [Mon, 2 Dec 2024 18:19:06 +0000 (19:19 +0100)]
iio: pressure: bmp280: Use sizeof() for denominator

Instead of using magic number 2 as a denominator, make it intuitive by
using sizeof().

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20241202181907.21471-3-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: chemical: bme680: add power management
Vasileios Amoiridis [Mon, 2 Dec 2024 19:23:41 +0000 (20:23 +0100)]
iio: chemical: bme680: add power management

Add runtime power management to the device.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20241202192341.33187-4-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: chemical: bme680: add regulators
Vasileios Amoiridis [Mon, 2 Dec 2024 19:23:40 +0000 (20:23 +0100)]
iio: chemical: bme680: add regulators

Add support for the regulators described in the dt-binding.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20241202192341.33187-3-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agodt-bindings: iio: bosch,bme680: Move from trivial-devices and add supplies
Vasileios Amoiridis [Mon, 2 Dec 2024 19:23:39 +0000 (20:23 +0100)]
dt-bindings: iio: bosch,bme680: Move from trivial-devices and add supplies

Move dt-binding for BME680 out of trivial-devices.yaml and extend it by
adding the missing supplies.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20241202192341.33187-2-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: imu: st_lsm6dsx: don't always auto-enable I2C, I3C and SPI interface drivers
Sean Nyekjaer [Tue, 3 Dec 2024 07:20:17 +0000 (08:20 +0100)]
iio: imu: st_lsm6dsx: don't always auto-enable I2C, I3C and SPI interface drivers

This patch makes I2C, I3C and SPI interface drivers for ST lsm6dsx
individually selectable via Kconfig.

The default is kept unchanged - I2C, I3C and SPI interface drivers are
still selected by default if the corresponding bus support is available.

However, the patch makes it possible to explicitly disable drivers
that are not needed for a particular target.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Link: https://patch.msgid.link/20241203-lsm6dsx-v1-1-6d7893443bc8@geanix.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agodt-bindings: iio: accel: fxls8962af: add wakeup-source property
Sean Nyekjaer [Tue, 3 Dec 2024 07:22:11 +0000 (08:22 +0100)]
dt-bindings: iio: accel: fxls8962af: add wakeup-source property

Add a wakeup-source property to the binding to describe whether the
wakeup interrupts from the accelerometer can wake the system from
suspend.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/20241203-fxlsdt-v2-1-ef523461b507@geanix.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: accel: adxl345: rename variable data to st
Lothar Rubusch [Thu, 5 Dec 2024 17:13:35 +0000 (17:13 +0000)]
iio: accel: adxl345: rename variable data to st

Rename the locally used variable data to st. The st refers to "state",
representing the internal state of the driver object. Further it
prepares the usage of an internal data pointer needed for the
implementation of the sensor features.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20241205171343.308963-3-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: accel: adxl345: refrase comment on probe
Lothar Rubusch [Thu, 5 Dec 2024 17:13:34 +0000 (17:13 +0000)]
iio: accel: adxl345: refrase comment on probe

Refrase comment on the probe function, avoid naming different hardware.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20241205171343.308963-2-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad7124: Implement temperature measurement
Uwe Kleine-König [Fri, 6 Dec 2024 17:28:42 +0000 (18:28 +0100)]
iio: adc: ad7124: Implement temperature measurement

If the maximal count of channels the driver supports isn't fully
utilized, add an attribute providing the internal temperature.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/433211af8ac3f02dee58586ecb51d2e98246a095.1733504533.git.u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad7124: Add error reporting during probe
Uwe Kleine-König [Fri, 6 Dec 2024 17:28:41 +0000 (18:28 +0100)]
iio: adc: ad7124: Add error reporting during probe

A driver that silently fails to probe is annoying and hard to debug. So
add messages in the error paths of the probe function.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/55e24392f1e4d5b9896f00a52a93c1c4b1feac43.1733504533.git.u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad_sigma_delta: Check for previous ready signals
Uwe Kleine-König [Fri, 6 Dec 2024 17:28:40 +0000 (18:28 +0100)]
iio: adc: ad_sigma_delta: Check for previous ready signals

It can happen if a previous conversion was aborted the ADC pulls down
the R̅D̅Y̅ line but the event wasn't handled before. In that case enabling
the irq might immediately fire (depending on the irq controller
capabilities) and even with a rdy-gpio isn't identified as an unrelated
one.

To cure that problem check for a pending event before the measurement is
started and clear it if needed.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/3ec6b61fb1e527e935133dc56f589aab4b2094a3.1733504533.git.u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad_sigma_delta: Store information about reset sequence length
Uwe Kleine-König [Fri, 6 Dec 2024 17:28:39 +0000 (18:28 +0100)]
iio: adc: ad_sigma_delta: Store information about reset sequence length

The various chips can be reset using a sequence of SPI transfers with
MOSI = 1. The length of such a sequence varies from chip to chip. Store
that length in struct ad_sigma_delta_info and replace the respective
parameter to ad_sd_reset() with it.

Note the ad7192 used to pass 48 as length but the documentation
specifies 40 as the required length. Assuming the latter is right.
(Using a too long sequence doesn't hurt apart from using a longer spi
transfer than necessary, so this is no relevant fix.)

The motivation for storing this information is that this is useful to
clear a pending R̅D̅Y̅ signal in the next change.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/9750db62fce638bf140ff48172c23bff7f785e5b.1733504533.git.u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad_sigma_delta: Fix a race condition
Uwe Kleine-König [Fri, 6 Dec 2024 17:28:38 +0000 (18:28 +0100)]
iio: adc: ad_sigma_delta: Fix a race condition

The ad_sigma_delta driver helper uses irq_disable_nosync(). With that
one it is possible that the irq handler still runs after the
irq_disable_nosync() function call returns. Also to properly synchronize
irq disabling in the different threads proper locking is needed and
because it's unclear if the irq handler's irq_disable_nosync() call
comes first or the one in the enabler's error path, all code locations
that disable the irq must check for .irq_dis first to ensure there is
exactly one disable call per enable call.

So add a spinlock to the struct ad_sigma_delta and use it to synchronize
irq enabling and disabling. Also only act in the irq handler if the irq
is still enabled.

Fixes: af3008485ea0 ("iio:adc: Add common code for ADI Sigma Delta devices")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/9e6def47e2e773e0e15b7a2c29d22629b53d91b1.1733504533.git.u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad_sigma_delta: Handle CS assertion as intended in ad_sd_read_reg_raw()
Uwe Kleine-König [Fri, 6 Dec 2024 17:28:37 +0000 (18:28 +0100)]
iio: adc: ad_sigma_delta: Handle CS assertion as intended in ad_sd_read_reg_raw()

When struct ad_sigma_delta::keep_cs_asserted was introduced only
register writing was adapted to honor this new flag. Also respect it
when reading a register.

Fixes: df1d80aee963 ("iio: ad_sigma_delta: Properly handle SPI bus locking vs CS assertion")
Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/8d76b4ea4a4363b269886c71193b840821c724ea.1733504533.git.u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad_sigma_delta: Add support for reading irq status using a GPIO
Uwe Kleine-König [Fri, 6 Dec 2024 17:28:36 +0000 (18:28 +0100)]
iio: adc: ad_sigma_delta: Add support for reading irq status using a GPIO

Some of the ADCs by Analog signal their irq condition on the MISO line.
So typically that line is connected to an SPI controller and a GPIO. The
GPIO is used as input and the respective interrupt is enabled when the
last SPI transfer is completed.

Depending on the GPIO controller the toggling MISO line might make the
interrupt pending even while it's masked. In that case the irq handler
is called immediately after irq_enable() and so before the device
actually pulls that line low which results in non-sense values being
reported to the upper layers.

The only way to find out if the line was actually pulled low is to read
the GPIO. (There is a flag in AD7124's status register that also signals
if an interrupt was asserted, but reading that register toggles the MISO
line and so might trigger another spurious interrupt.)

Add the possibility to specify an interrupt GPIO in the machine
description in addition to the plain interrupt. This GPIO is used then
to check if the irq line is actually active in the irq handler.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/5be9a4cc4dc600ec384c88db01dd661a21506b9c.1733504533.git.u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agodt-bindings: iio: adc: adi,ad7{124,173,192,780}: Allow specifications of a gpio for...
Uwe Kleine-König [Fri, 6 Dec 2024 17:28:35 +0000 (18:28 +0100)]
dt-bindings: iio: adc: adi,ad7{124,173,192,780}: Allow specifications of a gpio for irq line

For the AD7124 chip and some of its cousins the logical irq line (R̅D̅Y̅)
is physically on the same pin as the spi MISO output (DOUT) and so
reading a register might trigger an interrupt. For correct operation
it's critical that the actual state of the pin can be read to judge if
an interrupt event is a real one or just a spurious one triggered by
toggling the line in its MISO mode.

Allow specification of an "rdy-gpios" property that references a GPIO
that can be used for that purpose. While this is typically the same GPIO
also used (implicitly) as interrupt source, it is still supposed that
the interrupt is specified as before and usual.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/7fc92a8539e55802d514332e70ee836a3ed08b66.1733504533.git.u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad7124: Refuse invalid input specifiers
Uwe Kleine-König [Fri, 6 Dec 2024 17:28:34 +0000 (18:28 +0100)]
iio: adc: ad7124: Refuse invalid input specifiers

The ad7124-4 has 8 analog inputs; the input select values 8 to 15 are
reserved and not to be used. These are fine for ad7124-8. For both
ad7124-4 and ad7124-8 values bigger than 15 are internal channels that
might appear as inputs in the channels specified in the device
description according to the description of commit f1794fd7bdf7 ("iio:
adc: ad7124: Remove input number limitation"), values bigger than 31
don't fit into the respective register bit field and the driver masked
them to smaller values.

Check for these invalid input specifiers and fail to probe if one is
found.

Fixes: f1794fd7bdf7 ("iio: adc: ad7124: Remove input number limitation")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/80e3bd629d2b755ab5e061c8731dafa57d08698a.1733504533.git.u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: ad7124: Don't create more channels than the driver can handle
Uwe Kleine-König [Fri, 6 Dec 2024 17:28:33 +0000 (18:28 +0100)]
iio: adc: ad7124: Don't create more channels than the driver can handle

The ad7124-4 and ad7124-8 both support 16 channel registers and assigns
each channel defined in dt statically such a register. While the driver
could be a bit more clever about this, it currently isn't and specifying
more than 16 channels yields broken behaviour. So just refuse to bind in
this situation.

Fixes: b3af341bbd96 ("iio: adc: Add ad7124 support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://patch.msgid.link/1b9a5a1d334e5501294f7f9f9d5893f1cdf1b0ec.1733504533.git.u.kleine-koenig@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: rzg2l_adc: Add support for Renesas RZ/G3S
Claudiu Beznea [Fri, 6 Dec 2024 11:13:35 +0000 (13:13 +0200)]
iio: adc: rzg2l_adc: Add support for Renesas RZ/G3S

Add ADC support for the Renesas RZ/G3S SoC. The key features of this IP
include:
- 9 channels, with one dedicated to reading the temperature reported by the
  Thermal Sensor Unit (TSU)
- A different default ADCMP value, which is written to the ADM3 register.
- Different default sampling rates
- ADM3.ADSMP field is 8 bits wide
- ADINT.INTEN field is 11 bits wide

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://patch.msgid.link/20241206111337.726244-14-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agodt-bindings: iio: adc: renesas,rzg2l-adc: Document RZ/G3S SoC
Claudiu Beznea [Fri, 6 Dec 2024 11:13:34 +0000 (13:13 +0200)]
dt-bindings: iio: adc: renesas,rzg2l-adc: Document RZ/G3S SoC

Document the ADC IP available on the RZ/G3S SoC. The ADC IP on the RZ/G3S
differs slightly from the one found on the RZ/G2L. The identified
differences are as follows:
- different number of channels (one being used for temperature conversion);
  consequently, various registers differ; the temperature channel
  support was not available for the RZ/G2L variant; the #io-channel-cells
  property was added to be able to request the temperature channel from
  the thermal driver
- different default sampling periods
- the RZ/G3S variant lacks the ADVIC register.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://patch.msgid.link/20241206111337.726244-13-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: rzg2l_adc: Add suspend/resume support
Claudiu Beznea [Fri, 6 Dec 2024 11:13:33 +0000 (13:13 +0200)]
iio: adc: rzg2l_adc: Add suspend/resume support

The Renesas RZ/G3S SoC features a power-saving mode where power to most of
the SoC components is turned off, including the ADC IP.

Suspend/resume support has been added to the rzg2l_adc driver to restore
functionality after resuming from this power-saving mode. During suspend,
the ADC resets are asserted, and the ADC is powered down. On resume, the
ADC resets are de-asserted, the hardware is re-initialized, and the ADC
power is restored using the runtime PM APIs.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://patch.msgid.link/20241206111337.726244-12-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: rzg2l_adc: Add support for channel 8
Claudiu Beznea [Fri, 6 Dec 2024 11:13:32 +0000 (13:13 +0200)]
iio: adc: rzg2l_adc: Add support for channel 8

The ADC on the Renesas RZ/G3S SoC includes an additional channel (channel
8) dedicated to reading temperature values from the Thermal Sensor Unit
(TSU). There is a direct in-SoC connection between the ADC and TSU IPs.

To read the temperature reported by the TSU, a different sampling rate
(compared to channels 0-7) must be configured in the ADM3 register.

The rzg2l_adc driver has been updated to support reading the TSU
temperature.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://patch.msgid.link/20241206111337.726244-11-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: rzg2l_adc: Prepare for the addition of RZ/G3S support
Claudiu Beznea [Fri, 6 Dec 2024 11:13:31 +0000 (13:13 +0200)]
iio: adc: rzg2l_adc: Prepare for the addition of RZ/G3S support

The ADC IP available on the RZ/G3S differs slightly from the one found on
the RZ/G2L. The identified differences are as follows:
- different number of channels (one being used for temperature conversion);
  consequently, various registers differ
- different default sampling periods
- the RZ/G3S variant lacks the ADVIC register.

To accommodate these differences, the rzg2l_adc driver has been updated by
introducing the struct rzg2l_adc_hw_params, which encapsulates the
hardware-specific differences between the IP variants. A pointer to an
object of type struct rzg2l_adc_hw_params is embedded in
struct rzg2l_adc_data.

Additionally, the completion member of struct rzg2l_adc_data was relocated
to avoid potential padding, if any.

The code has been adjusted to utilize hardware-specific parameters stored
in the new structure instead of relying on plain macros.

The check of chan->channel in rzg2l_adc_read_raw() function, against the
driver specific mask was removed as the subsystem should have already
been done this before reaching the rzg2l_adc_read_raw() function. Along
with it the local variable ch was dropped as chan->channel could be used
instead.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://patch.msgid.link/20241206111337.726244-10-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: rzg2l_adc: Enable runtime PM autosuspend support
Claudiu Beznea [Fri, 6 Dec 2024 11:13:30 +0000 (13:13 +0200)]
iio: adc: rzg2l_adc: Enable runtime PM autosuspend support

Enable runtime PM autosuspend support for the rzg2l_adc driver. With this
change, consecutive conversion requests will no longer cause the device to
be runtime-enabled/disabled after each request. Instead, the device will
transition based on the delay configured by the user.

This approach reduces the frequency of hardware register access during
runtime PM suspend/resume cycles, thereby saving CPU cycles.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://patch.msgid.link/20241206111337.726244-9-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: rzg2l_adc: Simplify the locking scheme in rzg2l_adc_read_raw()
Claudiu Beznea [Fri, 6 Dec 2024 11:13:29 +0000 (13:13 +0200)]
iio: adc: rzg2l_adc: Simplify the locking scheme in rzg2l_adc_read_raw()

Simplify the locking scheme in rzg2l_adc_read_raw() by using
guard(mutex)().

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://patch.msgid.link/20241206111337.726244-8-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: rzg2l_adc: Use read_poll_timeout()
Claudiu Beznea [Fri, 6 Dec 2024 11:13:28 +0000 (13:13 +0200)]
iio: adc: rzg2l_adc: Use read_poll_timeout()

Replace the driver-specific implementation with the read_poll_timeout()
function. This change simplifies the code and improves maintainability by
leveraging the standardized helper.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://patch.msgid.link/20241206111337.726244-7-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: rzg2l_adc: Switch to RUNTIME_PM_OPS() and pm_ptr()
Claudiu Beznea [Fri, 6 Dec 2024 11:13:27 +0000 (13:13 +0200)]
iio: adc: rzg2l_adc: Switch to RUNTIME_PM_OPS() and pm_ptr()

The use of SET_RUNTIME_PM_OPS() is now deprecated and requires
__maybe_unused annotations to avoid warnings about unused functions.
Switching to RUNTIME_PM_OPS() and pm_ptr() eliminates the need for such
annotations because the compiler can directly reference the runtime PM
functions, thereby suppressing the warnings. As a result, the
__maybe_unused markings can be removed.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://patch.msgid.link/20241206111337.726244-6-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: rzg2l_adc: Simplify the runtime PM code
Claudiu Beznea [Fri, 6 Dec 2024 11:13:26 +0000 (13:13 +0200)]
iio: adc: rzg2l_adc: Simplify the runtime PM code

All Renesas SoCs using the rzg2l_adc driver manage ADC clocks through PM
domains. Calling pm_runtime_{resume_and_get, put_sync}() implicitly sets
the state of the clocks. As a result, the code in the rzg2l_adc driver that
explicitly manages ADC clocks can be removed, leading to simpler and
cleaner implementation.

Additionally, replace the use of rzg2l_adc_set_power() with direct PM
runtime API calls to further simplify and clean up the code.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://patch.msgid.link/20241206111337.726244-5-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: rzg2l_adc: Use devres helpers to request pre-deasserted reset controls
Claudiu Beznea [Fri, 6 Dec 2024 11:13:25 +0000 (13:13 +0200)]
iio: adc: rzg2l_adc: Use devres helpers to request pre-deasserted reset controls

Starting with commit d872bed85036 ("reset: Add devres helpers to request
pre-deasserted reset controls"), devres helpers are available to simplify
the process of requesting pre-deasserted reset controls. Update the
rzg2l_adc driver to utilize these helpers, reducing complexity in this
way.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://patch.msgid.link/20241206111337.726244-4-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: rzg2l_adc: Convert dev_err() to dev_err_probe()
Claudiu Beznea [Fri, 6 Dec 2024 11:13:24 +0000 (13:13 +0200)]
iio: adc: rzg2l_adc: Convert dev_err() to dev_err_probe()

Convert all occurrences of dev_err() in the probe path to dev_err_probe().
This improves readability and simplifies the code.

Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://patch.msgid.link/20241206111337.726244-3-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: kx022a: document new chip_info structure members
Matti Vaittinen [Fri, 6 Dec 2024 09:26:42 +0000 (11:26 +0200)]
iio: kx022a: document new chip_info structure members

The kx022a driver supports a few different HW variants. A chip-info
structure is used to describe sensor specific details. Support for
sensors with different measurement g-ranges was added recently,
introducing sensor specific scale arrays.

The members of the chip-info structure have been documented using
kerneldoc. The newly added members omitted the documentation. It is nice
to have all the entries documented for the sake of the consistency.
Furthermore, the scale table format may not be self explatonary, nor how
the amount of scales is informed.

Add documentation to scale table entries to maintain consistency and to
make it more obvious how the scales should be represented.

Suggested-by: Mehdi Djait <mehdi.djait@linux.intel.com>
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com>
Link: https://patch.msgid.link/Z1LDUj-naUdGSM6n@mva-rohm
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: proximity: aw96103: Constify struct iio_info​
Christophe JAILLET [Fri, 6 Dec 2024 22:07:23 +0000 (23:07 +0100)]
iio: proximity: aw96103: Constify struct iio_info​

'struct iio_info' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increase overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
   text    data     bss     dec     hex filename
  17366    1454      16   18836    4994 drivers/iio/proximity/aw96103.o

After:
=====
   text    data     bss     dec     hex filename
  17526    1294      16   18836    4994 drivers/iio/proximity/aw96103.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://patch.msgid.link/da4918af46fef03903ab0e9fdcb4f23e014f3821.1733522812.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: light: veml6030: add support for triggered buffer
Javier Carrasco [Sun, 24 Nov 2024 18:59:06 +0000 (19:59 +0100)]
iio: light: veml6030: add support for triggered buffer

All devices supported by this driver (currently veml6030, veml6035
and veml7700) have two 16-bit channels, and can profit for the same
configuration to support data access via triggered buffers.

The measurements are stored in two 16-bit consecutive registers
(addresses 0x04 and 0x05) as little endian, unsigned data.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20241124-veml6030_triggered_buffer-v3-1-565bb6b4b5c8@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: trigger: stm32-timer-trigger: Add check for clk_enable()
Jiasheng Jiang [Sat, 23 Nov 2024 22:01:49 +0000 (22:01 +0000)]
iio: trigger: stm32-timer-trigger: Add check for clk_enable()

Add check for the return value of clk_enable() in order to catch the
potential exception.

Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Link: https://patch.msgid.link/20241123220149.30655-1-jiashengjiangcool@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: core: fix doc reference to iio_push_to_buffers_with_ts_unaligned
Javier Carrasco [Mon, 25 Nov 2024 21:16:19 +0000 (22:16 +0100)]
iio: core: fix doc reference to iio_push_to_buffers_with_ts_unaligned

Use the right name of the function, which is defined in
drivers/iio/industrialio-buffer.c

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20241125-iio_memset_scan_holes-v1-11-0cb6e98d895c@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
9 months agoiio: adc: vf610_adc: limit i.MX6SX's channel number to 4
Frank Li [Tue, 26 Nov 2024 19:52:56 +0000 (14:52 -0500)]
iio: adc: vf610_adc: limit i.MX6SX's channel number to 4

i.MX6SX only has 4 ADC channels, so limit channel numbers to 4 for
compatible string 'fsl,imx6sx-adc'.

Reviewed-by: Haibo Chen <haibo.chen@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://patch.msgid.link/20241126195256.2441622-2-Frank.Li@nxp.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>