Commit Graph

41 Commits

Author SHA1 Message Date
Uwe Kleine-König
7cf15f4275 iio: Switch i2c drivers back to use .probe()
After commit b8a1a4cd5a ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
03c835f498 ("i2c: Switch .probe() to not take an id parameter") convert
back to (the new) .probe() to be able to eventually drop .probe_new() from
struct i2c_driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230515205048.19561-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-05-21 18:54:53 +01:00
Uwe Kleine-König
94e5ddbaac iio: dac: ad5446: Convert to i2c's .probe_new()
.probe_new() doesn't get the i2c_device_id * parameter, so determine
that explicitly in the probe function.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221118224540.619276-85-uwe@kleine-koenig.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-11-23 20:01:40 +00:00
Uwe Kleine-König
ed5c2f5fd1 i2c: Make remove callback return void
The value returned by an i2c driver's remove function is mostly ignored.
(Only an error message is printed if the value is non-zero that the
error is ignored.)

So change the prototype of the remove function to return no value. This
way driver authors are not tempted to assume that passing an error to
the upper layer is a good idea. All drivers are adapted accordingly.
There is no intended change of behaviour, all callbacks were prepared to
return 0 before.

Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com>
Reviewed-by: Jeremy Kerr <jk@codeconstruct.com.au>
Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Crt Mori <cmo@melexis.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Marek Behún <kabel@kernel.org> # for leds-turris-omnia
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Petr Machata <petrm@nvidia.com> # for mlxsw
Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com> # for surface3_power
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> # for bmc150-accel-i2c + kxcjk-1013
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> # for media/* + staging/media/*
Acked-by: Miguel Ojeda <ojeda@kernel.org> # for auxdisplay/ht16k33 + auxdisplay/lcd2s
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # for versaclock5
Reviewed-by: Ajay Gupta <ajayg@nvidia.com> # for ucsi_ccg
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # for iio
Acked-by: Peter Rosin <peda@axentia.se> # for i2c-mux-*, max9860
Acked-by: Adrien Grassein <adrien.grassein@gmail.com> # for lontium-lt8912b
Reviewed-by: Jean Delvare <jdelvare@suse.de> # for hwmon, i2c-core and i2c/muxes
Acked-by: Corey Minyard <cminyard@mvista.com> # for IPMI
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> # for drivers/power
Acked-by: Krzysztof Hałasa <khalasa@piap.pl>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-08-16 12:46:26 +02:00
Greg Kroah-Hartman
bcfa954650 First set of IIO new device support, features and cleanup for 5.19
Usual mixed bag. Stand out this time is Andy Shevchenko's continuing
 effort to move drivers over the generic firmware interfaces.
 
 Device support
 * sprd,sc2720
   - upm9620 binding addition.
   - Refactor and support for sc2720, sc2721 and sc2730.
 * ti,ads1015
   - Refactor driver and add support for TLA2024.
 
 Device support (IDs only)
 * invensense,mpu6050
   - Add ID for ICM-20608-D.
 * st,accel:
   -  Add ID for lis302dl.
 * st,lsm6dsx
   - Add support for ASM330LHHX (can fallback to LSM6DSR.)
 
 Features
 * convert drivers to device properties
   - IIO core
   - adi,ad7266
   - adi,adis16480
   - adi,adxl355
   - bosch,bmi160
   - domintech,dmard06
   - fsl,fxas21002c
   - invensense,mpu3050
   - linear,ltc2983
   - linear,ltc2632
   - maxbotix,mb1232
   - maxim,max31856
   - maxim,max31865
   - multiplexer
   - ping
   - rescale
   - taos,tsl2772
 * core
   - Add runtime check on whether realbits fit in storagebits for each
     channel.
 * adi,ad_sigma_delta
   - Add sequencer support and relevant update_scan_mode callbacks for
     adi,ad7192 and adi,ad7124.
 
 Cleanup and minor fixes
 * MAINTAINERS
   - Update Lorenzo Bianconi's email address for IIO drivers.
   - Add entry for ad3552r and update maintainer in dt-binding doc.
 * tree-wide
   - Replace strtobool() with kstrtobool().
   - Drop false OF dependencies.
 * core
   - Tidy up and document IIO modes.
   - Take iio_buffer_enabled() out of header allowing current_mode to be
     moved to the opaque structure.
   - As all kfifo buffers use the same mode value, drop that parameter
     and set it unconditionally.
   - White space fixes and similar.
   - Drop use of list iterator variable for
     list_for_each_entry_continue_reverse and use list_prepare_entry to
     restart.
 * sysfs-trigger
   - Replace use of 'found' variable with dedicate list iterator variable.
 * adi,ad7124
   - Drop misleading shift.
 * adi,ad2s1210
   - Remove redundant local variable assignment.
 * adi,adis16480
   - Use local device pointer to reduce repetition.
   - Improve handling of clocks.
 * domintech,dmard09
   - White space.
 * dummy driver
   - Improve error handling.
 * fsl,mma8452
   - Add missing documentation of name element.
 * invensense,mpu3050
   - Stop remove() returning non 0.
 * kionix,kxsd9
   - White space.
 * linear,ltc2688
   - Use local variable for struct device.
   - Combine of_node_put() error handling paths.
 * linear,ltc2983
   - Avoid use of constants in messages where a define is available.
 * microchip,mcp4131
   - Fix compatible in dt example.
 * pni,rm3100
   - Stop directly accessing iio_dev->current_mode just to find out
     if the buffer is enabled.
 * renesas,rzg2l
   - Relax kconfig constraint to include newer devices.
 * sprd,sc27xx
   - Fix wrong scaling mask.
   - Improve the calibration values.
 * samsung,ssp
   - Replace a 'found' variable in favor of an explicit value that was
     found.
 * sensortek,stk3xx
   - Add proximity-near-level binding and driver support.
 * st,st_sensors:
   - Drop unused accel_type enum.
   - Return early in *_write_raw()
   - Drop unnecessary locking in _avail functions.
   - Add local lock to protect odr against concurrent updates allowing
     mlock to no longer be used outside of the core.
   - Use iio_device_claim_direct_mode() rather than racy checking of
     the current mode.
 * st,stmpe-adc
   - Fix checks on wait_for_completion_timeout().
   - Allow use of of_device_id for matching.
 * st,stm32-dfsdm
   - Stop accessing iio_dev->current_mode to find out if the buffer
     is enabled (so we can hide that variable in the opaque structure)
 * st,vl53l0x
   - Fix checks on wait_for_completion_timeout.
 * ti,ads1015
   - Add missing ID for ti,ads1115 in binding doc.
   - Convert from repeated chip ID look up to selecting static const
     data.
   - Switch to read_avail() callback.
 * ti,ads8688
   - Use of_device_id for driver matching.
 * ti,palmas-adc
   - Drop a warning on minor calibration mismatch leading to slightly
     negative values after applying the calibration.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmJy4f0RHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FohyzQ//e2RJF/oUjd5WreX9fywnK2qwXE0n6yfQ
 OrXuLvdAZ4ZwELmQyCg7XWVZY1u6JXvW1/TJXpjI0Y4sXSCSs+Z514BJOQYOrEyv
 2MH5mqkXq5IeskKAOxKBLeOz8e8txKyB2S4lDSVH11y40i32U+3SMdZHUt4ThVJU
 xd6FMJqEvXrbramQSj3O61YvICBedOcoKe4Da7nJtmr42zkDuBYJRlmtCnRoXx1l
 wrNgozEdqMh/JIRayVjlKfPpu3OiEFwt/uKvLEepKei/djUMdRnMyjTcXTziDGNg
 +B/51pWm7BLKE3YiqVAFZGBOi7OXZ0bRFVaUZyPOOP/xRr7DrdDRgFVpM4/Z9D0y
 p3anrWwkp6UF+IlatxjIDNGiAlWlWgNUZsFxWBMjRHAunOGhlrTNV7PVh81+LNBM
 I8Z9B+FDW/ECuxRSP2oK0an+4fVwJiOfGWSnuo6cIkW2ewh8kwr6Vvnu3bDytyew
 7xU9TvJN3fhYgU8pWK1VQ3ZIYan4zcAL/v40KBHDVIF49iKerYbKHGkCI4vJvakH
 lzf+dsUzYfQesTmB2sQUDdVvwpBtVd/xbD+mytRWv3bjapGIZ9r9LDGbjr8rgH0M
 egyPpxfdfVYjTWdpIx/tDHfyPEkuL7EjitKV7B83NbMq0N6GhQN2sT8L8DM7aC5p
 0x7kV5B4ZnE=
 =wZYX
 -----END PGP SIGNATURE-----

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

