aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core
diff options
context:
space:
mode:
authorRoland Dreier <rolandd@cisco.com>2010-02-24 19:51:20 -0500
committerRoland Dreier <rolandd@cisco.com>2010-02-24 19:51:20 -0500
commita265e5587f078618c1f17c3a83da65046f18746f (patch)
treec2de5a76d93353c564348f3052a4ef17316c3754 /drivers/infiniband/core
parent920d706c892e8f8cfff95f46aeb95fc6344f0bd5 (diff)
IB/uverbs: Use anon_inodes instead of private infinibandeventfs
The anon_inodes interface has been split to allow creating a bare (non-installed) file pointer and also extended to allow specifying O_RDONLY in the flags. This makes it a suitable replacement for the private "infinibandeventfs" pseudo-filesystem used by uverbs, and this replacement saves a small chunk of boilerplate code. Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r--drivers/infiniband/core/uverbs_main.c60
1 files changed, 4 insertions, 56 deletions
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 5f284ffd430e..82b60c65dd4d 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -42,8 +42,8 @@
42#include <linux/poll.h> 42#include <linux/poll.h>
43#include <linux/sched.h> 43#include <linux/sched.h>
44#include <linux/file.h> 44#include <linux/file.h>
45#include <linux/mount.h>
46#include <linux/cdev.h> 45#include <linux/cdev.h>
46#include <linux/anon_inodes.h>
47 47
48#include <asm/uaccess.h> 48#include <asm/uaccess.h>
49 49
@@ -53,8 +53,6 @@ MODULE_AUTHOR("Roland Dreier");
53MODULE_DESCRIPTION("InfiniBand userspace verbs access"); 53MODULE_DESCRIPTION("InfiniBand userspace verbs access");
54MODULE_LICENSE("Dual BSD/GPL"); 54MODULE_LICENSE("Dual BSD/GPL");
55 55
56#define INFINIBANDEVENTFS_MAGIC 0x49426576 /* "IBev" */
57
58enum { 56enum {
59 IB_UVERBS_MAJOR = 231, 57 IB_UVERBS_MAJOR = 231,
60 IB_UVERBS_BASE_MINOR = 192, 58 IB_UVERBS_BASE_MINOR = 192,
@@ -111,8 +109,6 @@ static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file,
111 [IB_USER_VERBS_CMD_DESTROY_SRQ] = ib_uverbs_destroy_srq, 109 [IB_USER_VERBS_CMD_DESTROY_SRQ] = ib_uverbs_destroy_srq,
112}; 110};
113 111
114static struct vfsmount *uverbs_event_mnt;
115
116static void ib_uverbs_add_one(struct ib_device *device); 112static void ib_uverbs_add_one(struct ib_device *device);
117static void ib_uverbs_remove_one(struct ib_device *device); 113static void ib_uverbs_remove_one(struct ib_device *device);
118 114
@@ -492,7 +488,6 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
492 int is_async, int *fd) 488 int is_async, int *fd)
493{ 489{
494 struct ib_uverbs_event_file *ev_file; 490 struct ib_uverbs_event_file *ev_file;
495 struct path path;
496 struct file *filp; 491 struct file *filp;
497 int ret; 492 int ret;
498 493
@@ -515,27 +510,16 @@ struct file *ib_uverbs_alloc_event_file(struct ib_uverbs_file *uverbs_file,
515 goto err; 510 goto err;
516 } 511 }
517 512
518 /* 513 filp = anon_inode_getfile("[uverbs-event]", &uverbs_event_fops,
519 * fops_get() can't fail here, because we're coming from a 514 ev_file, O_RDONLY);
520 * system call on a uverbs file, which will already have a
521 * module reference.
522 */
523 path.mnt = uverbs_event_mnt;
524 path.dentry = uverbs_event_mnt->mnt_root;
525 path_get(&path);
526 filp = alloc_file(&path, FMODE_READ, fops_get(&uverbs_event_fops));
527 if (!filp) { 515 if (!filp) {
528 ret = -ENFILE; 516 ret = -ENFILE;
529 goto err_fd; 517 goto err_fd;
530 } 518 }
531 519
532 filp->private_data = ev_file;
533
534 return filp; 520 return filp;
535 521
536err_fd: 522err_fd:
537 fops_put(&uverbs_event_fops);
538 path_put(&path);
539 put_unused_fd(*fd); 523 put_unused_fd(*fd);
540 524
541err: 525err:
@@ -825,21 +809,6 @@ static void ib_uverbs_remove_one(struct ib_device *device)
825 kfree(uverbs_dev); 809 kfree(uverbs_dev);
826} 810}
827 811
828static int uverbs_event_get_sb(struct file_system_type *fs_type, int flags,
829 const char *dev_name, void *data,
830 struct vfsmount *mnt)
831{
832 return get_sb_pseudo(fs_type, "infinibandevent:", NULL,
833 INFINIBANDEVENTFS_MAGIC, mnt);
834}
835
836static struct file_system_type uverbs_event_fs = {
837 /* No owner field so module can be unloaded */
838 .name = "infinibandeventfs",
839 .get_sb = uverbs_event_get_sb,
840 .kill_sb = kill_litter_super
841};
842
843static int __init ib_uverbs_init(void) 812static int __init ib_uverbs_init(void)
844{ 813{
845 int ret; 814 int ret;
@@ -864,33 +833,14 @@ static int __init ib_uverbs_init(void)
864 goto out_class; 833 goto out_class;
865 } 834 }
866 835
867 ret = register_filesystem(&uverbs_event_fs);
868 if (ret) {
869 printk(KERN_ERR "user_verbs: couldn't register infinibandeventfs\n");
870 goto out_class;
871 }
872
873 uverbs_event_mnt = kern_mount(&uverbs_event_fs);
874 if (IS_ERR(uverbs_event_mnt)) {
875 ret = PTR_ERR(uverbs_event_mnt);
876 printk(KERN_ERR "user_verbs: couldn't mount infinibandeventfs\n");
877 goto out_fs;
878 }
879
880 ret = ib_register_client(&uverbs_client); 836 ret = ib_register_client(&uverbs_client);
881 if (ret) { 837 if (ret) {
882 printk(KERN_ERR "user_verbs: couldn't register client\n"); 838 printk(KERN_ERR "user_verbs: couldn't register client\n");
883 goto out_mnt; 839 goto out_class;
884 } 840 }
885 841
886 return 0; 842 return 0;
887 843
888out_mnt:
889 mntput(uverbs_event_mnt);
890
891out_fs:
892 unregister_filesystem(&uverbs_event_fs);
893
894out_class: 844out_class:
895 class_destroy(uverbs_class); 845 class_destroy(uverbs_class);
896 846
@@ -904,8 +854,6 @@ out:
904static void __exit ib_uverbs_cleanup(void) 854static void __exit ib_uverbs_cleanup(void)
905{ 855{
906 ib_unregister_client(&uverbs_client); 856 ib_unregister_client(&uverbs_client);
907 mntput(uverbs_event_mnt);
908 unregister_filesystem(&uverbs_event_fs);
909 class_destroy(uverbs_class); 857 class_destroy(uverbs_class);
910 unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES); 858 unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES);
911 idr_destroy(&ib_uverbs_pd_idr); 859 idr_destroy(&ib_uverbs_pd_idr);