Commit Graph

63 Commits

Author SHA1 Message Date
Joe Simmons-Talbott 9d9ec8d014 iio: Add blank lines after declarations.
As reported by checkpatch.pl add blank lines after declarations.

Signed-off-by: Joe Simmons-Talbott <joetalbott@gmail.com>
Link: https://lore.kernel.org/r/20220727181855.589052-2-joetalbott@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-08-15 22:29:56 +01:00
Joe Simmons-Talbott 295cc4268b iio: Be consistent with allocation result tests.
Make both allocation result tests use the same format

    if (!ptr)

Signed-off-by: Joe Simmons-Talbott <joetalbott@gmail.com>
Link: https://lore.kernel.org/r/20220718020348.32047-1-joetalbott@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-07-18 18:29:30 +01:00
Joe Simmons-Talbott ef7ceceeb1 iio: Use parens with sizeof
Prefer 'sizeof(var)' over 'sizeof var' as reported by checkpatch.pl.

Signed-off-by: Joe Simmons-Talbott <joetalbott@gmail.com>
Link: https://lore.kernel.org/r/20220717153438.10800-1-joetalbott@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-07-18 18:29:29 +01:00
Dmitry Rokosov bc72d938c1 iio: trigger: move trig->owner init to trigger allocate() stage
To provide a new IIO trigger to the IIO core, usually driver executes the
following pipeline: allocate()/register()/get(). Before, IIO core assigned
trig->owner as a pointer to the module which registered this trigger at
the register() stage. But actually the trigger object is owned by the
module earlier, on the allocate() stage, when trigger object is
successfully allocated for the driver.

This patch moves trig->owner initialization from register()
stage of trigger initialization pipeline to allocate() stage to
eliminate all misunderstandings and time gaps between trigger object
creation and owner acquiring.

Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
Link: https://lore.kernel.org/r/20220601174837.20292-1-ddrokosov@sberdevices.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-07-16 16:24:19 +01:00
Dmitry Rokosov 4a08069461 iio: trigger: warn about non-registered iio trigger getting attempt
As a part of patch series about wrong trigger register() and get()
calls order in the some IIO drivers trigger initialization path:

https://lore.kernel.org/all/20220524181150.9240-1-ddrokosov@sberdevices.ru/

runtime WARN_ONCE() is added to alarm IIO driver authors who make such
a mistake.

When an IIO driver allocates a new IIO trigger, it should register it
before calling the get() operation. In other words, each IIO driver
must abide by IIO trigger alloc()/register()/get() calls order.

Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru>
Link: https://lore.kernel.org/r/20220607183907.20017-1-ddrokosov@sberdevices.ru
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-18 14:26:17 +01:00
Joe Simmons-Talbott 9cf0b61859 iio: Use octal permissions and DEVICE_ATTR_{RO,RW}.
As reported by checkpatch.pl.  Where possible use DEVICE_ATTR_RO(),
DEVICE_ATTR_RW(), and __ATTR_RO().  Change function names to be
<var>_show() for read and <var>_store() for write.

Suggested-by: Joe Perches <joe@perches.com>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Joe Simmons-Talbott <joetalbott@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220601185414.251571-1-joetalbott@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-15 22:07:10 +01:00
keliu 319dbcd84f iio: Directly use ida_alloc()/free()
Use ida_alloc()/ida_free() instead of deprecated
ida_simple_get()/ida_simple_remove() .

