OSDN Git Service

PM / wakeup: Do not fail dev_pm_attach_wake_irq() unnecessarily
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 5 Jan 2018 01:18:42 +0000 (02:18 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 9 Jan 2018 12:09:16 +0000 (13:09 +0100)
commit7bf4e594c28afc67bc120a380ca774e43ca496d8
tree8f8620cca96c6a29eb8c3a1f7c31e350f8e96ae8
parent32bfa56ac158c1ebcc82df2518860f824be5e5be
PM / wakeup: Do not fail dev_pm_attach_wake_irq() unnecessarily

Returning an error code from dev_pm_attach_wake_irq() if
device_wakeup_attach_irq() called by it returns an error is
pointless, because the wakeup source used by it may be deleted
by user space via sysfs at any time and in particular right after
dev_pm_attach_wake_irq() has returned.  Moreover, it requires
the callers of dev_pm_attach_wake_irq() to create that wakeup
source via device_wakeup_enable() upfront, but that obviously is
racy with respect to the sysfs-based manipulations of it.

To avoid the race, modify device_wakeup_attach_irq() to check
that the wakeup source it is going to use is there (and return
early otherwise), make it void (as it cannot fail after that
change) and make dev_pm_attach_wake_irq() simply call it for
the device unconditionally.

Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/power.h
drivers/base/power/wakeirq.c
drivers/base/power/wakeup.c