]> git.hungrycats.org Git - linux/log
linux
11 months agoiio: pressure: bmp280: Fix regmap for BMP280 device
Vasileios Amoiridis [Thu, 11 Jul 2024 21:15:49 +0000 (23:15 +0200)]
iio: pressure: bmp280: Fix regmap for BMP280 device

Up to now, the BMP280 device is using the regmap of the BME280 which
has registers that exist only in the BME280 device.

Fixes: 14e8015f8569 ("iio: pressure: bmp280: split driver in logical parts")
Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240711211558.106327-2-vassilisamir@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoDocumentation: iio: Document ad4695 driver
David Lechner [Thu, 11 Jul 2024 19:15:43 +0000 (14:15 -0500)]
Documentation: iio: Document ad4695 driver

The Analog Devices Inc. AD4695 (and similar chips) are complex ADCs that
will benefit from a detailed driver documentation.

This documents the current features supported by the driver.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad4695: Add driver for AD4695 and similar ADCs
David Lechner [Thu, 11 Jul 2024 19:15:42 +0000 (14:15 -0500)]
iio: adc: ad4695: Add driver for AD4695 and similar ADCs

This is a new driver for Analog Devices Inc. AD4695 and similar ADCs.
The initial driver supports initializing the chip including configuring
all possible LDO and reference voltage sources as well as any possible
voltage input channel wiring configuration.

Only the 4-wire SPI wiring mode where the CNV pin is tied to the CS pin
is supported at this time. And reading sample data from the ADC can only
be done in direct mode for now.

Co-developed-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240711-iio-adc-ad4695-v4-2-c31621113b57@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: iio: adc: add AD4695 and similar ADCs
David Lechner [Thu, 11 Jul 2024 19:15:41 +0000 (14:15 -0500)]
dt-bindings: iio: adc: add AD4695 and similar ADCs

Add device tree bindings for AD4695 and similar ADCs.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20240711-iio-adc-ad4695-v4-0-c31621113b57@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: common: scmi_iio: Remove unnecessary u64 type cast
Thorsten Blum [Thu, 11 Jul 2024 13:45:03 +0000 (15:45 +0200)]
iio: common: scmi_iio: Remove unnecessary u64 type cast

The variable uHz already has the type u64 and casting it to u64 is
unnecessary. Remove the redundant type cast.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Link: https://patch.msgid.link/20240711134502.168484-1-thorsten.blum@toblux.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: dac: ltc2664: Add driver for LTC2664 and LTC2672
Kim Seer Paller [Thu, 18 Jul 2024 05:18:34 +0000 (13:18 +0800)]
iio: dac: ltc2664: Add driver for LTC2664 and LTC2672

LTC2664 4 channel, 12-/16-Bit Voltage Output SoftSpan DAC
LTC2672 5 channel, 12-/16-Bit Current Output Softspan DAC

Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Co-developed-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/20240718051834.32270-7-kimseer.paller@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: iio: dac: Add adi,ltc2672.yaml
Kim Seer Paller [Thu, 18 Jul 2024 05:18:33 +0000 (13:18 +0800)]
dt-bindings: iio: dac: Add adi,ltc2672.yaml

Add documentation for ltc2672.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Co-developed-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
Link: https://patch.msgid.link/20240718051834.32270-6-kimseer.paller@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: iio: dac: Add adi,ltc2664.yaml
Kim Seer Paller [Thu, 18 Jul 2024 05:18:32 +0000 (13:18 +0800)]
dt-bindings: iio: dac: Add adi,ltc2664.yaml

Add documentation for ltc2664.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Co-developed-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
Link: https://patch.msgid.link/20240718051834.32270-5-kimseer.paller@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: iio: dac: Generalize DAC common properties
Kim Seer Paller [Thu, 18 Jul 2024 05:18:31 +0000 (13:18 +0800)]
dt-bindings: iio: dac: Generalize DAC common properties

Introduce a generalized DAC binding that can be used by DACs that have
similar properties adding output-range-microamp and output-range-microvolt.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
Link: https://patch.msgid.link/20240718051834.32270-4-kimseer.paller@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: ABI: add DAC 42kohm_to_gnd powerdown mode
Kim Seer Paller [Thu, 18 Jul 2024 05:18:30 +0000 (13:18 +0800)]
iio: ABI: add DAC 42kohm_to_gnd powerdown mode

Add a new powerdown mode for DACs with 42kohm resistor to GND.

Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
Link: https://patch.msgid.link/20240718051834.32270-3-kimseer.paller@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: ABI: Generalize ABI documentation for DAC
Kim Seer Paller [Thu, 18 Jul 2024 05:18:29 +0000 (13:18 +0800)]
iio: ABI: Generalize ABI documentation for DAC

Introduces a more generalized ABI documentation for DAC. Instead of
having separate ABI files for each DAC, we now have a single ABI file
that covers the common sysfs interface for all DAC.

Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
https://patch.msgid.link/20240718051834.32270-2-kimseer.paller@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: backend: print message in case op is not implemented
Nuno Sa [Tue, 9 Jul 2024 11:14:29 +0000 (13:14 +0200)]
iio: backend: print message in case op is not implemented

For APIs that have a return value, -EOPNOTSUPP is returned in case the
backend does not support the functionality. However, for APIs that do
not have a return value we are left in silence. Hence, at least print a
debug message in case the callback is not implemented by the backend.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240709-dev-iio-backend-add-debugfs-v1-2-fb4b8f2373c7@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: backend: remove unused parameter
Nuno Sa [Tue, 9 Jul 2024 11:14:28 +0000 (13:14 +0200)]
iio: backend: remove unused parameter

Indio_dev was not being used in iio_backend_extend_chan_spec() so remove
it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240709-dev-iio-backend-add-debugfs-v1-1-fb4b8f2373c7@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodocs: iio: new docs for ad7380 driver
Julien Stephan [Tue, 9 Jul 2024 15:16:46 +0000 (17:16 +0200)]
docs: iio: new docs for ad7380 driver

This adds a new page to document how to use the ad7380 ADC driver.

Credit: this docs is based on ad7944 docs.