Signed-off-by: keliu <liuke94@huawei.com>
Link: https://lore.kernel.org/r/20220527091739.2949426-1-liuke94@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11 14:35:29 +01:00
Miquel Raynal 51570c9d4b iio: core: Move the currentmode entry to the opaque structure
This entry should, under no situation, be modified by device
drivers. Now that we have limited its read access to device drivers
really needing it and did so through a dedicated helper, we can
easily move this variable to the opaque structure in order to
prevent any further modification from non-authorized code (out of the
core, basically).

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20220207143840.707510-12-miquel.raynal@bootlin.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-10 16:23:01 +01:00
Greg Kroah-Hartman 1bb866dcb8 1st set of IIO new device support, features and cleanup for 5.17
Includes some fixes that were either late breaking, low priority or
 complex enough to not be good to rush in late in the cycle.
 
 Tree rebased today to fix up some trivial issues + pull in a fix that
 was previously on the fixes-togreg branch. Vast majority have been
 in linux-next for some time now.
 
 New device support
 * adi,ad7293
   - New driver and bindings for this Power Amplifier drain current
     controller.  A complex device with various related monitoring functions.
 * adi,ad75513R
   - New driver and bindings for this combined ADC and DAC device.
   - A few follow up fixes.
 * adi,admv8818
   - New driver (and type) for this 2-18GHz filter device. Includes
     bindings and ABI documentation to allow clk_notifier based auto
     adjustment of the filters in appropriate applications.
 * liteon,ltr501
   - Support for the ltr303.  ID and chip specific info table.
 * xilinx,ams
   - New generic firmware function fwnode_iomap() as used in this driver.
   - New driver and bindings for this ADC and on-chip sensors as found
     in various Xilinx devices.
 
 Core
 * Introduced IIO_VAL_INT_64 which uses val and val2 in IIO callbacks to
   form a 64 bit integer when higher precision needed.
 * Allow IIO_ENUM_AVAILABLE to be used with different shared values.
 * Fix a long term issue with scheduling whilst atomic when iio_trig_poll()
   is called but no trigger consumers are actually enabled and hence the
   trigger may be reenabled from the interrupt handler.  Seen in the wild
   on the tsc2046.
 * Mark iio_device_type const.
 * buffer: Use a separate index variable to simplify code.
 * buffer-dma: Clear out unused struct iio_buffer_block
 * buffer-dmaengine: Switch to cheaper round_down() as power of 2 values.
 
 Tests/tools
 * format_value
   - Check against NULL returns from allocations in tests.
   - Add IIO_VAL_INT_64 test case.
 * event_monitor
   - Flush the output after event to given more consistent latency
     when tool output piped to other programs.
 
 Driver Features
 * axp20x
   - Add support for NTC thermistor channel and document TS pin binding.
 * arm,scmi
   - Add reading of raw channel values (using IIO_VAL_INT_64)
 * liteon,ltr501
   - Add proximity-near-level support and dt-binding.
 
 Tree wide cleanup
 * Remove no-op trigger ops from multiple drivers.
 * Stop using dev_get_drvdata() on the iio_dev->dev in various drivers
   and then stop assigning it to allow this to be used for other purposes.
   We can always get to the indio_dev using dev_to_iio_dev() which is
   a container_of() based approach. Also cleanup up some related unnecessary
   convoluted cases.
   - atmel,at91-sam5d2
   - nxp,imx7d
   - meas,ms5611
   - st,st_sensors
 * Where available (or easy to introduce) use the scan_type.* values
   in place of a second copy for read_raw and similar paths.
   - adi,ad7266
   - bosch,bma220
   - fsl,mac3110
   - fsl,mma7455
   - fsl,mpl3115
   - kionix,kcjk-1013
   - sensortek,stk8ba50
   - sensortek,stk8312
   - ti,adc12138
   - ti,ads1015
   - vti,sca3000
   - xilinx,xadc-core
 * Switch drives over to generic firmware properties including appropriate
   header changes to avoid including of.h
   - Various DACs had false CONFIG_OF dependencies.
   - dpot-dac
   - envelope-detector
   - adi,ad5755
   - adi,ad5758
   - capella,cm3605
   - maxim,max9611
   - microchip,mcp41010
   - microchip,mcp3911
   - ti,adc12138
 * Trivial clang warning fixes for W=1 warnings.
 
 Driver specific cleanup and minor fixes
 * adi,ad7606
   - Comment fixes.
 * ams,ad3935
   - Drop pointless cast to the same type.
 * atmel,at91-sama5d2
   - Fix wrong cast of iio_dev->dev to platform_device that happened to
     be harmless.
 * fsl,mma7660
   - Stop i2c remove() function returning an error code. Part of a rework
     to eventually stop returning anything from these.
 * fsl,mma8452
   - Use correct type for local irqreturn_t.
 * nxp,imx8mq
   - Maintainer email address update.
 * nxp,lpc18xx_adc
   - Ensure clk_prepare_enable() called before clk_get_rate().
   - Switch of.h for mod_devicetable.h to reflect no of specific functions,
     just the id table.
 * renesas,rzg2l
   - Drop a dev_err() that just duplicates error printed in platform_get_irq()
 * sgx,vz89x
   - Drop pointless cast.
 * st,lsm6dsx
   - Make it possible to disable the sensorhub from DT to avoid a corner
     case where the address of a slave device many be accidentally modified.
 * st,stm32-adc
   - Stop leaking an of_node in an error path.
 * st,stmp2
    - Avoid wrong sized type for bit field which could result in
      over-reading (harmless). Precursor to enabling -Warray-bounds.
 * ti,adc081c
   - Put back some ACPI support for non standards compliant ADC081C
     ID because it is known to be in the wild on some Aaeon boards.
 * ti,ads8688
   - Cleanup redundant local ret variable assignment.
 * ti,ina2xx-adc
   - Use helper macro kthread_run() to replace some boilerplate.
   - Avoid double reference counting.
   - Drop pointless cast.
 * xilinx,xadc
   - Make the IRQ optional as not always wired to the host system.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmHB8WsRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FoiiUg/8Dsg+oaZ126Wo+xW1FGk8LQ2GjCpIMHnt
 pLW+O1ezBipqCL3pemQeV5b8GcAo5Tia/yplzZxxhbP3GMY9gMkMWqnCdY/81E69
 w1SQF84OvMFdN+jHGAqu0mnyBkHEdT/nLyNMExBXSXMzXWzITY3bWbygMsKeN5Rs
 /GWyiAgqA8PPi6DoMa9tiGiPGxejic7jEVHMLjXk4ytRLndNtD1IxUElD9yTFxhk
 Hteba0hq+Et56nw/yOjz3mP4oSZSd//qPWQJ/qbMcHCvnr6LJ24sqhXiEQXyZ2vA
 hjkoYRXQnzKdPcrYFcre4VY1nJdQ3v0GKCDEFPUHzRJh8iKJleQCH6dIGNNkiRld
 KvBah2SetS43zQ11c4JywAUxENiWrUGIrF6u9xPCLq8Pe9b454r+Fb5BCwR7Ra+7
 bit11aIazCQV98bFwQvwMzPL9L/SZI6cmsbizdjT2VMRBTPIWl4NhQRVoYQjb8v0
 yZ6/S1560ibTxurTStkcGjjBC+mUzvVNuKir2mHaBdzCVAX82+babJcOhxzlI8jh
 9adyfHsBL8HwOWBjxHgybjw87DDtuByiVuVy7h2jAVgQevPknVC1toj4Q2bNCbUj
 tB2Ln6hBIaU29B1dj6GDwGvrCmi9XQzHOd0MSf524E/GlOKy4JEDQZU9bHFW5MKS
 VcQSGTXSG7s=
 =xXvq
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.17a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

1st set of IIO new device support, features and cleanup for 5.17

Includes some fixes that were either late breaking, low priority or
complex enough to not be good to rush in late in the cycle.

Tree rebased today to fix up some trivial issues + pull in a fix that
was previously on the fixes-togreg branch. Vast majority have been
in linux-next for some time now.

New device support
* adi,ad7293
  - New driver and bindings for this Power Amplifier drain current
    controller.  A complex device with various related monitoring functions.
* adi,ad75513R
  - New driver and bindings for this combined ADC and DAC device.
  - A few follow up fixes.
* adi,admv8818
  - New driver (and type) for this 2-18GHz filter device. Includes
    bindings and ABI documentation to allow clk_notifier based auto
    adjustment of the filters in appropriate applications.
