linux/drivers/iio
Lars-Peter Clausen 8b7651f259 iio: iio_device_alloc(): Remove unnecessary self drvdata
Drvdata is typically used by drivers to attach driver specific data to a
device. It is used to retrieve driver specific information when only the
device to which the data is attached is available.

In the IIO core in the `iio_device_alloc()` function we call
`iio_device_set_drvdata(indio_dev, indio_dev)`. This sets the drvdata of
the IIO device to itself.

This is rather unnecessary since if we have a pointer to the IIO device to
call `iio_device_get_drvdata()` on it we don't need to call the function
since we already have the pointer. If we only have a pointer to the `struct
device` we can use `dev_to_iio_dev()` to get the IIO device from it.

Furthermore the drvdata is supposed to be reserved for drivers, so it
should not be used by the IIO core in the first place.

The `set_drvdata()` has been around from the very beginning of the IIO
framework and back then it was used in the IIO device sysfs attribute
handling code. But that was subsequently replaced with a `dev_to_iio_dev()`
in commit e53f5ac52e ("iio: Use dev_to_iio_dev()") and other cleanups.

The self `set_drvdata()` is now no longer needed and can be removed.

Verified that there no longer any users by checking for potential users
using the following two coccinelle scripts and reviewing that none of the
matches are problematic code.

<smpl>
@@
struct iio_dev *iio_dev;
expression dev;
identifier fn !~ "(remove|resume|suspend)";
@@
fn(...)
{
...
*iio_dev = dev_get_drvdata(dev)
...
}
</smpl>

<smpl>
@r1@
position p;
struct iio_dev *indio_dev;
identifier dev_fn =~ "^dev_";
identifier devm_fn =~ "^devm_";
@@
(
 dev_fn
|
 devm_fn
)
 (&indio_dev@p->dev, ...)

@@
struct iio_dev *indio_dev;
position p != r1.p;
@@
*&indio_dev@p->dev</smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-12-16 11:44:10 +00:00
..
accel iio: expose shared parameter in IIO_ENUM_AVAILABLE 2021-11-27 16:12:23 +00:00
adc iio:adc/dac:Kconfig: Update to drop OF dependencies. 2021-12-12 17:13:18 +00:00
addac iio: addac: add AD74413R driver 2021-12-12 17:09:11 +00:00
afe iio: afe: iio-rescale: Support processed channels 2021-06-03 18:24:13 +01:00
amplifiers iio: amplifiers: hmc425a: Simplify with dev_err_probe() 2020-09-03 19:40:50 +01:00
buffer iio: buffer-dma: Use round_down() instead of rounddown() 2021-11-27 15:12:44 +00:00
cdc iio:cdc:ad7150: Fix use of uninitialized ret 2021-04-07 08:36:39 +01:00
chemical iio: atlas-sensor: Remove no-op trigger ops 2021-11-17 17:51:38 +00:00
common iio/scmi: Add reading "raw" attribute. 2021-11-17 17:51:35 +00:00
dac iio:adc/dac:Kconfig: Update to drop OF dependencies. 2021-12-12 17:13:18 +00:00
dummy iio: dummy: Fix build error when CONFIG_IIO_TRIGGERED_BUFFER is not set 2021-06-13 17:00:17 +01:00
frequency iio: frequency: adrf6780: Fix adrf6780_spi_{read,write}() 2021-10-24 13:14:26 +02:00
gyro iio: gyro: mpu3050: Fix alignment and size issues with buffers. 2021-10-19 08:29:22 +01:00
health iio: afe4404: Remove no-op trigger ops 2021-11-17 17:51:37 +00:00
humidity iio: humidity: hdc100x: Add margin to the conversion time 2021-07-24 18:13:02 +01:00
imu iio: imu: st_lsm6dsx: add dts property to disable sensor-hub 2021-12-04 15:34:17 +00:00
light iio:light:cm3605: Switch to generic firmware properties. 2021-12-12 17:12:50 +00:00
magnetometer iio: expose shared parameter in IIO_ENUM_AVAILABLE 2021-11-27 16:12:23 +00:00
multiplexer iio: multiplexer: iio-mux: Support settle-time-us property 2021-10-21 20:02:54 +01:00
orientation iio: hid-sensors: bind IIO channels alloc to device object 2021-07-13 18:21:53 +01:00
position iio: hid-sensors: Update header includes 2021-06-16 14:53:13 +01:00
potentiometer iio:pot:mcp41010: Switch to generic firmware properties. 2021-12-12 17:12:47 +00:00
potentiostat iio: lmp91000: Remove no-op trigger ops 2021-11-17 17:51:38 +00:00
pressure iio: mpl3115: Use scan_type.shift and realbit in mpl3115_read_raw 2021-11-17 17:51:44 +00:00
proximity iio: as3935: Remove no-op trigger ops 2021-11-17 17:51:37 +00:00
resolver iio:resolver:ad2s1200: Drop of_match_ptr protection 2020-09-21 18:41:31 +01:00
temperature iio: temperature: Add MAX31865 RTD Support 2021-09-14 12:00:33 +01:00
test iio: test: Add test for IIO_VAL_INT_64. 2021-11-27 16:33:45 +00:00
trigger iio: expose shared parameter in IIO_ENUM_AVAILABLE 2021-11-27 16:12:23 +00:00
iio_core_trigger.h iio: core-trigger: make iio_device_register_trigger_consumer() an int return 2021-03-11 20:47:02 +00:00
iio_core.h iio: Mark iio_device_type as const 2021-11-17 17:51:35 +00:00
industrialio-buffer.c iio: buffer: Use dedicated variable in iio_buffers_alloc_sysfs_and_mask() 2021-11-20 14:17:22 +00:00
industrialio-configfs.c
industrialio-core.c iio: iio_device_alloc(): Remove unnecessary self drvdata 2021-12-16 11:44:10 +00:00
industrialio-event.c iio:event: Add timeout event info type 2021-04-07 08:36:36 +01:00
industrialio-sw-device.c
industrialio-sw-trigger.c
industrialio-trigger.c iio: trigger: Fix a scheduling whilst atomic issue seen on tsc2046 2021-12-12 17:12:18 +00:00
industrialio-triggered-event.c iio: core: move @id from struct iio_dev to struct iio_dev_opaque 2021-05-17 13:49:13 +01:00
inkern.c iio: inkern: introduce devm_iio_map_array_register() short-hand function 2021-10-19 08:27:34 +01:00
Kconfig iio: add addac subdirectory 2021-12-12 17:09:11 +00:00
Makefile iio: add addac subdirectory 2021-12-12 17:09:11 +00:00
TODO iio: add a TODO 2020-03-08 17:28:53 +00:00