hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/input/serio/i8042.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * i8042 keyboard and mouse controller driver for Linux
34 *
45 * Copyright (c) 1999-2004 Vojtech Pavlik
56 */
67
7
-/*
8
- * This program is free software; you can redistribute it and/or modify it
9
- * under the terms of the GNU General Public License version 2 as published by
10
- * the Free Software Foundation.
11
- */
128
139 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1410
....@@ -25,6 +21,7 @@
2521 #include <linux/i8042.h>
2622 #include <linux/slab.h>
2723 #include <linux/suspend.h>
24
+#include <linux/property.h>
2825
2926 #include <asm/io.h>
3027
....@@ -133,6 +130,7 @@
133130 static bool i8042_bypass_aux_irq_test;
134131 static char i8042_kbd_firmware_id[128];
135132 static char i8042_aux_firmware_id[128];
133
+static struct fwnode_handle *i8042_kbd_fwnode;
136134
137135 #include "i8042.h"
138136
....@@ -444,6 +442,20 @@
444442 {
445443 struct i8042_port *port = serio->port_data;
446444
445
+ device_set_wakeup_capable(&serio->dev, true);
446
+
447
+ /*
448
+ * On platforms using suspend-to-idle, allow the keyboard to
449
+ * wake up the system from sleep by enabling keyboard wakeups
450
+ * by default. This is consistent with keyboard wakeup
451
+ * behavior on many platforms using suspend-to-RAM (ACPI S3)
452
+ * by default.
453
+ */
454
+ if (pm_suspend_default_s2idle() &&
455
+ serio == i8042_ports[I8042_KBD_PORT_NO].serio) {
456
+ device_set_wakeup_enable(&serio->dev, true);
457
+ }
458
+
447459 spin_lock_irq(&i8042_lock);
448460 port->exists = true;
449461 spin_unlock_irq(&i8042_lock);
....@@ -558,7 +570,7 @@
558570 str = last_str;
559571 break;
560572 }
561
- /* fall through - report timeout */
573
+ fallthrough; /* report timeout */
562574 case 0xfc:
563575 case 0xfd:
564576 case 0xfe: dfl = SERIO_TIMEOUT; data = 0xfe; break;
....@@ -580,9 +592,6 @@
580592
581593 port = &i8042_ports[port_no];
582594 serio = port->exists ? port->serio : NULL;
583
-
584
- if (irq && serio)
585
- pm_wakeup_event(&serio->dev, 0);
586595
587596 filter_dbg(port->driver_bound, data, "<- i8042 (interrupt, %d, %d%s%s)\n",
588597 port_no, irq,
....@@ -1336,6 +1345,7 @@
13361345 strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys));
13371346 strlcpy(serio->firmware_id, i8042_kbd_firmware_id,
13381347 sizeof(serio->firmware_id));
1348
+ set_primary_fwnode(&serio->dev, i8042_kbd_fwnode);
13391349
13401350 port->serio = serio;
13411351 port->irq = I8042_KBD_IRQ;
....@@ -1412,17 +1422,6 @@
14121422 (unsigned long) I8042_COMMAND_REG,
14131423 i8042_ports[i].irq);
14141424 serio_register_port(serio);
1415
- device_set_wakeup_capable(&serio->dev, true);
1416
-
1417
- /*
1418
- * On platforms using suspend-to-idle, allow the keyboard to
1419
- * wake up the system from sleep by enabling keyboard wakeups
1420
- * by default. This is consistent with keyboard wakeup
1421
- * behavior on many platforms using suspend-to-RAM (ACPI S3)
1422
- * by default.
1423
- */
1424
- if (pm_suspend_via_s2idle() && i == I8042_KBD_PORT_NO)
1425
- device_set_wakeup_enable(&serio->dev, true);
14261425 }
14271426 }
14281427
....@@ -1544,8 +1543,6 @@
15441543 {
15451544 int error;
15461545
1547
- i8042_platform_device = dev;
1548
-
15491546 if (i8042_reset == I8042_RESET_ALWAYS) {
15501547 error = i8042_controller_selftest();
15511548 if (error)
....@@ -1583,7 +1580,6 @@
15831580 i8042_free_aux_ports(); /* in case KBD failed but AUX not */
15841581 i8042_free_irqs();
15851582 i8042_controller_reset(false);
1586
- i8042_platform_device = NULL;
15871583
15881584 return error;
15891585 }
....@@ -1593,7 +1589,6 @@
15931589 i8042_unregister_ports();
15941590 i8042_free_irqs();
15951591 i8042_controller_reset(false);
1596
- i8042_platform_device = NULL;
15971592
15981593 return 0;
15991594 }