* liteon,ltr501
  - Support for the ltr303.  ID and chip specific info table.
* xilinx,ams
  - New generic firmware function fwnode_iomap() as used in this driver.
  - New driver and bindings for this ADC and on-chip sensors as found
    in various Xilinx devices.

Core
* Introduced IIO_VAL_INT_64 which uses val and val2 in IIO callbacks to
  form a 64 bit integer when higher precision needed.
* Allow IIO_ENUM_AVAILABLE to be used with different shared values.
* Fix a long term issue with scheduling whilst atomic when iio_trig_poll()
  is called but no trigger consumers are actually enabled and hence the
  trigger may be reenabled from the interrupt handler.  Seen in the wild
  on the tsc2046.
* Mark iio_device_type const.
* buffer: Use a separate index variable to simplify code.
* buffer-dma: Clear out unused struct iio_buffer_block
* buffer-dmaengine: Switch to cheaper round_down() as power of 2 values.

Tests/tools
* format_value
  - Check against NULL returns from allocations in tests.
  - Add IIO_VAL_INT_64 test case.
* event_monitor
  - Flush the output after event to given more consistent latency
    when tool output piped to other programs.

Driver Features
* axp20x
  - Add support for NTC thermistor channel and document TS pin binding.
* arm,scmi
  - Add reading of raw channel values (using IIO_VAL_INT_64)
* liteon,ltr501
  - Add proximity-near-level support and dt-binding.

Tree wide cleanup
* Remove no-op trigger ops from multiple drivers.
* Stop using dev_get_drvdata() on the iio_dev->dev in various drivers
  and then stop assigning it to allow this to be used for other purposes.
  We can always get to the indio_dev using dev_to_iio_dev() which is
  a container_of() based approach. Also cleanup up some related unnecessary
  convoluted cases.
  - atmel,at91-sam5d2
  - nxp,imx7d
  - meas,ms5611
  - st,st_sensors
* Where available (or easy to introduce) use the scan_type.* values
  in place of a second copy for read_raw and similar paths.
  - adi,ad7266
  - bosch,bma220
  - fsl,mac3110
  - fsl,mma7455
  - fsl,mpl3115
  - kionix,kcjk-1013
  - sensortek,stk8ba50
  - sensortek,stk8312
  - ti,adc12138
  - ti,ads1015
  - vti,sca3000
  - xilinx,xadc-core
* Switch drives over to generic firmware properties including appropriate
  header changes to avoid including of.h
  - Various DACs had false CONFIG_OF dependencies.
  - dpot-dac
  - envelope-detector
  - adi,ad5755
  - adi,ad5758
  - capella,cm3605
  - maxim,max9611
  - microchip,mcp41010
  - microchip,mcp3911
  - ti,adc12138
* Trivial clang warning fixes for W=1 warnings.

Driver specific cleanup and minor fixes
* adi,ad7606
  - Comment fixes.
* ams,ad3935
  - Drop pointless cast to the same type.
* atmel,at91-sama5d2
  - Fix wrong cast of iio_dev->dev to platform_device that happened to
    be harmless.
* fsl,mma7660
  - Stop i2c remove() function returning an error code. Part of a rework
    to eventually stop returning anything from these.
* fsl,mma8452
  - Use correct type for local irqreturn_t.
* nxp,imx8mq
  - Maintainer email address update.
* nxp,lpc18xx_adc
  - Ensure clk_prepare_enable() called before clk_get_rate().
  - Switch of.h for mod_devicetable.h to reflect no of specific functions,
    just the id table.
* renesas,rzg2l
  - Drop a dev_err() that just duplicates error printed in platform_get_irq()
* sgx,vz89x
  - Drop pointless cast.
* st,lsm6dsx
  - Make it possible to disable the sensorhub from DT to avoid a corner
    case where the address of a slave device many be accidentally modified.
* st,stm32-adc
  - Stop leaking an of_node in an error path.
* st,stmp2
   - Avoid wrong sized type for bit field which could result in
     over-reading (harmless). Precursor to enabling -Warray-bounds.
* ti,adc081c
  - Put back some ACPI support for non standards compliant ADC081C
    ID because it is known to be in the wild on some Aaeon boards.
* ti,ads8688
  - Cleanup redundant local ret variable assignment.
* ti,ina2xx-adc
  - Use helper macro kthread_run() to replace some boilerplate.
  - Avoid double reference counting.
  - Drop pointless cast.
* xilinx,xadc
  - Make the IRQ optional as not always wired to the host system.

* tag 'iio-for-5.17a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (103 commits)
  iio: adc: ti-adc081c: Partial revert of removal of ACPI IDs
  iio:addac:ad74413r: Fix uninitialized ret in a path that won't be hit.
  MAINTAINERS: Add maintainer for xilinx-ams
  dt-bindings: iio: adc: Add Xilinx AMS binding documentation
  iio: adc: Add Xilinx AMS driver
  device property: Add fwnode_iomap()
  iio:accel:kxcjk-1013: Mark struct __maybe_unused to avoid warning.
  iio:accel:bmc150: Mark structure __maybe_unused as only needed with for pm ops.
  iio:dummy: Drop set but unused variable len.
  iio:magn:ak8975: Suppress clang W=1 warning about pointer to enum conversion.
  iio:imu:inv_mpu6050: Suppress clang W=1 warning about pointer to enum conversion.
  iio:imu:inv_icm42600: Suppress clang W=1 warning about pointer to enum conversion.
  iio:dac:mcp4725: Suppress clang W=1 warning about pointer to enum conversion.
  iio:amplifiers:hmc425a: Suppress clang W=1 warning about pointer to enum conversion.
  iio:adc:ti-ads1015: Suppress clang W=1 warning about pointer to enum conversion.
  iio:adc:rcar: Suppress clang W=1 warning about pointer to enum conversion.
  iio:adc:ina2xx-adc: Suppress clang W=1 warning about pointer to enum conversion.
  iio:accel:bma180: Suppress clang W=1 warning about pointer to enum conversion.
  drivers:iio:dac: Add AD3552R driver support
  dt-bindings: iio: dac: Add adi,ad3552r.yaml
  ...
