staging: lustre: move misc-device registration closer to related code.
authorNeilBrown <neilb@suse.com>
Mon, 7 May 2018 00:54:48 +0000 (10:54 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 May 2018 11:09:20 +0000 (13:09 +0200)
The ioctl handler for the misc device is in  lnet/libcfs/module.c
but is it registered in lnet/libcfs/linux/linux-module.c.

Keeping related code together make maintenance easier, so move the
code.

Reviewed-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/include/linux/libcfs/libcfs.h
drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
drivers/staging/lustre/lnet/libcfs/module.c

index 6e7754b2f296712cecb08e958102d74f2a5318df..9263e151451b5d9db91cc468f618b3655059789c 100644 (file)
@@ -141,11 +141,9 @@ int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
 int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
                         const struct libcfs_ioctl_hdr __user *uparam);
 int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
-int libcfs_ioctl(unsigned long cmd, void __user *arg);
 
 #define _LIBCFS_H
 
-extern struct miscdevice libcfs_dev;
 /**
  * The path of debug log dump upcall script.
  */
index c8908e816c4c24d00a40f170260687205f9eec9f..954b681f9db7cac486bb44e28aa68df59ba47fff 100644 (file)
@@ -166,31 +166,3 @@ free:
        kvfree(*hdr_pp);
        return err;
 }
-
-static long
-libcfs_psdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-       if (!capable(CAP_SYS_ADMIN))
-               return -EACCES;
-
-       if (_IOC_TYPE(cmd) != IOC_LIBCFS_TYPE ||
-           _IOC_NR(cmd) < IOC_LIBCFS_MIN_NR  ||
-           _IOC_NR(cmd) > IOC_LIBCFS_MAX_NR) {
-               CDEBUG(D_IOCTL, "invalid ioctl ( type %d, nr %d, size %d )\n",
-                      _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd));
-               return -EINVAL;
-       }
-
-       return libcfs_ioctl(cmd, (void __user *)arg);
-}
-
-static const struct file_operations libcfs_fops = {
-       .owner          = THIS_MODULE,
-       .unlocked_ioctl = libcfs_psdev_ioctl,
-};
-
-struct miscdevice libcfs_dev = {
-       .minor = MISC_DYNAMIC_MINOR,
-       .name = "lnet",
-       .fops = &libcfs_fops,
-};
index 4b9acd7bc5cfa6a74303716429d4dc670ac563cc..f627b2d1beb52f51a683e3e4854f3baecdc6c8ba 100644 (file)
@@ -95,7 +95,7 @@ int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand)
 }
 EXPORT_SYMBOL(libcfs_deregister_ioctl);
 
-int libcfs_ioctl(unsigned long cmd, void __user *uparam)
+static int libcfs_ioctl(unsigned long cmd, void __user *uparam)
 {
        struct libcfs_ioctl_data *data = NULL;
        struct libcfs_ioctl_hdr *hdr;
@@ -161,6 +161,34 @@ out:
        return err;
 }
 
+static long
+libcfs_psdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+       if (!capable(CAP_SYS_ADMIN))
+               return -EACCES;
+
+       if (_IOC_TYPE(cmd) != IOC_LIBCFS_TYPE ||
+           _IOC_NR(cmd) < IOC_LIBCFS_MIN_NR  ||
+           _IOC_NR(cmd) > IOC_LIBCFS_MAX_NR) {
+               CDEBUG(D_IOCTL, "invalid ioctl ( type %d, nr %d, size %d )\n",
+                      _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd));
+               return -EINVAL;
+       }
+
+       return libcfs_ioctl(cmd, (void __user *)arg);
+}
+
+static const struct file_operations libcfs_fops = {
+       .owner          = THIS_MODULE,
+       .unlocked_ioctl = libcfs_psdev_ioctl,
+};
+
+struct miscdevice libcfs_dev = {
+       .minor = MISC_DYNAMIC_MINOR,
+       .name = "lnet",
+       .fops = &libcfs_fops,
+};
+
 int lprocfs_call_handler(void *data, int write, loff_t *ppos,
                         void __user *buffer, size_t *lenp,
                         int (*handler)(void *data, int write, loff_t pos,