From: minyard@acm.org
To: Guenter Roeck <linux@roeck-us.net>,
Wim Van Sebroeck <wim@linux-watchdog.org>
Cc: linux-watchdog@vger.kernel.org,
Gabriele Paoloni <gabriele.paoloni@intel.com>,
Corey Minyard <cminyard@mvista.com>
Subject: [PATCH 3/6] watchdog: Add millisecond precision device attributes
Date: Sat, 20 Jun 2020 12:33:48 -0500 [thread overview]
Message-ID: <20200620173351.18752-4-minyard@acm.org> (raw)
In-Reply-To: <20200620173351.18752-1-minyard@acm.org>
From: Corey Minyard <cminyard@mvista.com>
Add timeleft_ms, timeout_ms, and pretimeout_ms that print microsecond
values.
Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
drivers/watchdog/watchdog_dev.c | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index eca13ce1dc91..b82049896204 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -562,6 +562,21 @@ static ssize_t bootstatus_show(struct device *dev,
}
static DEVICE_ATTR_RO(bootstatus);
+/*
+ * If _ms is in the attribute name, return milliseconds, otherwise
+ * return seconds.
+ */
+static unsigned int conv_time_to_attr_display(struct watchdog_device *wdd,
+ struct device_attribute *attr,
+ unsigned int val)
+{
+ bool in_msec = false;
+
+ if (strstr(attr->attr.name, "_ms"))
+ in_msec = true;
+ return watchdog_timeout_toexternal(wdd, in_msec, val);
+}
+
static ssize_t timeleft_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
@@ -575,11 +590,12 @@ static ssize_t timeleft_show(struct device *dev, struct device_attribute *attr,
mutex_unlock(&wd_data->lock);
if (!status)
status = sprintf(buf, "%u\n",
- watchdog_timeout_toexternal(wdd, false, val));
+ conv_time_to_attr_display(wdd, attr, val));
return status;
}
static DEVICE_ATTR_RO(timeleft);
+static DEVICE_ATTR(timeleft_ms, 0444, timeleft_show, NULL);
static ssize_t timeout_show(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -587,9 +603,10 @@ static ssize_t timeout_show(struct device *dev, struct device_attribute *attr,
struct watchdog_device *wdd = dev_get_drvdata(dev);
return sprintf(buf, "%u\n",
- watchdog_timeout_toexternal(wdd, false, wdd->timeout));
+ conv_time_to_attr_display(wdd, attr, wdd->timeout));
}
static DEVICE_ATTR_RO(timeout);
+static DEVICE_ATTR(timeout_ms, 0444, timeout_show, NULL);
static ssize_t pretimeout_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -597,10 +614,10 @@ static ssize_t pretimeout_show(struct device *dev,
struct watchdog_device *wdd = dev_get_drvdata(dev);
return sprintf(buf, "%u\n",
- watchdog_timeout_toexternal(wdd, false,
- wdd->pretimeout));
+ conv_time_to_attr_display(wdd, attr, wdd->pretimeout));
}
static DEVICE_ATTR_RO(pretimeout);
+static DEVICE_ATTR(pretimeout_ms, 0444, pretimeout_show, NULL);
static ssize_t identity_show(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -677,8 +694,11 @@ static struct attribute *wdt_attrs[] = {
&dev_attr_state.attr,
&dev_attr_identity.attr,
&dev_attr_timeout.attr,
+ &dev_attr_timeout_ms.attr,
&dev_attr_pretimeout.attr,
+ &dev_attr_pretimeout_ms.attr,
&dev_attr_timeleft.attr,
+ &dev_attr_timeleft_ms.attr,
&dev_attr_bootstatus.attr,
&dev_attr_status.attr,
&dev_attr_nowayout.attr,
--
2.17.1
next prev parent reply other threads:[~2020-06-20 17:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-20 17:33 [PATCH 0/6] watchdog: Add millisecond-level capabilities minyard
2020-06-20 17:33 ` [PATCH 1/6] watchdog: Allow a driver to use milliseconds instead of seconds minyard
2020-06-26 23:10 ` Guenter Roeck
2020-06-27 2:18 ` Corey Minyard
2020-06-27 4:08 ` Guenter Roeck
2020-06-28 14:54 ` Guenter Roeck
2020-06-28 17:56 ` Corey Minyard
2020-12-01 22:54 ` Corey Minyard
2020-12-01 23:43 ` Guenter Roeck
2020-06-20 17:33 ` [PATCH 2/6] watchdog: Add ioctls for millisecond timeout handling minyard
2020-06-20 17:33 ` minyard [this message]
2020-06-20 17:33 ` [PATCH 4/6] watchdog: Add documentation for millisecond interfaces minyard
2020-06-20 17:33 ` [PATCH 5/6] watchdog:i6300: Convert to a millisecond watchdog device minyard
2020-06-20 17:33 ` [PATCH 6/6] watchdog:softdog: Convert to a millisecond watchdog minyard
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=20200620173351.18752-4-minyard@acm.org \
--to=minyard@acm.org \
--cc=cminyard@mvista.com \
--cc=gabriele.paoloni@intel.com \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=wim@linux-watchdog.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.