2021-12-22 12:33:01 +01:00
Jonathan Cameron 9020ef6598 iio: trigger: Fix a scheduling whilst atomic issue seen on tsc2046
IIO triggers are software IRQ chips that split an incoming IRQ into
separate IRQs routed to all devices using the trigger.
When all consumers are done then a trigger callback reenable() is
called.  There are a few circumstances under which this can happen
in atomic context.

1) A single user of the trigger that calls the iio_trigger_done()
function from interrupt context.
2) A race between disconnecting the last device from a trigger and
the trigger itself sucessfully being disabled.

To avoid a resulting scheduling whilst atomic, close this second corner
by using schedule_work() to ensure the reenable is not done in atomic
context.

Note that drivers must be careful to manage the interaction of
set_state() and reenable() callbacks to ensure appropriate reference
counting if they are relying on the same hardware controls.

Deliberately taking this the slow path rather than via a fixes tree
because the error has hard to hit and I would like it to soak for a while
before hitting a release kernel.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Tested-by: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20211017172209.112387-1-jic23@kernel.org
2021-12-12 17:12:18 +00:00
Lars-Peter Clausen a827a49846 iio: trigger: Fix reference counting
In viio_trigger_alloc() device_initialize() is used to set the initial
reference count of the trigger to 1. Then another get_device() is called on
trigger. This sets the reference count to 2 before the trigger is returned.

iio_trigger_free(), which is the matching API to viio_trigger_alloc(),
calls put_device() which decreases the reference count by 1. But the second
reference count acquired in viio_trigger_alloc() is never dropped.

As a result the iio_trigger_release() function is never called and the
memory associated with the trigger is never freed.

Since there is no reason for the trigger to start its lifetime with two
reference counts just remove the extra get_device() in
viio_trigger_alloc().

Fixes: 5f9c035cae ("staging:iio:triggers. Add a reference get to the core for triggers.")
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20211024092700.6844-2-lars@metafoo.de
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-11-17 17:52:35 +00:00
Jonathan Cameron 3028e0c2af iio: core: move @trig_readonly from struct iio_dev to struct iio_dev_opaque
This is only set via the iio_trig_set_immutable() call and later used
by the IIO core so there is no benefit in drivers being able to access
it.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-5-jic23@kernel.org
2021-05-17 13:49:13 +01:00
Jonathan Cameron 6eaf9f6a27 iio: core: move @driver_module from struct iio_dev to struct iio_dev_opaque
Continuing move to hide internal elements from drivers, move this structure
element over.  It's only accessed from iio core files so this one was
straight forward and no accessor functions are needed.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-4-jic23@kernel.org
2021-05-17 13:49:13 +01:00
Yicong Yang 171a70afbd iio: trigger: simplify __devm_iio_trigger_register
Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.

Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/1617881896-3164-7-git-send-email-yangyicong@hisilicon.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-05-17 13:49:07 +01:00
Andy Shevchenko af3bac44b1 iio: trigger: Fix strange (ladder-type) indentation
In some cases indentation looks a bit weird with starting from = sign
and being in a ladder-type style. Unify it across the module.

While at it, add blank line after definition block where it needed,

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210402174911.44408-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:38 +01:00
Andy Shevchenko ebb9493c07 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".

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210402174911.44408-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-04-07 08:36:38 +01:00
Lars-Peter Clausen 83ca56b663 iio: core: Use sysfs_emit() (trivial bits)
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

   return s*printf(...)

to

   return sysfs_emit(...)

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210320071405.9347-2-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-29 11:12:30 +01:00
Gwendal Grignou 995071d36b iio: set default trig->dev.parent
When allocated with [devm_]iio_trigger_alloc(), set trig device parent to
the device the trigger is allocated for by default.

It can always be reassigned in the probe routine.

Change iio_trigger_alloc() API to add the device pointer to be coherent
with devm_iio_trigger_alloc, using similar interface to
iio_device_alloc().

Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210309193620.2176163-2-gwendal@chromium.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-25 19:13:50 +00:00
Alexandru Ardelean 32f171724e iio: core: rework iio device group creation
Up until now, the device groups that an IIO device had were limited to 6.
Two of these groups would account for buffer attributes (the buffer/ and
scan_elements/ directories).

Since we want to add multiple buffers per IIO device, this number may not
be enough, when adding a second buffer. So, this change reallocates the
groups array whenever an IIO device group is added, via a
iio_device_register_sysfs_group() helper.

This also means that the groups array should be assigned to
'indio_dev.dev.groups' really late, right before {cdev_}device_add() is
called to do the entire setup.
And we also must take care to free this array when the sysfs resources are
being cleaned up.

With this change we can also move the 'groups' & 'groupcounter' fields to
the iio_dev_opaque object. Up until now, this didn't make a whole lot of
sense (especially since we weren't sure how multibuffer support would look
like in the end).
But doing it now kills one birds with one stone.

An alternative, would be to add a configurable Kconfig symbol
CONFIG_IIO_MAX_BUFFERS_PER_DEVICE (or something like that) and compute a
static maximum of the groups we can support per IIO device. But that would
probably annoy a few people since that would make the system less
configurable.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-11-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:03 +00:00
Alexandru Ardelean e64506bf69 iio: core-trigger: make iio_device_register_trigger_consumer() an int return
Oddly enough the noop function is an int-return. This one seems to be void.
This change converts it to int, because we want to change how groups are
registered. With that change this function could error out with -ENOMEM.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20210215104043.91251-10-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-11 20:47:02 +00:00
Jonathan Cameron eca8523a38 iio:trigger: rename try_reenable() to reenable() plus return void
As we no longer support a try again if we cannot reenable the trigger
rename the function to reflect this.   Also we don't do anything with
the value returned so stop it returning anything.  For the few drivers
that didn't already print an error message in this patch, add such
a print.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Christian Oder <me@myself5.de>
Cc: Eugen Hristev <eugen.hristev@microchip.com>
Cc: Nishant Malpani <nish.malpani25@gmail.com>
Cc: Daniel Baluta <daniel.baluta@oss.nxp.com>
Link: https://lore.kernel.org/r/20200920132548.196452-3-jic23@kernel.org
2020-12-03 19:40:26 +00:00
Jonathan Cameron 01d37c8318 iio: Fix: Do not poll the driver again if try_reenable() callback returns non 0.
The original reason for this behaviour is long gone and no current
drivers are making use of this function correctly. Note however, that
you would be very unlucky to actually hit the problem as it would
require a bus comms failure in the callback.

