| .. | .. |
|---|
| 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 accel_3d_channel { |
|---|
| .. | .. |
|---|
| 292 | 277 | hid_sensor_convert_timestamp( |
|---|
| 293 | 278 | &accel_state->common_attributes, |
|---|
| 294 | 279 | *(int64_t *)raw_data); |
|---|
| 280 | + ret = 0; |
|---|
| 295 | 281 | break; |
|---|
| 296 | 282 | default: |
|---|
| 297 | 283 | break; |
|---|
| .. | .. |
|---|
| 402 | 388 | goto error_free_dev_mem; |
|---|
| 403 | 389 | } |
|---|
| 404 | 390 | |
|---|
| 405 | | - indio_dev->dev.parent = &pdev->dev; |
|---|
| 406 | 391 | indio_dev->info = &accel_3d_info; |
|---|
| 407 | 392 | indio_dev->name = name; |
|---|
| 408 | 393 | indio_dev->modes = INDIO_DIRECT_MODE; |
|---|
| 409 | 394 | |
|---|
| 410 | | - ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, |
|---|
| 411 | | - NULL, NULL); |
|---|
| 412 | | - if (ret) { |
|---|
| 413 | | - dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); |
|---|
| 414 | | - goto error_free_dev_mem; |
|---|
| 415 | | - } |
|---|
| 416 | 395 | atomic_set(&accel_state->common_attributes.data_ready, 0); |
|---|
| 396 | + |
|---|
| 417 | 397 | ret = hid_sensor_setup_trigger(indio_dev, name, |
|---|
| 418 | 398 | &accel_state->common_attributes); |
|---|
| 419 | 399 | if (ret < 0) { |
|---|
| 420 | 400 | dev_err(&pdev->dev, "trigger setup failed\n"); |
|---|
| 421 | | - goto error_unreg_buffer_funcs; |
|---|
| 401 | + goto error_free_dev_mem; |
|---|
| 422 | 402 | } |
|---|
| 423 | 403 | |
|---|
| 424 | 404 | ret = iio_device_register(indio_dev); |
|---|
| .. | .. |
|---|
| 442 | 422 | error_iio_unreg: |
|---|
| 443 | 423 | iio_device_unregister(indio_dev); |
|---|
| 444 | 424 | error_remove_trigger: |
|---|
| 445 | | - hid_sensor_remove_trigger(&accel_state->common_attributes); |
|---|
| 446 | | -error_unreg_buffer_funcs: |
|---|
| 447 | | - iio_triggered_buffer_cleanup(indio_dev); |
|---|
| 425 | + hid_sensor_remove_trigger(indio_dev, &accel_state->common_attributes); |
|---|
| 448 | 426 | error_free_dev_mem: |
|---|
| 449 | 427 | kfree(indio_dev->channels); |
|---|
| 450 | 428 | return ret; |
|---|
| .. | .. |
|---|
| 459 | 437 | |
|---|
| 460 | 438 | sensor_hub_remove_callback(hsdev, hsdev->usage); |
|---|
| 461 | 439 | iio_device_unregister(indio_dev); |
|---|
| 462 | | - hid_sensor_remove_trigger(&accel_state->common_attributes); |
|---|
| 463 | | - iio_triggered_buffer_cleanup(indio_dev); |
|---|
| 440 | + hid_sensor_remove_trigger(indio_dev, &accel_state->common_attributes); |
|---|
| 464 | 441 | kfree(indio_dev->channels); |
|---|
| 465 | 442 | |
|---|
| 466 | 443 | return 0; |
|---|