Jonathan writes:

First set of IIO new device support, features and cleanup for 5.19

Usual mixed bag. Stand out this time is Andy Shevchenko's continuing
effort to move drivers over the generic firmware interfaces.

Device support
* sprd,sc2720
  - upm9620 binding addition.
  - Refactor and support for sc2720, sc2721 and sc2730.
* ti,ads1015
  - Refactor driver and add support for TLA2024.

Device support (IDs only)
* invensense,mpu6050
  - Add ID for ICM-20608-D.
* st,accel:
  -  Add ID for lis302dl.
* st,lsm6dsx
  - Add support for ASM330LHHX (can fallback to LSM6DSR.)

Features
* convert drivers to device properties
  - IIO core
  - adi,ad7266
  - adi,adis16480
  - adi,adxl355
  - bosch,bmi160
  - domintech,dmard06
  - fsl,fxas21002c
  - invensense,mpu3050
  - linear,ltc2983
  - linear,ltc2632
  - maxbotix,mb1232
  - maxim,max31856
  - maxim,max31865
  - multiplexer
  - ping
  - rescale
  - taos,tsl2772
* core
  - Add runtime check on whether realbits fit in storagebits for each
    channel.
* adi,ad_sigma_delta
  - Add sequencer support and relevant update_scan_mode callbacks for
    adi,ad7192 and adi,ad7124.