This dates back a long way.  The original board on which I did a lot
of early IIO development only supported edge interrupts, but some of the
sensors were level interrupt based.  As such, the lis3l02dq driver did
a dance with checking a GPIO to identify if it should retrigger.
That was an unsustainable hack so we later just stopped supporting interrupts
for that particular combination.

There are a number of drivers where a fault on a bus read in the
try_reenable() callback will result in them returning non 0 and
incorrectly then causing iio_trigger_poll() to be called.

Anyhow, this handling is unused and causing issues so let us rip it out.
Link: https://lore.kernel.org/linux-iio/20200813075358.13310-1-lars@metafoo.de/

After this the try_reenable() naming makes no sense, so as a follow up
patch I'll rename it to simply reenable().  I haven't done that here
as it will add noise to the fix for backporting.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Christian Eggers <ceggers@arri.de>
Link: https://lore.kernel.org/r/20200920132548.196452-2-jic23@kernel.org
2020-12-03 19:40:25 +00:00
Jonathan Cameron cd7798cbd2 iio: Add __printf() attributes to various allocation functions
A partial set of these was added to IIO a long time back.
This fills in some gaps in coverage highlighted by building
with W=1

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20200913132115.800131-3-jic23@kernel.org
2020-09-21 18:54:18 +01:00
Lars-Peter Clausen f11d59d87b iio: Move attach/detach of the poll func to the core
All devices using a triggered buffer need to attach and detach the trigger
to the device in order to properly work. Instead of doing this in each and
every driver by hand move this into the core.

At this point in time, all drivers should have been resolved to
attach/detach the poll-function in the same order.

This patch removes all explicit calls of iio_triggered_buffer_postenable()
& iio_triggered_buffer_predisable() in all drivers, since the core handles
now the pollfunc attach/detach.

The more peculiar change is for the 'at91-sama5d2_adc' driver, since it's
not immediately obvious that removing the hooks doesn't break anything.
Eugen was able to test on at91-sama5d2-adc driver, sama5d2-xplained board.
All seems to be fine.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Tested-by: Eugen Hristev <eugen.hristev@microchip.com> #for at91-sama5d2-adc
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-20 17:34:44 +01:00
Alexandru Ardelean 92b7ed7fe4 iio: core: drop devm_iio_trigger_free() API call
It's unused so far, so it can be removed. Also makes sense to remove it
to discourage weird uses of this call during review.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:37 +01:00
Alexandru Ardelean 83381c9803 iio: core: drop devm_iio_trigger_unregister() API call
It's unused so far, so it can be removed. Also makes sense to remove it
to discourage weird uses of this call during review.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:36 +01:00
Thomas Gleixner d2912cb15b treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500
Based on 2 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 as
  published by the free software foundation

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 as
  published by the free software foundation #

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 4122 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Enrico Weigelt <info@metux.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-19 17:09:55 +02:00
Mathieu Othacehe be35d281da iio: trigger: Print an error if there is no available irq
If there are more trigger consumers than
CONFIG_IIO_CONSUMERS_PER_TRIGGER, iio_trigger_attach_poll_func will
silently fail. Add an error message to inform the user that
CONFIG_IIO_CONSUMERS_PER_TRIGGER limit might be exceeded.

Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-04-04 20:19:41 +01:00
Jonathan Cameron 04581681df iio:trigger: Remove necessity to have a trig->ops structure.
There are a few cases where none of the callbacks are supplied and the
ops structure purely existed to provide the driver module.

Given that is done differently now, we don't need to have a trig_ops structure.
Allow for it not being there required a few additional sanity checks when
trying check if particular callbacks are set.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:20:28 +01:00
Jonathan Cameron 035c70aeb6 iio: triggers: Use macros to avoid boilerplate assignment of owner.
This trig_ops.owner assignment occurs in all trigger drivers and
can be simply automated using a macro as has been done in many
other places in the kernel.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:18:32 +01:00
Jonathan Cameron 63b19547cc iio: Use macro magic to avoid manual assign of driver_module
Starting point in boiler plate reduction similar to that done for
many similar cases elsewhere in the kernel.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 20:03:14 +01:00
Marcin Niestroj 4eecbe8188 iio: trigger: fix NULL pointer dereference in iio_trigger_write_current()
In case oldtrig == trig == NULL (which happens when we set none
trigger, when there is already none set) there is a NULL pointer
dereference during iio_trigger_put(trig). Below is kernel output when
this occurs:

