On Mon, Aug 19, 2019 at 10:55 AM Stephen Boyd <[email protected]> wrote: > > 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 986845e747af ("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: 986845e747af ("PM / wakeup: Show wakeup sources stats in sysfs") > Reported-by: Qian Cai <[email protected]> > Cc: Qian Cai <[email protected]> > Cc: Tri Vo <[email protected]> > Signed-off-by: Stephen Boyd <[email protected]>
Reviewed-by: Tri Vo <[email protected]>

