提交 c8a144b2 编写于 作者: S Stephen Boyd 提交者: Dmitry Torokhov

Input: i8042 - enable wakeup on a stable struct device

We don't know when the device will be added with device_add() in
serio_add_port() because serio_add_port() is called from a workqueue
that this driver schedules by calling serio_register_port(). The best we
can know is that the device will definitely not have been added yet when
the start callback is called on the serio device.

While it hasn't been shown to be a problem, proactively move the wakeup
enabling calls to the start hook so that we don't race with the
workqueue calling device_add(). This will avoid racy situations where
code tries to add wakeup sysfs attributes for this device from
dpm_sysfs_add() but the path in device_set_wakeup_capable() has already
done so.
Signed-off-by: NStephen Boyd <swboyd@chromium.org>
Signed-off-by: NDmitry Torokhov <dmitry.torokhov@gmail.com>
上级 53119e51
......@@ -432,6 +432,20 @@ static int i8042_start(struct serio *serio)
{
struct i8042_port *port = serio->port_data;
device_set_wakeup_capable(&serio->dev, true);
/*
* On platforms using suspend-to-idle, allow the keyboard to
* wake up the system from sleep by enabling keyboard wakeups
* by default. This is consistent with keyboard wakeup
* behavior on many platforms using suspend-to-RAM (ACPI S3)
* by default.
*/
if (pm_suspend_default_s2idle() &&
serio == i8042_ports[I8042_KBD_PORT_NO].serio) {
device_set_wakeup_enable(&serio->dev, true);
}
spin_lock_irq(&i8042_lock);
port->exists = true;
spin_unlock_irq(&i8042_lock);
......@@ -1397,17 +1411,6 @@ static void __init i8042_register_ports(void)
(unsigned long) I8042_COMMAND_REG,
i8042_ports[i].irq);
serio_register_port(serio);
device_set_wakeup_capable(&serio->dev, true);
/*
* On platforms using suspend-to-idle, allow the keyboard to
* wake up the system from sleep by enabling keyboard wakeups
* by default. This is consistent with keyboard wakeup
* behavior on many platforms using suspend-to-RAM (ACPI S3)
* by default.
*/
if (pm_suspend_default_s2idle() && i == I8042_KBD_PORT_NO)
device_set_wakeup_enable(&serio->dev, true);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册