Signed-off-by: Julien Stephan <jstephan@baylibre.com>
Link: https://patch.msgid.link/20240709-ad7380-add-docs-v1-1-458ced3dfcc5@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodocs: iio: add documentation for adxl380 driver
Antoniu Miclaus [Mon, 8 Jul 2024 10:40:13 +0000 (13:40 +0300)]
docs: iio: add documentation for adxl380 driver

Add documentation for adxl380 driver which describes the driver
device files and shows how the user may use the ABI for various
scenarios (configuration, measurement, etc.).

Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20240708104114.29894-3-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: add ADXL380 driver
Antoniu Miclaus [Mon, 8 Jul 2024 10:40:12 +0000 (13:40 +0300)]
iio: accel: add ADXL380 driver

The ADXL380/ADXL382 is a low noise density, low power, 3-axis
accelerometer with selectable measurement ranges. The ADXL380 supports
the +/-4 g, +/-8 g, and +/-16 g ranges, and the ADXL382 supports
+/-15 g, +/-30 g and +/-60 g ranges.
The ADXL380/ADXL382 offers industry leading noise, enabling precision
applications with minimal calibration. The low noise, and low power
ADXL380/ADXL382 enables accurate measurement in an environment with
high vibration, heart sounds and audio.

In addition to its low power consumption, the ADXL380/ADXL382 has many
features to enable true system level performance. These include a
built-in micropower temperature sensor, single / double / triple tap
detection and a state machine to prevent a false triggering. In
addition, the ADXL380/ADXL382 has provisions for external control of
the sampling time and/or an external clock.

Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20240708104114.29894-2-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: iio: accel: add ADXL380
Antoniu Miclaus [Mon, 8 Jul 2024 10:40:11 +0000 (13:40 +0300)]
dt-bindings: iio: accel: add ADXL380

Add dt-bindings for ADXL380/ADLX382 low noise density, low
power, 3-axis accelerometer with selectable measurement ranges.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Ramona Gradinariu <ramona.gradinariu@analog.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20240708104114.29894-1-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: pressure: bmp280: Add triggered buffer support
Vasileios Amoiridis [Fri, 28 Jun 2024 17:17:26 +0000 (19:17 +0200)]
iio: pressure: bmp280: Add triggered buffer support

BMP2xx, BME280, BMP3xx, and BMP5xx use continuous buffers for their
temperature, pressure and humidity readings. This facilitates the
use of burst/bulk reads in order to acquire data faster. The
approach is different from the one used in oneshot captures.

BMP085 & BMP1xx devices use a completely different measurement
process that is well defined and is used in their buffer_handler().

Suggested-by: Angel Iglesias <ang.iglesiasg@gmail.com>
Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://lore.kernel.org/r/20240512230524.53990-6-vassilisamir@gmail.com
Link: https://patch.msgid.link/20240628171726.124852-4-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: pressure: bmp280: Add SCALE, RAW values in channels and refactorize them
Vasileios Amoiridis [Fri, 28 Jun 2024 17:17:25 +0000 (19:17 +0200)]
iio: pressure: bmp280: Add SCALE, RAW values in channels and refactorize them

Add extra IIO_CHAN_INFO_SCALE and IIO_CHAN_INFO_RAW channels in order
to be able to calculate the processed value with standard userspace
IIO tools. Can be used for triggered buffers as well.

Even though it is not a good design choice to have SCALE, RAW and
PROCESSED together, the PROCESSED channel is kept for ABI compatibility.

While at it, separate BMPxxx and BMExxx device channels since BME
supports also humidity measurements.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://lore.kernel.org/r/20240512230524.53990-5-vassilisamir@gmail.com
Link: https://patch.msgid.link/20240628171726.124852-3-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: pressure: bmp280: Generalize read_*() functions
Vasileios Amoiridis [Fri, 28 Jun 2024 17:17:24 +0000 (19:17 +0200)]
iio: pressure: bmp280: Generalize read_*() functions

Add the coefficients for the IIO standard units and the IIO value
inside the chip_info structure.

Move the calculations for the IIO unit compatibility from inside the
read_{temp,press,humid}() functions and move them to the general
read_raw() function.

In this way, all the data for the calculation of the value are
located in the chip_info structure of the respective sensor.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Acked-by: Adam Rizkalla <ajarizzo@gmail.com>
Link: https://patch.msgid.link/20240628171726.124852-2-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: light: ltrf216a: Add LTR-308 support
Marek Vasut [Mon, 8 Jul 2024 11:41:18 +0000 (13:41 +0200)]
iio: light: ltrf216a: Add LTR-308 support

Add LiteOn LTR-308 support into LTR-F216A kernel driver.

The two devices seem to have almost identical register map, except that
the LTR-308 does not have three CLEAR_DATA registers, which are unused
by this driver. Furthermore, LTR-308 and LTR-F216A use different lux
calculation constants, 0.6 and 0.45 respectively. Both differences are
handled using chip info data.

https://optoelectronics.liteon.com/upload/download/DS86-2016-0027/LTR-308ALS_Final_%20DS_V1%201.pdf
https://optoelectronics.liteon.com/upload/download/DS86-2019-0016/LTR-F216A_Final_DS_V1.4.PDF

Signed-off-by: Marek Vasut <marex@denx.de>
Link: https://patch.msgid.link/20240708114227.18283-2-marex@denx.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: iio: light: ltrf216a: Document LTR-308 support
Marek Vasut [Mon, 8 Jul 2024 11:41:17 +0000 (13:41 +0200)]
dt-bindings: iio: light: ltrf216a: Document LTR-308 support

Document LiteOn LTR-308 support in LTR-F216A bindings.

The two devices seem to have almost identical register map, except that
the LTR-308 does not have three CLEAR_DATA registers, which are unused
by this driver. Furthermore, LTR-308 and LTR-F216A use different lux
calculation constants, 0.6 and 0.45 respectively.

https://optoelectronics.liteon.com/upload/download/DS86-2016-0027/LTR-308ALS_Final_%20DS_V1%201.pdf
https://optoelectronics.liteon.com/upload/download/DS86-2019-0016/LTR-F216A_Final_DS_V1.4.PDF