[   26.741790] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[   26.750179] pgd = cacc0000
[   26.752936] [00000000] *pgd=8adc6835, *pte=00000000, *ppte=00000000
[   26.759531] Internal error: Oops: 17 [#1] SMP ARM
[   26.764261] Modules linked in: usb_f_ncm u_ether usb_f_acm u_serial usb_f_fs libcomposite configfs evbug
[   26.773844] CPU: 0 PID: 152 Comm: synchro Not tainted 4.12.0-rc1 #2
[   26.780128] Hardware name: Freescale i.MX6 Ultralite (Device Tree)
[   26.786329] task: cb1de200 task.stack: cac92000
[   26.790892] PC is at iio_trigger_write_current+0x188/0x1f4
[   26.796403] LR is at lock_release+0xf8/0x20c
[   26.800696] pc : [<c0736f34>]    lr : [<c016efb0>]    psr: 600d0013
[   26.800696] sp : cac93e30  ip : cac93db0  fp : cac93e5c
[   26.812193] r10: c0e64fe8  r9 : 00000000  r8 : 00000001
[   26.817436] r7 : cb190810  r6 : 00000010  r5 : 00000001  r4 : 00000000
[   26.823982] r3 : 00000000  r2 : 00000000  r1 : cb1de200  r0 : 00000000
[   26.830528] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[   26.837683] Control: 10c5387d  Table: 8acc006a  DAC: 00000051
[   26.843448] Process synchro (pid: 152, stack limit = 0xcac92210)
[   26.849475] Stack: (0xcac93e30 to 0xcac94000)
[   26.853857] 3e20:                                     00000001 c0736dac c054033c cae6b680
[   26.862060] 3e40: cae6b680 00000000 00000001 cb3f8610 cac93e74 cac93e60 c054035c c0736db8
[   26.870264] 3e60: 00000001 c054033c cac93e94 cac93e78 c029bf34 c0540348 00000000 00000000
[   26.878469] 3e80: cb3f8600 cae6b680 cac93ed4 cac93e98 c029b320 c029bef0 00000000 00000000
[   26.886672] 3ea0: 00000000 cac93f78 cb2d41fc caed3280 c029b214 cac93f78 00000001 000e20f8
[   26.894874] 3ec0: 00000001 00000000 cac93f44 cac93ed8 c0221dcc c029b220 c0e1ca39 cb2d41fc
[   26.903079] 3ee0: cac93f04 cac93ef0 c0183ef0 c0183ab0 cb2d41fc 00000000 cac93f44 cac93f08
[   26.911282] 3f00: c0225eec c0183ebc 00000001 00000000 c0223728 00000000 c0245454 00000001
[   26.919485] 3f20: 00000001 caed3280 000e20f8 cac93f78 000e20f8 00000001 cac93f74 cac93f48
[   26.927690] 3f40: c0223680 c0221da4 c0246520 c0245460 caed3283 caed3280 00000000 00000000
[   26.935893] 3f60: 000e20f8 00000001 cac93fa4 cac93f78 c0224520 c02235e4 00000000 00000000
[   26.944096] 3f80: 00000001 000e20f8 00000001 00000004 c0107f84 cac92000 00000000 cac93fa8
[   26.952299] 3fa0: c0107de0 c02244e8 00000001 000e20f8 0000000e 000e20f8 00000001 fbad2484
[   26.960502] 3fc0: 00000001 000e20f8 00000001 00000004 beb6b698 00064260 0006421c beb6b4b4
[   26.968705] 3fe0: 00000000 beb6b450 b6f219a0 b6e2f268 800d0010 0000000e cac93ff4 cac93ffc
[   26.976896] Backtrace:
[   26.979388] [<c0736dac>] (iio_trigger_write_current) from [<c054035c>] (dev_attr_store+0x20/0x2c)
[   26.988289]  r10:cb3f8610 r9:00000001 r8:00000000 r7:cae6b680 r6:cae6b680 r5:c054033c
[   26.996138]  r4:c0736dac r3:00000001
[   26.999747] [<c054033c>] (dev_attr_store) from [<c029bf34>] (sysfs_kf_write+0x50/0x54)
[   27.007686]  r5:c054033c r4:00000001
[   27.011290] [<c029bee4>] (sysfs_kf_write) from [<c029b320>] (kernfs_fop_write+0x10c/0x224)
[   27.019579]  r7:cae6b680 r6:cb3f8600 r5:00000000 r4:00000000
[   27.025271] [<c029b214>] (kernfs_fop_write) from [<c0221dcc>] (__vfs_write+0x34/0x120)
[   27.033214]  r10:00000000 r9:00000001 r8:000e20f8 r7:00000001 r6:cac93f78 r5:c029b214
[   27.041059]  r4:caed3280
[   27.043622] [<c0221d98>] (__vfs_write) from [<c0223680>] (vfs_write+0xa8/0x170)
[   27.050959]  r9:00000001 r8:000e20f8 r7:cac93f78 r6:000e20f8 r5:caed3280 r4:00000001
[   27.058731] [<c02235d8>] (vfs_write) from [<c0224520>] (SyS_write+0x44/0x98)
[   27.065806]  r9:00000001 r8:000e20f8 r7:00000000 r6:00000000 r5:caed3280 r4:caed3283
[   27.073582] [<c02244dc>] (SyS_write) from [<c0107de0>] (ret_fast_syscall+0x0/0x1c)
[   27.081179]  r9:cac92000 r8:c0107f84 r7:00000004 r6:00000001 r5:000e20f8 r4:00000001
[   27.088947] Code: 1a000009 e1a04009 e3a06010 e1a05008 (e5943000)
[   27.095244] ---[ end trace 06d1dab86d6e6bab ]---

To fix that problem call iio_trigger_put(trig) only when trig is not
NULL.

Fixes: d5d24bcc0a ("iio: trigger: close race condition in acquiring trigger reference")
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-05-21 12:36:59 +01:00
Dan Carpenter 2c99f1a09d iio: trigger: clean up viio_trigger_alloc()
1) Reverse the test for kmalloc() failure so we can pull everything
   back one tab.
2) Use gotos for unwinding.
3) Some of the extra line breaks for the 80 character limit are no
   longer needed so we can remove them.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:37:34 +00:00
Bhumika Goyal 3bdafc49f5 iio: industrialio-trigger: constify device_type structures
Declare device_type structure as const as it is only stored in the
type field of a device structure. This field is of type const, so add
const to declaration of device_type structure.

File size before:
   text	   data	    bss	    dec	    hex	filename
   5389	    208	     48	   5645	   160d	iio/industrialio-trigger.o