Cleanup and minor fixes
* MAINTAINERS
  - Update Lorenzo Bianconi's email address for IIO drivers.
  - Add entry for ad3552r and update maintainer in dt-binding doc.
* tree-wide
  - Replace strtobool() with kstrtobool().
  - Drop false OF dependencies.
* core
  - Tidy up and document IIO modes.
  - Take iio_buffer_enabled() out of header allowing current_mode to be
    moved to the opaque structure.
  - As all kfifo buffers use the same mode value, drop that parameter
    and set it unconditionally.
  - White space fixes and similar.
  - Drop use of list iterator variable for
    list_for_each_entry_continue_reverse and use list_prepare_entry to
    restart.
* sysfs-trigger
  - Replace use of 'found' variable with dedicate list iterator variable.
* adi,ad7124
  - Drop misleading shift.
* adi,ad2s1210
  - Remove redundant local variable assignment.
* adi,adis16480
  - Use local device pointer to reduce repetition.
  - Improve handling of clocks.
* domintech,dmard09
  - White space.
* dummy driver
  - Improve error handling.
* fsl,mma8452
  - Add missing documentation of name element.
* invensense,mpu3050
  - Stop remove() returning non 0.
* kionix,kxsd9
  - White space.
* linear,ltc2688
  - Use local variable for struct device.
  - Combine of_node_put() error handling paths.
* linear,ltc2983
  - Avoid use of constants in messages where a define is available.
* microchip,mcp4131
  - Fix compatible in dt example.
* pni,rm3100
  - Stop directly accessing iio_dev->current_mode just to find out
    if the buffer is enabled.
* renesas,rzg2l
  - Relax kconfig constraint to include newer devices.
* sprd,sc27xx
  - Fix wrong scaling mask.
  - Improve the calibration values.
* samsung,ssp
  - Replace a 'found' variable in favor of an explicit value that was
    found.
* sensortek,stk3xx
  - Add proximity-near-level binding and driver support.
* st,st_sensors:
  - Drop unused accel_type enum.
  - Return early in *_write_raw()
  - Drop unnecessary locking in _avail functions.
  - Add local lock to protect odr against concurrent updates allowing
    mlock to no longer be used outside of the core.
  - Use iio_device_claim_direct_mode() rather than racy checking of
    the current mode.
* st,stmpe-adc
  - Fix checks on wait_for_completion_timeout().
  - Allow use of of_device_id for matching.
* st,stm32-dfsdm
  - Stop accessing iio_dev->current_mode to find out if the buffer
    is enabled (so we can hide that variable in the opaque structure)
* st,vl53l0x
  - Fix checks on wait_for_completion_timeout.
* ti,ads1015
  - Add missing ID for ti,ads1115 in binding doc.
  - Convert from repeated chip ID look up to selecting static const
    data.
  - Switch to read_avail() callback.
* ti,ads8688
  - Use of_device_id for driver matching.
* ti,palmas-adc
  - Drop a warning on minor calibration mismatch leading to slightly
    negative values after applying the calibration.

