Merge tag 'vfio-v4.4-rc1' of git://github.com/awilliam/linux-vfio
[linux-2.6-block.git] / kernel / printk / printk.c
index 8f0324ef72ab374925badb5454aa0a79ae731c61..2ce8826f1053d801f0b003f5a3e67de0fdfe8e30 100644 (file)
@@ -269,6 +269,9 @@ static u32 clear_idx;
 #define PREFIX_MAX             32
 #define LOG_LINE_MAX           (1024 - PREFIX_MAX)
 
+#define LOG_LEVEL(v)           ((v) & 0x07)
+#define LOG_FACILITY(v)                ((v) >> 3 & 0xff)
+
 /* record buffer */
 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
 #define LOG_ALIGN 4
@@ -517,6 +520,7 @@ int check_syslog_permissions(int type, int source)
 ok:
        return security_syslog(type);
 }
+EXPORT_SYMBOL_GPL(check_syslog_permissions);
 
 static void append_char(char **pp, char *e, char c)
 {
@@ -611,7 +615,6 @@ struct devkmsg_user {
 static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
 {
        char *buf, *line;
-       int i;
        int level = default_message_loglevel;
        int facility = 1;       /* LOG_USER */
        size_t len = iov_iter_count(from);
@@ -641,12 +644,13 @@ static ssize_t devkmsg_write(struct kiocb *iocb, struct iov_iter *from)
        line = buf;
        if (line[0] == '<') {
                char *endp = NULL;
+               unsigned int u;
 
-               i = simple_strtoul(line+1, &endp, 10);
+               u = simple_strtoul(line + 1, &endp, 10);
                if (endp && endp[0] == '>') {
-                       level = i & 7;
-                       if (i >> 3)
-                               facility = i >> 3;
+                       level = LOG_LEVEL(u);
+                       if (LOG_FACILITY(u) != 0)
+                               facility = LOG_FACILITY(u);
                        endp++;
                        len -= endp - line;
                        line = endp;