Signed-off-by: Marek Vasut <marex@denx.de>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240708114227.18283-1-marex@denx.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: bu27034: Add a read only HARDWAREGAIN
Matti Vaittinen [Fri, 5 Jul 2024 10:55:49 +0000 (13:55 +0300)]
iio: bu27034: Add a read only HARDWAREGAIN

The ROHM BU27034 light sensor has two data channels for measuring
different frequencies of light. The result from these channels is
combined into Lux value while the raw channel values are reported via
intensity channels.

Both of the intensity channels have adjustable gain setting which
impacts the scale of the raw channels. Eg, doubling the gain will double
the values read from the raw channels, which halves the scale value. The
integration time can also be set for the sensor. This does also have an
impact to the scale of the intensity channels because increasing the
integration time will also increase the values reported via the raw
channels.

Impact of integration time to the scale and the fact that the scale value
does not start from '1', can make it hard for a human reader to compute the
gain values based on the scale.

Add read-only HARDWAREGAIN to help debugging.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/ec349847cc994f3bd632e99b408a31e7c70581d0.1720176341.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agobu27034: ROHM BU27034ANUC correct lux calculation
Matti Vaittinen [Fri, 5 Jul 2024 10:55:34 +0000 (13:55 +0300)]
bu27034: ROHM BU27034ANUC correct lux calculation

The ROHM BU27034NUC was cancelled and BU27034ANUC is replacing this
sensor. The lux computation based on the data from a BU27034ANUC is
different from the computation for the data from an old BU27034NUC.

Fix the lux computation.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/b7bea76b54b28eb354dc523771a0e0a8b6f26095.1720176341.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agobu27034: ROHM BU27034ANUC correct gains and times
Matti Vaittinen [Fri, 5 Jul 2024 10:55:19 +0000 (13:55 +0300)]
bu27034: ROHM BU27034ANUC correct gains and times

The ROHM BU27034NUC was cancelled and BU27034ANUC is replacing this
sensor. The BU27034ANUC does not support all the gains or all the
integration times that were supported on BU27034NUC.

Srop unsupported times and gains

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/19f8cca2b5498fbfea6e657b7b9c90b78516866a.1720176341.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agobu27034: ROHM BU27034NUC to BU27034ANUC drop data2
Matti Vaittinen [Fri, 5 Jul 2024 10:55:03 +0000 (13:55 +0300)]
bu27034: ROHM BU27034NUC to BU27034ANUC drop data2

The ROHM BU27034NUC was cancelled and BU27034ANUC is replacing this
sensor. The BU27034ANUC does not have the data2 channel.

Drop the data2 channel.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/6f261d4499e9c0e161279717261cc9a20764a6bd.1720176341.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agobu27034: ROHM BU27034NUC to BU27034ANUC
Matti Vaittinen [Fri, 5 Jul 2024 10:54:47 +0000 (13:54 +0300)]
bu27034: ROHM BU27034NUC to BU27034ANUC

The ROHM BU27034NUC was cancelled and BU27034ANUC is replacing this
sensor. These senors aren't compatible from the software point of view.

According to ROHM, the BU27034NUC was never mass-produced. Hence dropping
the BU27034NUC support and using this driver to support BU27034ANUC
should not be a problem to users. We however need to ensure than people
who use old kernel with the old BU27034NUC driver don't get the old
driver probed for the new sensor.

Prepare to use the BU27034NUC driver to support the new BU27034ANUC and
change the compatible to prevent probing the old driver with the new
sensor.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/ed8b963b0cd3a84c06a494c79969a136d5abcf92.1720176341.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: iio: BU27034 => BU27034ANUC
Matti Vaittinen [Fri, 5 Jul 2024 10:54:12 +0000 (13:54 +0300)]
dt-bindings: iio: BU27034 => BU27034ANUC

The BU27034NUC was cancelled before it entered mass production. It was
replaced by a new variant BU27034ANUC (note, added 'A'). The new
variant gained a few significant changes, like removal of the 3.rd data
channel and dropping some of the gain settings. This means that, from
software point of view these ICs are incompatible. Lux calculation based
on the data from the sensors needs to be done differently, and on the
BU27034ANUC the channel 3 data is missing. Also, the gain setting
differencies matter.

Unfortunately, the identification register was not changed so there is no
safe way for the software to distinguish the variants.

According to the ROHM HQ engineers, the old BU27034NUC should not be
encountered in the wild. Hence it makes sense to remove the support for
the old BU27034NUC and add support for the new BU27034ANUC. Change the
compatible in order to not load the incompatible old driver for new sensor
(or, if someone had the old sensor, the new driver for it).

Drop the compatible for old sensor which should not be in the wild and
add a new compatible for the new model with accurate model suffix
'anuc'.  Rename the file to match the new compatible.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/c39f9c67b3c07a27d7a13109c7b69cff9cfd2b9b.1720176341.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Refactorize reading functions
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:26 +0000 (01:38 +0200)]
iio: chemical: bme680: Refactorize reading functions

The reading of the pressure and humidity value, requires an update of the
t_fine variable which happens by reading the temperature value.

So the bme680_read_{press/humid}() functions of the above sensors are
internally calling the equivalent bme680_read_temp() function in order to
update the t_fine value. By just looking at the code this relation is a
bit hidden and is not easy to understand why those channels are not
independent.

This commit tries to clear these thing a bit by splitting the
bme680_{read/compensate}_{temp/press/humid}() to the following:

i. bme680_read_{temp/press/humid}_adc(): read the raw value from the
sensor.

ii. bme680_calc_t_fine(): calculate the t_fine variable.

iii. bme680_get_t_fine(): get the t_fine variable.

iv. bme680_compensate_{temp/press/humid}(): compensate the adc values and
return the calculated value.

v. bme680_read_{temp/press/humid}(): combine calls of the aforementioned
functions to return the requested value.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-16-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Move forced mode setup in ->read_raw()
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:25 +0000 (01:38 +0200)]
iio: chemical: bme680: Move forced mode setup in ->read_raw()

