sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it
knows about the sysfs buffer specifics and has some built-in checks for
size and alignment.
Use sysfs_emit() to format the custom `in_power_shunt_resistor` and
`in_current_shunt_resistor` device attributes of the max9611 driver.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Link: https://lore.kernel.org/r/20211216185217.1054495-11-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Note the handling of the device tree node in this driver was somewhat
unusual. I have cleaned that up whilst also moving over to generic
properties.
Part of a general attempt to move all IIO drivers over to generic
firmware properties both as a general improvement and to avoid sources
of cut and paste into future drivers.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
No attempt has been made to document any of the demoted structs here.
Fixes the following W=1 kernel build warning(s):
drivers/iio/adc/max9611.c:117: warning: cannot understand function prototype: 'const unsigned int max9611_mux_conf[][2] = '
drivers/iio/adc/max9611.c:145: warning: cannot understand function prototype: 'const unsigned int max9611_gain_conf[][2] = '
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
If a driver does not assign an of_node to a IIO device to IIO core will
automatically assign the of_node of the parent device. This automatic
assignment is done in the iio_device_register() function.
There is a fair amount of drivers that currently manually assign the
of_node of the IIO device. All but 4 of them can make use of the automatic
assignment though.
The exceptions are:
* mxs-lradc-adc: Which uses the of_node of the parent of the parent.
* stm32-dfsdm-adc, stm32-adc and stm32-dac: Which reference the of_node
assigned to the IIO device before iio_device_register() is called.
All other drivers are updated to use automatic assignment. This reduces
the amount of boilerplate code involved in setting up the IIO device.
The patch has mostly been auto-generated with the following semantic patch
// <smpl>
@exists@
expression indio_dev;
expression parent;
@@
indio_dev = \(devm_iio_device_alloc\|iio_device_alloc\)(&parent, ...)
...
-indio_dev->dev.of_node = parent.of_node;
@exists@
expression indio_dev;
expression parent;
@@
indio_dev = \(devm_iio_device_alloc\|iio_device_alloc\)(parent, ...)
...
-indio_dev->dev.of_node = parent->of_node;
// </smpl>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This patch applies the semantic patch:
@@
expression I, P, SP;
@@
I = devm_iio_device_alloc(P, SP);
...
- I->dev.parent = P;
It updates 302 files and does 307 deletions.
This semantic patch also removes some comments like
'/* Establish that the iio_dev is a child of the i2c device */'
But this is is only done in case where the block is left empty.
The patch does not seem to cover all cases. It looks like in some cases a
different variable is used in some cases to assign the parent, but it
points to the same reference.
In other cases, the block covered by ... may be just too big to be covered
by the semantic patch.
However, this looks pretty good as well, as it does cover a big bulk of the
drivers that should remove the parent assignment.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
New device support
* ad7091r5 ADC
- New driver with follow up patch adding scale and vref support.
- DT bindings
* ad7923
- Support for ad7908, ad7918 and ad7928 added to driver.
* bma180
- Support the BMA254 accelerometer. Required fairly substantial rework
to allow for small differences between this an existing parts.
* bma400 accelerometer
- New driver with follow up patch for regulator support.
- DT bindings.
* asc dlhl60d
- New driver support this range of pressure and temperature sensors.
- DT bindings.
* ltc2496 ADC
- New driver to support this ADC.
- Split the existing LTC2497 driver generic component out and reuse.
- DT bindings.
* parallax ping
- New driver supporting ultrasonic and laser tof distance sensors.
- Bindings for these sensors.
New features
* core
- New char type for read_raw returns, used for thermocouple types.
- Rename read_first_n callback to read. The reasons behind the original
naming are lost to the mists of time.
* ad799x
- Allow pm_ops to disable device completely allowing regulator power down.
* bma180
- Enable basic regulator support.
* dmaengine buffer
- Report platform data alignment requirements via new ABI.
* max31856
- Add option to set mains filter rejection frequency and document
new in_temp_filter_notch_center_frequency ABI.
- Add support for configuring HW averaging (oversampling ratio)
- Add runtime configuration of thermocouple type and document new ABI.
* maxim-thermocouple
- Add read only access to thermocouple type using new ABI, includes
adding more specific compatibles to reflect which variant of the
chip is being used.
* mpu6050
- Provide option to support the PMU9150 in package magnetometer directly
rather than via auxiliary bus.
* stm32_adc
- Add overrun interrupt checks to detect if this happens.
* st_lsm6dsx
- Enable the sensor-hub support for lsm6dsm. Includes various reworks to
allow this.
Cleanups and minor fixes
* Subsystem wide
- Tidy up indentation in Kconfig and fix alphabetical order of AD7091R5.
- Drop linux/gpio.h and linux/of_gpio.h from drivers that don't use them.
* ad7266
- Convert to GPIO descriptors.
* ad7303
- Avoid a dance with checking if the regulator is supplied by just
using the optional request interface.
* ad7887
- Simplify channel specification assignment to enable adding more devices.
* ad7923
- Drop some unused and largely pointless defines of BOB_N==N variety.
- Tidy up checkpatch warnings.
- Add missing of_device_id table.
* adf4350
- Convert to GPIO descriptors.
* ak8975
- Convert to GPIO descriptors.
* ADIS library and drivers
- Expand scope of txrx_lock to cover all state and rename as state_lock
- Add unlocked read / write to allow grouping of consecutive calls under
single lock / unlock.
- Add unlocked check_status, reset to allow grouping under single
lock / unlock.
- Remove remaining uses of core mlock for local state protection.
mlock should never be used directly as it protects tightly defined
core IIO device management state.
* adis16240
- Enforce only supported SPI mode on driver load + add DT binding doc.
* atlas-ph-sensor
- Rename to atlas-sensor given it now covers things beyond ph sensors.
* bma180
- Use local dev variable to tidy up code.
- Use c99 style explicity .member assignment to make driver more readable.
* bmp280
- Drop ACPI support. No evidence this was used and appropriate ID is not
registered.
- Allow ACPI to bind device via PRP0001
* dmaengine buffer
- Use dma_request_chan instead of dma_request_slave_channel_reason as that
ABI is going away.
- Add module info to avoid tainting the kernel.
* hts221
- Avoid magic number defines when only used to fill structure elements
that are self describing.
* lm3533
- Drop a stray semicolon.
* max9611
- Cleanup enum handling to be more resilient to future changes.
* mpu6050
- Delete MPU9150 from supported SPI devices as doesn't provide SPI.
- Select I2C_MUX again after kbuild issue fixed elsewhere.
* stm32-timer
- Drop an unnecessary register update.
* ssp_sensors
- Convert to GPIO descriptors.
* st_sensors
- drop !CONFIG_ACPI defines as ACPI_PTR() will stop them being used
anyway.
- Make default platform data structures __maybe_unsued.
- Fill in some missing kernel-doc function parameters.
* st_lsm6dsx
- white space fixes.
- Mark some constants that aren't always used as __maybe_unused.
- Drop of ID table guards as they just pervent use under ACPI.
- Switch to device properties to allow ACPI usage.
* st_uvis25
- Drop acpi.h include as no ACPI APIs used.
* ti-ads1015
- Drop legacy platform data as no one seems to be using it.
- Use the device property API instead of OF specific.
* ti-ads7950
- typo fix in error message.
-----BEGIN PGP SIGNATURE-----
iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl4R2mwRHGppYzIzQGtl
cm5lbC5vcmcACgkQVIU0mcT0Fogfow//Rfsrd2oiAwy4ypm70ZWGnr84C3O/Vpic
Agwdd2/lHiCA2Gjg+n7ZT6XkKQmKiojuBMT05PuskEm5onJVQuSAKMVppXwU6UDP
uOUS5MAbo87GLogzXJnAR/eCrx/VkC4UqFRBSi7IUIj+lTpjiOhmoqm78VTMxkgT
hvp5PVN/mLNxNV3eVrR9uILjZLpbBjKjWil00IS2zj0o78sGtd2QtMIdTbn3iBLp
m0ngCDww1KDH+idwbOIn8YX8GSK8mTjNV5q4r9+xnjoAk8RPk+H317idyRHCKfCM
wWFSFB6u/oqtHXRgQVi3ndRrZnPLTycA/R20f3ezzhVYZzf3RpH8Upcx0lqqCmrB
+ZTbYW1L7KL6zCSR4ZYIEmw2TeQngfCGy0yDoEDXm9V8/B2nGWFc3Iknq+fK415V
7OgJCWAw6ybF2LZfJHpcuJTb0EPxCKnInHbRsaxCsSAPRyERSdAz8RLn3lpH/k2D
X32Q9hz/6sXKzIAD1Y0jv8ll28D5S7d2FgaWufy1tpB+CMb0Mp0RQn+Ho8lNMh70
Zh9SF8RvknAiCT9iHeVIdbJxoYEtMuCaDwScliukVcg12gVViY5VzXMbSV/4jCnZ
bAVZDpcM3LVLxCGbWqCNxjQ9wle99LsVHRld/KDpOfI6VIYDb8Y900Nf6efkQkAs
a6z6rhpVdDg=
=8FmM
-----END PGP SIGNATURE-----
Merge tag 'iio-for-5.6a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
First set of new device support, features and cleanups for IIO in the 5.6 cycle
New device support
* ad7091r5 ADC
- New driver with follow up patch adding scale and vref support.
- DT bindings
* ad7923
- Support for ad7908, ad7918 and ad7928 added to driver.
* bma180
- Support the BMA254 accelerometer. Required fairly substantial rework
to allow for small differences between this an existing parts.
* bma400 accelerometer
- New driver with follow up patch for regulator support.
- DT bindings.
* asc dlhl60d
- New driver support this range of pressure and temperature sensors.
- DT bindings.
* ltc2496 ADC
- New driver to support this ADC.
- Split the existing LTC2497 driver generic component out and reuse.
- DT bindings.
* parallax ping
- New driver supporting ultrasonic and laser tof distance sensors.
- Bindings for these sensors.
New features
* core
- New char type for read_raw returns, used for thermocouple types.
- Rename read_first_n callback to read. The reasons behind the original
naming are lost to the mists of time.
* ad799x
- Allow pm_ops to disable device completely allowing regulator power down.
* bma180
- Enable basic regulator support.
* dmaengine buffer
- Report platform data alignment requirements via new ABI.
* max31856
- Add option to set mains filter rejection frequency and document
new in_temp_filter_notch_center_frequency ABI.
- Add support for configuring HW averaging (oversampling ratio)
- Add runtime configuration of thermocouple type and document new ABI.
* maxim-thermocouple
- Add read only access to thermocouple type using new ABI, includes
adding more specific compatibles to reflect which variant of the
chip is being used.
* mpu6050
- Provide option to support the PMU9150 in package magnetometer directly
rather than via auxiliary bus.
* stm32_adc
- Add overrun interrupt checks to detect if this happens.
* st_lsm6dsx
- Enable the sensor-hub support for lsm6dsm. Includes various reworks to
allow this.
Cleanups and minor fixes
* Subsystem wide
- Tidy up indentation in Kconfig and fix alphabetical order of AD7091R5.
- Drop linux/gpio.h and linux/of_gpio.h from drivers that don't use them.
* ad7266
- Convert to GPIO descriptors.
* ad7303
- Avoid a dance with checking if the regulator is supplied by just
using the optional request interface.
* ad7887
- Simplify channel specification assignment to enable adding more devices.
* ad7923
- Drop some unused and largely pointless defines of BOB_N==N variety.
- Tidy up checkpatch warnings.
- Add missing of_device_id table.
* adf4350
- Convert to GPIO descriptors.
* ak8975
- Convert to GPIO descriptors.
* ADIS library and drivers
- Expand scope of txrx_lock to cover all state and rename as state_lock
- Add unlocked read / write to allow grouping of consecutive calls under
single lock / unlock.
- Add unlocked check_status, reset to allow grouping under single
lock / unlock.
- Remove remaining uses of core mlock for local state protection.
mlock should never be used directly as it protects tightly defined
core IIO device management state.
* adis16240
- Enforce only supported SPI mode on driver load + add DT binding doc.
* atlas-ph-sensor
- Rename to atlas-sensor given it now covers things beyond ph sensors.
* bma180
- Use local dev variable to tidy up code.
- Use c99 style explicity .member assignment to make driver more readable.
* bmp280
- Drop ACPI support. No evidence this was used and appropriate ID is not
registered.
- Allow ACPI to bind device via PRP0001
* dmaengine buffer
- Use dma_request_chan instead of dma_request_slave_channel_reason as that
ABI is going away.
- Add module info to avoid tainting the kernel.
* hts221
- Avoid magic number defines when only used to fill structure elements
that are self describing.
* lm3533
- Drop a stray semicolon.
* max9611
- Cleanup enum handling to be more resilient to future changes.
* mpu6050
- Delete MPU9150 from supported SPI devices as doesn't provide SPI.
- Select I2C_MUX again after kbuild issue fixed elsewhere.
* stm32-timer
- Drop an unnecessary register update.
* ssp_sensors
- Convert to GPIO descriptors.
* st_sensors
- drop !CONFIG_ACPI defines as ACPI_PTR() will stop them being used
anyway.
- Make default platform data structures __maybe_unsued.
- Fill in some missing kernel-doc function parameters.
* st_lsm6dsx
- white space fixes.
- Mark some constants that aren't always used as __maybe_unused.
- Drop of ID table guards as they just pervent use under ACPI.
- Switch to device properties to allow ACPI usage.
* st_uvis25
- Drop acpi.h include as no ACPI APIs used.
* ti-ads1015
- Drop legacy platform data as no one seems to be using it.
- Use the device property API instead of OF specific.
* ti-ads7950
- typo fix in error message.
* tag 'iio-for-5.6a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (99 commits)
iio: accel: bma180: BMA254 support
iio: pressure: bmp280: Allow device to be enumerated from ACPI
iio: pressure: bmp280: Drop ACPI support
dt-bindings: iio: adc: convert sd modulator to json-schema
iio: buffer: rename 'read_first_n' callback to 'read'
iio: buffer-dmaengine: Report buffer length requirements
bindings: iio: pressure: Add documentation for dlh driver
dt-bindings: Add asc vendor
iio: pressure: Add driver for DLH pressure sensors
iio: buffer-dmaengine: Add module information
iio: accel: bma180: Use explicit member assignment
iio: accel: bma180: Basic regulator support
iio: accel: bma180: Add dev helper variable
iio: imu: st_lsm6dsx: enable sensor-hub support for lsm6dsm
iio: imu: st_lsm6dsx: rename st_lsm6dsx_shub_read_reg in st_lsm6dsx_shub_read_output
iio: imu: st_lsm6dsx: check if shub_output reg is located in primary page
iio: imu: st_lsm6dsx: check if pull_up is located in primary page
iio: imu: st_lsm6dsx: check if master_enable is located in primary page
iio: imu: st_lsm6dsx: export max num of slave devices in st_lsm6dsx_shub_settings
iio: light: remove unneeded semicolon
...
As of commit b9ddd50911 ("iio: adc: max9611: Fix temperature
reading in probe"), max9611 initialization sometimes fails on the
Salvator-X(S) development board with:
max9611 4-007f: Invalid value received from ADC 0x8000: aborting
max9611: probe of 4-007f failed with error -5
The max9611 driver tests communications with the chip by reading the die
temperature during the probe function, which returns an invalid value.
According to the datasheet, the typical ADC conversion time is 2 ms, but
no minimum or maximum values are provided. Maxim Technical Support
confirmed this was tested with temperature Ta=25 degreeC, and promised
to inform me if a maximum/minimum value is available (they didn't get
back to me, so I assume it is not).
However, the driver assumes a 1 ms conversion time. Usually the
usleep_range() call returns after more than 1.8 ms, hence it succeeds.
When it returns earlier, the data register may be read too early, and
the previous measurement value will be returned. After boot, this is
the temperature POR (power-on reset) value, causing the failure above.
Fix this by increasing the delay from 1000-2000 µs to 3000-3300 µs.
Note that this issue has always been present, but it was exposed by the
aformentioned commit.
Fixes: 69780a3bbc ("iio: adc: Add Maxim max9611 ADC driver")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The relations between enum values and array indices values are currently
not enforced by the code, which makes them fragile w.r.t. future
changes.
Fix this by:
1. Using designated array initializers, to make sure array indices and
enums values match,
2. Linking max9611_csa_gain enum values to the corresponding
max9611_conf_ids enum values, as the latter is cast to the former
in max9611_read_csa_voltage().
No change in generated code.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The max9611 driver reads the die temperature at probe time to validate
the communication channel. Use the actual read value to perform the test
instead of the read function return value, which was mistakenly used so
far.
The temperature reading test was only successful because the 0 return
value is in the range of supported temperatures.
Fixes: 69780a3bbc ("iio: adc: Add Maxim max9611 ADC driver")
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Arguments are supposed to be ordered high then low.
Signed-off-by: Joe Perches <joe@perches.com>
Fixes: 69780a3bbc ("iio: adc: Add Maxim max9611 ADC driver")
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This patch updates license to use SPDX-License-Identifier
instead of verbose license text.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
After finding a reasonable gain, the function converts the configured
gain to a gain configuration option selector enum max9611_csa_gain.
Make the conversion clearly visible by using an explicit cast. This
also avoids a warning seen with clang:
drivers/iio/adc/max9611.c:292:16: warning: implicit conversion from
enumeration type 'enum max9611_conf_ids' to different enumeration
type 'enum max9611_csa_gain' [-Wenum-conversion]
*csa_gain = gain_selectors[i];
~ ^~~~~~~~~~~~~~~~~
Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This has been handled by the i2c core for some time.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
The equivalent of both of these are now done via macro magic when
the relevant register calls are made. The actual structure
elements will shortly go away.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Now that we have a custom printf format specifier, convert users of
full_name to use %pOF instead. This is preparation to remove storing
of the full path string for each node.
Signed-off-by: Rob Herring <robh@kernel.org>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Carlo Caione <carlo@caione.org>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: linux-iio@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-amlogic@lists.infradead.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The power and current "shunt-resistor" attribute's 'show' function
displays the resistor value in milli-Ohms, while the ABI description
specifies it should be displayed in Ohms. Fix it.
Reported-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>