@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/* sysfs entries for device PM */
#include <linux/device.h>
+#include <linux/kobject.h>
#include <linux/string.h>
#include <linux/export.h>
#include <linux/pm_qos.h>
@@ -739,12 +740,29 @@ int dpm_sysfs_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid)
int wakeup_sysfs_add(struct device *dev)
{
- return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group);
+ int ret = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group);
+
+ if (!ret) {
+ int tmp = kobject_uevent(&dev->kobj, KOBJ_CHANGE);
+
+ if (tmp)
+ dev_err(dev, "Error in uevent for wakeup_sysfs_add: %d",
+ tmp);
+ }
+
+ return ret;
}
void wakeup_sysfs_remove(struct device *dev)
{
+ int tmp;
+
sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
+
+ tmp = kobject_uevent(&dev->kobj, KOBJ_CHANGE);
+ if (tmp)
+ dev_err(dev, "Error in uevent for wakeup_sysfs_remove: %d",
+ tmp);
}
int pm_qos_sysfs_add_resume_latency(struct device *dev)
Udev rules that depend on the power/wakeup attribute don't get triggered correctly if device_set_wakeup_capable is called after the device is created. This can happen for several reasons (driver sets wakeup after device is created, wakeup is changed on parent device, etc) and it seems reasonable to emit a changed event when adding or removing attributes on the device. Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> --- drivers/base/power/sysfs.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)