File size after:
   text	   data	    bss	    dec	    hex	filename
   5453	    176	     48	   5677	   162d	iio/industrialio-trigger.o

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:21:42 +00:00
Alison Schofield d5d24bcc0a iio: trigger: close race condition in acquiring trigger reference
In iio_trigger_write_current() we find the trigger we want while
holding mutex on the list of triggers, but we don't actually do a
get on it while holding mutex.  We wait until further validations
are completed and we're sure it's the one we want.  Race condition
is that it could be freed by the time we do the get.

Solution is to grab the trigger (iio_trigger_get) as soon as we
find it while holding mutex on the list of triggers.  If later
we decide it's not the right one, put it back. (iio_trigger_put).

Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-22 13:21:41 +00:00
Lars-Peter Clausen 43ece27e70 iio:trigger: Add helper function to verify that a trigger belongs to the same device
Some triggers can only be attached to the IIO device that corresponds to
the same physical device. Currently each driver that requires this
implements its own trigger validation function.

Introduce a new helper function called iio_trigger_validate_own_device()
that can be used to do this check. Having a common implementation avoids
code duplication and unnecessary boiler-plate code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-09-27 20:32:55 +01:00
Linus Walleij 702a7b8e06 iio: trigger: helpers to determine own trigger
This adds a helper function to the IIO trigger framework:

iio_trigger_using_own(): for an IIO device, this tells
  whether the device is using itself as a trigger.
  This is true if the indio device:
  (A) supplies a trigger and
  (B) has assigned its own buffer poll function to use this
      trigger.

This helper function is good when constructing triggered,
buffered drivers that can either use its own hardware *OR*
an external trigger such as a HRTimer or even the trigger from
a totally different sensor.

Under such circumstances it is important to know for example
if the timestamp from the same trigger hardware should be used
when populating the buffer: if iio_trigger_using_own() is true,
we can use this timestamp, else we need to pick a unique
timestamp directly in the trigger handler.

For this to work of course IIO devices registering hardware
triggers must follow the convention to set the parent device
properly, as as well as setting the parent of the IIO device
itself.

When a new poll function is attached, we check if the parent
device of the IIO of the poll function is the same as the
parent device of the trigger and in that case we conclude that
the hardware is using itself as trigger.

Cc: Giuseppe Barba <giuseppe.barba@st.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Cc: Crestez Dan Leonard <leonard.crestez@intel.com>
Cc: Gregor Boirie <gregor.boirie@parrot.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-09-10 16:49:14 +01:00
Gregor Boirie 9083325f11 iio:trigger: add resource managed (un)register
Add resource managed devm_iio_trigger_register() and
devm_iio_triger_unregister() to automatically clean up registered triggers
allocated by IIO drivers, thus leading to simplified IIO drivers code.

Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-09-04 15:42:37 +01:00
Matt Ranostay c8cdf70890 iio: trigger: allow immutable triggers to be assigned
There are times when an assigned trigger to a device shouldn't ever
change after intialization.

Examples of this being used is when an provider device has a trigger
that is assigned to an ADC, which uses it populate data into a callback
buffer.

Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-09-03 15:31:55 +01:00
Gregor Boirie bc2b7dab62 iio:core: timestamping clock selection support
Adds a new per-device sysfs attribute "current_timestamp_clock" to allow
userspace to select a particular POSIX clock for buffered samples and
events timestamping.

Following clocks, as listed in clock_gettime(2), are supported:
CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_MONOTONIC_RAW,
CLOCK_REALTIME_COARSE, CLOCK_MONOTONIC_COARSE, CLOCK_BOOTTIME and
CLOCK_TAI.

Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com>
Acked-by: Sanchayan Maity <maitysanchayan@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-30 19:41:38 +01:00
Greg Kroah-Hartman 3c9a6793bd Second round of new iio device support, features and cleanups in the 4.8 cycle
Firstly some contact detail updates:
 * NXP took over freescale. Update the mma8452 header to reflect this.
 * Martin Kepplinger email address change in mma8452 header.
 * Adriana Reus has changed email address. Update .mailmap.
 * Matt Ranostay has changed email address. Update .mailmap.
 
 New Device Support
 * max1363
   - add the missing i2c_device_ids for a couple of parts so they can actually
     be used.
 * ms5867
   - add device ids for ms5805 and ms5837 parts.
 
 New Features
 * ad5755
   - DT support.  This one was a bit controversial and under review for a long
     time.  Still no one could come up with a better solution.
 * stx104
   - add gpio support
 * ti-adc081c
   - Add ACPI device ID matching.
 
 Core changes
 * Refuse to register triggers with duplicate names.  There is no way to
   distinguish between them so this makes no sense.  A few drivers do not
   generate unique names for each instance of the device present.  We can't
   fix this without changing ABI so leave them and wait for someone to
   actually take the rare step of two identical accelerometers on the same
   board.
 * buffer-dma
   - use ARRAY_SIZE in a few appropriate locations.
 
 Tools
 * Fix the fact that the --trigger-num option in generic_buffer didn't allow
   0 which is perfectly valid in the ABI.
 
 Cleanups
 * as3935
   - improve error reporting.
   - remove redundant zeroing of a field in iio_priv.
 * gp2ap020a00f
   - use the iio_device_claim_*_mode helpers rather than open coding locking
   around mode changes.
 * isl29125
   - use the iio_device_claim_*_mode helpers rather than open coding locking.
 * lidar
   - use the iio_device_claim_*_mode helpers rather than open coding locking.
 * mma8452
   - more detail in devices supported description in comments (addresses and
   similar)
 * sca3000
   - add a missing error check.
 * tcs3414
   - use the iio_device_claim_*_mode helpers rather than open coding locking.
 * tcs3472
   - use the iio_device_claim_*_mode helpers rather than open coding locking.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABCAAGBQJXdAT2AAoJEFSFNJnE9BaIq68P/3Z0q1lc1cb+K8HV5jgukEKw
 eoxZa5lFIOuHAGeXo9GAdJiH5oT/yAIhadf3gzuuQLaTJwWYKD51aPVwgpT5M2+x
 Bnu2XiYcaoIm/Foat70ycjeYaGxO/xO2vbLp5v0BJV2ujvjm/oCKw5pxYeU4Jm63
 iKaZo9jn/HoshOMpZBrcPZ7Q1TogRdopBNe2fsc8nXFFsv8ODjOZ9Nebs2lk36e+
 PWLUWfSkv2LMBSE2LOFyjSW8E4ItBBngBcyqBTFiiln7mpXU5Vv2QSvUhpP2YjUZ
 rxKvDiG7ADuxMr901whASxyCO180yCxTRIcBsN8oP73gTGHrJnMT0Sptfz7AUUVN
 gJneiy+iy3TecJ/R6w/DnNzqmZMiEVqlYGkdXVGu8SXrKWilvzcTp5iTmDVM5zLb
 1fDZxjbLdNJuHzoSYNiCBcnfzIixOAyKTGFi3jUaPPQ/Lc1qfmgerWWlOzKeUgCZ
 5Bzak8MvWuxcO7jkMG8mbARufy3Nu6eh8a39JXFhViGtTtySydMa8eXdYPjqoAtv
 vgwJNh9U53yYui8i7vU90dM3gJaGg5a4R6EjEKCYcEJf6kM9Go8xCvjU8YWPtIKk
 rfykpPkKcQzbax07YKvb4f015x7r0V6WCGJjPn0Fi14ugNGJJ6M88l+2UcXcx1zS
 RRtVRD49Le7pIDCs1Rqn
 =6Lja
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-4.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Second round of new iio device support, features and cleanups in the 4.8 cycle

