diff options
author | Alexandru Ardelean <alexandru.ardelean@analog.com> | 2020-04-24 06:34:18 +0200 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2020-05-10 10:35:53 +0200 |
commit | 067fda1c065ff5655fcd2600f4b9f72a6ab5b7d9 (patch) | |
tree | 5cd2d9e78adf7119be9fd543f7422f48bf2af06e /drivers/iio/pressure/hid-sensor-press.c | |
parent | iio: vcnl4000: Add buffer support for VCNL4010/20. (diff) | |
download | linux-067fda1c065ff5655fcd2600f4b9f72a6ab5b7d9.tar.xz linux-067fda1c065ff5655fcd2600f4b9f72a6ab5b7d9.zip |
iio: hid-sensors: move triggered buffer setup into hid_sensor_setup_trigger
The main intent here is to get rid of the iio_buffer_set_attrs() helper, or
at least rework it's usage a bit.
The problem with that helper is that it needs a pointer to the buffer,
which makes supporting multiple buffers per IIO device a bit more
cumbersome.
The hid_sensor_setup_trigger() is pretty much used in the same way:
- iio_triggered_buffer_setup() gets called before
- then hid_sensor_setup_trigger() and hid_sensor_setup_batch_mode() gets
called which may attach some fifo attributes
This change merges the 2 together under the hid_sensor_setup_trigger()
function. Only the &iio_pollfunc_store_time is passed to all devices, so
it's not even required to pass it explicitly outside of the common
hid_sensor_setup_trigger() function.
Moving the devm_iio_triggered_buffer_setup/cleanup() calls into the common
place code can help the rework of the buffer code, since it is in one
place.
One detail of the change is that there are 2 drivers that use
devm_iio_triggered_buffer_setup(). That function gets implicitly
replaced with iio_triggered_buffer_setup()/cleanup(), but since all drivers
call both hid_sensor_setup_trigger9) & hid_sensor_remove_trigger() trigger,
the iio_triggered_buffer_cleanup() piggy backs on the
hid_sensor_remove_trigger() call, which should cover the cleanup.
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/pressure/hid-sensor-press.c')
-rw-r--r-- | drivers/iio/pressure/hid-sensor-press.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c index 953235052155..5e6663f757ae 100644 --- a/drivers/iio/pressure/hid-sensor-press.c +++ b/drivers/iio/pressure/hid-sensor-press.c @@ -14,8 +14,6 @@ #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> #include <linux/iio/buffer.h> -#include <linux/iio/trigger_consumer.h> -#include <linux/iio/triggered_buffer.h> #include "../common/hid-sensors/hid-sensor-trigger.h" #define CHANNEL_SCAN_INDEX_PRESSURE 0 @@ -290,18 +288,13 @@ static int hid_press_probe(struct platform_device *pdev) indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; - ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, - NULL, NULL); - if (ret) { - dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); - goto error_free_dev_mem; - } atomic_set(&press_state->common_attributes.data_ready, 0); + ret = hid_sensor_setup_trigger(indio_dev, name, &press_state->common_attributes); if (ret) { dev_err(&pdev->dev, "trigger setup failed\n"); - goto error_unreg_buffer_funcs; + goto error_free_dev_mem; } ret = iio_device_register(indio_dev); @@ -325,9 +318,7 @@ static int hid_press_probe(struct platform_device *pdev) error_iio_unreg: iio_device_unregister(indio_dev); error_remove_trigger: - hid_sensor_remove_trigger(&press_state->common_attributes); -error_unreg_buffer_funcs: - iio_triggered_buffer_cleanup(indio_dev); + hid_sensor_remove_trigger(indio_dev, &press_state->common_attributes); error_free_dev_mem: kfree(indio_dev->channels); return ret; @@ -342,8 +333,7 @@ static int hid_press_remove(struct platform_device *pdev) sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_PRESSURE); iio_device_unregister(indio_dev); - hid_sensor_remove_trigger(&press_state->common_attributes); - iio_triggered_buffer_cleanup(indio_dev); + hid_sensor_remove_trigger(indio_dev, &press_state->common_attributes); kfree(indio_dev->channels); return 0; |