* tag 'iio-for-5.19a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (95 commits)
  iio: ti-ads8688: use of_device_id for OF matching
  iio: stmpe-adc: use of_device_id for OF matching
  dt-bindings: iio: Fix incorrect compatible strings in examples
  iio: gyro: mpu3050: Make mpu3050_common_remove() return void
  iio: dac: ltc2632: Make use of device properties
  iio: temperature: max31865: Make use of device properties
  iio: proximity: mb1232: Switch to use fwnode_irq_get()
  iio: imu: adis16480: Improve getting the optional clocks
  iio: imu: adis16480: Use temporary variable for struct device
  iio: imu: adis16480: Make use of device properties
  staging: iio: ad2s1210: remove redundant assignment to variable negative
  iio: adc: sc27xx: add support for PMIC sc2730
  iio: adc: sc27xx: add support for PMIC sc2720 and sc2721
  iio: adc: sc27xx: refactor some functions for support more PMiCs
  iio: adc: sc27xx: structure adjustment and optimization
  iio: adc: sc27xx: Fine tune the scale calibration values
  iio: adc: sc27xx: fix read big scale voltage not right
  dt-bindings:iio:adc: add sprd,ump9620-adc dt-binding
  iio: proximity: stk3310: Export near level property for proximity sensor
  dt-bindings: iio: light: stk33xx: Add proximity-near-level
  ...
2022-05-19 16:53:08 +02:00
Lars-Peter Clausen
74f582ec12 iio: Replace strtobool() with kstrtobool()
strtobool() is deprecated and just a wrapper around kstrtobool().Replace
it with kstrtobool() so the deprecated function can be removed eventually.

Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220409105812.2113895-1-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-28 19:22:54 +01:00
Michael Hennerich
89a01cd688 iio: dac: ad5446: Fix read_raw not returning set value
read_raw should return the un-scaled value.

Fixes: 5e06bdfb46 ("staging:iio:dac:ad5446: Return cached value for 'raw' attribute")
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220406105620.1171340-1-michael.hennerich@analog.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-10 17:45:24 +01:00
Uwe Kleine-König
a0386bba70
spi: make remove callback a void function
The value returned by an spi driver's remove function is mostly ignored.
(Only an error message is printed if the value is non-zero that the
error is ignored.)

So change the prototype of the remove function to return no value. This
way driver authors are not tempted to assume that passing an error to
the upper layer is a good idea. All drivers are adapted accordingly.
There is no intended change of behaviour, all callbacks were prepared to
return 0 before.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Claudius Heine <ch@denx.de>
Acked-by: Stefan Schmidt <stefan@datenfreihafen.org>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC
Acked-by: Marcus Folkesson <marcus.folkesson@gmail.com>
Acked-by: Łukasz Stelmach <l.stelmach@samsung.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Link: https://lore.kernel.org/r/20220123175201.34839-6-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
2022-02-09 13:00:45 +00:00
Antoniu Miclaus
ffc7c5172a iio: expose shared parameter in IIO_ENUM_AVAILABLE
The shared parameter should be configurable based on its usage, and not
constrained to IIO_SHARED_BY_TYPE.

This patch aims to improve the flexibility in using the
IIO_ENUM_AVAILABLE define and avoid redefining custom iio enums that
expose the shared parameter.

An example is the ad5766.c driver where IIO_ENUM_AVAILABLE_SHARED was
defined in order to achieve `shared` parameter customization.

The current state of the IIO_ENUM_AVAILABLE implementation will imply
similar redefinitions each time a driver will require access to the
`shared` parameter. An example would be admv1013 driver which will
require custom device attribute for the frequency translation modes:
Quadrature I/Q mode and Intermediate Frequency mode.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20211119085627.6348-1-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-11-27 16:12:23 +00:00
Greg Kroah-Hartman
8210a2004d First set of IIO fixes for the 5.16 cycle
As these are very late in the 5.15 cycle and non are particularly urgent,
 they can wait for the merge window.
 
 Key element in this set is Yang Yingliang has identified a number of
 issues in error paths introduced recently when we added multiple
 buffer support.
 
 Other fixes:
 * adi,ad5662
   - Fix handling of i2c_master_send() return value.
 * adi,ad5766
   - Fix a wrong dt-property name that indicated wrong units and
     did not mach the bindings.
   - Associated 'fix' of the bindings example to have a possible scale.
 * st,pressure-spi
   - Add some missing entries to the spi_device_id table to ensure
     auto-loading works.
 * ti,tsc2046
   - Fix a backwards comparison leading to a false dev_warn
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmFxs7kRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FojEXhAAn8OoUwEaViRbrVuPJmWCLuhZR8/ke1HE
 9WFXYjVvr6+FIyxgOxTVhoVd0LmcqzgeMg0si8CvnXvmx0mYqRyGxSgZ0oSWOfNR
 /RhfbL3RKyWmbp5ey3JuJxGS9Py1LXSFycsC7igjrgySqGo05kLrMpGkMr2g3d6a
 OKBOaoiBQPEvYmkNlFLOhtWGHNA4mICmi7UWwcfeN667SWKT3VFpBllSQwRpRXtz
 h/h0XhJg72x7JdJJsiBAWX9IsbBm9bXjaeXWZldDNnrZRS3VKTXzAkMTI0Wu0Rrq
 voEXvh74ys280aXoh5eHzN4OLdGBTJLVRjNaEAUaSMry4oWPpnkkda9pYY8dCcaR
 b8kPxn68PnrjbBG5et3PBo+/XAh7C0Ny2ETEqI8qlNk9adqUEl0wixuUUEljEqVE
 2rB35SEJYJzl0V0Up2uZMzYhPsfw+kbZoLUPyLfL9uNW3r1l9xgQURTM74UZcSdI
 cV2kcGWZdIX6IKVrChhPpeXcsS9ZWljWzUGu4IFBw1h9X6jwhbWJvACj889Rf4EI
 +ndjCylpE4aJfoZI7JSg5i41KvEGbwE3SkrKZTMNWe6aPajhcylzeG9+jxsAYaPn
 +hnKbPTE99oaopu1Od/s2EUtmIontZQy74aDfbQM3HU8fHmauk8/+L9kDNlkV2b3
 ZWbSw6Z2g4g=
 =jYCH
 -----END PGP SIGNATURE-----

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

