]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/infiniband/core/ucm.c
[POWERPC] PS3: Fix reading pm interval in logical performance monitor
[linux-2.6-omap-h63xx.git] / drivers / infiniband / core / ucm.c
index ee51d79a7ad5048ba97830934ad1961abf5b0376..4291ab42a5b9c60fb78eeecdf09087b9af10f58b 100644 (file)
@@ -106,6 +106,9 @@ enum {
        IB_UCM_MAX_DEVICES = 32
 };
 
+/* ib_cm and ib_user_cm modules share /sys/class/infiniband_cm */
+extern struct class cm_class;
+
 #define IB_UCM_BASE_DEV MKDEV(IB_UCM_MAJOR, IB_UCM_BASE_MINOR)
 
 static void ib_ucm_add_one(struct ib_device *device);
@@ -407,29 +410,18 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file,
 
        mutex_lock(&file->file_mutex);
        while (list_empty(&file->events)) {
+               mutex_unlock(&file->file_mutex);
 
-               if (file->filp->f_flags & O_NONBLOCK) {
-                       result = -EAGAIN;
-                       break;
-               }
-
-               if (signal_pending(current)) {
-                       result = -ERESTARTSYS;
-                       break;
-               }
+               if (file->filp->f_flags & O_NONBLOCK)
+                       return -EAGAIN;
 
-               prepare_to_wait(&file->poll_wait, &wait, TASK_INTERRUPTIBLE);
+               if (wait_event_interruptible(file->poll_wait,
+                                            !list_empty(&file->events)))
+                       return -ERESTARTSYS;
 
-               mutex_unlock(&file->file_mutex);
-               schedule();
                mutex_lock(&file->file_mutex);
-
-               finish_wait(&file->poll_wait, &wait);
        }
 
-       if (result)
-               goto done;
-
        uevent = list_entry(file->events.next, struct ib_ucm_event, file_list);
 
        if (ib_ucm_new_cm_id(uevent->resp.event)) {
@@ -834,7 +826,6 @@ static ssize_t ib_ucm_send_rep(struct ib_ucm_file *file,
        param.private_data_len    = cmd.len;
        param.responder_resources = cmd.responder_resources;
        param.initiator_depth     = cmd.initiator_depth;
-       param.target_ack_delay    = cmd.target_ack_delay;
        param.failover_accepted   = cmd.failover_accepted;
        param.flow_control        = cmd.flow_control;
        param.rnr_retry_count     = cmd.rnr_retry_count;
@@ -1211,7 +1202,7 @@ static int ib_ucm_close(struct inode *inode, struct file *filp)
        return 0;
 }
 
-static void ib_ucm_release_class_dev(struct class_device *class_dev)
+static void ucm_release_class_dev(struct class_device *class_dev)
 {
        struct ib_ucm_device *dev;
 
@@ -1229,11 +1220,6 @@ static const struct file_operations ucm_fops = {
        .poll    = ib_ucm_poll,
 };
 
-static struct class ucm_class = {
-       .name    = "infiniband_cm",
-       .release = ib_ucm_release_class_dev
-};
-
 static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
 {
        struct ib_ucm_device *dev;
@@ -1269,9 +1255,10 @@ static void ib_ucm_add_one(struct ib_device *device)
        if (cdev_add(&ucm_dev->dev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1))
                goto err;
 
-       ucm_dev->class_dev.class = &ucm_class;
+       ucm_dev->class_dev.class = &cm_class;
        ucm_dev->class_dev.dev = device->dma_device;
        ucm_dev->class_dev.devt = ucm_dev->dev.dev;
+       ucm_dev->class_dev.release = ucm_release_class_dev;
        snprintf(ucm_dev->class_dev.class_id, BUS_ID_SIZE, "ucm%d",
                 ucm_dev->devnum);
        if (class_device_register(&ucm_dev->class_dev))
@@ -1318,40 +1305,34 @@ static int __init ib_ucm_init(void)
                                     "infiniband_cm");
        if (ret) {
                printk(KERN_ERR "ucm: couldn't register device number\n");
-               goto err;
-       }
-
-       ret = class_register(&ucm_class);
-       if (ret) {
-               printk(KERN_ERR "ucm: couldn't create class infiniband_cm\n");
-               goto err_chrdev;
+               goto error1;
        }
 
-       ret = class_create_file(&ucm_class, &class_attr_abi_version);
+       ret = class_create_file(&cm_class, &class_attr_abi_version);
        if (ret) {
                printk(KERN_ERR "ucm: couldn't create abi_version attribute\n");
-               goto err_class;
+               goto error2;
        }
 
        ret = ib_register_client(&ucm_client);
        if (ret) {
                printk(KERN_ERR "ucm: couldn't register client\n");
-               goto err_class;
+               goto error3;
        }
        return 0;
 
-err_class:
-       class_unregister(&ucm_class);
-err_chrdev:
+error3:
+       class_remove_file(&cm_class, &class_attr_abi_version);
+error2:
        unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
-err:
+error1:
        return ret;
 }
 
 static void __exit ib_ucm_cleanup(void)
 {
        ib_unregister_client(&ucm_client);
-       class_unregister(&ucm_class);
+       class_remove_file(&cm_class, &class_attr_abi_version);
        unregister_chrdev_region(IB_UCM_BASE_DEV, IB_UCM_MAX_DEVICES);
        idr_destroy(&ctx_id_table);
 }