diff options
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r-- | drivers/infiniband/core/sysfs.c | 76 | ||||
-rw-r--r-- | drivers/infiniband/core/ucm.c | 62 | ||||
-rw-r--r-- | drivers/infiniband/core/user_mad.c | 109 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs.h | 4 | ||||
-rw-r--r-- | drivers/infiniband/core/uverbs_main.c | 51 |
5 files changed, 154 insertions, 148 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c index 5a4b2e6..9575655 100644 --- a/drivers/infiniband/core/sysfs.c +++ b/drivers/infiniband/core/sysfs.c @@ -427,17 +427,17 @@ static struct kobj_type port_type = { .default_attrs = port_default_attrs }; -static void ib_device_release(struct class_device *cdev) +static void ib_device_release(struct device *device) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); kfree(dev); } -static int ib_device_uevent(struct class_device *cdev, +static int ib_device_uevent(struct device *device, struct kobj_uevent_env *env) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); if (add_uevent_var(env, "NAME=%s", dev->name)) return -ENOMEM; @@ -567,9 +567,10 @@ err_put: return ret; } -static ssize_t show_node_type(struct class_device *cdev, char *buf) +static ssize_t show_node_type(struct device *device, + struct device_attribute *attr, char *buf) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); if (!ibdev_is_alive(dev)) return -ENODEV; @@ -583,9 +584,10 @@ static ssize_t show_node_type(struct class_device *cdev, char *buf) } } -static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) +static ssize_t show_sys_image_guid(struct device *device, + struct device_attribute *dev_attr, char *buf) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); struct ib_device_attr attr; ssize_t ret; @@ -603,9 +605,10 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3])); } -static ssize_t show_node_guid(struct class_device *cdev, char *buf) +static ssize_t show_node_guid(struct device *device, + struct device_attribute *attr, char *buf) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); if (!ibdev_is_alive(dev)) return -ENODEV; @@ -617,17 +620,19 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf) be16_to_cpu(((__be16 *) &dev->node_guid)[3])); } -static ssize_t show_node_desc(struct class_device *cdev, char *buf) +static ssize_t show_node_desc(struct device *device, + struct device_attribute *attr, char *buf) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); return sprintf(buf, "%.64s\n", dev->node_desc); } -static ssize_t set_node_desc(struct class_device *cdev, const char *buf, - size_t count) +static ssize_t set_node_desc(struct device *device, + struct device_attribute *attr, + const char *buf, size_t count) { - struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); + struct ib_device *dev = container_of(device, struct ib_device, dev); struct ib_device_modify desc = {}; int ret; @@ -642,44 +647,43 @@ static ssize_t set_node_desc(struct class_device *cdev, const char *buf, return count; } -static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); -static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); -static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); -static CLASS_DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, - set_node_desc); - -static struct class_device_attribute *ib_class_attributes[] = { - &class_device_attr_node_type, - &class_device_attr_sys_image_guid, - &class_device_attr_node_guid, - &class_device_attr_node_desc +static DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); +static DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); +static DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); +static DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, set_node_desc); + +static struct device_attribute *ib_class_attributes[] = { + &dev_attr_node_type, + &dev_attr_sys_image_guid, + &dev_attr_node_guid, + &dev_attr_node_desc }; static struct class ib_class = { .name = "infiniband", - .release = ib_device_release, - .uevent = ib_device_uevent, + .dev_release = ib_device_release, + .dev_uevent = ib_device_uevent, }; int ib_device_register_sysfs(struct ib_device *device) { - struct class_device *class_dev = &device->class_dev; + struct device *class_dev = &device->dev; int ret; int i; class_dev->class = &ib_class; - class_dev->class_data = device; - class_dev->dev = device->dma_device; - strlcpy(class_dev->class_id, device->name, BUS_ID_SIZE); + class_dev->driver_data = device; + class_dev->parent = device->dma_device; + strlcpy(class_dev->bus_id, device->name, BUS_ID_SIZE); INIT_LIST_HEAD(&device->port_list); - ret = class_device_register(class_dev); + ret = device_register(class_dev); if (ret) goto err; for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) { - ret = class_device_create_file(class_dev, ib_class_attributes[i]); + ret = device_create_file(class_dev, ib_class_attributes[i]); if (ret) goto err_unregister; } @@ -723,7 +727,7 @@ err_put: kobject_put(&class_dev->kobj); err_unregister: - class_device_unregister(class_dev); + device_unregister(class_dev); err: return ret; @@ -744,7 +748,7 @@ void ib_device_unregister_sysfs(struct ib_device *device) } kobject_put(device->ports_parent); - class_device_unregister(&device->class_dev); + device_unregister(&device->dev); } int ib_sysfs_setup(void) diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 4291ab4..d7a6881 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c @@ -58,8 +58,8 @@ MODULE_LICENSE("Dual BSD/GPL"); struct ib_ucm_device { int devnum; - struct cdev dev; - struct class_device class_dev; + struct cdev cdev; + struct device dev; struct ib_device *ib_dev; }; @@ -1171,7 +1171,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp) filp->private_data = file; file->filp = filp; - file->device = container_of(inode->i_cdev, struct ib_ucm_device, dev); + file->device = container_of(inode->i_cdev, struct ib_ucm_device, cdev); return 0; } @@ -1202,14 +1202,14 @@ static int ib_ucm_close(struct inode *inode, struct file *filp) return 0; } -static void ucm_release_class_dev(struct class_device *class_dev) +static void ib_ucm_release_dev(struct device *dev) { - struct ib_ucm_device *dev; + struct ib_ucm_device *ucm_dev; - dev = container_of(class_dev, struct ib_ucm_device, class_dev); - cdev_del(&dev->dev); - clear_bit(dev->devnum, dev_map); - kfree(dev); + ucm_dev = container_of(dev, struct ib_ucm_device, dev); + cdev_del(&ucm_dev->cdev); + clear_bit(ucm_dev->devnum, dev_map); + kfree(ucm_dev); } static const struct file_operations ucm_fops = { @@ -1220,14 +1220,15 @@ static const struct file_operations ucm_fops = { .poll = ib_ucm_poll, }; -static ssize_t show_ibdev(struct class_device *class_dev, char *buf) +static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr, + char *buf) { - struct ib_ucm_device *dev; + struct ib_ucm_device *ucm_dev; - dev = container_of(class_dev, struct ib_ucm_device, class_dev); - return sprintf(buf, "%s\n", dev->ib_dev->name); + ucm_dev = container_of(dev, struct ib_ucm_device, dev); + return sprintf(buf, "%s\n", ucm_dev->ib_dev->name); } -static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); +static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); static void ib_ucm_add_one(struct ib_device *device) { @@ -1249,32 +1250,31 @@ static void ib_ucm_add_one(struct ib_device *device) set_bit(ucm_dev->devnum, dev_map); - cdev_init(&ucm_dev->dev, &ucm_fops); - ucm_dev->dev.owner = THIS_MODULE; - kobject_set_name(&ucm_dev->dev.kobj, "ucm%d", ucm_dev->devnum); - if (cdev_add(&ucm_dev->dev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1)) + cdev_init(&ucm_dev->cdev, &ucm_fops); + ucm_dev->cdev.owner = THIS_MODULE; + kobject_set_name(&ucm_dev->cdev.kobj, "ucm%d", ucm_dev->devnum); + if (cdev_add(&ucm_dev->cdev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1)) goto err; - 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->dev.class = &cm_class; + ucm_dev->dev.parent = device->dma_device; + ucm_dev->dev.devt = ucm_dev->cdev.dev; + ucm_dev->dev.release = ib_ucm_release_dev; + snprintf(ucm_dev->dev.bus_id, BUS_ID_SIZE, "ucm%d", ucm_dev->devnum); - if (class_device_register(&ucm_dev->class_dev)) + if (device_register(&ucm_dev->dev)) goto err_cdev; - if (class_device_create_file(&ucm_dev->class_dev, - &class_device_attr_ibdev)) - goto err_class; + if (device_create_file(&ucm_dev->dev, &dev_attr_ibdev)) + goto err_dev; ib_set_client_data(device, &ucm_client, ucm_dev); return; -err_class: - class_device_unregister(&ucm_dev->class_dev); +err_dev: + device_unregister(&ucm_dev->dev); err_cdev: - cdev_del(&ucm_dev->dev); + cdev_del(&ucm_dev->cdev); clear_bit(ucm_dev->devnum, dev_map); err: kfree(ucm_dev); @@ -1288,7 +1288,7 @@ static void ib_ucm_remove_one(struct ib_device *device) if (!ucm_dev) return; - class_device_unregister(&ucm_dev->class_dev); + device_unregister(&ucm_dev->dev); } static ssize_t show_abi_version(struct class *class, char *buf) diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c index 4e91510..9a9d344 100644 --- a/drivers/infiniband/core/user_mad.c +++ b/drivers/infiniband/core/user_mad.c @@ -88,11 +88,11 @@ enum { */ struct ib_umad_port { - struct cdev *dev; - struct class_device *class_dev; + struct cdev *cdev; + struct device *dev; - struct cdev *sm_dev; - struct class_device *sm_class_dev; + struct cdev *sm_cdev; + struct device *sm_dev; struct semaphore sm_sem; struct mutex file_mutex; @@ -948,27 +948,29 @@ static struct ib_client umad_client = { .remove = ib_umad_remove_one }; -static ssize_t show_ibdev(struct class_device *class_dev, char *buf) +static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr, + char *buf) { - struct ib_umad_port *port = class_get_devdata(class_dev); + struct ib_umad_port *port = dev_get_drvdata(dev); if (!port) return -ENODEV; return sprintf(buf, "%s\n", port->ib_dev->name); } -static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); +static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); -static ssize_t show_port(struct class_device *class_dev, char *buf) +static ssize_t show_port(struct device *dev, struct device_attribute *attr, + char *buf) { - struct ib_umad_port *port = class_get_devdata(class_dev); + struct ib_umad_port *port = dev_get_drvdata(dev); if (!port) return -ENODEV; return sprintf(buf, "%d\n", port->port_num); } -static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); +static DEVICE_ATTR(port, S_IRUGO, show_port, NULL); static ssize_t show_abi_version(struct class *class, char *buf) { @@ -994,48 +996,47 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, mutex_init(&port->file_mutex); INIT_LIST_HEAD(&port->file_list); - port->dev = cdev_alloc(); - if (!port->dev) + port->cdev = cdev_alloc(); + if (!port->cdev) return -1; - port->dev->owner = THIS_MODULE; - port->dev->ops = &umad_fops; - kobject_set_name(&port->dev->kobj, "umad%d", port->dev_num); - if (cdev_add(port->dev, base_dev + port->dev_num, 1)) + port->cdev->owner = THIS_MODULE; + port->cdev->ops = &umad_fops; + kobject_set_name(&port->cdev->kobj, "umad%d", port->dev_num); + if (cdev_add(port->cdev, base_dev + port->dev_num, 1)) goto err_cdev; - port->class_dev = class_device_create(umad_class, NULL, port->dev->dev, - device->dma_device, - "umad%d", port->dev_num); - if (IS_ERR(port->class_dev)) + port->dev = device_create(umad_class, device->dma_device, + port->cdev->dev, "umad%d", port->dev_num); + if (IS_ERR(port->dev)) goto err_cdev; - if (class_device_create_file(port->class_dev, &class_device_attr_ibdev)) - goto err_class; - if (class_device_create_file(port->class_dev, &class_device_attr_port)) - goto err_class; - - port->sm_dev = cdev_alloc(); - if (!port->sm_dev) - goto err_class; - port->sm_dev->owner = THIS_MODULE; - port->sm_dev->ops = &umad_sm_fops; - kobject_set_name(&port->sm_dev->kobj, "issm%d", port->dev_num); - if (cdev_add(port->sm_dev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) + if (device_create_file(port->dev, &dev_attr_ibdev)) + goto err_dev; + if (device_create_file(port->dev, &dev_attr_port)) + goto err_dev; + + port->sm_cdev = cdev_alloc(); + if (!port->sm_cdev) + goto err_dev; + port->sm_cdev->owner = THIS_MODULE; + port->sm_cdev->ops = &umad_sm_fops; + kobject_set_name(&port->sm_cdev->kobj, "issm%d", port->dev_num); + if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) goto err_sm_cdev; - port->sm_class_dev = class_device_create(umad_class, NULL, port->sm_dev->dev, - device->dma_device, - "issm%d", port->dev_num); - if (IS_ERR(port->sm_class_dev)) + port->sm_dev = device_create(umad_class, device->dma_device, + port->sm_cdev->dev, + "issm%d", port->dev_num); + if (IS_ERR(port->sm_dev)) goto err_sm_cdev; - class_set_devdata(port->class_dev, port); - class_set_devdata(port->sm_class_dev, port); + dev_set_drvdata(port->dev, port); + dev_set_drvdata(port->sm_dev, port); - if (class_device_create_file(port->sm_class_dev, &class_device_attr_ibdev)) - goto err_sm_class; - if (class_device_create_file(port->sm_class_dev, &class_device_attr_port)) - goto err_sm_class; + if (device_create_file(port->sm_dev, &dev_attr_ibdev)) + goto err_sm_dev; + if (device_create_file(port->sm_dev, &dev_attr_port)) + goto err_sm_dev; spin_lock(&port_lock); umad_port[port->dev_num] = port; @@ -1043,17 +1044,17 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, return 0; -err_sm_class: - class_device_destroy(umad_class, port->sm_dev->dev); +err_sm_dev: + device_destroy(umad_class, port->sm_cdev->dev); err_sm_cdev: - cdev_del(port->sm_dev); + cdev_del(port->sm_cdev); -err_class: - class_device_destroy(umad_class, port->dev->dev); +err_dev: + device_destroy(umad_class, port->cdev->dev); err_cdev: - cdev_del(port->dev); + cdev_del(port->cdev); clear_bit(port->dev_num, dev_map); return -1; @@ -1065,14 +1066,14 @@ static void ib_umad_kill_port(struct ib_umad_port *port) int already_dead; int id; - class_set_devdata(port->class_dev, NULL); - class_set_devdata(port->sm_class_dev, NULL); + dev_set_drvdata(port->dev, NULL); + dev_set_drvdata(port->sm_dev, NULL); - class_device_destroy(umad_class, port->dev->dev); - class_device_destroy(umad_class, port->sm_dev->dev); + device_destroy(umad_class, port->cdev->dev); + device_destroy(umad_class, port->sm_cdev->dev); - cdev_del(port->dev); - cdev_del(port->sm_dev); + cdev_del(port->cdev); + cdev_del(port->sm_cdev); spin_lock(&port_lock); umad_port[port->dev_num] = NULL; diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index 2cad8b4..376a57c 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h @@ -73,8 +73,8 @@ struct ib_uverbs_device { struct kref ref; struct completion comp; int devnum; - struct cdev *dev; - struct class_device *class_dev; + struct cdev *cdev; + struct device *dev; struct ib_device *ib_dev; int num_comp_vectors; }; diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index f49f946..cc1afa2 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -690,27 +690,29 @@ static struct ib_client uverbs_client = { .remove = ib_uverbs_remove_one }; -static ssize_t show_ibdev(struct class_device *class_dev, char *buf) +static ssize_t show_ibdev(struct device *device, struct device_attribute *attr, + char *buf) { - struct ib_uverbs_device *dev = class_get_devdata(class_dev); + struct ib_uverbs_device *dev = dev_get_drvdata(device); if (!dev) return -ENODEV; return sprintf(buf, "%s\n", dev->ib_dev->name); } -static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); +static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); -static ssize_t show_dev_abi_version(struct class_device *class_dev, char *buf) +static ssize_t show_dev_abi_version(struct device *device, + struct device_attribute *attr, char *buf) { - struct ib_uverbs_device *dev = class_get_devdata(class_dev); + struct ib_uverbs_device *dev = dev_get_drvdata(device); if (!dev) return -ENODEV; return sprintf(buf, "%d\n", dev->ib_dev->uverbs_abi_ver); } -static CLASS_DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); +static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); static ssize_t show_abi_version(struct class *class, char *buf) { @@ -744,27 +746,26 @@ static void ib_uverbs_add_one(struct ib_device *device) uverbs_dev->ib_dev = device; uverbs_dev->num_comp_vectors = device->num_comp_vectors; - uverbs_dev->dev = cdev_alloc(); - if (!uverbs_dev->dev) + uverbs_dev->cdev = cdev_alloc(); + if (!uverbs_dev->cdev) goto err; - uverbs_dev->dev->owner = THIS_MODULE; - uverbs_dev->dev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops; - kobject_set_name(&uverbs_dev->dev->kobj, "uverbs%d", uverbs_dev->devnum); - if (cdev_add(uverbs_dev->dev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) + uverbs_dev->cdev->owner = THIS_MODULE; + uverbs_dev->cdev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops; + kobject_set_name(&uverbs_dev->cdev->kobj, "uverbs%d", uverbs_dev->devnum); + if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) goto err_cdev; - uverbs_dev->class_dev = class_device_create(uverbs_class, NULL, - uverbs_dev->dev->dev, - device->dma_device, - "uverbs%d", uverbs_dev->devnum); - if (IS_ERR(uverbs_dev->class_dev)) + uverbs_dev->dev = device_create(uverbs_class, device->dma_device, + uverbs_dev->cdev->dev, + "uverbs%d", uverbs_dev->devnum); + if (IS_ERR(uverbs_dev->dev)) goto err_cdev; - class_set_devdata(uverbs_dev->class_dev, uverbs_dev); + dev_set_drvdata(uverbs_dev->dev, uverbs_dev); - if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_ibdev)) + if (device_create_file(uverbs_dev->dev, &dev_attr_ibdev)) goto err_class; - if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_abi_version)) + if (device_create_file(uverbs_dev->dev, &dev_attr_abi_version)) goto err_class; spin_lock(&map_lock); @@ -776,10 +777,10 @@ static void ib_uverbs_add_one(struct ib_device *device) return; err_class: - class_device_destroy(uverbs_class, uverbs_dev->dev->dev); + device_destroy(uverbs_class, uverbs_dev->cdev->dev); err_cdev: - cdev_del(uverbs_dev->dev); + cdev_del(uverbs_dev->cdev); clear_bit(uverbs_dev->devnum, dev_map); err: @@ -796,9 +797,9 @@ static void ib_uverbs_remove_one(struct ib_device *device) if (!uverbs_dev) return; - class_set_devdata(uverbs_dev->class_dev, NULL); - class_device_destroy(uverbs_class, uverbs_dev->dev->dev); - cdev_del(uverbs_dev->dev); + dev_set_drvdata(uverbs_dev->dev, NULL); + device_destroy(uverbs_class, uverbs_dev->cdev->dev); + cdev_del(uverbs_dev->cdev); spin_lock(&map_lock); dev_table[uverbs_dev->devnum] = NULL; |