From: Wolfram Sang <wsa@the-dreams.de>
To: linux-watchdog@vger.kernel.org
Cc: Wolfram Sang <wsa@the-dreams.de>,
linux-renesas-soc@vger.kernel.org,
Guenter Roeck <linux@roeck-us.net>,
Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Subject: [RFC 1/2] watchdog: dev: add helper for creating uevent on dev
Date: Wed, 25 May 2016 15:47:41 +0200 [thread overview]
Message-ID: <1464184062-5230-2-git-send-email-wsa@the-dreams.de> (raw)
In-Reply-To: <1464184062-5230-1-git-send-email-wsa@the-dreams.de>
From: Wolfram Sang <wsa+renesas@sang-engineering.com>
Mechanisms like pretimeout governors may want to notify userspace via
uevents. Add a helper because all the needed data is private to the
watchdog device. To allow calling it in atomic contexts, put actual
signalling to a workqueue.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/watchdog/watchdog_dev.c | 20 ++++++++++++++++++++
include/linux/watchdog.h | 3 +++
2 files changed, 23 insertions(+)
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index 9e2e668e1c6b2d..2a7d04034641dc 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -63,6 +63,7 @@ struct watchdog_core_data {
struct kref kref;
struct cdev cdev;
struct watchdog_device *wdd;
+ struct device *dev;
struct mutex lock;
unsigned long last_keepalive;
unsigned long last_hw_keepalive;
@@ -70,6 +71,7 @@ struct watchdog_core_data {
unsigned long status; /* Internal status bits */
#define _WDOG_DEV_OPEN 0 /* Opened ? */
#define _WDOG_ALLOW_RELEASE 1 /* Did we receive the magic char ? */
+ struct work_struct uevent_work;
};
/* the dev_t structure to store the dynamically allocated watchdog devices */
@@ -821,6 +823,21 @@ static struct miscdevice watchdog_miscdev = {
.fops = &watchdog_fops,
};
+void watchdog_dev_uevent(struct watchdog_device *wdd)
+{
+ queue_work(watchdog_wq, &wdd->wd_data->uevent_work);
+}
+
+static void watchdog_dev_uevent_work(struct work_struct *work)
+{
+ struct watchdog_core_data *wd_data = container_of(work, struct watchdog_core_data,
+ uevent_work);
+
+ mutex_lock(&wd_data->lock);
+ kobject_uevent(&wd_data->dev->kobj, KOBJ_CHANGE);
+ mutex_unlock(&wd_data->lock);
+}
+
/*
* watchdog_cdev_register: register watchdog character device
* @wdd: watchdog device
@@ -849,6 +866,7 @@ static int watchdog_cdev_register(struct watchdog_device *wdd, dev_t devno)
return -ENODEV;
INIT_DELAYED_WORK(&wd_data->work, watchdog_ping_work);
+ INIT_WORK(&wd_data->uevent_work, watchdog_dev_uevent_work);
if (wdd->id == 0) {
old_wd_data = wd_data;
@@ -968,6 +986,8 @@ int watchdog_dev_register(struct watchdog_device *wdd)
watchdog_cdev_unregister(wdd);
}
+ wdd->wd_data->dev = dev;
+
return ret;
}
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
index 496e52e5b91fc7..f0f77f06d9813b 100644
--- a/include/linux/watchdog.h
+++ b/include/linux/watchdog.h
@@ -194,6 +194,9 @@ extern int watchdog_init_timeout(struct watchdog_device *wdd,
extern int watchdog_register_device(struct watchdog_device *);
extern void watchdog_unregister_device(struct watchdog_device *);
+/* drivers/watchdog/watchdog_dev.c */
+void watchdog_dev_uevent(struct watchdog_device *wdd);
+
/* drivers/watchdog/watchdog_pretimeout.c */
#ifdef CONFIG_WATCHDOG_PRETIMEOUT_GOV
void watchdog_notify_pretimeout(struct watchdog_device *wdd);
--
2.8.1
next prev parent reply other threads:[~2016-05-25 13:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-25 13:47 [RFC 0/2] watchdog: pretimeout: userspace governor Wolfram Sang
2016-05-25 13:47 ` Wolfram Sang [this message]
2016-05-25 13:47 ` [RFC 2/2] watchdog: pretimeout: add userspace notifier pretimeout governor Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1464184062-5230-2-git-send-email-wsa@the-dreams.de \
--to=wsa@the-dreams.de \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=vladimir_zapolskiy@mentor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).