From: Calvin Owens <calvinowens@fb.com>
To: Petr Mladek <pmladek@suse.com>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jonathan Corbet <corbet@lwn.net>
Cc: <linux-kernel@vger.kernel.org>, <linux-serial@vger.kernel.org>,
Calvin Owens <calvinowens@fb.com>
Subject: [PATCH 4/4] printk: Add a device attribute for the per-console loglevel
Date: Fri, 1 Mar 2019 16:48:20 -0800 [thread overview]
Message-ID: <4f71564063a07837e3c4df41326bad25e7dc4db4.1551486733.git.calvinowens@fb.com> (raw)
In-Reply-To: <cover.1551486732.git.calvinowens@fb.com>
Signed-off-by: Calvin Owens <calvinowens@fb.com>
---
kernel/printk/printk.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 67e1e993ab80..e7e602fa2d0b 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2560,8 +2560,48 @@ static int __init keep_bootcon_setup(char *str)
early_param("keep_bootcon", keep_bootcon_setup);
+static ssize_t loglevel_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct console *con = container_of(dev, struct console, dev);
+ return sprintf(buf, "%d\n", con->level);
+}
+
+static ssize_t loglevel_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct console *con = container_of(dev, struct console, dev);
+ ssize_t ret;
+ int tmp;
+
+ ret = kstrtoint(buf, 10, &tmp);
+ if (ret < 0)
+ return ret;
+
+ if (tmp < LOGLEVEL_EMERG)
+ return -ERANGE;
+
+ /*
+ * Mimic the behavior of /dev/kmsg with respect to minimum_loglevel.
+ */
+ if (tmp < minimum_console_loglevel)
+ tmp = minimum_console_loglevel;
+
+ con->level = tmp;
+ return ret;
+}
+
+static DEVICE_ATTR_RW(loglevel);
+
+static struct attribute *console_sysfs_attrs[] = {
+ &dev_attr_loglevel.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(console_sysfs);
+
static struct bus_type console_subsys = {
.name = "console",
+ .dev_groups = console_sysfs_groups,
};
static void console_release(struct device *dev)
--
2.17.1
next prev parent reply other threads:[~2019-03-02 0:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-02 0:48 [RFC][PATCH 0/4] Per-console loglevel support, console device bus Calvin Owens
2019-03-02 0:48 ` [PATCH 1/4] printk: Introduce per-console loglevel setting Calvin Owens
2019-03-08 3:10 ` Sergey Senozhatsky
2019-03-12 21:00 ` Calvin Owens
2019-03-08 15:09 ` Petr Mladek
2019-03-14 14:12 ` Tetsuo Handa
2019-03-20 15:37 ` Petr Mladek
2019-03-02 0:48 ` [PATCH 2/4] printk: Add ability to set loglevel via "console=" cmdline Calvin Owens
2019-03-08 15:44 ` Petr Mladek
2019-03-02 0:48 ` [PATCH 3/4] printk: Add consoles to a virtual "console" bus Calvin Owens
2019-03-08 2:56 ` John Ogness
2019-03-08 15:58 ` Petr Mladek
2019-03-08 16:34 ` Greg Kroah-Hartman
2019-03-12 20:44 ` Calvin Owens
2019-03-08 15:53 ` Petr Mladek
2019-03-12 20:52 ` Calvin Owens
2019-03-11 13:33 ` Petr Mladek
2019-03-12 21:52 ` Calvin Owens
2019-03-13 10:08 ` Petr Mladek
2019-03-02 0:48 ` Calvin Owens [this message]
2019-03-04 8:06 ` [PATCH 4/4] printk: Add a device attribute for the per-console loglevel Sergey Senozhatsky
2019-03-04 19:10 ` Calvin Owens
2019-03-08 3:11 ` Sergey Senozhatsky
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=4f71564063a07837e3c4df41326bad25e7dc4db4.1551486733.git.calvinowens@fb.com \
--to=calvinowens@fb.com \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.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).