| .. | .. |
|---|
| 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> |
|---|
| .. | .. |
|---|
| 27 | 14 | #include <linux/iio/iio.h> |
|---|
| 28 | 15 | #include <linux/iio/sysfs.h> |
|---|
| 29 | 16 | #include <linux/iio/buffer.h> |
|---|
| 30 | | -#include <linux/iio/trigger_consumer.h> |
|---|
| 31 | | -#include <linux/iio/triggered_buffer.h> |
|---|
| 32 | 17 | #include "../common/hid-sensors/hid-sensor-trigger.h" |
|---|
| 33 | 18 | |
|---|
| 34 | 19 | enum gyro_3d_channel { |
|---|
| .. | .. |
|---|
| 334 | 319 | } |
|---|
| 335 | 320 | |
|---|
| 336 | 321 | indio_dev->num_channels = ARRAY_SIZE(gyro_3d_channels); |
|---|
| 337 | | - indio_dev->dev.parent = &pdev->dev; |
|---|
| 338 | 322 | indio_dev->info = &gyro_3d_info; |
|---|
| 339 | 323 | indio_dev->name = name; |
|---|
| 340 | 324 | indio_dev->modes = INDIO_DIRECT_MODE; |
|---|
| 341 | 325 | |
|---|
| 342 | | - ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, |
|---|
| 343 | | - NULL, NULL); |
|---|
| 344 | | - if (ret) { |
|---|
| 345 | | - dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); |
|---|
| 346 | | - goto error_free_dev_mem; |
|---|
| 347 | | - } |
|---|
| 348 | 326 | atomic_set(&gyro_state->common_attributes.data_ready, 0); |
|---|
| 327 | + |
|---|
| 349 | 328 | ret = hid_sensor_setup_trigger(indio_dev, name, |
|---|
| 350 | 329 | &gyro_state->common_attributes); |
|---|
| 351 | 330 | if (ret < 0) { |
|---|
| 352 | 331 | dev_err(&pdev->dev, "trigger setup failed\n"); |
|---|
| 353 | | - goto error_unreg_buffer_funcs; |
|---|
| 332 | + goto error_free_dev_mem; |
|---|
| 354 | 333 | } |
|---|
| 355 | 334 | |
|---|
| 356 | 335 | ret = iio_device_register(indio_dev); |
|---|
| .. | .. |
|---|
| 374 | 353 | error_iio_unreg: |
|---|
| 375 | 354 | iio_device_unregister(indio_dev); |
|---|
| 376 | 355 | error_remove_trigger: |
|---|
| 377 | | - hid_sensor_remove_trigger(&gyro_state->common_attributes); |
|---|
| 378 | | -error_unreg_buffer_funcs: |
|---|
| 379 | | - iio_triggered_buffer_cleanup(indio_dev); |
|---|
| 356 | + hid_sensor_remove_trigger(indio_dev, &gyro_state->common_attributes); |
|---|
| 380 | 357 | error_free_dev_mem: |
|---|
| 381 | 358 | kfree(indio_dev->channels); |
|---|
| 382 | 359 | return ret; |
|---|
| .. | .. |
|---|
| 391 | 368 | |
|---|
| 392 | 369 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D); |
|---|
| 393 | 370 | iio_device_unregister(indio_dev); |
|---|
| 394 | | - hid_sensor_remove_trigger(&gyro_state->common_attributes); |
|---|
| 395 | | - iio_triggered_buffer_cleanup(indio_dev); |
|---|
| 371 | + hid_sensor_remove_trigger(indio_dev, &gyro_state->common_attributes); |
|---|
| 396 | 372 | kfree(indio_dev->channels); |
|---|
| 397 | 373 | |
|---|
| 398 | 374 | return 0; |
|---|