Whenever the sensor is set to forced mode, a TPHG cycle is triggered and
the values of temperature, pressure, humidity and gas become ready to be
read.

The setup of the forced mode to trigger measurements was located inside
the read_{temp/gas}() functions. This was not posing a functional problem
since read_{humid/press}() are internally calling read_temp() so the
forced mode is set through this call.

This is not very clear and it is kind of hidden that regardless of the
measurement, the setup of the forced mode needs to happen before any
measurement.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-15-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Remove redundant gas configuration
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:24 +0000 (01:38 +0200)]
iio: chemical: bme680: Remove redundant gas configuration

There is no need to explicitly configure the gas measurement registers
every time a gas measurement takes place. These are initial configurations
which are written in the beginning and they are not changed throughout
the lifetime of the driver.

If in the future, the device starts to support multiple configuration
profiles with variable heater duration and heater temperature, then they
could become members of the ->read_avail().

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-14-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Move probe errors to dev_err_probe()
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:23 +0000 (01:38 +0200)]
iio: chemical: bme680: Move probe errors to dev_err_probe()

There are multiple cases in the probe function that dev_err_probe() fits
the needs, so use it.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-13-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Modify startup procedure
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:22 +0000 (01:38 +0200)]
iio: chemical: bme680: Modify startup procedure

Modify the startup procedure to reflect the procedure of the Bosch BME68x
Sensor API. The initial readings and configuration of the sensor need to
happen in the following order:

1) Read calibration data [1,2]
2) Chip general configuration [3]
3) Gas configuration [4]

After the chip configuration it is necessary to ensure that the sensor is
in sleeping mode, in order to apply the gas configuration settings [5].

Also, after the soft reset, it is advised to wait for 5ms [6].

Link: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/bme68x.c#L162
Link: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/examples/forced_mode/forced_mode.c#L44
Link: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/examples/forced_mode/forced_mode.c#L53
Link: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/examples/forced_mode/forced_mode.c#L60
Link: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/bme68x.c#L640
Link: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/bme68x.c#L294
Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-12-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Make error checks consistent
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:21 +0000 (01:38 +0200)]
iio: chemical: bme680: Make error checks consistent

In the majority of the error checks after a regmap_{read,write}()
operation the following coding style is used:

ret = regmap_{read,write}(data->regmap, ...);
if (ret < 0) {
dev_err(dev, ...);
return ret;
}

In this particular case it was different so change it for consistency.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-11-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Add read buffers in read/write buffer union
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:20 +0000 (01:38 +0200)]
iio: chemical: bme680: Add read buffers in read/write buffer union

Move the buffers that are used in order to read data from the device in
the union which handles all the device read/write buffers. Also create
defines for the number of bytes that are being read from the device and
don't use magic numbers.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-10-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Allocate IIO device before chip initialization
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:19 +0000 (01:38 +0200)]
iio: chemical: bme680: Allocate IIO device before chip initialization

Move the IIO device allocation before the actual initialization of the
chip to be more consistent with most IIO drivers and also to have the
ability to use any driver specific data for the chip initialization.

While at it, fix also a misaligned line.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-9-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Use bulk reads for calibration data
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:18 +0000 (01:38 +0200)]
iio: chemical: bme680: Use bulk reads for calibration data

Calibration data are located in contiguous-ish registers inside the chip.
For that reason we can use bulk reads as is done as well in the BME68x
Sensor API [1].

The arrays that are used for reading the data out of the sensor
are located inside DMA safe buffer.

Link: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/bme68x.c#L1769
Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-8-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Remove duplicate register read
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:17 +0000 (01:38 +0200)]
iio: chemical: bme680: Remove duplicate register read

The LSB of the gas register was read first to check if the following
check was correct and then the MSB+LSB were read together. Simplify this
by reading together the MSB+LSB immediately.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-7-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Sort headers alphabetically
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:16 +0000 (01:38 +0200)]
iio: chemical: bme680: Sort headers alphabetically

Sort headers in alphabetical order and split the iio specific functions
with a blank line

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-6-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Remove remaining ACPI-only stuff
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:15 +0000 (01:38 +0200)]
iio: chemical: bme680: Remove remaining ACPI-only stuff

The ACPI ID table was removed with the following 2 commits:
Commit b73d21dccf68 ("iio: bme680_i2c: Remove acpi_device_id table")
Commit f0e4057e97c1 ("iio: bme680_spi: Remove acpi_device_id table")

Remove the remaining ACPI related stuff to this driver since they are
not directly used.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-5-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Drop unnecessary casts and correct adc data types
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:14 +0000 (01:38 +0200)]
iio: chemical: bme680: Drop unnecessary casts and correct adc data types

Delete any redundant casts in the code and use unsigned integers for the
raw adc values.

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-4-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Fix typo in define
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:13 +0000 (01:38 +0200)]
iio: chemical: bme680: Fix typo in define

Fix a define typo that instead of BME680_... it is saying BM6880_...

Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-3-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Fix read/write ops to device by adding mutexes
Vasileios Amoiridis [Sun, 9 Jun 2024 23:38:12 +0000 (01:38 +0200)]
iio: chemical: bme680: Fix read/write ops to device by adding mutexes

Add mutexes in the {read/write}_raw() functions of the device to guard the
read/write of data from/to the device. This is necessary because for any
operation other than temperature, multiple reads need to take place from
the device. Even though regmap has a locking by itself, it won't protect us
from multiple applications trying to read at the same time temperature and
pressure since the pressure reading includes an internal temperature
reading and there is nothing to ensure that this temperature+pressure
reading will happen sequentially without any other operation interfering
in the meantime.

Fixes: 1b3bd8592780 ("iio: chemical: Add support for Bosch BME680 sensor")
Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240609233826.330516-2-vassilisamir@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoABI: testing: fix admv8818 attr description
Antoniu Miclaus [Tue, 2 Jul 2024 08:18:50 +0000 (11:18 +0300)]
ABI: testing: fix admv8818 attr description

Fix description of the filter_mode_available attribute by pointing to
the correct name of the attribute that can be written with valid values.

