aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core
diff options
context:
space:
mode:
authorTony Jones <tonyj@suse.de>2008-02-21 18:13:36 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-04-19 22:10:30 -0400
commitf4e91eb4a81559da87a3843758a641b5cc590b65 (patch)
tree534335821d076764cbc072586b19c4b061710e3d /drivers/infiniband/core
parentc4c66cf1787d408066fbfc69209185701f5df15f (diff)
IB: convert struct class_device to struct device
This converts the main ib_device to use struct device instead of struct class_device as class_device is going away. Signed-off-by: Tony Jones <tonyj@suse.de> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Cc: Roland Dreier <rolandd@cisco.com> Cc: Sean Hefty <sean.hefty@intel.com> Cc: Hal Rosenstock <hal.rosenstock@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r--drivers/infiniband/core/sysfs.c76
-rw-r--r--drivers/infiniband/core/ucm.c62
-rw-r--r--drivers/infiniband/core/user_mad.c109
-rw-r--r--drivers/infiniband/core/uverbs.h4
-rw-r--r--drivers/infiniband/core/uverbs_main.c51
5 files changed, 154 insertions, 148 deletions
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 5a4b2e65534b..95756551cf7c 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -427,17 +427,17 @@ static struct kobj_type port_type = {
427 .default_attrs = port_default_attrs 427 .default_attrs = port_default_attrs
428}; 428};
429 429
430static void ib_device_release(struct class_device *cdev) 430static void ib_device_release(struct device *device)
431{ 431{
432 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 432 struct ib_device *dev = container_of(device, struct ib_device, dev);
433 433
434 kfree(dev); 434 kfree(dev);
435} 435}
436 436
437static int ib_device_uevent(struct class_device *cdev, 437static int ib_device_uevent(struct device *device,
438 struct kobj_uevent_env *env) 438 struct kobj_uevent_env *env)
439{ 439{
440 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 440 struct ib_device *dev = container_of(device, struct ib_device, dev);
441 441
442 if (add_uevent_var(env, "NAME=%s", dev->name)) 442 if (add_uevent_var(env, "NAME=%s", dev->name))
443 return -ENOMEM; 443 return -ENOMEM;
@@ -567,9 +567,10 @@ err_put:
567 return ret; 567 return ret;
568} 568}
569 569
570static ssize_t show_node_type(struct class_device *cdev, char *buf) 570static ssize_t show_node_type(struct device *device,
571 struct device_attribute *attr, char *buf)
571{ 572{
572 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 573 struct ib_device *dev = container_of(device, struct ib_device, dev);
573 574
574 if (!ibdev_is_alive(dev)) 575 if (!ibdev_is_alive(dev))
575 return -ENODEV; 576 return -ENODEV;
@@ -583,9 +584,10 @@ static ssize_t show_node_type(struct class_device *cdev, char *buf)
583 } 584 }
584} 585}
585 586
586static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) 587static ssize_t show_sys_image_guid(struct device *device,
588 struct device_attribute *dev_attr, char *buf)
587{ 589{
588 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 590 struct ib_device *dev = container_of(device, struct ib_device, dev);
589 struct ib_device_attr attr; 591 struct ib_device_attr attr;
590 ssize_t ret; 592 ssize_t ret;
591 593
@@ -603,9 +605,10 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf)
603 be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3])); 605 be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3]));
604} 606}
605 607
606static ssize_t show_node_guid(struct class_device *cdev, char *buf) 608static ssize_t show_node_guid(struct device *device,
609 struct device_attribute *attr, char *buf)
607{ 610{
608 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 611 struct ib_device *dev = container_of(device, struct ib_device, dev);
609 612
610 if (!ibdev_is_alive(dev)) 613 if (!ibdev_is_alive(dev))
611 return -ENODEV; 614 return -ENODEV;
@@ -617,17 +620,19 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf)
617 be16_to_cpu(((__be16 *) &dev->node_guid)[3])); 620 be16_to_cpu(((__be16 *) &dev->node_guid)[3]));
618} 621}
619 622
620static ssize_t show_node_desc(struct class_device *cdev, char *buf) 623static ssize_t show_node_desc(struct device *device,
624 struct device_attribute *attr, char *buf)
621{ 625{
622 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 626 struct ib_device *dev = container_of(device, struct ib_device, dev);
623 627
624 return sprintf(buf, "%.64s\n", dev->node_desc); 628 return sprintf(buf, "%.64s\n", dev->node_desc);
625} 629}
626 630
627static ssize_t set_node_desc(struct class_device *cdev, const char *buf, 631static ssize_t set_node_desc(struct device *device,
628 size_t count) 632 struct device_attribute *attr,
633 const char *buf, size_t count)
629{ 634{
630 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 635 struct ib_device *dev = container_of(device, struct ib_device, dev);
631 struct ib_device_modify desc = {}; 636 struct ib_device_modify desc = {};
632 int ret; 637 int ret;
633 638
@@ -642,44 +647,43 @@ static ssize_t set_node_desc(struct class_device *cdev, const char *buf,
642 return count; 647 return count;
643} 648}
644 649
645static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); 650static DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
646static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL); 651static DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL);
647static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL); 652static DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL);
648static CLASS_DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, 653static DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, set_node_desc);
649 set_node_desc); 654
650 655static struct device_attribute *ib_class_attributes[] = {
651static struct class_device_attribute *ib_class_attributes[] = { 656 &dev_attr_node_type,
652 &class_device_attr_node_type, 657 &dev_attr_sys_image_guid,
653 &class_device_attr_sys_image_guid, 658 &dev_attr_node_guid,
654 &class_device_attr_node_guid, 659 &dev_attr_node_desc
655 &class_device_attr_node_desc
656}; 660};
657 661
658static struct class ib_class = { 662static struct class ib_class = {
659 .name = "infiniband", 663 .name = "infiniband",
660 .release = ib_device_release, 664 .dev_release = ib_device_release,
661 .uevent = ib_device_uevent, 665 .dev_uevent = ib_device_uevent,
662}; 666};
663 667
664int ib_device_register_sysfs(struct ib_device *device) 668int ib_device_register_sysfs(struct ib_device *device)
665{ 669{
666 struct class_device *class_dev = &device->class_dev; 670 struct device *class_dev = &device->dev;
667 int ret; 671 int ret;
668 int i; 672 int i;
669 673
670 class_dev->class = &ib_class; 674 class_dev->class = &ib_class;
671 class_dev->class_data = device; 675 class_dev->driver_data = device;
672 class_dev->dev = device->dma_device; 676 class_dev->parent = device->dma_device;
673 strlcpy(class_dev->class_id, device->name, BUS_ID_SIZE); 677 strlcpy(class_dev->bus_id, device->name, BUS_ID_SIZE);
674 678
675 INIT_LIST_HEAD(&device->port_list); 679 INIT_LIST_HEAD(&device->port_list);
676 680
677 ret = class_device_register(class_dev); 681 ret = device_register(class_dev);
678 if (ret) 682 if (ret)
679 goto err; 683 goto err;
680 684
681 for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) { 685 for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) {
682 ret = class_device_create_file(class_dev, ib_class_attributes[i]); 686 ret = device_create_file(class_dev, ib_class_attributes[i]);
683 if (ret) 687 if (ret)
684 goto err_unregister; 688 goto err_unregister;
685 } 689 }
@@ -723,7 +727,7 @@ err_put:
723 kobject_put(&class_dev->kobj); 727 kobject_put(&class_dev->kobj);
724 728
725err_unregister: 729err_unregister:
726 class_device_unregister(class_dev); 730 device_unregister(class_dev);
727 731
728err: 732err:
729 return ret; 733 return ret;
@@ -744,7 +748,7 @@ void ib_device_unregister_sysfs(struct ib_device *device)
744 } 748 }
745 749
746 kobject_put(device->ports_parent); 750 kobject_put(device->ports_parent);
747 class_device_unregister(&device->class_dev); 751 device_unregister(&device->dev);
748} 752}
749 753
750int ib_sysfs_setup(void) 754int ib_sysfs_setup(void)
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index 4291ab42a5b9..d7a6881b571d 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -58,8 +58,8 @@ MODULE_LICENSE("Dual BSD/GPL");
58 58
59struct ib_ucm_device { 59struct ib_ucm_device {
60 int devnum; 60 int devnum;
61 struct cdev dev; 61 struct cdev cdev;
62 struct class_device class_dev; 62 struct device dev;
63 struct ib_device *ib_dev; 63 struct ib_device *ib_dev;
64}; 64};
65 65
@@ -1171,7 +1171,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp)
1171 1171
1172 filp->private_data = file; 1172 filp->private_data = file;
1173 file->filp = filp; 1173 file->filp = filp;
1174 file->device = container_of(inode->i_cdev, struct ib_ucm_device, dev); 1174 file->device = container_of(inode->i_cdev, struct ib_ucm_device, cdev);
1175 1175
1176 return 0; 1176 return 0;
1177} 1177}
@@ -1202,14 +1202,14 @@ static int ib_ucm_close(struct inode *inode, struct file *filp)
1202 return 0; 1202 return 0;
1203} 1203}
1204 1204
1205static void ucm_release_class_dev(struct class_device *class_dev) 1205static void ib_ucm_release_dev(struct device *dev)
1206{ 1206{
1207 struct ib_ucm_device *dev; 1207 struct ib_ucm_device *ucm_dev;
1208 1208
1209 dev = container_of(class_dev, struct ib_ucm_device, class_dev); 1209 ucm_dev = container_of(dev, struct ib_ucm_device, dev);
1210 cdev_del(&dev->dev); 1210 cdev_del(&ucm_dev->cdev);
1211 clear_bit(dev->devnum, dev_map); 1211 clear_bit(ucm_dev->devnum, dev_map);
1212 kfree(dev); 1212 kfree(ucm_dev);
1213} 1213}
1214 1214
1215static const struct file_operations ucm_fops = { 1215static const struct file_operations ucm_fops = {
@@ -1220,14 +1220,15 @@ static const struct file_operations ucm_fops = {
1220 .poll = ib_ucm_poll, 1220 .poll = ib_ucm_poll,
1221}; 1221};
1222 1222
1223static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 1223static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
1224 char *buf)
1224{ 1225{
1225 struct ib_ucm_device *dev; 1226 struct ib_ucm_device *ucm_dev;
1226 1227
1227 dev = container_of(class_dev, struct ib_ucm_device, class_dev); 1228 ucm_dev = container_of(dev, struct ib_ucm_device, dev);
1228 return sprintf(buf, "%s\n", dev->ib_dev->name); 1229 return sprintf(buf, "%s\n", ucm_dev->ib_dev->name);
1229} 1230}
1230static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 1231static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
1231 1232
1232static void ib_ucm_add_one(struct ib_device *device) 1233static void ib_ucm_add_one(struct ib_device *device)
1233{ 1234{
@@ -1249,32 +1250,31 @@ static void ib_ucm_add_one(struct ib_device *device)
1249 1250
1250 set_bit(ucm_dev->devnum, dev_map); 1251 set_bit(ucm_dev->devnum, dev_map);
1251 1252
1252 cdev_init(&ucm_dev->dev, &ucm_fops); 1253 cdev_init(&ucm_dev->cdev, &ucm_fops);
1253 ucm_dev->dev.owner = THIS_MODULE; 1254 ucm_dev->cdev.owner = THIS_MODULE;
1254 kobject_set_name(&ucm_dev->dev.kobj, "ucm%d", ucm_dev->devnum); 1255 kobject_set_name(&ucm_dev->cdev.kobj, "ucm%d", ucm_dev->devnum);
1255 if (cdev_add(&ucm_dev->dev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1)) 1256 if (cdev_add(&ucm_dev->cdev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1))
1256 goto err; 1257 goto err;
1257 1258
1258 ucm_dev->class_dev.class = &cm_class; 1259 ucm_dev->dev.class = &cm_class;
1259 ucm_dev->class_dev.dev = device->dma_device; 1260 ucm_dev->dev.parent = device->dma_device;
1260 ucm_dev->class_dev.devt = ucm_dev->dev.dev; 1261 ucm_dev->dev.devt = ucm_dev->cdev.dev;
1261 ucm_dev->class_dev.release = ucm_release_class_dev; 1262 ucm_dev->dev.release = ib_ucm_release_dev;
1262 snprintf(ucm_dev->class_dev.class_id, BUS_ID_SIZE, "ucm%d", 1263 snprintf(ucm_dev->dev.bus_id, BUS_ID_SIZE, "ucm%d",
1263 ucm_dev->devnum); 1264 ucm_dev->devnum);
1264 if (class_device_register(&ucm_dev->class_dev)) 1265 if (device_register(&ucm_dev->dev))
1265 goto err_cdev; 1266 goto err_cdev;
1266 1267
1267 if (class_device_create_file(&ucm_dev->class_dev, 1268 if (device_create_file(&ucm_dev->dev, &dev_attr_ibdev))
1268 &class_device_attr_ibdev)) 1269 goto err_dev;
1269 goto err_class;
1270 1270
1271 ib_set_client_data(device, &ucm_client, ucm_dev); 1271 ib_set_client_data(device, &ucm_client, ucm_dev);
1272 return; 1272 return;
1273 1273
1274err_class: 1274err_dev:
1275 class_device_unregister(&ucm_dev->class_dev); 1275 device_unregister(&ucm_dev->dev);
1276err_cdev: 1276err_cdev:
1277 cdev_del(&ucm_dev->dev); 1277 cdev_del(&ucm_dev->cdev);
1278 clear_bit(ucm_dev->devnum, dev_map); 1278 clear_bit(ucm_dev->devnum, dev_map);
1279err: 1279err:
1280 kfree(ucm_dev); 1280 kfree(ucm_dev);
@@ -1288,7 +1288,7 @@ static void ib_ucm_remove_one(struct ib_device *device)
1288 if (!ucm_dev) 1288 if (!ucm_dev)
1289 return; 1289 return;
1290 1290
1291 class_device_unregister(&ucm_dev->class_dev); 1291 device_unregister(&ucm_dev->dev);
1292} 1292}
1293 1293
1294static ssize_t show_abi_version(struct class *class, char *buf) 1294static 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 4e915104ac4c..9a9d3446c6ed 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -88,11 +88,11 @@ enum {
88 */ 88 */
89 89
90struct ib_umad_port { 90struct ib_umad_port {
91 struct cdev *dev; 91 struct cdev *cdev;
92 struct class_device *class_dev; 92 struct device *dev;
93 93
94 struct cdev *sm_dev; 94 struct cdev *sm_cdev;
95 struct class_device *sm_class_dev; 95 struct device *sm_dev;
96 struct semaphore sm_sem; 96 struct semaphore sm_sem;
97 97
98 struct mutex file_mutex; 98 struct mutex file_mutex;
@@ -948,27 +948,29 @@ static struct ib_client umad_client = {
948 .remove = ib_umad_remove_one 948 .remove = ib_umad_remove_one
949}; 949};
950 950
951static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 951static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
952 char *buf)
952{ 953{
953 struct ib_umad_port *port = class_get_devdata(class_dev); 954 struct ib_umad_port *port = dev_get_drvdata(dev);
954 955
955 if (!port) 956 if (!port)
956 return -ENODEV; 957 return -ENODEV;
957 958
958 return sprintf(buf, "%s\n", port->ib_dev->name); 959 return sprintf(buf, "%s\n", port->ib_dev->name);
959} 960}
960static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 961static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
961 962
962static ssize_t show_port(struct class_device *class_dev, char *buf) 963static ssize_t show_port(struct device *dev, struct device_attribute *attr,
964 char *buf)
963{ 965{
964 struct ib_umad_port *port = class_get_devdata(class_dev); 966 struct ib_umad_port *port = dev_get_drvdata(dev);
965 967
966 if (!port) 968 if (!port)
967 return -ENODEV; 969 return -ENODEV;
968 970
969 return sprintf(buf, "%d\n", port->port_num); 971 return sprintf(buf, "%d\n", port->port_num);
970} 972}
971static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 973static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
972 974
973static ssize_t show_abi_version(struct class *class, char *buf) 975static ssize_t show_abi_version(struct class *class, char *buf)
974{ 976{
@@ -994,48 +996,47 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
994 mutex_init(&port->file_mutex); 996 mutex_init(&port->file_mutex);
995 INIT_LIST_HEAD(&port->file_list); 997 INIT_LIST_HEAD(&port->file_list);
996 998
997 port->dev = cdev_alloc(); 999 port->cdev = cdev_alloc();
998 if (!port->dev) 1000 if (!port->cdev)
999 return -1; 1001 return -1;
1000 port->dev->owner = THIS_MODULE; 1002 port->cdev->owner = THIS_MODULE;
1001 port->dev->ops = &umad_fops; 1003 port->cdev->ops = &umad_fops;
1002 kobject_set_name(&port->dev->kobj, "umad%d", port->dev_num); 1004 kobject_set_name(&port->cdev->kobj, "umad%d", port->dev_num);
1003 if (cdev_add(port->dev, base_dev + port->dev_num, 1)) 1005 if (cdev_add(port->cdev, base_dev + port->dev_num, 1))
1004 goto err_cdev; 1006 goto err_cdev;
1005 1007
1006 port->class_dev = class_device_create(umad_class, NULL, port->dev->dev, 1008 port->dev = device_create(umad_class, device->dma_device,
1007 device->dma_device, 1009 port->cdev->dev, "umad%d", port->dev_num);
1008 "umad%d", port->dev_num); 1010 if (IS_ERR(port->dev))
1009 if (IS_ERR(port->class_dev))
1010 goto err_cdev; 1011 goto err_cdev;
1011 1012
1012 if (class_device_create_file(port->class_dev, &class_device_attr_ibdev)) 1013 if (device_create_file(port->dev, &dev_attr_ibdev))
1013 goto err_class; 1014 goto err_dev;
1014 if (class_device_create_file(port->class_dev, &class_device_attr_port)) 1015 if (device_create_file(port->dev, &dev_attr_port))
1015 goto err_class; 1016 goto err_dev;
1016 1017
1017 port->sm_dev = cdev_alloc(); 1018 port->sm_cdev = cdev_alloc();
1018 if (!port->sm_dev) 1019 if (!port->sm_cdev)
1019 goto err_class; 1020 goto err_dev;
1020 port->sm_dev->owner = THIS_MODULE; 1021 port->sm_cdev->owner = THIS_MODULE;
1021 port->sm_dev->ops = &umad_sm_fops; 1022 port->sm_cdev->ops = &umad_sm_fops;
1022 kobject_set_name(&port->sm_dev->kobj, "issm%d", port->dev_num); 1023 kobject_set_name(&port->sm_cdev->kobj, "issm%d", port->dev_num);
1023 if (cdev_add(port->sm_dev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) 1024 if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1))
1024 goto err_sm_cdev; 1025 goto err_sm_cdev;
1025 1026
1026 port->sm_class_dev = class_device_create(umad_class, NULL, port->sm_dev->dev, 1027 port->sm_dev = device_create(umad_class, device->dma_device,
1027 device->dma_device, 1028 port->sm_cdev->dev,
1028 "issm%d", port->dev_num); 1029 "issm%d", port->dev_num);
1029 if (IS_ERR(port->sm_class_dev)) 1030 if (IS_ERR(port->sm_dev))
1030 goto err_sm_cdev; 1031 goto err_sm_cdev;
1031 1032
1032 class_set_devdata(port->class_dev, port); 1033 dev_set_drvdata(port->dev, port);
1033 class_set_devdata(port->sm_class_dev, port); 1034 dev_set_drvdata(port->sm_dev, port);
1034 1035
1035 if (class_device_create_file(port->sm_class_dev, &class_device_attr_ibdev)) 1036 if (device_create_file(port->sm_dev, &dev_attr_ibdev))
1036 goto err_sm_class; 1037 goto err_sm_dev;
1037 if (class_device_create_file(port->sm_class_dev, &class_device_attr_port)) 1038 if (device_create_file(port->sm_dev, &dev_attr_port))
1038 goto err_sm_class; 1039 goto err_sm_dev;
1039 1040
1040 spin_lock(&port_lock); 1041 spin_lock(&port_lock);
1041 umad_port[port->dev_num] = port; 1042 umad_port[port->dev_num] = port;
@@ -1043,17 +1044,17 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
1043 1044
1044 return 0; 1045 return 0;
1045 1046
1046err_sm_class: 1047err_sm_dev:
1047 class_device_destroy(umad_class, port->sm_dev->dev); 1048 device_destroy(umad_class, port->sm_cdev->dev);
1048 1049
1049err_sm_cdev: 1050err_sm_cdev:
1050 cdev_del(port->sm_dev); 1051 cdev_del(port->sm_cdev);
1051 1052
1052err_class: 1053err_dev:
1053 class_device_destroy(umad_class, port->dev->dev); 1054 device_destroy(umad_class, port->cdev->dev);
1054 1055
1055err_cdev: 1056err_cdev:
1056 cdev_del(port->dev); 1057 cdev_del(port->cdev);
1057 clear_bit(port->dev_num, dev_map); 1058 clear_bit(port->dev_num, dev_map);
1058 1059
1059 return -1; 1060 return -1;
@@ -1065,14 +1066,14 @@ static void ib_umad_kill_port(struct ib_umad_port *port)
1065 int already_dead; 1066 int already_dead;
1066 int id; 1067 int id;
1067 1068
1068 class_set_devdata(port->class_dev, NULL); 1069 dev_set_drvdata(port->dev, NULL);
1069 class_set_devdata(port->sm_class_dev, NULL); 1070 dev_set_drvdata(port->sm_dev, NULL);
1070 1071
1071 class_device_destroy(umad_class, port->dev->dev); 1072 device_destroy(umad_class, port->cdev->dev);
1072 class_device_destroy(umad_class, port->sm_dev->dev); 1073 device_destroy(umad_class, port->sm_cdev->dev);
1073 1074
1074 cdev_del(port->dev); 1075 cdev_del(port->cdev);
1075 cdev_del(port->sm_dev); 1076 cdev_del(port->sm_cdev);
1076 1077
1077 spin_lock(&port_lock); 1078 spin_lock(&port_lock);
1078 umad_port[port->dev_num] = NULL; 1079 umad_port[port->dev_num] = NULL;
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index 2cad8b4b5292..376a57ce1b40 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -73,8 +73,8 @@ struct ib_uverbs_device {
73 struct kref ref; 73 struct kref ref;
74 struct completion comp; 74 struct completion comp;
75 int devnum; 75 int devnum;
76 struct cdev *dev; 76 struct cdev *cdev;
77 struct class_device *class_dev; 77 struct device *dev;
78 struct ib_device *ib_dev; 78 struct ib_device *ib_dev;
79 int num_comp_vectors; 79 int num_comp_vectors;
80}; 80};
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index f49f94653a96..cc1afa28c181 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 = {
690 .remove = ib_uverbs_remove_one 690 .remove = ib_uverbs_remove_one
691}; 691};
692 692
693static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 693static ssize_t show_ibdev(struct device *device, struct device_attribute *attr,
694 char *buf)
694{ 695{
695 struct ib_uverbs_device *dev = class_get_devdata(class_dev); 696 struct ib_uverbs_device *dev = dev_get_drvdata(device);
696 697
697 if (!dev) 698 if (!dev)
698 return -ENODEV; 699 return -ENODEV;
699 700
700 return sprintf(buf, "%s\n", dev->ib_dev->name); 701 return sprintf(buf, "%s\n", dev->ib_dev->name);
701} 702}
702static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 703static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
703 704
704static ssize_t show_dev_abi_version(struct class_device *class_dev, char *buf) 705static ssize_t show_dev_abi_version(struct device *device,
706 struct device_attribute *attr, char *buf)
705{ 707{
706 struct ib_uverbs_device *dev = class_get_devdata(class_dev); 708 struct ib_uverbs_device *dev = dev_get_drvdata(device);
707 709
708 if (!dev) 710 if (!dev)
709 return -ENODEV; 711 return -ENODEV;
710 712
711 return sprintf(buf, "%d\n", dev->ib_dev->uverbs_abi_ver); 713 return sprintf(buf, "%d\n", dev->ib_dev->uverbs_abi_ver);
712} 714}
713static CLASS_DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL); 715static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL);
714 716
715static ssize_t show_abi_version(struct class *class, char *buf) 717static ssize_t show_abi_version(struct class *class, char *buf)
716{ 718{
@@ -744,27 +746,26 @@ static void ib_uverbs_add_one(struct ib_device *device)
744 uverbs_dev->ib_dev = device; 746 uverbs_dev->ib_dev = device;
745 uverbs_dev->num_comp_vectors = device->num_comp_vectors; 747 uverbs_dev->num_comp_vectors = device->num_comp_vectors;
746 748
747 uverbs_dev->dev = cdev_alloc(); 749 uverbs_dev->cdev = cdev_alloc();
748 if (!uverbs_dev->dev) 750 if (!uverbs_dev->cdev)
749 goto err; 751 goto err;
750 uverbs_dev->dev->owner = THIS_MODULE; 752 uverbs_dev->cdev->owner = THIS_MODULE;
751 uverbs_dev->dev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops; 753 uverbs_dev->cdev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops;
752 kobject_set_name(&uverbs_dev->dev->kobj, "uverbs%d", uverbs_dev->devnum); 754 kobject_set_name(&uverbs_dev->cdev->kobj, "uverbs%d", uverbs_dev->devnum);
753 if (cdev_add(uverbs_dev->dev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) 755 if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1))
754 goto err_cdev; 756 goto err_cdev;
755 757
756 uverbs_dev->class_dev = class_device_create(uverbs_class, NULL, 758 uverbs_dev->dev = device_create(uverbs_class, device->dma_device,
757 uverbs_dev->dev->dev, 759 uverbs_dev->cdev->dev,
758 device->dma_device, 760 "uverbs%d", uverbs_dev->devnum);
759 "uverbs%d", uverbs_dev->devnum); 761 if (IS_ERR(uverbs_dev->dev))
760 if (IS_ERR(uverbs_dev->class_dev))
761 goto err_cdev; 762 goto err_cdev;
762 763
763 class_set_devdata(uverbs_dev->class_dev, uverbs_dev); 764 dev_set_drvdata(uverbs_dev->dev, uverbs_dev);
764 765
765 if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_ibdev)) 766 if (device_create_file(uverbs_dev->dev, &dev_attr_ibdev))
766 goto err_class; 767 goto err_class;
767 if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_abi_version)) 768 if (device_create_file(uverbs_dev->dev, &dev_attr_abi_version))
768 goto err_class; 769 goto err_class;
769 770
770 spin_lock(&map_lock); 771 spin_lock(&map_lock);
@@ -776,10 +777,10 @@ static void ib_uverbs_add_one(struct ib_device *device)
776 return; 777 return;
777 778
778err_class: 779err_class:
779 class_device_destroy(uverbs_class, uverbs_dev->dev->dev); 780 device_destroy(uverbs_class, uverbs_dev->cdev->dev);
780 781
781err_cdev: 782err_cdev:
782 cdev_del(uverbs_dev->dev); 783 cdev_del(uverbs_dev->cdev);
783 clear_bit(uverbs_dev->devnum, dev_map); 784 clear_bit(uverbs_dev->devnum, dev_map);
784 785
785err: 786err:
@@ -796,9 +797,9 @@ static void ib_uverbs_remove_one(struct ib_device *device)
796 if (!uverbs_dev) 797 if (!uverbs_dev)
797 return; 798 return;
798 799
799 class_set_devdata(uverbs_dev->class_dev, NULL); 800 dev_set_drvdata(uverbs_dev->dev, NULL);
800 class_device_destroy(uverbs_class, uverbs_dev->dev->dev); 801 device_destroy(uverbs_class, uverbs_dev->cdev->dev);
801 cdev_del(uverbs_dev->dev); 802 cdev_del(uverbs_dev->cdev);
802 803
803 spin_lock(&map_lock); 804 spin_lock(&map_lock);
804 dev_table[uverbs_dev->devnum] = NULL; 805 dev_table[uverbs_dev->devnum] = NULL;