Revert "kmsg: add additional buffers support to memory class"
authorMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 25 Apr 2018 09:54:22 +0000 (11:54 +0200)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Wed, 25 Apr 2018 09:54:22 +0000 (11:54 +0200)
This reverts commit 62bbd37627b8fa194ae668b352d40c090d9cc6e0.

drivers/char/mem.c
include/linux/printk.h
kernel/printk/printk.c

index 7d462343a4b0282d30cbb4b5ea3753e72121ecb3..6b1721f978c2945f4af716636c8373fe8807dca0 100644 (file)
@@ -799,6 +799,9 @@ static const struct memdev {
         [7] = { "full", 0666, &full_fops, 0 },
         [8] = { "random", 0666, &random_fops, 0 },
         [9] = { "urandom", 0666, &urandom_fops, 0 },
+#ifdef CONFIG_PRINTK
+       [11] = { "kmsg", 0644, &kmsg_fops, 0 },
+#endif
 };
 
 static int memory_open(struct inode *inode, struct file *filp)
@@ -808,7 +811,7 @@ static int memory_open(struct inode *inode, struct file *filp)
 
        minor = iminor(inode);
        if (minor >= ARRAY_SIZE(devlist))
-               return kmsg_memory_open(inode, filp);
+               return -ENXIO;
 
        dev = &devlist[minor];
        if (!dev->fops)
@@ -830,28 +833,16 @@ static const struct file_operations memory_fops = {
 
 static char *mem_devnode(struct device *dev, umode_t *mode)
 {
-       int minor = MINOR(dev->devt);
-
-       if (!mode)
-               goto out;
-
-       if (minor >= ARRAY_SIZE(devlist)) {
-               kmsg_mode(minor, mode);
-               goto out;
-       }
-
-       if (devlist[minor].mode)
-               *mode = devlist[minor].mode;
-out:
+       if (mode && devlist[MINOR(dev->devt)].mode)
+               *mode = devlist[MINOR(dev->devt)].mode;
        return NULL;
 }
 
-struct class *mem_class;
+static struct class *mem_class;
 
 static int __init chr_dev_init(void)
 {
        int minor;
-       struct device *kmsg;
 
        if (register_chrdev(MEM_MAJOR, "mem", &memory_fops))
                printk("unable to get major %d for memory devs\n", MEM_MAJOR);
@@ -875,10 +866,6 @@ static int __init chr_dev_init(void)
                              NULL, devlist[minor].name);
        }
 
-       kmsg = init_kmsg(KMSG_MINOR, 0644);
-       if (IS_ERR(kmsg))
-               return PTR_ERR(kmsg);
-
        return tty_init();
 }
 
index 4147304f394b4f52cfc95e77c47709c872c2f7ef..58b1fec40d37373001a6d46840702d33e70f1001 100644 (file)
@@ -417,40 +417,8 @@ do {                                                                       \
        no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
 #endif
 
-struct file;
-struct inode;
-
-#ifdef CONFIG_PRINTK
-
-extern struct class *mem_class;
-
-#define KMSG_MINOR     11
-
 extern const struct file_operations kmsg_fops;
 
-extern struct device *init_kmsg(int minor, umode_t mode);
-extern int kmsg_memory_open(struct inode *inode, struct file *filp);
-extern int kmsg_mode(int minor, umode_t *mode);
-
-#else
-
-static inline struct device *init_kmsg(int minor, umode_t mode)
-{
-       return NULL;
-}
-
-static inline int kmsg_memory_open(struct inode *inode, struct file *filp)
-{
-       return -ENXIO;
-}
-
-static inline int kmsg_mode(int minor, umode_t *mode)
-{
-       return -ENXIO;
-}
-
-#endif
-
 enum {
        DUMP_PREFIX_NONE,
        DUMP_PREFIX_ADDRESS,
index 94ae006569fb7b7d90a8e7dd4caca3d7af7b0ed9..ab82f563a0ea96ed9b6bf860e00557b3246782b9 100644 (file)
@@ -46,8 +46,6 @@
 #include <linux/utsname.h>
 #include <linux/ctype.h>
 #include <linux/uio.h>
-#include <linux/device.h>
-#include <linux/kdev_t.h>
 
 #include <asm/uaccess.h>
 
@@ -243,7 +241,6 @@ struct log_buffer {
        u64 next_seq;
 #ifdef CONFIG_PRINTK
        u32 next_idx;           /* index of the next record to store */
-       int mode;               /* mode of device */
        int minor;              /* minor representing buffer device */
 #endif
 };
@@ -286,7 +283,6 @@ static struct log_buffer log_buf = {
        .first_idx      = 0,
        .next_seq       = 0,
        .next_idx       = 0,
-       .mode           = 0,
        .minor          = 0,
 };
 
@@ -1190,45 +1186,6 @@ const struct file_operations kmsg_fops = {
        .release = devkmsg_release,
 };
 
-/* Should be used for device registration */
-struct device *init_kmsg(int minor, umode_t mode)
-{
-       log_buf.minor = minor;
-       log_buf.mode = mode;
-       return device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
-                       NULL, "kmsg");
-}
-
-int kmsg_memory_open(struct inode *inode, struct file *filp)
-{
-       filp->f_op = &kmsg_fops;
-
-       return kmsg_fops.open(inode, filp);
-}
-
-int kmsg_mode(int minor, umode_t *mode)
-{
-       int ret = -ENXIO;
-       struct log_buffer *log_b;
-
-       if (minor == log_buf.minor) {
-               *mode = log_buf.mode;
-               return 0;
-       }
-
-       rcu_read_lock();
-       list_for_each_entry_rcu(log_b, &log_buf.list, list) {
-               if (log_b->minor == minor) {
-                       *mode = log_b->mode;
-                       ret = 0;
-                       break;
-               }
-       }
-       rcu_read_unlock();
-
-       return ret;
-}
-
 #ifdef CONFIG_KEXEC
 /*
  * This appends the listed symbols to /proc/vmcore