Jonathan writes:

First set of IIO fixes for the 5.16 cycle

As these are very late in the 5.15 cycle and non are particularly urgent,
they can wait for the merge window.

Key element in this set is Yang Yingliang has identified a number of
issues in error paths introduced recently when we added multiple
buffer support.

Other fixes:
* adi,ad5662
  - Fix handling of i2c_master_send() return value.
* adi,ad5766
  - Fix a wrong dt-property name that indicated wrong units and
    did not mach the bindings.
  - Associated 'fix' of the bindings example to have a possible scale.
* st,pressure-spi
  - Add some missing entries to the spi_device_id table to ensure
    auto-loading works.
* ti,tsc2046
  - Fix a backwards comparison leading to a false dev_warn

* tag 'iio-fixes-for-5.16a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: buffer: Fix memory leak in iio_buffers_alloc_sysfs_and_mask()
  iio: adc: tsc2046: fix scan interval warning
  iio: core: fix double free in iio_device_unregister_sysfs()
  iio: core: check return value when calling dev_set_name()
  iio: buffer: Fix memory leak in iio_buffer_register_legacy_sysfs_groups()
  iio: buffer: Fix double-free in iio_buffers_alloc_sysfs_and_mask()
  iio: buffer: Fix memory leak in __iio_buffer_alloc_sysfs_and_mask()
  iio: buffer: check return value of kstrdup_const()
  iio: dac: ad5446: Fix ad5622_write() return value
  Documentation:devicetree:bindings:iio:dac: Fix val
  drivers: iio: dac: ad5766: Fix dt property name
  iio: st_pressure_spi: Add missing entries SPI to device ID table
2021-10-24 13:08:36 +02:00
Uwe Kleine-König
1f10848f18 iio: dac: ad5446: Make ad5446_remove() return void
Up to now ad5446_remove() returns zero unconditionally. Make it return
void instead which makes it easier to see in the callers that there is
no error to handle.

Also the return value of i2c and spi remove callbacks is ignored anyway.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20211013203223.2694577-9-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-19 08:30:45 +01:00
Pekka Korpinen
558df982d4 iio: dac: ad5446: Fix ad5622_write() return value
On success i2c_master_send() returns the number of bytes written. The
call from iio_write_channel_info(), however, expects the return value to
be zero on success.

This bug causes incorrect consumption of the sysfs buffer in
iio_write_channel_info(). When writing more than two characters to
out_voltage0_raw, the ad5446 write handler is called multiple times
causing unexpected behavior.

