hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/platform/x86/asus-laptop.c
....@@ -1,25 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * asus-laptop.c - Asus Laptop Support
3
- *
44 *
55 * Copyright (C) 2002-2005 Julien Lerouge, 2003-2006 Karol Kozimor
66 * Copyright (C) 2006-2007 Corentin Chary
77 * 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
- *
238 *
249 * The development page for this driver is located at
2510 * http://sourceforge.net/projects/acpi4asus/
....@@ -49,7 +34,6 @@
4934 #include <linux/uaccess.h>
5035 #include <linux/input.h>
5136 #include <linux/input/sparse-keymap.h>
52
-#include <linux/input-polldev.h>
5337 #include <linux/rfkill.h>
5438 #include <linux/slab.h>
5539 #include <linux/dmi.h>
....@@ -259,7 +243,7 @@
259243
260244 struct input_dev *inputdev;
261245 struct key_entry *keymap;
262
- struct input_polled_dev *pega_accel_poll;
246
+ struct input_dev *pega_accel_poll;
263247
264248 struct asus_led wled;
265249 struct asus_led bled;
....@@ -461,9 +445,9 @@
461445 return clamp_val((short)val, -PEGA_ACC_CLAMP, PEGA_ACC_CLAMP);
462446 }
463447
464
-static void pega_accel_poll(struct input_polled_dev *ipd)
448
+static void pega_accel_poll(struct input_dev *input)
465449 {
466
- struct device *parent = ipd->input->dev.parent;
450
+ struct device *parent = input->dev.parent;
467451 struct asus_laptop *asus = dev_get_drvdata(parent);
468452
469453 /* In some cases, the very first call to poll causes a
....@@ -472,10 +456,10 @@
472456 * device, and perhaps a firmware bug. Fake the first report. */
473457 if (!asus->pega_acc_live) {
474458 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);
479463 return;
480464 }
481465
....@@ -486,25 +470,24 @@
486470 /* Note transform, convert to "right/up/out" in the native
487471 * landscape orientation (i.e. the vector is the direction of
488472 * "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);
493477 }
494478
495479 static void pega_accel_exit(struct asus_laptop *asus)
496480 {
497481 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;
500484 }
501
- asus->pega_accel_poll = NULL;
502485 }
503486
504487 static int pega_accel_init(struct asus_laptop *asus)
505488 {
506489 int err;
507
- struct input_polled_dev *ipd;
490
+ struct input_dev *input;
508491
509492 if (!asus->is_pega_lucid)
510493 return -ENODEV;
....@@ -514,37 +497,39 @@
514497 acpi_check_handle(asus->handle, METHOD_XLRZ, NULL))
515498 return -ENODEV;
516499
517
- ipd = input_allocate_polled_device();
518
- if (!ipd)
500
+ input = input_allocate_device();
501
+ if (!input)
519502 return -ENOMEM;
520503
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;
525508
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,
533510 -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,
535512 -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,
537514 -PEGA_ACC_CLAMP, PEGA_ACC_CLAMP, 0, 0);
538515
539
- err = input_register_polled_device(ipd);
516
+ err = input_setup_polling(input, pega_accel_poll);
540517 if (err)
541518 goto exit;
542519
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;
544529 return 0;
545530
546531 exit:
547
- input_free_polled_device(ipd);
532
+ input_free_device(input);
548533 return err;
549534 }
550535
....@@ -655,22 +640,15 @@
655640
656641 static void asus_led_exit(struct asus_laptop *asus)
657642 {
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
+
674652 if (asus->led_workqueue) {
675653 destroy_workqueue(asus->led_workqueue);
676654 asus->led_workqueue = NULL;
....@@ -1163,7 +1141,7 @@
11631141 ret = write_acpi_int(asus->handle, METHOD_ALS_CONTROL, value);
11641142 }
11651143 if (ret)
1166
- pr_warning("Error setting light sensor switch\n");
1144
+ pr_warn("Error setting light sensor switch\n");
11671145
11681146 asus->light_switch = value;
11691147 }
....@@ -1565,8 +1543,7 @@
15651543
15661544 /* Accelerometer "coarse orientation change" event */
15671545 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);
15701547 return ;
15711548 }
15721549