iio: hrtimer-trigger: Fix potential integer overflow in iio_hrtimer_store_sampling_frequency
Add suffix ULL to constant 1000 in order to avoid a potential integer
overflow and give the compiler complete information about the proper
arithmetic to use. Notice that this constant is being used in a context
that expects an expression of type unsigned long long, but it's
currently evaluated using 32-bit arithmetic.
Addresses-Coverity-ID: 1503062 ("Unintentional integer overflow") Fixes: dafcf4ed8392 ("iio: hrtimer: Allow sub Hz granularity") Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Link: https://lore.kernel.org/r/20210329205817.GA188755@embeddedor Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This driver was in an odd half way state between devm based cleanup
and manual cleanup (most of which was missing).
I would guess something went wrong with a rebase or similar.
Anyhow, this basically finishes the job as a precursor to improving
the regulator handling.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Fixes: 4bb2b8f94ace3 ("iio: adc: ad7476: implement devm_add_action_or_reset") Cc: Michael Hennerich <michael.hennerich@analog.com> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Cc: <Stable@vger.kernel.org> Link: https://lore.kernel.org/r/20210401171759.318140-2-jic23@kernel.org
iio:adc:ad_sigma_delta: Use IRQF_NO_AUTOEN rather than request and disable
These devices are not able to mask the signal used as a data ready
interrupt. As such they previously requested the irq then immediately
disabled it. Now we can avoid the potential of a spurious interrupt
by avoiding the irq being auto enabled in the first place.
I'm not sure how this code could have been called with the irq already
disabled, so I believe the conditional would always have been true and
have removed it.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Alexandru Ardelean <ardeleanalex@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20210402184544.488862-8-jic23@kernel.org
iio:imu:adis: Use IRQF_NO_AUTOEN instead of irq request then disable
This is a bit involved as the adis library code already has some
sanity checking of the flags of the requested irq that we need
to ensure is happy to pass through the IRQF_NO_AUTOEN flag untouched.
Using this flag avoids us autoenabling the irq in the adis16460 and
adis16475 drivers which cover parts that don't have any means of
masking the interrupt on the device end.
Note, compile tested only!
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Alexandru Ardelean <ardeleanalex@gmail.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Reviewed-by: Barry Song <song.bao.hua@hisilicon.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20210402184544.488862-7-jic23@kernel.org
iio:chemical:scd30: Use IRQF_NO_AUTOEN to avoid irq request then disable
This new flag cleanly avoids the need for a dance where we request the
interrupt only to immediately disabling it by ensuring it is not
auto-enabled in the first place.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Tomasz Duszynski <tomasz.duszynski@octakon.com> Reviewed-by: Barry Song <song.bao.hua@hisilicon.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20210402184544.488862-6-jic23@kernel.org
iio:adc:sun4i-gpadc: Use new IRQF_NO_AUTOEN flag instead of request then disable
This new flag ensures a requested irq is not autoenabled, thus removing
the need for the disable_irq() that follows and closing off any chance
of spurious interrupts.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Maxime Ripard <maxime.ripard@bootlin.com> Reviewed-by: Barry Song <song.bao.hua@hisilicon.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20210402184544.488862-5-jic23@kernel.org
iio:adc:nau7802: Use IRQF_NO_AUTOEN instead of request then disable
Whilst a race during interrupt enabling is probably not a problem,
it is better to not enable the interrupt at all. The new
IRQF_NO_AUTOEN flag allows us to do that.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com> Reviewed-by: Barry Song <song.bao.hua@hisilicon.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20210402184544.488862-4-jic23@kernel.org
iio:adc:exynos-adc: Use new IRQF_NO_AUTOEN flag rather than separate irq_disable()
Disabling an irq before the driver has actually atempted to request it
may work, but is definitely not as clean as just requesting it as
normal but with the auto enable disabled.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Krzysztof Kozlowski <krzk@kernel.org> Reviewed-by: Barry Song <song.bao.hua@hisilicon.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20210402184544.488862-3-jic23@kernel.org
iio:adc:ad7766: Use new IRQF_NO_AUTOEN to reduce boilerplate
As iio_poll_trigger() is safe against spurious interrupts when the
trigger is not enabled, this is not a fix despite looking like
a race. It is nice to simplify the code however so the interrupt
is never enabled in the first place.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Lars-Peter Clausen <lars@metafoo.de> Reviewed-by: Barry Song <song.bao.hua@hisilicon.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20210402184544.488862-2-jic23@kernel.org
iio: buffer: use sysfs_attr_init() on allocated attrs
When dynamically allocating sysfs attributes, it's a good idea to call
sysfs_attr_init() on them to initialize lock_class_keys.
This change does that.
The lock_class_keys are set when the CONFIG_DEBUG_LOCK_ALLOC symbol is
enabled. Which is [likely] one reason why I did not see this during
development.
I also am not able to see this even with CONFIG_DEBUG_LOCK_ALLOC enabled,
so this may [likely] be reproduce-able on some system configurations.
This was reported via:
https://lore.kernel.org/linux-iio/CA+U=DsrsvGgXEF30-vXuXS_k=-mjSjiBwEEzwKb1hJVn1P98OA@mail.gmail.com/T/#u
Fixes: 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr") Reported-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210402174226.630346-1-aardelean@deviqon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Andy Shevchenko [Fri, 2 Apr 2021 17:49:10 +0000 (20:49 +0300)]
iio: trigger: Replace explicit casting and wrong specifier with proper one
By unknown reason device name is set with an index casted from int
to unsigned long while at the same time with "%ld" specifier. Both parts
seems wrong to me, thus replace replace explicit casting and wrong specifier
with proper one, i.e. "%d".
iio:adc: Drop false comment about lack of timestamp control
The timestamp control has been a function implemented in the core of
IIO for a long time, so this comment is incorrect and has clearly been
cut and paste into all these drivers.
The remainder of the comment added nothing and was confusing so dropped
that as well.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Michael Hennerich <Michael.Hennerich@analog.com> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Link: https://lore.kernel.org/r/20210401145410.226917-1-jic23@kernel.org
Jonathan Cameron [Sun, 14 Mar 2021 18:15:11 +0000 (18:15 +0000)]
iio:cdc:ad7150: Move driver out of staging.
This capacitance to digital converter (CDC) driver is compliant with
the IIO ABI. Note, not all features supported (e.g. window event modes)
but the driver should be in a useful functional state.
The cleanup was done against QEMU emulation of the device rather than
actual hardware. Whilst this was a bit of an experiment, it made it
easy to confirm that the driver remained in a consistent working state
through the various refactors. If it worked in the first place, it
should still be working after this cleanup.
Given some IIO drivers require expensive hardware setups, (not particularly
true with this one) the use of QEMU may provide a viable way forward
for providing testing during code changes where previously we'd had
to rely on sharp eyes and crossed fingers.
Note, no explicit MAINTAINERS entry as it will be covered by the
generic catch-alls for ADI and IIO drivers which are sufficient.
Jonathan Cameron [Sun, 14 Mar 2021 18:15:10 +0000 (18:15 +0000)]
dt-bindings:iio:cdc:adi,ad7150 binding doc
Binding covering the ad7150, ad7151 and ad7156 capacitance to digital
convertors. The only difference between these is how many channels they
have (1 or 2)
Whilst it is clearly necessary to provide power to the part, we don't
need to know the voltage or anything so if it is always on, there should
be no need to have it specified in the binding.
Jonathan Cameron [Sun, 14 Mar 2021 18:15:08 +0000 (18:15 +0000)]
iio:Documentation:ABI Add missing elements as used by the adi,ad7150
Main additions are around thresh_adaptive. This has been supported
by the core of IIO for a long time, but no driver that uses it has
previously graduated from staging, hence we are missing Docs.
Jonathan Cameron [Sun, 14 Mar 2021 18:15:05 +0000 (18:15 +0000)]
staging:iio:cdc:ad7150: Add scale and offset to info_mask_shared_by_type
The datasheet provides these two values on the assumption they are applied
to unshift raw value. Hence shift both the offset and scale by 4
to compensate.
Jonathan Cameron [Sun, 14 Mar 2021 18:15:04 +0000 (18:15 +0000)]
staging:iio:cdc:ad7150: Shift the _raw readings by 4 bits.
Every other register related to raw value on the datasheet is
described as correpsonding to the 12MSB of the actual
data registers + the bottom 4 bits are 0. So lets treat this
as what it actually is, which is a 12 bit value.
Note that we will have to be a little careful to compensate for
the offset and scale values.
Jonathan Cameron [Sun, 14 Mar 2021 18:15:00 +0000 (18:15 +0000)]
staging:iio:cdc:ad7150: More consistent register and field naming
Add _REG postfix to register addresses to avoid confusion with
fields. Also add additional field defines and use throughout the
driver in place of magic numbers.
Jonathan Cameron [Sun, 14 Mar 2021 18:14:59 +0000 (18:14 +0000)]
staging:iio:cdc:ad7150: Rework interrupt handling.
Note this doesn't support everything the chip can do as we ignore
window mode for now (in window / out of window).
* Given the chip doesn't have any way of disabling the threshold
pins, use disable_irq() etc to mask them except when we actually
want them enabled (previously events were always enabled).
Note there are race conditions, but using the current state from
the status register and disabling interrupts across changes in
type of event should mean those races result in interrupts,
but no events to userspace.
* Correctly reflect that there is one threshold line per channel.
* Only take notice of rising edge. If anyone wants the other edge
then they should set the other threshold (they are available for
rising and falling directions). This isn't perfect but it makes
it a lot simpler.
* If insufficient interrupts are specified in firnware, don't support
events.
* Adaptive events use the same pos/neg values of thrMD as non adaptive
ones.
Jonathan Cameron [Sun, 14 Mar 2021 18:14:58 +0000 (18:14 +0000)]
staging:iio:cdc:ad7150: Change timeout units to seconds and use core support
Now we have core support for timeouts related to adaptive events, let us
use it. Note the units of that attribute are seconds, so we also need
to scale the cycles value by the period of each sample.
Jonathan Cameron [Sun, 14 Mar 2021 18:14:57 +0000 (18:14 +0000)]
iio:event: Add timeout event info type
For adaptive threshold events, the current value is compared with a
(typically) low pass filtered version of the same signal that slowly
tracks large scale changes. However, sometimes a step change can
result in a large lag before the low pass filtered version begins
to track the signal again. Timeouts can be used to made an
instantaneous 'correction'. Documentation of this attribute
is added in a later patch.
Jonathan Cameron [Sun, 14 Mar 2021 18:14:54 +0000 (18:14 +0000)]
staging:iio:cdc:ad7150: Simplify event handling by only using rising direction.
The event line is active high and not maskable within the device.
It indicates current state directly.
The device supports separate rising and falling thresholds so rather
than trying to using each bound to detect in both directions just use
IRQF_TRIGGER_RISING. If a user wants to detect the value falling
back below the threshold, then set the falling threshold appropriately.
Jonathan Cameron [Sun, 14 Mar 2021 18:14:53 +0000 (18:14 +0000)]
staging:iio:cdc:ad7150: Handle variation in chan_spec across device and irq present or not
The driver supports devices with different numbers of channels and
also can function without provision of an IRQ (with reduced features),
so this patch handles this cleanly by having multiple chan_spec
arrays and iio_info structures to pick between depending on what we
have.
Jonathan Cameron [Sun, 14 Mar 2021 18:14:51 +0000 (18:14 +0000)]
staging:iio:cdc:ad7150: Timeout register covers both directions so both need updating
The timeout is treated as one single value, but the datasheet describes
it as two 4 bit values, one for each direction of event.
As such change the driver to support the separate directions.
Also add limit checking to ensure it fits within the 4 bits.
Original code was ordered in a fairly unituitive fashion with
the non adaptive threshold handling returning from the switch
statement, whilst the adapative path did the actual writes outside
the switch. Make it more readable by bringing everything within
the switch statement cases and reducing scope of local variables
as appropriate.
The devices support window detection, but that corresponds to
being outside of a range defined by a lower an uppper bound rather
than being related to magnitude as such. Hence drop this interface
in the interests of making the driver ABI compliant.
We may bring back support for the window mode at somepoint in the future
but it will be in an ABI compliant fashion.
The inv_mpu6050 driver requires an interrupt for buffered capture. But non
buffered reading for measurements works just fine without an interrupt
connected.
iio: buffer: return 0 for buffer getfd ioctl handler
As Lars pointed out, we could either return the FD vs memcpy-ing it to the
userspace data object.
However, this comment exposed a bug. We should return 0 or negative from
these ioctl() handlers. Because an ioctl() handler can also return
IIO_IOCTL_UNHANDLED (which is positive 1), which means that the ioctl()
handler doesn't support this ioctl number. Positive 1 could also be a valid
FD number in some corner cases.
The reason we did this is to be able to differentiate between an error
code and an unsupported ioctl number; for unsupported ioctl numbers, the
main loop should keep going.
Maybe we should change this to a higher negative number, to avoid such
cases when/if we add more ioctl() handlers.
Cc: Lars-Peter Clausen <lars@metafoo.de> Fixes: f73f7f4da5818 ("iio: buffer: add ioctl() to support opening extra buffers for IIO device") Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com> Link: https://lore.kernel.org/r/20210322084135.17536-1-aardelean@deviqon.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Linus Walleij [Tue, 23 Mar 2021 12:27:05 +0000 (13:27 +0100)]
iio: Fix iio_read_channel_processed_scale()
The code was checking if (ret) from the processed
channel readout, not smart, we need to check if (ret < 0)
as this will likely be something like IIO_VAL_INT.
Lucas Stankus [Sun, 28 Mar 2021 21:46:46 +0000 (18:46 -0300)]
iio: adc: ad7923: register device with devm_iio_device_register
Registers the device using the devm variant.
This is the final step of converting the ad7923 to only use devm routines,
meaning that the ad7923_remove() function is no longer needed to release
resources on device detach.
Lucas Stankus [Sun, 28 Mar 2021 21:46:26 +0000 (18:46 -0300)]
iio: adc: ad7923: use device-managed function for triggered buffer
Converts the iio_triggered_buffer_setup() call to its device-managed
counterpart.
With this, the error handling routine in the ad7923_probe() function
becomes unnecessary as well as the iio_triggered_buffer_cleanup() call.
Lucas Stankus [Sun, 28 Mar 2021 21:46:04 +0000 (18:46 -0300)]
iio: adc: ad7923: use devm_add_action_or_reset for regulator disable
Adds a device-managed action to handle disabling the driver's regulator on
device detach.
This slightly simplifies deinitialization and enables further conversion of
the driver to device-managed routines without breaking the init order.
And when you want to use it to read periodically from
your magnetometer like this:
> iio_generic_buffer -a -c 100 -n hscdtd008a -t mpu6050-dev1
Then the following happens:
[ 209.951334] Internal error: Oops: 5 [#1] SMP ARM
(...)
[ 209.981969] Hardware name: ST-Ericsson Ux5x0 platform (Device Tree Support)
[ 209.988925] PC is at inv_scan_query_mpu6050+0x8/0xb8
[ 209.993914] LR is at inv_mpu6050_set_enable+0x40/0x194
This is because since we are not using any channels from the
same device, the indio_dev->active_scan_mask is NULL.
Just checking for that and bailing out is however not enough:
we have to enable some kind of FIFO for the readout to work.
So enable the temperature as a dummy FIFO and all works
fine.
Not suitable for backporting to stable. It is an odd corner case
and does not represent a regression.
Jonathan Cameron [Sun, 21 Mar 2021 18:29:56 +0000 (18:29 +0000)]
iio:accel:adis16201: Fix wrong axis assignment that prevents loading
Whilst running some basic tests as part of writing up the dt-bindings for
this driver (to follow), it became clear it doesn't actually load
currently.
iio iio:device1: tried to double register : in_incli_x_index
adis16201 spi0.0: Failed to create buffer sysfs interfaces
adis16201: probe of spi0.0 failed with error -16
Looks like a cut and paste / update bug. Fixes tag obviously not accurate
but we don't want to bother carry thing back to before the driver moved
out of staging.
Fixes: 591298e54cea ("Staging: iio: accel: adis16201: Move adis16201 driver out of staging") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: <Stable@vger.kernel.org> Cc: Himanshu Jha <himanshujha199640@gmail.com> Cc: Nuno Sá <nuno.sa@analog.com> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Link: https://lore.kernel.org/r/20210321182956.844652-1-jic23@kernel.org
iio: dac: Convert powerdown read callbacks to sysfs_emit()
Update DAC drivers powerdown attribute show callback to use the new
sysfs_emit() function.
sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it
knows about the sysfs buffer specifics and has some built-in sanity checks.
iio: __iio_format_value(): Convert to sysfs_emit_at()
sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it
knows about the sysfs buffer specifics and has some built-in sanity checks.
Convert __iio_format_value() and related functions to use this new
interface.
This conversion involves changing the signature of __iio_format_value() so
that it similar to sysfs_emit_at() and takes the buffers start address and
an offset where to write within the buffer.
iio: iio_enum_available_read(): Convert to sysfs_emit_at()
sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it
knows about the sysfs buffer specifics and has some built-in sanity checks.
Convert the iio_enum_available_read() function to use sysfs_emit_at()
instead of scnprintf().
The conversion is straight forward, the only difference is that
sysfs_emit_at() takes the buffers start address and an offset as parameters
and already knows about the buffer's size limit.
sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it
knows about the sysfs buffer specifics and has some built-in sanity checks.
This patch converts the places in the iio core that follow the pattern of
Merge tag 'iio-for-5.13a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
1st set of IIO/counter device support, features and cleanup in the 5.13 cycle
Big set in here from Alexandru Ardelean enabling multiple buffer support.
This includes providing a new directory per buffer that combines
what was previously in buffer/ and scan_elements/. Old interfaces still
in place for compatiblity.
Note immuatable branch for scmi patches to allow for some significant
rework going on in that subsystem. Merge required updating to reflect
some changes in IIO.
Late rebase to fix some wrong fixes tags due to some earlier rebases
made necessary by messing up the immutable branch.
IIO New Device Support
* adi,ad5686
- Add info to support AD5673R and AD5677R
* bosch,bmi088
- New driver supporting this accelerometer + gyroscope
* cros_ec_mkbp
- New driver for this proximity sensor that exposes a 'front'
sensor. Very simple switch like device, but driver allows it
to share interface with more sophisticated proximity sensors.
* iio_scmi
- New driver to support ARM SCMI protocol to expose underlying
accelerometers and gyroscopes via this firmware interface.
* st,st_magn
- Add ID for IISMDC magnetometer.
* ti,ads131e0
- New driver supporting ads131e04, ads131e06 and ads131e08 24 bit ADCs
Counter New Device Support
* IRQ or GPIO based counter
- New driver for a conceptually simple counter that uses interrupts
to perform the count.
Features
* core
- Dual buffer supprt including:
Various helpers to centralize handling of bufferer related elements.
Document existing and new IOCTLs
Register the IIO chrdev only if it can actually be used for anything.
Rework attribute group creation in the core (lots of patches)
Merge buffer/ and scan_elements/ entries into one list + maintain
backwards compatible set.
Introduce the internal logic and IOCTL to allow multiple buffers
+ access to an anon FD per buffer to actually read from it.
Tidy up tools/iio/iio_generic_buffer and switch to new interfaces.
Update ABI docs.
A few follow up fixes, unsuprising as this was a huge bit of rework.
- Move common case setting of trig->parent to the core.
- Provide an iio_read_channel_processed_scale() to avoid loss of
precision from iio_read_channel_processed() then applying integer
scale. Use it in ntc_thermistor driver in hwmon.
- Allow drivers to specify labels from elsewhere than DT. Use it for
bmc150 and kxcjk-1013 labels related to position on 2 in one tablets.
- Document label usage for proximity and accelerometer sensors.
- Some local variable renames for consistency
tools
- Add -a parameter to iio_event_monitor to allow autoenabling of events.
* acpi_als
- Add trigger support for devices that don't support notification method.
* adi,ad7124
- Allow more than 8 channels. This is a complex little device, but is
capable of supporting up to 16 channels if the share certain
configuration settings.
* hrtimer-trigger
- Support sampling frequency below 1Hz.
* mediatek,mt8195-auxadc
- Add compatible to binding docs (always also includes mt8173)
* st,stm32-adc
- Enable timetamps when not using DMA.
* vishay,vcnl3020
- Sampling frequency control.
Cleanup and minor fixes:
* treewide
- Use some getter and setter functions instead of opencoding.
- Set of fixes for pointless casts in various drivers.
- Avoid wrong kernel-doc marking on comment blocks.
- Fix various other minor kernel-doc issues shown by W=1
* core
- Use a signed temporary for IIO_VAL_FRACTIONAL_LOG2 to avoid odd casts.
- Fix IIO_VAL_FRACTIONAL_LOG2 for values between -1.0 and 0.0
- Add unit tests for iio_format_value()
* docs
- Fix formatting/typos in iio_configfs.rst and buffers.rst
- Add documentation of index in buffers.rst
- Fix scan element description
- Avoid some issues with HTML generation from ABI docs by moving
duplicated defintions to more generic files.
- Drop reference to long dead mailing list.
* 104-quad
- Remove left over deprecated IIO counter ABI.
* adi,adi-axi-adc
- Fix wrong bit of docs.
* adi,ad5791
- Typos
* adi,ad9834
- Switch to device managed functions in probe.
* adi,adis*
- Add and use helpers for locking to reduced duplication.
* adi,adis16480
- Fix calculation of sampling frequency when using pulse per second input.
* adi,adis16475
- Calculate the IMU scaled internal sampling rate and runtime depending
on sysfs based configuration rather than getting from DT. Drop now
unnecessary property from DT bindings doc.
* cros_ec
- Fix result of a series of recent changes that means extended buffer
attributes turn up in the wrong place. Too complex to revert the
various patches unfortunately so this is a bit messy.
* fsl,mma3452
- Indentation cleanup.
* hid-sensors
- Size of storage needs to increase for some parts when using quaternions.
- Move the get sensistivity attribute to hid-sensors-common to reduce
duplication. Enable it for more device types.
- Correctly handle relative sensitivity if reported that way including
documenting the new ABI.
* maxim,max517
- Use device managed functions in probe.
* mediatek,mt6360-adc
- Use asm/unaligned.h instead of directly including
unaligned/be_byteshift.h
* novuton,npcm-adc
- Local lock instead of missusing mlock.
* semtech,sx9500
- Typos
* st,sensor
- typo fix
* st,spear-adc
- Local lock instead of missusing mlock.
* st,stm32-adc
- Long standing HAS_IOMEM dependency fix.
* st,stm32-counter
- Remove left over deprecated IIO counter ABI.
* ti,palmas-adc
- Local lock instead of missusing mlock.
* ti,tmp007
- Switch to device managed functions in probe.
Other
* MAINTAINERS
- Move Peter Meerwald-Stadler to Credits at his request
* tag 'iio-for-5.13a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (119 commits)
iio: acpi_als: Add trigger support
iio: acpi_als: Add local variable dev in probe
iio: acpi_als: Add timestamp channel
iio: adc: ad7292: Modify the bool initialization assignment
iio: cros: unify hw fifo attributes without API changes
iio: kfifo: add devm_iio_triggered_buffer_setup_ext variant
iio: event_monitor: Enable events before monitoring
dt-bindings: iio: adc: Add compatible for Mediatek MT8195
iio:magnetometer: Add Support for ST IIS2MDC
dt-bindings: iio: st,st-sensors add IIS2MDC.
staging: iio: ad9832: kernel-doc fixes
iio:dac:max517.c: Use devm_iio_device_register()
iio:cros_ec_sensors: Fix a wrong function name in kernel doc.
iio: buffer: kfifo_buf: kernel-doc, typo in function name.
iio: accel: sca3000: kernel-doc fixes. Missing - and wrong function names.
iio: adc: adi-axi-adc: Drop false marking for kernel-doc
iio: adc: cpcap-adc: kernel-doc fix - that should be _ in structure name
iio: dac: ad5504: fix wrong part number in kernel-doc structure name.
iio: dac: ad5770r: kernel-doc fix case of letter R wrong in structure name
iio: adc: ti-adc084s021: kernel-doc fixes, missing function names
...
Gwendal Grignou [Wed, 17 Mar 2021 07:40:12 +0000 (00:40 -0700)]
iio: acpi_als: Add trigger support
As some firmware does not notify on illuminance changes, add a
trigger to be able to query light via software (sysfs-trigger or
hrtrigger).
Add a hardware trigger set as the default trigger to maintain backward
compatibility.
Check iio_info reports the sensor as buffer capable:
iio:device0: acpi-als (buffer capable)
To test, check we can get data on demand on an Intel based chromebook:
IIO_DEV="iio:device0"
echo 1 > iio_sysfs_trigger/add_trigger
cat trigger2/name > ${IIO_DEV}/trigger/current_trigger
for i in ${IIO_DEV}/scan_elements/*_en ${IIO_DEV}/buffer/enable ; do
echo 1 > $i
done
od -x /dev/${IIO_DEV} &
echo 1 > trigger2/trigger_now
Gwendal Grignou [Thu, 18 Mar 2021 18:48:57 +0000 (11:48 -0700)]
iio: cros: unify hw fifo attributes without API changes
Commit 2e2366c2d141 ("iio: cros_ec: unify hw fifo attributes into the core file")
should be reverted as it set buffer extended attributes at
the wrong place. However, to revert it will requires to revert more
commits:
commit 165aea80e2e2 ("iio: cros_ec: use devm_iio_triggered_buffer_setup_ext()")
commit 21232b4456ba ("iio: buffer: remove iio_buffer_set_attrs() helper")).
and we would still have conflict with more recent development.
commit ee708e6baacd ("iio: buffer: introduce support for attaching more IIO buffers")
Instead, this commit reverts the first 2 commits without re-adding
iio_buffer_set_attrs() and set the buffer extended attributes at the
right place:
1. Instead of adding has_fw_fifo, deduct it from the configuration:
- EC must support FIFO (EC_FEATURE_MOTION_SENSE_FIFO) set.
- sensors send data a regular interval (accelerometer, gyro,
magnetomer, barometer, light sensor).
- "Legacy accelerometer" is only present on EC without FIFO, so we don't
need to set buffer attributes.
2. devm_iio_triggered_buffer_setup_ext() does not need to be called when
EC does not support FIFO, as there is no FIFO to manage.
3. Use devm_iio_triggered_buffer_setup_ext() when EC has a FIFO to
specify the buffer extended attributes.
Fixes: 2e2366c2d141 ("iio: cros_ec: unify hw fifo attributes into the core file") Fixes: 165aea80e2e2 ("iio: cros_ec: use devm_iio_triggered_buffer_setup_ext()") Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210318184857.2679181-1-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This is similar to the {devm_}iio_triggered_buffer_setup_ext variants added
via commit 5164c7889857 ("iio: triggered-buffer: add
{devm_}iio_triggered_buffer_setup_ext variants").
These can be used to pass extra buffer attributes to the buffer object.
This is a bit of temporary mechanism (hopefully) so that drivers that want
to allocate a kfifo buffer with extra buffer attributes, don't need to
include 'buffer_impl.h' directly. This can also become an API function (in
it's own right, unfortunately), but it may be a little less bad vs drivers
having to include 'buffer_impl.h'.
So, far the drivers that want to pass buffer attributes, all have to do
with some HW FIFO attributes, so there may be a chance of unifying them
into IIO core somehow (as some standard API). But, until that happens, we
just need to let them register their HW FIFO attributes directly (without
having to let them include 'buffer_impl.h' directly).
Linus Walleij [Fri, 19 Mar 2021 13:53:01 +0000 (14:53 +0100)]
iio: event_monitor: Enable events before monitoring
After some painful sessions with a driver that register an
enable/disable sysfs knob (gp2ap002) and manually going
in and enabling the event before monitoring it:
cd /sys/bus/iio/devices/iio\:device2/events
# ls
in_proximity_thresh_either_en
# echo 1 > in_proximity_thresh_either_en
I realized that it's better if the iio_event_monitor is
smart enough to enable all events by itself and disable them
after use, if passed the -a flag familiar from the
iio_generic_buffer tool.
Auto-enabling events depend on the hardware being able
to handle all events at the same time which isn't
necessarily the case, so a command line option is required
for this.
LI Qingwu [Wed, 17 Mar 2021 06:39:02 +0000 (06:39 +0000)]
iio:magnetometer: Add Support for ST IIS2MDC
Add support for ST magnetometer IIS2MDC,
an I2C/SPI interface 3-axis magnetometer.
The patch was tested on the instrument with IIS2MDC via I2C interface.
LI Qingwu [Wed, 17 Mar 2021 06:39:01 +0000 (06:39 +0000)]
dt-bindings: iio: st,st-sensors add IIS2MDC.
Add support for ST magnetometer IIS2MDC,
an I2C/SPI interface 3-axis magnetometer sensor.
The patch was tested on the instrument with IIS2MDC via I2C interface.
Jonathan Cameron [Sun, 14 Mar 2021 16:46:49 +0000 (16:46 +0000)]
iio: adc: ti-adc084s021: kernel-doc fixes, missing function names
The documentation in this driver was nearly kernel-doc and was marked
as such. Unfortunately the format was wrong and function names were
missing. This patch puts them in with minor edits to keep the resulting
line short.
Oleksij Rempel [Mon, 1 Mar 2021 08:04:01 +0000 (09:04 +0100)]
counter: add IRQ or GPIO based counter
Add simple IRQ or GPIO base counter. This device is used to measure
rotation speed of some agricultural devices, so no high frequency on the
counter pin is expected.
The maximal measurement frequency depends on the CPU and system load. On
the idle iMX6S I was able to measure up to 20kHz without count drops.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Reviewed-by: William Breathitt Gray <vilhelm.gray@gmail.com> Link: https://lore.kernel.org/r/20210301080401.22190-3-o.rempel@pengutronix.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
staging: iio: ad9834: convert to device-managed functions in probe
This change converts the driver to use device-managed functions in the
probe function. For the clock and regulator disable, some
devm_add_action_or_reset() calls are required, and then
devm_iio_device_register() function can be used register the IIO device.
The final aim here would be for IIO to export only the device-managed
functions of it's API. That's a long way to go and this a small step in
that direction.
iio: temperature: tmp007: use device-managed functions in probe
This change converts the driver to use device-managed functions in the
probe function. The power-down call is handled now via a
devm_add_action_or_reset() hook, and then devm_iio_device_register() can be
used to register the IIO device.
The final aim here would be for IIO to export only the device-managed
functions of it's API. That's a long way to go and this a small step in
that direction.
iio: buffer: fix use-after-free for attached_buffers array
Thanks to Lars for finding this.
The free of the 'attached_buffers' array should be done as late as
possible. This change moves it to iio_buffers_put(), which looks like
the best place for it, since it takes place right before the IIO device
data is free'd.
The free of this array will be handled by calling iio_device_free().
The iio_buffers_put() function is renamed to iio_device_detach_buffers()
since the role of this function changes a bit.
It looks like this issue was ocurring on the error path of
iio_buffers_alloc_sysfs_and_mask() and in
iio_buffers_free_sysfs_and_mask()
Added a comment in the doc-header of iio_device_attach_buffer() to
mention how this will be free'd in case anyone is reading the code
and becoming confused about it.
Fixes: ee708e6baacd ("iio: buffer: introduce support for attaching more IIO buffers") Reported-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com> Link: https://lore.kernel.org/r/20210307185444.32924-1-ardeleanalex@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Linus Walleij [Mon, 8 Mar 2021 10:02:19 +0000 (11:02 +0100)]
hwmon: (ntc_thermistor): try reading processed
Before trying the custom method of reading the sensor
as raw and then converting, we want to use
iio_read_channel_processed_scale() which first tries to
see if the ADC can provide a processed value directly,
else reads raw and applies scaling inside of IIO
using the scale attributes of the ADC. We need to
multiply the scaled value with 1000 to get to
microvolts from millivolts which is what processed
IIO channels returns.
Keep the code that assumes 12bit ADC around as a
fallback.
This gives correct readings on the AB8500 thermistor
inputs used in the Ux500 HREFP520 platform for reading
battery and board temperature.