| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * asus-laptop.c - Asus Laptop Support |
|---|
| 3 | | - * |
|---|
| 4 | 4 | * |
|---|
| 5 | 5 | * Copyright (C) 2002-2005 Julien Lerouge, 2003-2006 Karol Kozimor |
|---|
| 6 | 6 | * Copyright (C) 2006-2007 Corentin Chary |
|---|
| 7 | 7 | * Copyright (C) 2011 Wind River Systems |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 10 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 11 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 | | - * (at your option) any later version. |
|---|
| 13 | | - * |
|---|
| 14 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 15 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | | - * GNU General Public License for more details. |
|---|
| 18 | | - * |
|---|
| 19 | | - * You should have received a copy of the GNU General Public License |
|---|
| 20 | | - * along with this program; if not, write to the Free Software |
|---|
| 21 | | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 22 | | - * |
|---|
| 23 | 8 | * |
|---|
| 24 | 9 | * The development page for this driver is located at |
|---|
| 25 | 10 | * http://sourceforge.net/projects/acpi4asus/ |
|---|
| .. | .. |
|---|
| 49 | 34 | #include <linux/uaccess.h> |
|---|
| 50 | 35 | #include <linux/input.h> |
|---|
| 51 | 36 | #include <linux/input/sparse-keymap.h> |
|---|
| 52 | | -#include <linux/input-polldev.h> |
|---|
| 53 | 37 | #include <linux/rfkill.h> |
|---|
| 54 | 38 | #include <linux/slab.h> |
|---|
| 55 | 39 | #include <linux/dmi.h> |
|---|
| .. | .. |
|---|
| 259 | 243 | |
|---|
| 260 | 244 | struct input_dev *inputdev; |
|---|
| 261 | 245 | struct key_entry *keymap; |
|---|
| 262 | | - struct input_polled_dev *pega_accel_poll; |
|---|
| 246 | + struct input_dev *pega_accel_poll; |
|---|
| 263 | 247 | |
|---|
| 264 | 248 | struct asus_led wled; |
|---|
| 265 | 249 | struct asus_led bled; |
|---|
| .. | .. |
|---|
| 461 | 445 | return clamp_val((short)val, -PEGA_ACC_CLAMP, PEGA_ACC_CLAMP); |
|---|
| 462 | 446 | } |
|---|
| 463 | 447 | |
|---|
| 464 | | -static void pega_accel_poll(struct input_polled_dev *ipd) |
|---|
| 448 | +static void pega_accel_poll(struct input_dev *input) |
|---|
| 465 | 449 | { |
|---|
| 466 | | - struct device *parent = ipd->input->dev.parent; |
|---|
| 450 | + struct device *parent = input->dev.parent; |
|---|
| 467 | 451 | struct asus_laptop *asus = dev_get_drvdata(parent); |
|---|
| 468 | 452 | |
|---|
| 469 | 453 | /* In some cases, the very first call to poll causes a |
|---|
| .. | .. |
|---|
| 472 | 456 | * device, and perhaps a firmware bug. Fake the first report. */ |
|---|
| 473 | 457 | if (!asus->pega_acc_live) { |
|---|
| 474 | 458 | asus->pega_acc_live = true; |
|---|
| 475 | | - input_report_abs(ipd->input, ABS_X, 0); |
|---|
| 476 | | - input_report_abs(ipd->input, ABS_Y, 0); |
|---|
| 477 | | - input_report_abs(ipd->input, ABS_Z, 0); |
|---|
| 478 | | - input_sync(ipd->input); |
|---|
| 459 | + input_report_abs(input, ABS_X, 0); |
|---|
| 460 | + input_report_abs(input, ABS_Y, 0); |
|---|
| 461 | + input_report_abs(input, ABS_Z, 0); |
|---|
| 462 | + input_sync(input); |
|---|
| 479 | 463 | return; |
|---|
| 480 | 464 | } |
|---|
| 481 | 465 | |
|---|
| .. | .. |
|---|
| 486 | 470 | /* Note transform, convert to "right/up/out" in the native |
|---|
| 487 | 471 | * landscape orientation (i.e. the vector is the direction of |
|---|
| 488 | 472 | * "real up" in the device's cartiesian coordinates). */ |
|---|
| 489 | | - input_report_abs(ipd->input, ABS_X, -asus->pega_acc_x); |
|---|
| 490 | | - input_report_abs(ipd->input, ABS_Y, -asus->pega_acc_y); |
|---|
| 491 | | - input_report_abs(ipd->input, ABS_Z, asus->pega_acc_z); |
|---|
| 492 | | - input_sync(ipd->input); |
|---|
| 473 | + input_report_abs(input, ABS_X, -asus->pega_acc_x); |
|---|
| 474 | + input_report_abs(input, ABS_Y, -asus->pega_acc_y); |
|---|
| 475 | + input_report_abs(input, ABS_Z, asus->pega_acc_z); |
|---|
| 476 | + input_sync(input); |
|---|
| 493 | 477 | } |
|---|
| 494 | 478 | |
|---|
| 495 | 479 | static void pega_accel_exit(struct asus_laptop *asus) |
|---|
| 496 | 480 | { |
|---|
| 497 | 481 | if (asus->pega_accel_poll) { |
|---|
| 498 | | - input_unregister_polled_device(asus->pega_accel_poll); |
|---|
| 499 | | - input_free_polled_device(asus->pega_accel_poll); |
|---|
| 482 | + input_unregister_device(asus->pega_accel_poll); |
|---|
| 483 | + asus->pega_accel_poll = NULL; |
|---|
| 500 | 484 | } |
|---|
| 501 | | - asus->pega_accel_poll = NULL; |
|---|
| 502 | 485 | } |
|---|
| 503 | 486 | |
|---|
| 504 | 487 | static int pega_accel_init(struct asus_laptop *asus) |
|---|
| 505 | 488 | { |
|---|
| 506 | 489 | int err; |
|---|
| 507 | | - struct input_polled_dev *ipd; |
|---|
| 490 | + struct input_dev *input; |
|---|
| 508 | 491 | |
|---|
| 509 | 492 | if (!asus->is_pega_lucid) |
|---|
| 510 | 493 | return -ENODEV; |
|---|
| .. | .. |
|---|
| 514 | 497 | acpi_check_handle(asus->handle, METHOD_XLRZ, NULL)) |
|---|
| 515 | 498 | return -ENODEV; |
|---|
| 516 | 499 | |
|---|
| 517 | | - ipd = input_allocate_polled_device(); |
|---|
| 518 | | - if (!ipd) |
|---|
| 500 | + input = input_allocate_device(); |
|---|
| 501 | + if (!input) |
|---|
| 519 | 502 | return -ENOMEM; |
|---|
| 520 | 503 | |
|---|
| 521 | | - ipd->poll = pega_accel_poll; |
|---|
| 522 | | - ipd->poll_interval = 125; |
|---|
| 523 | | - ipd->poll_interval_min = 50; |
|---|
| 524 | | - ipd->poll_interval_max = 2000; |
|---|
| 504 | + input->name = PEGA_ACCEL_DESC; |
|---|
| 505 | + input->phys = PEGA_ACCEL_NAME "/input0"; |
|---|
| 506 | + input->dev.parent = &asus->platform_device->dev; |
|---|
| 507 | + input->id.bustype = BUS_HOST; |
|---|
| 525 | 508 | |
|---|
| 526 | | - ipd->input->name = PEGA_ACCEL_DESC; |
|---|
| 527 | | - ipd->input->phys = PEGA_ACCEL_NAME "/input0"; |
|---|
| 528 | | - ipd->input->dev.parent = &asus->platform_device->dev; |
|---|
| 529 | | - ipd->input->id.bustype = BUS_HOST; |
|---|
| 530 | | - |
|---|
| 531 | | - set_bit(EV_ABS, ipd->input->evbit); |
|---|
| 532 | | - input_set_abs_params(ipd->input, ABS_X, |
|---|
| 509 | + input_set_abs_params(input, ABS_X, |
|---|
| 533 | 510 | -PEGA_ACC_CLAMP, PEGA_ACC_CLAMP, 0, 0); |
|---|
| 534 | | - input_set_abs_params(ipd->input, ABS_Y, |
|---|
| 511 | + input_set_abs_params(input, ABS_Y, |
|---|
| 535 | 512 | -PEGA_ACC_CLAMP, PEGA_ACC_CLAMP, 0, 0); |
|---|
| 536 | | - input_set_abs_params(ipd->input, ABS_Z, |
|---|
| 513 | + input_set_abs_params(input, ABS_Z, |
|---|
| 537 | 514 | -PEGA_ACC_CLAMP, PEGA_ACC_CLAMP, 0, 0); |
|---|
| 538 | 515 | |
|---|
| 539 | | - err = input_register_polled_device(ipd); |
|---|
| 516 | + err = input_setup_polling(input, pega_accel_poll); |
|---|
| 540 | 517 | if (err) |
|---|
| 541 | 518 | goto exit; |
|---|
| 542 | 519 | |
|---|
| 543 | | - asus->pega_accel_poll = ipd; |
|---|
| 520 | + input_set_poll_interval(input, 125); |
|---|
| 521 | + input_set_min_poll_interval(input, 50); |
|---|
| 522 | + input_set_max_poll_interval(input, 2000); |
|---|
| 523 | + |
|---|
| 524 | + err = input_register_device(input); |
|---|
| 525 | + if (err) |
|---|
| 526 | + goto exit; |
|---|
| 527 | + |
|---|
| 528 | + asus->pega_accel_poll = input; |
|---|
| 544 | 529 | return 0; |
|---|
| 545 | 530 | |
|---|
| 546 | 531 | exit: |
|---|
| 547 | | - input_free_polled_device(ipd); |
|---|
| 532 | + input_free_device(input); |
|---|
| 548 | 533 | return err; |
|---|
| 549 | 534 | } |
|---|
| 550 | 535 | |
|---|
| .. | .. |
|---|
| 655 | 640 | |
|---|
| 656 | 641 | static void asus_led_exit(struct asus_laptop *asus) |
|---|
| 657 | 642 | { |
|---|
| 658 | | - if (!IS_ERR_OR_NULL(asus->wled.led.dev)) |
|---|
| 659 | | - led_classdev_unregister(&asus->wled.led); |
|---|
| 660 | | - if (!IS_ERR_OR_NULL(asus->bled.led.dev)) |
|---|
| 661 | | - led_classdev_unregister(&asus->bled.led); |
|---|
| 662 | | - if (!IS_ERR_OR_NULL(asus->mled.led.dev)) |
|---|
| 663 | | - led_classdev_unregister(&asus->mled.led); |
|---|
| 664 | | - if (!IS_ERR_OR_NULL(asus->tled.led.dev)) |
|---|
| 665 | | - led_classdev_unregister(&asus->tled.led); |
|---|
| 666 | | - if (!IS_ERR_OR_NULL(asus->pled.led.dev)) |
|---|
| 667 | | - led_classdev_unregister(&asus->pled.led); |
|---|
| 668 | | - if (!IS_ERR_OR_NULL(asus->rled.led.dev)) |
|---|
| 669 | | - led_classdev_unregister(&asus->rled.led); |
|---|
| 670 | | - if (!IS_ERR_OR_NULL(asus->gled.led.dev)) |
|---|
| 671 | | - led_classdev_unregister(&asus->gled.led); |
|---|
| 672 | | - if (!IS_ERR_OR_NULL(asus->kled.led.dev)) |
|---|
| 673 | | - led_classdev_unregister(&asus->kled.led); |
|---|
| 643 | + led_classdev_unregister(&asus->wled.led); |
|---|
| 644 | + led_classdev_unregister(&asus->bled.led); |
|---|
| 645 | + led_classdev_unregister(&asus->mled.led); |
|---|
| 646 | + led_classdev_unregister(&asus->tled.led); |
|---|
| 647 | + led_classdev_unregister(&asus->pled.led); |
|---|
| 648 | + led_classdev_unregister(&asus->rled.led); |
|---|
| 649 | + led_classdev_unregister(&asus->gled.led); |
|---|
| 650 | + led_classdev_unregister(&asus->kled.led); |
|---|
| 651 | + |
|---|
| 674 | 652 | if (asus->led_workqueue) { |
|---|
| 675 | 653 | destroy_workqueue(asus->led_workqueue); |
|---|
| 676 | 654 | asus->led_workqueue = NULL; |
|---|
| .. | .. |
|---|
| 1163 | 1141 | ret = write_acpi_int(asus->handle, METHOD_ALS_CONTROL, value); |
|---|
| 1164 | 1142 | } |
|---|
| 1165 | 1143 | if (ret) |
|---|
| 1166 | | - pr_warning("Error setting light sensor switch\n"); |
|---|
| 1144 | + pr_warn("Error setting light sensor switch\n"); |
|---|
| 1167 | 1145 | |
|---|
| 1168 | 1146 | asus->light_switch = value; |
|---|
| 1169 | 1147 | } |
|---|
| .. | .. |
|---|
| 1565 | 1543 | |
|---|
| 1566 | 1544 | /* Accelerometer "coarse orientation change" event */ |
|---|
| 1567 | 1545 | if (asus->pega_accel_poll && event == 0xEA) { |
|---|
| 1568 | | - kobject_uevent(&asus->pega_accel_poll->input->dev.kobj, |
|---|
| 1569 | | - KOBJ_CHANGE); |
|---|
| 1546 | + kobject_uevent(&asus->pega_accel_poll->dev.kobj, KOBJ_CHANGE); |
|---|
| 1570 | 1547 | return ; |
|---|
| 1571 | 1548 | } |
|---|
| 1572 | 1549 | |
|---|