]> git.baikalelectronics.ru Git - kernel.git/commit
PM / wakeup: Register wakeup class kobj after device is added
authorStephen Boyd <swboyd@chromium.org>
Mon, 19 Aug 2019 22:41:57 +0000 (15:41 -0700)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 20 Aug 2019 22:25:16 +0000 (00:25 +0200)
commit169380a2bbba4da6ef56350987244716e7f8fe9d
tree89b3ae2a339df6e794c3f7efef474a3e089e8185
parente9dfbaf3b9c7a67c5ce68ac5d11c56449c84d2e0
PM / wakeup: Register wakeup class kobj after device is added

The device_set_wakeup_enable() function can be called on a device that
hasn't been registered with device_add() yet. This allows the device to
be in a state where wakeup is enabled for it but the device isn't
published to userspace in sysfs yet.

After commit d0a5011f212d ("PM / wakeup: Show wakeup sources stats in
sysfs"), calling device_set_wakeup_enable() will fail for a device that
hasn't been registered with the driver core via device_add(). This is
because we try to create sysfs entries for the device and associate a
wakeup class kobject with it before the device has been registered.
Let's follow a similar approach that device_set_wakeup_capable() takes
here and register the wakeup class either from
device_set_wakeup_enable() when the device is already registered, or
from dpm_sysfs_add() when the device is being registered with the driver
core via device_add().

Fixes: d0a5011f212d ("PM / wakeup: Show wakeup sources stats in sysfs")
Reported-by: Qian Cai <cai@lca.pw>
Reviewed-by: Tri Vo <trong@android.com>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/base/power/power.h
drivers/base/power/sysfs.c
drivers/base/power/wakeup.c
drivers/base/power/wakeup_stats.c