hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
....@@ -1,20 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * HID Sensors Driver
34 * 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
- *
185 */
196 #include <linux/device.h>
207 #include <linux/platform_device.h>
....@@ -26,6 +13,8 @@
2613 #include <linux/hid-sensor-hub.h>
2714 #include <linux/iio/iio.h>
2815 #include <linux/iio/trigger.h>
16
+#include <linux/iio/triggered_buffer.h>
17
+#include <linux/iio/trigger_consumer.h>
2918 #include <linux/iio/buffer.h>
3019 #include <linux/iio/sysfs.h>
3120 #include "hid-sensor-trigger.h"
....@@ -235,7 +224,8 @@
235224 return hid_sensor_power_state(iio_trigger_get_drvdata(trig), state);
236225 }
237226
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)
239229 {
240230 if (atomic_read(&attrb->runtime_pm_enable))
241231 pm_runtime_disable(&attrb->pdev->dev);
....@@ -246,6 +236,7 @@
246236 cancel_work_sync(&attrb->work);
247237 iio_trigger_unregister(attrb->trigger);
248238 iio_trigger_free(attrb->trigger);
239
+ iio_triggered_buffer_cleanup(indio_dev);
249240 }
250241 EXPORT_SYMBOL(hid_sensor_remove_trigger);
251242
....@@ -259,11 +250,18 @@
259250 int ret;
260251 struct iio_trigger *trig;
261252
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
+
262260 trig = iio_trigger_alloc("%s-dev%d", name, indio_dev->id);
263261 if (trig == NULL) {
264262 dev_err(&indio_dev->dev, "Trigger Allocate Failed\n");
265263 ret = -ENOMEM;
266
- goto error_ret;
264
+ goto error_triggered_buffer_cleanup;
267265 }
268266
269267 trig->dev.parent = indio_dev->dev.parent;
....@@ -297,7 +295,8 @@
297295 iio_trigger_unregister(trig);
298296 error_free_trig:
299297 iio_trigger_free(trig);
300
-error_ret:
298
+error_triggered_buffer_cleanup:
299
+ iio_triggered_buffer_cleanup(indio_dev);
301300 return ret;
302301 }
303302 EXPORT_SYMBOL(hid_sensor_setup_trigger);