Fixes: bf92d87d7c67 ("iio:filter:admv8818: Add sysfs ABI documentation")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20240702081851.4663-1-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: proximity: Add driver support for TYHX's HX9023S capacitive proximity sensor
Yasin Lee [Tue, 2 Jul 2024 14:12:34 +0000 (22:12 +0800)]
iio: proximity: Add driver support for TYHX's HX9023S capacitive proximity sensor

A SAR sensor from NanjingTianyihexin Electronics Ltd.

The device has the following entry points:

Usual frequency:
- sampling_frequency

Instant reading of current values for different sensors:
- in_proximity0_raw
- in_proximity1_raw
- in_proximity2_raw
- in_proximity3_raw
- in_proximity4_raw
and associated events in events/

Signed-off-by: Yasin Lee <yasin.lee.x@gmail.com>
Link: https://patch.msgid.link/20240702-add-tyhx-hx9023s-sensor-driver-v9-3-c030f1801d9b@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: iio: proximity: Add TYHX HX9023S
Yasin Lee [Tue, 2 Jul 2024 14:12:33 +0000 (22:12 +0800)]
dt-bindings: iio: proximity: Add TYHX HX9023S

A capacitive proximity sensor

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Yasin Lee <yasin.lee.x@gmail.com>
Link: https://patch.msgid.link/20240702-add-tyhx-hx9023s-sensor-driver-v9-2-c030f1801d9b@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: vendor-prefixes: add tyhx
Yasin Lee [Tue, 2 Jul 2024 14:12:32 +0000 (22:12 +0800)]
dt-bindings: vendor-prefixes: add tyhx

Add vendor prefix for NanjingTianyihexin Electronics Ltd.
http://www.tianyihexin.com

Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Yasin Lee <yasin.lee.x@gmail.com>
Link: https://patch.msgid.link/20240702-add-tyhx-hx9023s-sensor-driver-v9-1-c030f1801d9b@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: dac: ti-dac7311: Add check for spi_setup
Chen Ni [Fri, 5 Jul 2024 08:42:50 +0000 (16:42 +0800)]
iio: dac: ti-dac7311: Add check for spi_setup

Add check for the return value of spi_setup() and return the error
if it fails in order to catch the error.

Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
Link: https://patch.msgid.link/20240705084250.3006527-1-nichen@iscas.ac.cn
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad7606: switch mutexes to guard
Guillaume Stols [Tue, 2 Jul 2024 17:34:12 +0000 (17:34 +0000)]
iio: adc: ad7606: switch mutexes to guard

Switching to guard simplifies the code and avoids to take care to
unlock the mutex in case of premature return.

Signed-off-by: Guillaume Stols <gstols@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad7606: fix standby gpio state to match the documentation
Guillaume Stols [Tue, 2 Jul 2024 17:34:11 +0000 (17:34 +0000)]
iio: adc: ad7606: fix standby gpio state to match the documentation

The binding's documentation specifies that "As the line is active low, it
should be marked GPIO_ACTIVE_LOW". However, in the driver, it was handled
the opposite way. This commit sets the driver's behaviour in sync with the
documentation

Fixes: 722407a4e8c0 ("staging:iio:ad7606: Use GPIO descriptor API")
Signed-off-by: Guillaume Stols <gstols@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad7606: fix oversampling gpio array
Guillaume Stols [Tue, 2 Jul 2024 17:34:10 +0000 (17:34 +0000)]
iio: adc: ad7606: fix oversampling gpio array

gpiod_set_array_value was misused here: the implementation relied on the
assumption that an unsigned long was required for each gpio, while the
function expects a bit array stored in "as much unsigned long as needed
for storing one bit per GPIO", i.e it is using a bit field.

This leaded to incorrect parameter passed to gpiod_set_array_value, that
would set 1 value instead of 3.
It also prevents to select the software mode correctly for the AD7606B.

Fixes: d2a415c86c6b ("iio: adc: ad7606: Add support for AD7606B ADC")
Fixes: 41f71e5e7daf ("staging: iio: adc: ad7606: Use find_closest() macro")
Signed-off-by: Guillaume Stols <gstols@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: iio: adc: adi,ad7606: add conditions
Guillaume Stols [Tue, 2 Jul 2024 17:34:09 +0000 (17:34 +0000)]
dt-bindings: iio: adc: adi,ad7606: add conditions

Since the driver supports several parts that present differences in
their layout and behaviour, it is necessary to describe the differences
from one chip to another.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Guillaume Stols <gstols@baylibre.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: iio: adc: adi,ad7606: fix example
Guillaume Stols [Tue, 2 Jul 2024 17:34:08 +0000 (17:34 +0000)]
dt-bindings: iio: adc: adi,ad7606: fix example

Example uses adi,ad7606-8 as compatible, but adi,sw-mode is not
available for it. So remove this property from example.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Guillaume Stols <gstols@baylibre.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: iio: adc: adi,ad7606: add supply properties
Guillaume Stols [Tue, 2 Jul 2024 17:34:07 +0000 (17:34 +0000)]
dt-bindings: iio: adc: adi,ad7606: add supply properties

Add voltage supplies

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Guillaume Stols <gstols@baylibre.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: iio: adc: adi,ad7606: improve descriptions
Guillaume Stols [Tue, 2 Jul 2024 17:34:06 +0000 (17:34 +0000)]
dt-bindings: iio: adc: adi,ad7606: improve descriptions

Reword a few descriptions, and normalize the text width to 80 characters.

Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Guillaume Stols <gstols@baylibre.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: iio: adc: adi,ad7606: normalize textwidth
Guillaume Stols [Tue, 2 Jul 2024 17:34:05 +0000 (17:34 +0000)]
dt-bindings: iio: adc: adi,ad7606: normalize textwidth

Normalize textwidth to 80 columns on the descriptions.

Acked-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Guillaume Stols <gstols@baylibre.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad9467: support new parts
Nuno Sa [Thu, 4 Jul 2024 09:25:25 +0000 (11:25 +0200)]
iio: adc: ad9467: support new parts

