| .. | .. |
|---|
| 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 magn_3d_channel { |
|---|
| .. | .. |
|---|
| 527 | 512 | |
|---|
| 528 | 513 | indio_dev->channels = channels; |
|---|
| 529 | 514 | indio_dev->num_channels = chan_count; |
|---|
| 530 | | - indio_dev->dev.parent = &pdev->dev; |
|---|
| 531 | 515 | indio_dev->info = &magn_3d_info; |
|---|
| 532 | 516 | indio_dev->name = name; |
|---|
| 533 | 517 | indio_dev->modes = INDIO_DIRECT_MODE; |
|---|
| 534 | 518 | |
|---|
| 535 | | - ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, |
|---|
| 536 | | - NULL, NULL); |
|---|
| 537 | | - if (ret) { |
|---|
| 538 | | - dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); |
|---|
| 539 | | - return ret; |
|---|
| 540 | | - } |
|---|
| 541 | 519 | atomic_set(&magn_state->magn_flux_attributes.data_ready, 0); |
|---|
| 520 | + |
|---|
| 542 | 521 | ret = hid_sensor_setup_trigger(indio_dev, name, |
|---|
| 543 | 522 | &magn_state->magn_flux_attributes); |
|---|
| 544 | 523 | if (ret < 0) { |
|---|
| 545 | 524 | dev_err(&pdev->dev, "trigger setup failed\n"); |
|---|
| 546 | | - goto error_unreg_buffer_funcs; |
|---|
| 525 | + return ret; |
|---|
| 547 | 526 | } |
|---|
| 548 | 527 | |
|---|
| 549 | 528 | ret = iio_device_register(indio_dev); |
|---|
| .. | .. |
|---|
| 567 | 546 | error_iio_unreg: |
|---|
| 568 | 547 | iio_device_unregister(indio_dev); |
|---|
| 569 | 548 | error_remove_trigger: |
|---|
| 570 | | - hid_sensor_remove_trigger(&magn_state->magn_flux_attributes); |
|---|
| 571 | | -error_unreg_buffer_funcs: |
|---|
| 572 | | - iio_triggered_buffer_cleanup(indio_dev); |
|---|
| 549 | + hid_sensor_remove_trigger(indio_dev, &magn_state->magn_flux_attributes); |
|---|
| 573 | 550 | return ret; |
|---|
| 574 | 551 | } |
|---|
| 575 | 552 | |
|---|
| .. | .. |
|---|
| 582 | 559 | |
|---|
| 583 | 560 | sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_COMPASS_3D); |
|---|
| 584 | 561 | iio_device_unregister(indio_dev); |
|---|
| 585 | | - hid_sensor_remove_trigger(&magn_state->magn_flux_attributes); |
|---|
| 586 | | - iio_triggered_buffer_cleanup(indio_dev); |
|---|
| 562 | + hid_sensor_remove_trigger(indio_dev, &magn_state->magn_flux_attributes); |
|---|
| 587 | 563 | |
|---|
| 588 | 564 | return 0; |
|---|
| 589 | 565 | } |
|---|