.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * HID Sensors Driver |
---|
3 | 4 | * Copyright (c) 2012, Intel Corporation. |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify it |
---|
6 | | - * under the terms and conditions of the GNU General Public License, |
---|
7 | | - * version 2, as published by the Free Software Foundation. |
---|
8 | | - * |
---|
9 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
---|
10 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
11 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
12 | | - * more details. |
---|
13 | | - * |
---|
14 | | - * You should have received a copy of the GNU General Public License along with |
---|
15 | | - * this program; if not, write to the Free Software Foundation, Inc., |
---|
16 | | - * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. |
---|
17 | | - * |
---|
18 | 5 | */ |
---|
19 | 6 | #include <linux/device.h> |
---|
20 | 7 | #include <linux/platform_device.h> |
---|
.. | .. |
---|
26 | 13 | #include <linux/hid-sensor-hub.h> |
---|
27 | 14 | #include <linux/iio/iio.h> |
---|
28 | 15 | #include <linux/iio/trigger.h> |
---|
| 16 | +#include <linux/iio/triggered_buffer.h> |
---|
| 17 | +#include <linux/iio/trigger_consumer.h> |
---|
29 | 18 | #include <linux/iio/buffer.h> |
---|
30 | 19 | #include <linux/iio/sysfs.h> |
---|
31 | 20 | #include "hid-sensor-trigger.h" |
---|
.. | .. |
---|
235 | 224 | return hid_sensor_power_state(iio_trigger_get_drvdata(trig), state); |
---|
236 | 225 | } |
---|
237 | 226 | |
---|
238 | | -void hid_sensor_remove_trigger(struct hid_sensor_common *attrb) |
---|
| 227 | +void hid_sensor_remove_trigger(struct iio_dev *indio_dev, |
---|
| 228 | + struct hid_sensor_common *attrb) |
---|
239 | 229 | { |
---|
240 | 230 | if (atomic_read(&attrb->runtime_pm_enable)) |
---|
241 | 231 | pm_runtime_disable(&attrb->pdev->dev); |
---|
.. | .. |
---|
246 | 236 | cancel_work_sync(&attrb->work); |
---|
247 | 237 | iio_trigger_unregister(attrb->trigger); |
---|
248 | 238 | iio_trigger_free(attrb->trigger); |
---|
| 239 | + iio_triggered_buffer_cleanup(indio_dev); |
---|
249 | 240 | } |
---|
250 | 241 | EXPORT_SYMBOL(hid_sensor_remove_trigger); |
---|
251 | 242 | |
---|
.. | .. |
---|
259 | 250 | int ret; |
---|
260 | 251 | struct iio_trigger *trig; |
---|
261 | 252 | |
---|
| 253 | + ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, |
---|
| 254 | + NULL, NULL); |
---|
| 255 | + if (ret) { |
---|
| 256 | + dev_err(&indio_dev->dev, "Triggered Buffer Setup Failed\n"); |
---|
| 257 | + return ret; |
---|
| 258 | + } |
---|
| 259 | + |
---|
262 | 260 | trig = iio_trigger_alloc("%s-dev%d", name, indio_dev->id); |
---|
263 | 261 | if (trig == NULL) { |
---|
264 | 262 | dev_err(&indio_dev->dev, "Trigger Allocate Failed\n"); |
---|
265 | 263 | ret = -ENOMEM; |
---|
266 | | - goto error_ret; |
---|
| 264 | + goto error_triggered_buffer_cleanup; |
---|
267 | 265 | } |
---|
268 | 266 | |
---|
269 | 267 | trig->dev.parent = indio_dev->dev.parent; |
---|
.. | .. |
---|
297 | 295 | iio_trigger_unregister(trig); |
---|
298 | 296 | error_free_trig: |
---|
299 | 297 | iio_trigger_free(trig); |
---|
300 | | -error_ret: |
---|
| 298 | +error_triggered_buffer_cleanup: |
---|
| 299 | + iio_triggered_buffer_cleanup(indio_dev); |
---|
301 | 300 | return ret; |
---|
302 | 301 | } |
---|
303 | 302 | EXPORT_SYMBOL(hid_sensor_setup_trigger); |
---|