Add support for new devices:
 * Analog Devices AD9652 16-bit 310 MSPS ADC;
 * Analog Devices AD9643 14-Bit, 170/210/250 MSPS ADC;
 * Analog Devices AD9649 14-bit 20/40/65/80 MSPS ADC.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240704-dev-iio-ad9467-new-devs-v1-5-f1adfee921f7@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agodt-bindings: adc: ad9467: support new parts
Nuno Sa [Thu, 4 Jul 2024 09:25:24 +0000 (11:25 +0200)]
dt-bindings: adc: ad9467: support new parts

Add support for new devices:
 * Analog Devices AD9652 16-bit 310 MSPS ADC;
 * Analog Devices AD9643 14-Bit, 170/210/250 MSPS ADC;
 * Analog Devices AD9649 14-bit 20/40/65/80 MSPS ADC.

Note all these parts have subtle differences in their programming model
(different scales, number of channels, etc..) so fallbacks are not
possible.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240704-dev-iio-ad9467-new-devs-v1-4-f1adfee921f7@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad9467: don't allow reading vref if not available
Nuno Sa [Thu, 4 Jul 2024 09:25:23 +0000 (11:25 +0200)]
iio: adc: ad9467: don't allow reading vref if not available

If there's only one possible scale, there's no way to change the Vref
select in the device so avoid reading the register in ad9467_get_scale().
In this case, it makes no sense to provide the .read_available()
callback nor allowing for writing the scale attribute.

Note this is in preparation for supporting a new device that only has
one possible scale.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240704-dev-iio-ad9467-new-devs-v1-3-f1adfee921f7@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad9467: add new chip_info variables
Nuno Sa [Thu, 4 Jul 2024 09:25:22 +0000 (11:25 +0200)]
iio: adc: ad9467: add new chip_info variables

Add new variables to the per chip info structure:

* test_points: Number of valid test points for calibration;
* has_dco_invert: Supports inverting DCO (Data clock output) polarity;
* dco_en: Specicic mask to enable DCO delays.

This is in preparation for supporting new parts with subtle differences
in how to configure the hardware.

Note that with the new test_points variable, we also add a new
calib_map_size to 'struct ad9467_state' so we know our map size
depending on how many test points we have and if we can run the
calibration in the inverted state or not.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240704-dev-iio-ad9467-new-devs-v1-2-f1adfee921f7@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad9467: support multiple channels calibration
Nuno Sa [Thu, 4 Jul 2024 09:25:21 +0000 (11:25 +0200)]
iio: adc: ad9467: support multiple channels calibration

The calibration process mixes the support for calibrating multiple
channels with only having one channel. Some paths do have 'num_channels'
into account while others don't.

As of now, the driver only supports devices with one channel so the
above is not really a problem. That said, we'll add support for devices
with more than one channel, hence let's properly make the calibration
process to work with it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240704-dev-iio-ad9467-new-devs-v1-1-f1adfee921f7@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ti-tsc2046: simplify with cleanup.h
Krzysztof Kozlowski [Fri, 5 Jul 2024 10:40:48 +0000 (12:40 +0200)]
iio: adc: ti-tsc2046: simplify with cleanup.h

Allocate the memory with scoped/cleanup.h to reduce error handling and
make the code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://patch.msgid.link/20240705-cleanup-h-iio-v1-5-77114c7e84c5@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: max1363: simplify with cleanup.h
Krzysztof Kozlowski [Fri, 5 Jul 2024 10:40:47 +0000 (12:40 +0200)]
iio: adc: max1363: simplify with cleanup.h

Allocate the memory with scoped/cleanup.h to reduce error handling and
make the code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240705-cleanup-h-iio-v1-4-77114c7e84c5@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: at91: simplify with cleanup.h
Krzysztof Kozlowski [Fri, 5 Jul 2024 10:40:46 +0000 (12:40 +0200)]
iio: adc: at91: simplify with cleanup.h

Allocate the memory with scoped/cleanup.h to reduce error handling and
make the code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240705-cleanup-h-iio-v1-3-77114c7e84c5@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad7280a: simplify with cleanup.h
Krzysztof Kozlowski [Fri, 5 Jul 2024 10:40:45 +0000 (12:40 +0200)]
iio: adc: ad7280a: simplify with cleanup.h

Allocate the memory with scoped/cleanup.h to reduce error handling and
make the code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240705-cleanup-h-iio-v1-2-77114c7e84c5@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: bma400: simplify with cleanup.h
Krzysztof Kozlowski [Fri, 5 Jul 2024 10:40:44 +0000 (12:40 +0200)]
iio: accel: bma400: simplify with cleanup.h

Allocate the memory with scoped/cleanup.h to reduce error handling and
make the code a bit simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240705-cleanup-h-iio-v1-1-77114c7e84c5@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: pressure: bmp280: Constify struct regmap_bus
Javier Carrasco [Wed, 3 Jul 2024 21:04:53 +0000 (23:04 +0200)]
iio: pressure: bmp280: Constify struct regmap_bus

`bmp280_regmap_bus` and `bmp380_regmap_bus` are conditionally assigned
to `bmp_regmap_bus`, which is only used to pass the struct as a
read-only member.

Add the const modifier to the structs and the pointer to move the data
to a read-only section.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Tested-By: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240703-iio-cont-regmap_bus-v1-10-34754f355b65@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: light: gp2ap002: Constify struct regmap_bus
Javier Carrasco [Wed, 3 Jul 2024 21:04:52 +0000 (23:04 +0200)]
iio: light: gp2ap002: Constify struct regmap_bus

`gp2ap002_regmap_bus` is not modified and can be declared as const to
move its data to a read-only section.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20240703-iio-cont-regmap_bus-v1-9-34754f355b65@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: imu: bno055: Constify struct regmap_bus
Javier Carrasco [Wed, 3 Jul 2024 21:04:51 +0000 (23:04 +0200)]
iio: imu: bno055: Constify struct regmap_bus

