| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * HID Sensors Driver |
|---|
| 3 | 4 | * Copyright (c) 2013, 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 | | - * |
|---|
| 17 | 5 | */ |
|---|
| 18 | 6 | |
|---|
| 19 | 7 | #include <linux/device.h> |
|---|
| .. | .. |
|---|
| 27 | 15 | #include <linux/iio/iio.h> |
|---|
| 28 | 16 | #include <linux/iio/sysfs.h> |
|---|
| 29 | 17 | #include <linux/iio/buffer.h> |
|---|
| 30 | | -#include <linux/iio/trigger_consumer.h> |
|---|
| 31 | | -#include <linux/iio/triggered_buffer.h> |
|---|
| 32 | 18 | #include "../common/hid-sensors/hid-sensor-trigger.h" |
|---|
| 33 | 19 | |
|---|
| 34 | 20 | enum incl_3d_channel { |
|---|
| .. | .. |
|---|
| 353 | 339 | } |
|---|
| 354 | 340 | |
|---|
| 355 | 341 | indio_dev->num_channels = ARRAY_SIZE(incl_3d_channels); |
|---|
| 356 | | - indio_dev->dev.parent = &pdev->dev; |
|---|
| 357 | 342 | indio_dev->info = &incl_3d_info; |
|---|
| 358 | 343 | indio_dev->name = name; |
|---|
| 359 | 344 | indio_dev->modes = INDIO_DIRECT_MODE; |
|---|
| 360 | 345 | |
|---|
| 361 | | - ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, |
|---|
| 362 | | - NULL, NULL); |
|---|
| 363 | | - if (ret) { |
|---|
| 364 | | - dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); |
|---|
| 365 | | - goto error_free_dev_mem; |
|---|
| 366 | | - } |
|---|
| 367 | 346 | atomic_set(&incl_state->common_attributes.data_ready, 0); |
|---|
| 347 | + |
|---|
| 368 | 348 | ret = hid_sensor_setup_trigger(indio_dev, name, |
|---|
| 369 | 349 | &incl_state->common_attributes); |
|---|
| 370 | 350 | if (ret) { |
|---|
| 371 | 351 | dev_err(&pdev->dev, "trigger setup failed\n"); |
|---|
| 372 | | - goto error_unreg_buffer_funcs; |
|---|
| 352 | + goto error_free_dev_mem; |
|---|
| 373 | 353 | } |
|---|
| 374 | 354 | |
|---|
| 375 | 355 | ret = iio_device_register(indio_dev); |
|---|
| .. | .. |
|---|
| 394 | 374 | error_iio_unreg: |
|---|
| 395 | 375 | iio_device_unregister(indio_dev); |
|---|
| 396 | 376 | error_remove_trigger: |
|---|
| 397 | | - hid_sensor_remove_trigger(&incl_state->common_attributes); |
|---|
| 398 | | -error_unreg_buffer_funcs: |
|---|
| 399 | | - iio_triggered_buffer_cleanup(indio_dev); |
|---|
| 377 | + hid_sensor_remove_trigger(indio_dev, &incl_state->common_attributes); |
|---|
| 400 | 378 | error_free_dev_mem: |
|---|
| 401 | 379 | kfree(indio_dev->channels); |
|---|
| 402 | 380 | return ret; |
|---|
| .. | .. |
|---|
| 411 | 389 | |
|---|
| 412 | 390 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_INCLINOMETER_3D); |
|---|
| 413 | 391 | iio_device_unregister(indio_dev); |
|---|
| 414 | | - hid_sensor_remove_trigger(&incl_state->common_attributes); |
|---|
| 415 | | - iio_triggered_buffer_cleanup(indio_dev); |
|---|
| 392 | + hid_sensor_remove_trigger(indio_dev, &incl_state->common_attributes); |
|---|
| 416 | 393 | kfree(indio_dev->channels); |
|---|
| 417 | 394 | |
|---|
| 418 | 395 | return 0; |
|---|