Fixes: 3ec36a2cf0 ("iio:ad5446: Add support for I2C based DACs")
Signed-off-by: Pekka Korpinen <pekka.korpinen@iki.fi>
Link: https://lore.kernel.org/r/20210929185755.2384-1-pekka.korpinen@iki.fi
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-17 11:42:04 +01:00
Lars-Peter Clausen
f46ac00978 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.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210320071405.9347-5-lars@metafoo.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-03-29 11:12:30 +01:00
Jonathan Cameron
b49e6eb1c7 iio:dac:ad5446: Drop of_match_ptr and CONFIG_OF protections
These prevent use of this driver with ACPI via PRP0001 and are
an example of an anti pattern I'm trying to remove from IIO.
Hence drop them from this driver.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Link: https://lore.kernel.org/r/20200910173242.621168-10-jic23@kernel.org
2020-09-21 18:41:27 +01:00
Lee Jones
af390b8c0a iio: dac: ad5446: Complete 'struct ad5446_state' doc and demote unworthy kerneldocs
Fixes the following W=1 kernel build warning(s):

 drivers/iio/dac/ad5446.c:48: warning: Function parameter or member 'dev' not described in 'ad5446_state'
 drivers/iio/dac/ad5446.c:48: warning: Function parameter or member 'cached_val' not described in 'ad5446_state'
 drivers/iio/dac/ad5446.c:48: warning: Function parameter or member 'pwr_down_mode' not described in 'ad5446_state'
 drivers/iio/dac/ad5446.c:48: warning: Function parameter or member 'pwr_down' not described in 'ad5446_state'
 drivers/iio/dac/ad5446.c:48: warning: Function parameter or member 'lock' not described in 'ad5446_state'
 drivers/iio/dac/ad5446.c:323: warning: cannot understand function prototype: 'enum ad5446_supported_spi_device_ids '
 drivers/iio/dac/ad5446.c:545: warning: cannot understand function prototype: 'enum ad5446_supported_i2c_device_ids '

Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-07-20 09:02:59 +01:00
Alexandru Ardelean
2cbd54129f iio: remove left-over comments about parent assignment
These were obtained by doing a 'git diff | grep \/\*', in the previous diff
to find comments. These needed a bit more manual review, as the semantic
patch isn't great for catching these.

The result is:
 	/* Initialize Counter device and driver data */
 	/* Initialize IIO device */
 	/* Establish that the iio_dev is a child of the spi device */
 	/* Estabilish that the iio_dev is a child of the spi device */
 	/* Initiate the Industrial I/O device */
 	/* Establish that the iio_dev is a child of the device */
-	/* establish that the iio_dev is a child of the i2c device */
-	/* establish that the iio_dev is a child of the i2c device */
 	/* This is only used for removal purposes */
 	/* setup the industrialio driver allocated elements */
 	/* variant specific configuration */
 	/* Setup for userspace synchronous on demand sampling. */
 	st->readback_delay_us += 5; /* Add tWAIT */
-	/* Establish that the iio_dev is a child of the i2c device */
 	/* Establish that the iio_dev is a child of the i2c device */

Out of which, 4 are really left-over comments about parent assignment.
3 of them are removed by the semantic patch, as the comment removed (by
spatch) would be for an empty line.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:50:00 +01:00
Alexandru Ardelean
d3be83244c iio: remove explicit IIO device parent assignment
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>
2020-06-14 11:49:59 +01:00
Sergiu Cuciurean
0b4b5925bf iio: dac: ad5446: Replace indio_dev->mlock with own device lock
As part of the general cleanup of indio_dev->mlock, this change replaces
it with a local lock on the device's state structure.

Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-16 16:14:36 +01:00
Andy Shevchenko
6ef9d68b58 iio: dac: ad5446: Use put_unaligned_be24()
This makes the driver code slightly easier to read.

Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 09:47:19 +01:00
Stefan Popa
6376cbe549 iio: dac: ad5446: Add support for new AD5600 DAC
The AD5600 is a single channel, 16-bit resolution, voltage output digital
to analog converter (DAC). The AD5600 uses a 3-wire SPI interface. It is
part of the AD5541 family of DACs.

The ad5446 IIO driver implements support for some of these DACs (in the
AD5441 family), so the change is a simple entry in this driver.

Link: https://www.analog.com/media/en/technical-documentation/data-sheets/AD5600.pdf

Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-11-10 15:14:06 +00:00
Thomas Gleixner
80503b23b2 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 149
Based on 1 normalized pattern(s):

  licensed under the gpl 2 or later

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190524100845.150836982@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-30 11:25:18 -07:00
Michael Hennerich
9920ed25ec drivers: iio: Update MODULE AUTHOR email address
no functional changes

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2018-08-19 17:23:39 +01:00
Lukas Wunner
49b3f87496 drivers: misc: ti_dac7512: Remove duplicate driver
The Texas Instruments DAC7512 has the exact same pinout, programming
interface and power-down modes as the Texas Instruments DAC121S101 and
Analog Devices AD5320, which are already supported by the IIO driver
ad5446.c.  Remove the duplicate misc driver.

This requires user space to migrate to the standardized IIO sysfs ABI.
(In other words, it needs to change a filename.)

The IIO driver supports the chip's features more fully, e.g. the ability
to power down the output or choose one of the available powerdown modes.

There is an oddity with the misc driver in that it initializes the SPI
slave to SPI_MODE_0, in contradiction to the datasheet which specifies
that data is latched in on the falling edge, implying that SPI_MODE_1
or SPI_MODE_2 must be used.  Another oddity is that Kconfig and the
MODULE_DESCRIPTION() claim the chip has 16-bit resolution although it
actually has 12-bit.