`bno055_ser_regmap_bus` is not modified and can be declared as const to
move its data to a read-only section.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20240703-iio-cont-regmap_bus-v1-8-34754f355b65@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: imu: bmi323: Constify struct regmap_bus
Javier Carrasco [Wed, 3 Jul 2024 21:04:50 +0000 (23:04 +0200)]
iio: imu: bmi323: Constify struct regmap_bus

`bmi323_regmap_bus` is not modified and can be declared as const to
move its data to a read-only section.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20240703-iio-cont-regmap_bus-v1-7-34754f355b65@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: dac: ltc2688: Constify struct regmap_bus
Javier Carrasco [Wed, 3 Jul 2024 21:04:49 +0000 (23:04 +0200)]
iio: dac: ltc2688: Constify struct regmap_bus

`ltc2688_regmap_bus` is not modified and can be declared as const to
move its data to a read-only section.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240703-iio-cont-regmap_bus-v1-6-34754f355b65@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: chemical: bme680: Constify struct regmap_bus
Javier Carrasco [Wed, 3 Jul 2024 21:04:48 +0000 (23:04 +0200)]
iio: chemical: bme680: Constify struct regmap_bus

`bme680_regmap_bus` is not modified and can be declared as const to
move its data to a read-only section.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Tested-By: Vasileios Amoiridis <vassilisamir@gmail.com>
Link: https://patch.msgid.link/20240703-iio-cont-regmap_bus-v1-5-34754f355b65@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad7091r8: Constify struct regmap_bus
Javier Carrasco [Wed, 3 Jul 2024 21:04:47 +0000 (23:04 +0200)]
iio: adc: ad7091r8: Constify struct regmap_bus

`ad7091r8_regmap_bus` is not modified and can be declared as const to
move its data to a read-only section.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240703-iio-cont-regmap_bus-v1-4-34754f355b65@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: bmi088: Constify struct regmap_bus
Javier Carrasco [Wed, 3 Jul 2024 21:04:46 +0000 (23:04 +0200)]
iio: accel: bmi088: Constify struct regmap_bus

`bmi088_regmap_bus` is not modified and can be declared as const to
move its data to a read-only section.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20240703-iio-cont-regmap_bus-v1-3-34754f355b65@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: bma400: Constify struct regmap_bus
Javier Carrasco [Wed, 3 Jul 2024 21:04:45 +0000 (23:04 +0200)]
iio: accel: bma400: Constify struct regmap_bus

`bma400_regmap_bus` is not modified and can be declared as const to
move its data to a read-only section.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20240703-iio-cont-regmap_bus-v1-2-34754f355b65@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: adxl367: Constify struct regmap_bus
Javier Carrasco [Wed, 3 Jul 2024 21:04:44 +0000 (23:04 +0200)]
iio: accel: adxl367: Constify struct regmap_bus

`adxl367_spi_regmap_bus` is not modified and can be declared as const to
move its data to a read-only section.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://patch.msgid.link/20240703-iio-cont-regmap_bus-v1-1-34754f355b65@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: imu: adis16480: make use of iio_for_each_active_channel()
Nuno Sa [Tue, 2 Jul 2024 16:02:52 +0000 (18:02 +0200)]
iio: imu: adis16480: make use of iio_for_each_active_channel()

Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-20-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: imu: adis16475: make use of iio_for_each_active_channel()
Nuno Sa [Tue, 2 Jul 2024 16:02:51 +0000 (18:02 +0200)]
iio: imu: adis16475: make use of iio_for_each_active_channel()

Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-19-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: at91_adc: make use of iio_for_each_active_channel()
Nuno Sa [Tue, 2 Jul 2024 16:02:50 +0000 (18:02 +0200)]
iio: adc: at91_adc: make use of iio_for_each_active_channel()

Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-18-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad_sigma_delta: use new '.masklength' accessors
Nuno Sa [Tue, 2 Jul 2024 16:02:49 +0000 (18:02 +0200)]
iio: adc: ad_sigma_delta: use new '.masklength' accessors

Make use of iio_get_masklength) and iio_for_each_active_channel() to
access '.masklength' so it can be annotated as __private when there
are no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-17-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad799x: make use of iio_get_masklength()
Nuno Sa [Tue, 2 Jul 2024 16:02:48 +0000 (18:02 +0200)]
iio: adc: ad799x: make use of iio_get_masklength()

Use iio_get_masklength() to access '.masklength' so it can be annotated
as __private when there are no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-16-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad7298: make use of iio_get_masklength()
Nuno Sa [Tue, 2 Jul 2024 16:02:47 +0000 (18:02 +0200)]
iio: adc: ad7298: make use of iio_get_masklength()

Use iio_get_masklength() to access '.masklength' so it can be annotated
as __private when there are no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-15-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: adc: ad7266: make use of iio_get_masklength()
Nuno Sa [Tue, 2 Jul 2024 16:02:46 +0000 (18:02 +0200)]
iio: adc: ad7266: make use of iio_get_masklength()

Use iio_get_masklength() to access '.masklength' so it can be annotated
as __private when there are no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-14-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: stk8ba50: make use of iio_for_each_active_channel()
Nuno Sa [Tue, 2 Jul 2024 16:02:45 +0000 (18:02 +0200)]
iio: accel: stk8ba50: make use of iio_for_each_active_channel()

Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-13-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: stk8312: make use of iio_for_each_active_channel()
Nuno Sa [Tue, 2 Jul 2024 16:02:44 +0000 (18:02 +0200)]
iio: accel: stk8312: make use of iio_for_each_active_channel()

Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-12-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: sca3300: make use of iio_for_each_active_channel()
Nuno Sa [Tue, 2 Jul 2024 16:02:43 +0000 (18:02 +0200)]
iio: accel: sca3300: make use of iio_for_each_active_channel()

Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-11-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: msa311: make use of iio_for_each_active_channel()
Nuno Sa [Tue, 2 Jul 2024 16:02:42 +0000 (18:02 +0200)]
iio: accel: msa311: make use of iio_for_each_active_channel()

Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-10-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: fxls8962af-core: make use of iio_for_each_active_channel()
Nuno Sa [Tue, 2 Jul 2024 16:02:41 +0000 (18:02 +0200)]
iio: accel: fxls8962af-core: make use of iio_for_each_active_channel()

Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there
are no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-9-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: cros_ec_accel_legacy: make use of iio_get_masklength()
Nuno Sa [Tue, 2 Jul 2024 16:02:40 +0000 (18:02 +0200)]
iio: accel: cros_ec_accel_legacy: make use of iio_get_masklength()

