[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190724174355.255314-2-ravisadineni@chromium.org>
Date: Wed, 24 Jul 2019 10:43:54 -0700
From: Ravi Chandra Sadineni <ravisadineni@...omium.org>
To: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, hpa@...or.com,
x86@...nel.org, rjw@...ysocki.net, pavel@....cz,
len.brown@...el.com, gregkh@...uxfoundation.org,
ravisadineni@...omium.org, bhe@...hat.com, dyoung@...hat.com,
linux-kernel@...r.kernel.org, linux-pm@...r.kernel.org,
tbroch@...omium.org, trong@...gle.com
Subject: [PATCH 1/2] power: sysfs: Add link to wakeup class device.
https://patchwork.kernel.org/patch/11045069/ creates a virtual device
under wakeup class for each wake capable device exposing all related
sysfs attributes. But there isn't a symlink from the actual device
node to these virtual devices. This patch creates a symlink from the
actual device to the corresponding wakeup_source device under wakeup
class.
Signed-off-by: Ravi Chandra Sadineni <ravisadineni@...omium.org>
---
drivers/base/power/power.h | 2 ++
drivers/base/power/sysfs.c | 25 +++++++++++++++++++++++++
drivers/base/power/wakeup.c | 2 ++
3 files changed, 29 insertions(+)
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index c511def48b48..32b0f5c080a9 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -67,6 +67,8 @@ extern void dpm_sysfs_remove(struct device *dev);
extern void rpm_sysfs_remove(struct device *dev);
extern int wakeup_sysfs_add(struct device *dev);
extern void wakeup_sysfs_remove(struct device *dev);
+extern void wakeup_source_sysfs_link_add(struct device *dev);
+extern void wakeup_source_sysfs_link_remove(struct device *dev);
extern int pm_qos_sysfs_add_resume_latency(struct device *dev);
extern void pm_qos_sysfs_remove_resume_latency(struct device *dev);
extern int pm_qos_sysfs_add_flags(struct device *dev);
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index d713738ce796..fbbdb7b16ac5 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -95,6 +95,7 @@
const char power_group_name[] = "power";
EXPORT_SYMBOL_GPL(power_group_name);
+static const char wakeup_source_symlink_name[] = "wakeup_source";
static const char ctrl_auto[] = "auto";
static const char ctrl_on[] = "on";
@@ -679,6 +680,30 @@ int dpm_sysfs_add(struct device *dev)
return rc;
}
+void wakeup_source_sysfs_link_add(struct device *dev)
+{
+ struct wakeup_source *ws;
+ int err;
+
+ ws = dev->power.wakeup;
+ if (ws && ws->dev) {
+ err = sysfs_add_link_to_group(&dev->kobj, power_group_name,
+ &ws->dev->kobj, wakeup_source_symlink_name);
+ if (err) {
+ dev_err(dev,
+ "could not add %s symlink err %d\n",
+ wakeup_source_symlink_name,
+ err);
+ }
+ }
+}
+
+void wakeup_source_sysfs_link_remove(struct device *dev)
+{
+ sysfs_remove_link_from_group(&dev->kobj, power_group_name,
+ wakeup_source_symlink_name);
+}
+
int wakeup_sysfs_add(struct device *dev)
{
return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group);
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index fe779fe13a7f..87dfe401b035 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -270,6 +270,7 @@ static int device_wakeup_attach(struct device *dev, struct wakeup_source *ws)
if (dev->power.wakeirq)
device_wakeup_attach_irq(dev, dev->power.wakeirq);
spin_unlock_irq(&dev->power.lock);
+ wakeup_source_sysfs_link_add(dev);
return 0;
}
@@ -391,6 +392,7 @@ static struct wakeup_source *device_wakeup_detach(struct device *dev)
ws = dev->power.wakeup;
dev->power.wakeup = NULL;
spin_unlock_irq(&dev->power.lock);
+ wakeup_source_sysfs_link_remove(dev);
return ws;
}
--
2.20.1
Powered by blists - more mailing lists