Datasheets:
http://www.ti.com/lit/ds/symlink/dac7512.pdf
http://www.ti.com/lit/ds/symlink/dac121s101.pdf
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5320.pdf

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Acked-by: Daniel Mack <daniel@zonque.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-13 17:49:57 +01:00
Lukas Wunner
9cad3b9854 iio: dac: ad5446: Add IDs of compatible Texas Instruments chips
The Texas Instruments DAC081S101, DAC101S101 and DAC121S101 have the
exact same pinout, programming interface and power-down modes as the
AD5300, AD5310 and AD5320, respectively, and their datasheets declare
them "a direct replacement" for the Analog Devices chips.  This may
not be immediately obvious to a casual observer, so add them to the
supported modalias strings.

Datasheets:
http://www.ti.com/lit/ds/symlink/dac081s101.pdf
http://www.ti.com/lit/ds/symlink/dac101s101.pdf
http://www.ti.com/lit/ds/symlink/dac121s101.pdf
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5300.pdf
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5310.pdf
http://www.analog.com/media/en/technical-documentation/data-sheets/AD5320.pdf

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-09-13 17:49:57 +01:00
Jonathan Cameron
ea9e3f3588 iio:dac: drop assignment of iio_info.driver_module
The equivalent of this is now done via macro magic when
the relevant register call is made.  The actual structure
element will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:26:54 +01:00
Andrew F. Davis
3821a065f5 spi: Drop owner assignment from spi_drivers
An spi_driver does not need to set an owner, it will be populated by the
driver core.

Signed-off-by: Andrew F. Davis <afd@ti.com>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2015-10-28 10:30:17 +09:00
Krzysztof Kozlowski
2155971a66 iio: Drop owner assignment from i2c_driver
i2c_driver does not need to set an owner because i2c_register_driver()
will set it.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-07-11 18:50:07 +01:00
Jonathan Cameron
e3019c21de iio:dac:ad5446 replaces IIO_ST macro with explicit entries to struct scan_type
IIO_ST is going away as it is a pain to maintain.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
2013-12-17 21:00:09 +00:00
Lars-Peter Clausen
0a99b60143 iio:ad5446: Report scale as fractional value
Move the complexity of calculating the fixed point scale to the core.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-10-01 16:19:09 +01:00
Aida Mynzhasova
4fa2a9e468 iio: dac: ad5446: Add support for AD5641
This patch adds support for the AD5641 single channel,
14-bit, buffered voltage output DAC.

Signed-off-by: Aida Mynzhasova <aida.mynzhasova@skitlab.ru>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-09-23 20:20:47 +01:00
Jonathan Cameron
3704432fb1 iio: refactor info mask and ext_info attribute creation.
Introduce an enum to specify whether the attribute is separate or
shared.

Factor out the bitmap handling for loop into a separate function.

Tidy up error handling and add a NULL assignment to squish a false
positive warning from GCC.

Change ext_info shared type from boolean to enum and update in all
drivers.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2013-09-15 17:43:20 +01:00
Sachin Kamat
ba7272954e iio: dac: ad5446: Use devm_* APIs
devm_* APIs are device managed and make code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2013-08-19 20:25:43 +01:00
Jonathan Cameron
2f6a4a4421 iio:dac:ad5446 move to info_mask_(shared_by_type/separate)
The original info_mask is going away in favour of the broken out versions.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
2013-03-17 19:49:32 +00:00
Linus Torvalds
b87fc3e6e2 Staging fixes for 3.8-rc3
Here are a number of small fixes to staging drivers for your 3.8-rc3
 tree.
 
 Well, the omapdrm fixes aren't really "small" but they were waiting on a
 number of other drm patches to go in through the drm tree, and got
 delayed by my vacation over the holidays.  They are totally
 self-contained, everyone involved have acked them, and they fix issues
 that people have been having with the driver.
 
 Other than that one, it's a bunch of tiny bugfixes for a number of
 reported issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.19 (GNU/Linux)
 
 iEYEABECAAYFAlDzjqQACgkQMUfUDdst+ym/FgCfTOKtRk2YP9FJ+GlJnO7Ij2Ez
 r/AAoJhhlxUwn59zhyCA6iIOLLix0tfU
 =llcV
 -----END PGP SIGNATURE-----