Ue iio_get_masklength() to access '.masklength' so it can be annotated
as __private when there are no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-8-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: bmc150-accel-core: make use of iio_for_each_active_channel()
Nuno Sa [Tue, 2 Jul 2024 16:02:39 +0000 (18:02 +0200)]
iio: accel: bmc150-accel-core: make use of iio_for_each_active_channel()

Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-7-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: bma180: make use of iio_for_each_active_channel()
Nuno Sa [Tue, 2 Jul 2024 16:02:38 +0000 (18:02 +0200)]
iio: accel: bma180: make use of iio_for_each_active_channel()

Use iio_for_each_active_channel() to iterate over active channels
accessing '.masklength' so it can be annotated as __private when there are
no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-6-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: adxl372: make use of iio_get_masklength()
Nuno Sa [Tue, 2 Jul 2024 16:02:37 +0000 (18:02 +0200)]
iio: accel: adxl372: make use of iio_get_masklength()

Use iio_get_masklength() to access '.masklength' so it can be annotated
as __private when there are no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-5-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: accel: adxl367: make use of iio_get_masklength()
Nuno Sa [Tue, 2 Jul 2024 16:02:36 +0000 (18:02 +0200)]
iio: accel: adxl367: make use of iio_get_masklength()

Use iio_get_masklength() to access '.masklength' so it can be annotated
as __private when there are no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-4-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: buffer: make use of iio_get_masklength()
Nuno Sa [Tue, 2 Jul 2024 16:02:35 +0000 (18:02 +0200)]
iio: buffer: make use of iio_get_masklength()

Use iio_get_masklength() to access '.masklength' so it can be annotated
as __private when there are no more direct users of it.

While at it, remove some unneeded line breaks.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-3-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: core: make use of iio_get_masklength()
Nuno Sa [Tue, 2 Jul 2024 16:02:34 +0000 (18:02 +0200)]
iio: core: make use of iio_get_masklength()

Use iio_get_masklength() to access '.masklength' so it can be annotated
as __private when there are no more direct users of it.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-2-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoiio: core: add accessors 'masklength'
Nuno Sa [Tue, 2 Jul 2024 16:02:33 +0000 (18:02 +0200)]
iio: core: add accessors 'masklength'

'masklength' is supposed to be an IIO private member. However, drivers
(often in trigger handlers) need to access it to iterate over the
enabled channels for example (there are other reasons). Hence, a couple
of new accessors are being added:

 * iio_for_each_active_channel() - Iterates over the active channels;
 * iio_get_masklength() - Get length of the channels mask.

The goal of these new accessors is to annotate 'masklength' as private
as soon as all drivers accessing it are converted to use the new
helpers.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Alexandru Ardelean <aardelean@baylibre.com>
Link: https://patch.msgid.link/20240702-dev-iio-masklength-private-v1-1-98193bf536a6@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
11 months agoLinux 6.11-rc1
Linus Torvalds [Sun, 28 Jul 2024 21:19:55 +0000 (14:19 -0700)]
Linux 6.11-rc1

11 months agoMerge tag 'kbuild-fixes-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/masah...
Linus Torvalds [Sun, 28 Jul 2024 21:02:48 +0000 (14:02 -0700)]
Merge tag 'kbuild-fixes-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

 - Fix RPM package build error caused by an incorrect locale setup

 - Mark modules.weakdep as ghost in RPM package

 - Fix the odd combination of -S and -c in stack protector scripts,
   which is an error with the latest Clang

* tag 'kbuild-fixes-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: Fix '-S -c' in x86 stack protector scripts
  kbuild: rpm-pkg: ghost modules.weakdep file
  kbuild: rpm-pkg: Fix C locale setup

11 months agominmax: simplify and clarify min_t()/max_t() implementation
Linus Torvalds [Sun, 28 Jul 2024 20:50:01 +0000 (13:50 -0700)]
minmax: simplify and clarify min_t()/max_t() implementation

This simplifies the min_t() and max_t() macros by no longer making them
work in the context of a C constant expression.

That means that you can no longer use them for static initializers or
for array sizes in type definitions, but there were only a couple of
such uses, and all of them were converted (famous last words) to use
MIN_T/MAX_T instead.

Cc: David Laight <David.Laight@aculab.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
11 months agominmax: add a few more MIN_T/MAX_T users
Linus Torvalds [Sun, 28 Jul 2024 20:03:48 +0000 (13:03 -0700)]
minmax: add a few more MIN_T/MAX_T users

Commit 3a7e02c040b1 ("minmax: avoid overly complicated constant
expressions in VM code") added the simpler MIN_T/MAX_T macros in order
to avoid some excessive expansion from the rather complicated regular
min/max macros.

The complexity of those macros stems from two issues:

 (a) trying to use them in situations that require a C constant
     expression (in static initializers and for array sizes)

 (b) the type sanity checking

and MIN_T/MAX_T avoids both of these issues.

Now, in the whole (long) discussion about all this, it was pointed out
that the whole type sanity checking is entirely unnecessary for
min_t/max_t which get a fixed type that the comparison is done in.

But that still leaves min_t/max_t unnecessarily complicated due to
worries about the C constant expression case.

However, it turns out that there really aren't very many cases that use
min_t/max_t for this, and we can just force-convert those.

This does exactly that.

Which in turn will then allow for much simpler implementations of
min_t()/max_t().  All the usual "macros in all upper case will evaluate
the arguments multiple times" rules apply.

We should do all the same things for the regular min/max() vs MIN/MAX()
cases, but that has the added complexity of various drivers defining
their own local versions of MIN/MAX, so that needs another level of
fixes first.

Link: https://lore.kernel.org/all/b47fad1d0cf8449886ad148f8c013dae@AcuMS.aculab.com/
Cc: David Laight <David.Laight@aculab.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>