Firstly some contact detail updates:
* NXP took over freescale. Update the mma8452 header to reflect this.
* Martin Kepplinger email address change in mma8452 header.
* Adriana Reus has changed email address. Update .mailmap.
* Matt Ranostay has changed email address. Update .mailmap.

New Device Support
* max1363
  - add the missing i2c_device_ids for a couple of parts so they can actually
    be used.
* ms5867
  - add device ids for ms5805 and ms5837 parts.

New Features
* ad5755
  - DT support.  This one was a bit controversial and under review for a long
    time.  Still no one could come up with a better solution.
* stx104
  - add gpio support
* ti-adc081c
  - Add ACPI device ID matching.

Core changes
* Refuse to register triggers with duplicate names.  There is no way to
  distinguish between them so this makes no sense.  A few drivers do not
  generate unique names for each instance of the device present.  We can't
  fix this without changing ABI so leave them and wait for someone to
  actually take the rare step of two identical accelerometers on the same
  board.
* buffer-dma
  - use ARRAY_SIZE in a few appropriate locations.

Tools
* Fix the fact that the --trigger-num option in generic_buffer didn't allow
  0 which is perfectly valid in the ABI.

Cleanups
* as3935
  - improve error reporting.
  - remove redundant zeroing of a field in iio_priv.
* gp2ap020a00f
  - use the iio_device_claim_*_mode helpers rather than open coding locking
  around mode changes.
* isl29125
  - use the iio_device_claim_*_mode helpers rather than open coding locking.
* lidar
  - use the iio_device_claim_*_mode helpers rather than open coding locking.
* mma8452
  - more detail in devices supported description in comments (addresses and
  similar)
* sca3000
  - add a missing error check.
* tcs3414
  - use the iio_device_claim_*_mode helpers rather than open coding locking.
* tcs3472
  - use the iio_device_claim_*_mode helpers rather than open coding locking.
2016-06-29 15:35:01 -07:00
Crestez Dan Leonard 3b8e73ec82 iio: Refuse to register triggers with duplicate names
The trigger name is documented as unique but drivers are currently
allowed to register triggers with duplicate names. This should be
considered a bug since it makes the 'current_trigger' interface
unusable.

Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-27 20:59:08 +01:00
Greg Kroah-Hartman af52739b92 Merge 4.7-rc4 into staging-next
We want the fixes in here, and we can resolve a merge issue in
drivers/iio/industrialio-trigger.c

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-20 08:25:44 -07:00
Crestez Dan Leonard 9954382335 iio: Fix error handling in iio_trigger_attach_poll_func
When attaching a pollfunc iio_trigger_attach_poll_func will allocate a
virtual irq and call the driver's set_trigger_state function. Fix error
handling to undo previous steps if any fails.

In particular this fixes handling errors from a driver's
set_trigger_state function. When using triggered buffers a failure to
enable the trigger used to make the buffer unusable.

Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-03 12:54:46 +01:00
Jonathan Cameron ef2d71d6b7 iio: triggers: Make trigger ops structure explicitly non optional.
This structure has not been optional for a long time (if ever) but the
code implies that it is.  As we then use it later in a fashion that would
crash if it was in fact NULL, it's inconsistent so fix it up by removing
unnecessary checks.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-29 15:00:10 +01:00
Vladimir Barinov 735ad074ff iio: Support triggered events
Support triggered events.

This is useful for chips that don't have their own interrupt sources.
It allows to use generic/standalone iio triggers for those drivers.

Signed-off-by: Vladimir Barinov <vladimir.barinov@cogentembedded.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-27 20:47:09 +01:00
Cristina Opriceana 8e563b0dab iio: trigger: Add missing fields in kernel docs
Fix kernel docs warnings by adding the missing description
for each of the existing function parameters.

Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-08-08 12:45:49 +01:00
Peter Meerwald 398fd22b6b iio: Remove timestamp argument from iio_trigger_poll() and iio_trigger_poll_chained()
argument has been ignored; adjust drivers accordingly

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-06-14 16:25:59 +01:00
Hartmut Knaack 92825ff974 iio get rid of unneccessary error_ret
Get rid of obsolete uses of goto error_ret and some empty lines.

Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-02-18 08:46:36 +00:00
Axel Lin f59c2576c1 iio:trigger: Convert to use ATTRIBUTE_GROUPS
Use new ATTRIBUTE_GROUPS macro to declare attribute groups.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-12-03 20:22:29 +00:00