Merge tag 'staging-3.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging fixes from Greg Kroah-Hartman:
 "Here are a number of small fixes to staging drivers for your 3.8-rc3
  tree.

  Well, the omapdrm fixes aren't really "small" but they were waiting on
  a number of other drm patches to go in through the drm tree, and got
  delayed by my vacation over the holidays.  They are totally
  self-contained, everyone involved have acked them, and they fix issues
  that people have been having with the driver.

  Other than that one, it's a bunch of tiny bugfixes for a number of
  reported issues.

  Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>"

* tag 'staging-3.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (36 commits)
  staging: zram: fix invalid memory references during disk write
  staging: tidspbridge: use prepare/unprepare on dsp clocks
  staging: tidspbridge: Fix build breakage due to splitting CM functions.
  staging: comedi: comedi_test: fix race when cancelling command
  staging: comedi: Kconfig: COMEDI_NI_AT_A2150 should select COMEDI_FC
  staging: comedi: prevent auto-unconfig of manually configured devices
  staging: comedi: fix minimum AO period for NI 625x and NI 628x
  staging: vme_pio2: fix oops on module unloading
  staging: speakup: avoid out-of-range access in synth_add()
  staging: speakup: avoid out-of-range access in synth_init()
  staging: rtl8192e: Fix failure to check pci_map_single()
  staging: rtl8187se: Fix failure to check pci_map_single()
  staging: drm/imx: fix double free bug in error path
  staging: drm/imx: several bug fixes
  staging: drm/imx: check return value of ipu_reset()
  staging: drm/omap: fix flags in dma buf exporting
  staging: drm/omap: use omapdss low level API
  staging/fwserial: Update TODO file per reviewer comments
  staging/fwserial: Limit tx/rx to 1394-2008 spec maximum
  staging/fwserial: Refine Kconfig help text
  ...
2013-01-14 09:08:38 -08:00
Greg Kroah-Hartman
fc52692c49 Drivers: iio: remove __dev* attributes.
CONFIG_HOTPLUG is going away as an option.  As a result, the __dev*
markings need to be removed.

This change removes the use of __devinit, __devexit_p, and __devexit
from these drivers.

Based on patches originally written by Bill Pemberton, but redone by me
in order to handle some of the coding style issues better, by hand.

Cc: Bill Pemberton <wfp5p@virginia.edu>
Cc: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-01-03 15:57:03 -08:00
Axel Lin
13e57ee205 iio: dac: ad5446: Don't set error code to voltage_uv
regulator_get_voltage() may return negative error code.
Add error checking to avoid setting error code to voltage_uv.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-12-27 11:00:27 +00:00
Lars-Peter Clausen
bf83238019 iio:ad5446: Add device ids for ad5301/ad5311/ad5321
The ad5301/ad5311/ad5321 are software compatible to the ad5602/ad5612/ad5622.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-08 10:14:46 +01:00
Lars-Peter Clausen
2fafbce250 iio:ad5446: Add support for the ad5300/ad5310/ad5320
The ad5300/ad5310/ad5320 is a family of single channel DACs with a SPI interface
similar to the ad5601/ad5611/ad5621 but use a different shift factor for the
data word.

While we are at it also reorder the device part numbers in the ad5446 driver
Kconfig to be ordered alphabetically.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-08 10:14:45 +01:00
Jean-Francois Dagenais
2e15c903c1 iio:ad5446: get rid of private header file
Most of the defines in there were not even used, and the structs left are
private to the .c file. Makes the driver more in line with most of the
kernel drivers.

Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03 20:26:45 +01:00
Jean-Francois Dagenais
3ec36a2cf0 iio:ad5446: Add support for I2C based DACs
This patch adds support for I2C based single channel DACs to the ad5446
driver. Specifically AD5602, AD5612 and AD5622.

V1: from Lars-Peter Clausen <lars@metafoo.de>
V2: Split the device IDs into two enums and move them to the c file.

Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03 20:26:45 +01:00
Lars-Peter Clausen
779c0c4619 iio:dac:ad5446: Add support for the AD5450/51/52/53
This patch adds support for the Analog Devices AD5450/51/52/53 Digital-to-Analog
converters.

The AD5452 and AD5453 are software compatible to the existing AD5444 and AD5446.
The AD5450 and AD5451 are similar but have a smaller resolution.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-26 14:57:30 -07:00
Lars-Peter Clausen
dbdc025bb2 staging:iio: Move DAC drivers out of staging
The IIO DAC drivers are in a reasonably good shape. They all make use of channel
spec and non of them provides non-documented sysfs attributes. Code style should
be OK as well, both checkpatch and coccicheck only report trivial issues.

So lets move the whole folder out of staging.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-06-05 14:02:25 +09:00