| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * HID Sensors Driver |
|---|
| 3 | 4 | * Copyright (c) 2014, 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. |
|---|
| 16 | | - * |
|---|
| 17 | 5 | */ |
|---|
| 18 | 6 | #include <linux/device.h> |
|---|
| 19 | 7 | #include <linux/platform_device.h> |
|---|
| .. | .. |
|---|
| 26 | 14 | #include <linux/iio/iio.h> |
|---|
| 27 | 15 | #include <linux/iio/sysfs.h> |
|---|
| 28 | 16 | #include <linux/iio/buffer.h> |
|---|
| 29 | | -#include <linux/iio/trigger_consumer.h> |
|---|
| 30 | | -#include <linux/iio/triggered_buffer.h> |
|---|
| 31 | 17 | #include "../common/hid-sensors/hid-sensor-trigger.h" |
|---|
| 32 | 18 | |
|---|
| 33 | 19 | #define CHANNEL_SCAN_INDEX_PRESENCE 0 |
|---|
| .. | .. |
|---|
| 302 | 288 | } |
|---|
| 303 | 289 | |
|---|
| 304 | 290 | indio_dev->num_channels = ARRAY_SIZE(prox_channels); |
|---|
| 305 | | - indio_dev->dev.parent = &pdev->dev; |
|---|
| 306 | 291 | indio_dev->info = &prox_info; |
|---|
| 307 | 292 | indio_dev->name = name; |
|---|
| 308 | 293 | indio_dev->modes = INDIO_DIRECT_MODE; |
|---|
| 309 | 294 | |
|---|
| 310 | | - ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, |
|---|
| 311 | | - NULL, NULL); |
|---|
| 312 | | - if (ret) { |
|---|
| 313 | | - dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); |
|---|
| 314 | | - goto error_free_dev_mem; |
|---|
| 315 | | - } |
|---|
| 316 | 295 | atomic_set(&prox_state->common_attributes.data_ready, 0); |
|---|
| 296 | + |
|---|
| 317 | 297 | ret = hid_sensor_setup_trigger(indio_dev, name, |
|---|
| 318 | 298 | &prox_state->common_attributes); |
|---|
| 319 | 299 | if (ret) { |
|---|
| 320 | 300 | dev_err(&pdev->dev, "trigger setup failed\n"); |
|---|
| 321 | | - goto error_unreg_buffer_funcs; |
|---|
| 301 | + goto error_free_dev_mem; |
|---|
| 322 | 302 | } |
|---|
| 323 | 303 | |
|---|
| 324 | 304 | ret = iio_device_register(indio_dev); |
|---|
| .. | .. |
|---|
| 342 | 322 | error_iio_unreg: |
|---|
| 343 | 323 | iio_device_unregister(indio_dev); |
|---|
| 344 | 324 | error_remove_trigger: |
|---|
| 345 | | - hid_sensor_remove_trigger(&prox_state->common_attributes); |
|---|
| 346 | | -error_unreg_buffer_funcs: |
|---|
| 347 | | - iio_triggered_buffer_cleanup(indio_dev); |
|---|
| 325 | + hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes); |
|---|
| 348 | 326 | error_free_dev_mem: |
|---|
| 349 | 327 | kfree(indio_dev->channels); |
|---|
| 350 | 328 | return ret; |
|---|
| .. | .. |
|---|
| 359 | 337 | |
|---|
| 360 | 338 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_PROX); |
|---|
| 361 | 339 | iio_device_unregister(indio_dev); |
|---|
| 362 | | - hid_sensor_remove_trigger(&prox_state->common_attributes); |
|---|
| 363 | | - iio_triggered_buffer_cleanup(indio_dev); |
|---|
| 340 | + hid_sensor_remove_trigger(indio_dev, &prox_state->common_attributes); |
|---|
| 364 | 341 | kfree(indio_dev->channels); |
|---|
| 365 | 342 | |
|---|
| 366 | 343 | return 0; |
|---|