aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--drivers/infiniband/hw/amso1100/c2_provider.c48
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_provider.c75
-rw-r--r--drivers/infiniband/hw/ipath/ipath_diag.c10
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c44
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h8
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c37
-rw-r--r--drivers/infiniband/hw/mlx4/main.c49
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c48
-rw-r--r--drivers/infiniband/hw/nes/nes_verbs.c48
-rw-r--r--include/rdma/ib_verbs.h2
15 files changed, 352 insertions, 319 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;
diff --git a/drivers/infiniband/hw/amso1100/c2_provider.c b/drivers/infiniband/hw/amso1100/c2_provider.c
index e10d27a6e145..6af2c0f79a67 100644
--- a/drivers/infiniband/hw/amso1100/c2_provider.c
+++ b/drivers/infiniband/hw/amso1100/c2_provider.c
@@ -523,45 +523,49 @@ static int c2_dereg_mr(struct ib_mr *ib_mr)
523 return err; 523 return err;
524} 524}
525 525
526static ssize_t show_rev(struct class_device *cdev, char *buf) 526static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
527 char *buf)
527{ 528{
528 struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev); 529 struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev);
529 pr_debug("%s:%u\n", __func__, __LINE__); 530 pr_debug("%s:%u\n", __func__, __LINE__);
530 return sprintf(buf, "%x\n", dev->props.hw_ver); 531 return sprintf(buf, "%x\n", c2dev->props.hw_ver);
531} 532}
532 533
533static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 534static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr,
535 char *buf)
534{ 536{
535 struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev); 537 struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev);
536 pr_debug("%s:%u\n", __func__, __LINE__); 538 pr_debug("%s:%u\n", __func__, __LINE__);
537 return sprintf(buf, "%x.%x.%x\n", 539 return sprintf(buf, "%x.%x.%x\n",
538 (int) (dev->props.fw_ver >> 32), 540 (int) (c2dev->props.fw_ver >> 32),
539 (int) (dev->props.fw_ver >> 16) & 0xffff, 541 (int) (c2dev->props.fw_ver >> 16) & 0xffff,
540 (int) (dev->props.fw_ver & 0xffff)); 542 (int) (c2dev->props.fw_ver & 0xffff));
541} 543}
542 544
543static ssize_t show_hca(struct class_device *cdev, char *buf) 545static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
546 char *buf)
544{ 547{
545 pr_debug("%s:%u\n", __func__, __LINE__); 548 pr_debug("%s:%u\n", __func__, __LINE__);
546 return sprintf(buf, "AMSO1100\n"); 549 return sprintf(buf, "AMSO1100\n");
547} 550}
548 551
549static ssize_t show_board(struct class_device *cdev, char *buf) 552static ssize_t show_board(struct device *dev, struct device_attribute *attr,
553 char *buf)
550{ 554{
551 pr_debug("%s:%u\n", __func__, __LINE__); 555 pr_debug("%s:%u\n", __func__, __LINE__);
552 return sprintf(buf, "%.*s\n", 32, "AMSO1100 Board ID"); 556 return sprintf(buf, "%.*s\n", 32, "AMSO1100 Board ID");
553} 557}
554 558
555static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 559static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
556static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 560static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
557static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 561static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
558static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 562static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
559 563
560static struct class_device_attribute *c2_class_attributes[] = { 564static struct device_attribute *c2_dev_attributes[] = {
561 &class_device_attr_hw_rev, 565 &dev_attr_hw_rev,
562 &class_device_attr_fw_ver, 566 &dev_attr_fw_ver,
563 &class_device_attr_hca_type, 567 &dev_attr_hca_type,
564 &class_device_attr_board_id 568 &dev_attr_board_id
565}; 569};
566 570
567static int c2_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 571static int c2_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
@@ -861,9 +865,9 @@ int c2_register_device(struct c2_dev *dev)
861 if (ret) 865 if (ret)
862 goto out1; 866 goto out1;
863 867
864 for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) { 868 for (i = 0; i < ARRAY_SIZE(c2_dev_attributes); ++i) {
865 ret = class_device_create_file(&dev->ibdev.class_dev, 869 ret = device_create_file(&dev->ibdev.dev,
866 c2_class_attributes[i]); 870 c2_dev_attributes[i]);
867 if (ret) 871 if (ret)
868 goto out0; 872 goto out0;
869 } 873 }
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c
index ca7265443c05..ab4695c1dd56 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c
@@ -1041,61 +1041,60 @@ static int iwch_query_port(struct ib_device *ibdev,
1041 return 0; 1041 return 0;
1042} 1042}
1043 1043
1044static ssize_t show_rev(struct class_device *cdev, char *buf) 1044static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
1045 char *buf)
1045{ 1046{
1046 struct iwch_dev *dev = container_of(cdev, struct iwch_dev, 1047 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
1047 ibdev.class_dev); 1048 ibdev.dev);
1048 PDBG("%s class dev 0x%p\n", __func__, cdev); 1049 PDBG("%s dev 0x%p\n", __func__, dev);
1049 return sprintf(buf, "%d\n", dev->rdev.t3cdev_p->type); 1050 return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type);
1050} 1051}
1051 1052
1052static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 1053static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf)
1053{ 1054{
1054 struct iwch_dev *dev = container_of(cdev, struct iwch_dev, 1055 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
1055 ibdev.class_dev); 1056 ibdev.dev);
1056 struct ethtool_drvinfo info; 1057 struct ethtool_drvinfo info;
1057 struct net_device *lldev = dev->rdev.t3cdev_p->lldev; 1058 struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
1058 1059
1059 PDBG("%s class dev 0x%p\n", __func__, cdev); 1060 PDBG("%s dev 0x%p\n", __func__, dev);
1060 rtnl_lock();
1061 lldev->ethtool_ops->get_drvinfo(lldev, &info); 1061 lldev->ethtool_ops->get_drvinfo(lldev, &info);
1062 rtnl_unlock();
1063 return sprintf(buf, "%s\n", info.fw_version); 1062 return sprintf(buf, "%s\n", info.fw_version);
1064} 1063}
1065 1064
1066static ssize_t show_hca(struct class_device *cdev, char *buf) 1065static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
1066 char *buf)
1067{ 1067{
1068 struct iwch_dev *dev = container_of(cdev, struct iwch_dev, 1068 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
1069 ibdev.class_dev); 1069 ibdev.dev);
1070 struct ethtool_drvinfo info; 1070 struct ethtool_drvinfo info;
1071 struct net_device *lldev = dev->rdev.t3cdev_p->lldev; 1071 struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
1072 1072
1073 PDBG("%s class dev 0x%p\n", __func__, cdev); 1073 PDBG("%s dev 0x%p\n", __func__, dev);
1074 rtnl_lock();
1075 lldev->ethtool_ops->get_drvinfo(lldev, &info); 1074 lldev->ethtool_ops->get_drvinfo(lldev, &info);
1076 rtnl_unlock();
1077 return sprintf(buf, "%s\n", info.driver); 1075 return sprintf(buf, "%s\n", info.driver);
1078} 1076}
1079 1077
1080static ssize_t show_board(struct class_device *cdev, char *buf) 1078static ssize_t show_board(struct device *dev, struct device_attribute *attr,
1079 char *buf)
1081{ 1080{
1082 struct iwch_dev *dev = container_of(cdev, struct iwch_dev, 1081 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
1083 ibdev.class_dev); 1082 ibdev.dev);
1084 PDBG("%s class dev 0x%p\n", __func__, dev); 1083 PDBG("%s dev 0x%p\n", __func__, dev);
1085 return sprintf(buf, "%x.%x\n", dev->rdev.rnic_info.pdev->vendor, 1084 return sprintf(buf, "%x.%x\n", iwch_dev->rdev.rnic_info.pdev->vendor,
1086 dev->rdev.rnic_info.pdev->device); 1085 iwch_dev->rdev.rnic_info.pdev->device);
1087} 1086}
1088 1087
1089static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 1088static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
1090static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 1089static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
1091static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 1090static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
1092static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 1091static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
1093 1092
1094static struct class_device_attribute *iwch_class_attributes[] = { 1093static struct device_attribute *iwch_class_attributes[] = {
1095 &class_device_attr_hw_rev, 1094 &dev_attr_hw_rev,
1096 &class_device_attr_fw_ver, 1095 &dev_attr_fw_ver,
1097 &class_device_attr_hca_type, 1096 &dev_attr_hca_type,
1098 &class_device_attr_board_id 1097 &dev_attr_board_id
1099}; 1098};
1100 1099
1101int iwch_register_device(struct iwch_dev *dev) 1100int iwch_register_device(struct iwch_dev *dev)
@@ -1189,8 +1188,8 @@ int iwch_register_device(struct iwch_dev *dev)
1189 goto bail1; 1188 goto bail1;
1190 1189
1191 for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) { 1190 for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) {
1192 ret = class_device_create_file(&dev->ibdev.class_dev, 1191 ret = device_create_file(&dev->ibdev.dev,
1193 iwch_class_attributes[i]); 1192 iwch_class_attributes[i]);
1194 if (ret) { 1193 if (ret) {
1195 goto bail2; 1194 goto bail2;
1196 } 1195 }
@@ -1208,8 +1207,8 @@ void iwch_unregister_device(struct iwch_dev *dev)
1208 1207
1209 PDBG("%s iwch_dev %p\n", __func__, dev); 1208 PDBG("%s iwch_dev %p\n", __func__, dev);
1210 for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) 1209 for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i)
1211 class_device_remove_file(&dev->ibdev.class_dev, 1210 device_remove_file(&dev->ibdev.dev,
1212 iwch_class_attributes[i]); 1211 iwch_class_attributes[i]);
1213 ib_unregister_device(&dev->ibdev); 1212 ib_unregister_device(&dev->ibdev);
1214 return; 1213 return;
1215} 1214}
diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c
index 6d49d2f18a88..d4ce8b63e19e 100644
--- a/drivers/infiniband/hw/ipath/ipath_diag.c
+++ b/drivers/infiniband/hw/ipath/ipath_diag.c
@@ -79,7 +79,7 @@ static const struct file_operations diagpkt_file_ops = {
79 79
80static atomic_t diagpkt_count = ATOMIC_INIT(0); 80static atomic_t diagpkt_count = ATOMIC_INIT(0);
81static struct cdev *diagpkt_cdev; 81static struct cdev *diagpkt_cdev;
82static struct class_device *diagpkt_class_dev; 82static struct device *diagpkt_dev;
83 83
84int ipath_diag_add(struct ipath_devdata *dd) 84int ipath_diag_add(struct ipath_devdata *dd)
85{ 85{
@@ -89,7 +89,7 @@ int ipath_diag_add(struct ipath_devdata *dd)
89 if (atomic_inc_return(&diagpkt_count) == 1) { 89 if (atomic_inc_return(&diagpkt_count) == 1) {
90 ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR, 90 ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR,
91 "ipath_diagpkt", &diagpkt_file_ops, 91 "ipath_diagpkt", &diagpkt_file_ops,
92 &diagpkt_cdev, &diagpkt_class_dev); 92 &diagpkt_cdev, &diagpkt_dev);
93 93
94 if (ret) { 94 if (ret) {
95 ipath_dev_err(dd, "Couldn't create ipath_diagpkt " 95 ipath_dev_err(dd, "Couldn't create ipath_diagpkt "
@@ -102,7 +102,7 @@ int ipath_diag_add(struct ipath_devdata *dd)
102 102
103 ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name, 103 ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name,
104 &diag_file_ops, &dd->diag_cdev, 104 &diag_file_ops, &dd->diag_cdev,
105 &dd->diag_class_dev); 105 &dd->diag_dev);
106 if (ret) 106 if (ret)
107 ipath_dev_err(dd, "Couldn't create %s device: %d", 107 ipath_dev_err(dd, "Couldn't create %s device: %d",
108 name, ret); 108 name, ret);
@@ -114,9 +114,9 @@ done:
114void ipath_diag_remove(struct ipath_devdata *dd) 114void ipath_diag_remove(struct ipath_devdata *dd)
115{ 115{
116 if (atomic_dec_and_test(&diagpkt_count)) 116 if (atomic_dec_and_test(&diagpkt_count))
117 ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_class_dev); 117 ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_dev);
118 118
119 ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_class_dev); 119 ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_dev);
120} 120}
121 121
122/** 122/**
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 1e627aab18bf..8b1752202e78 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -2434,11 +2434,11 @@ static ssize_t ipath_writev(struct kiocb *iocb, const struct iovec *iov,
2434static struct class *ipath_class; 2434static struct class *ipath_class;
2435 2435
2436static int init_cdev(int minor, char *name, const struct file_operations *fops, 2436static int init_cdev(int minor, char *name, const struct file_operations *fops,
2437 struct cdev **cdevp, struct class_device **class_devp) 2437 struct cdev **cdevp, struct device **devp)
2438{ 2438{
2439 const dev_t dev = MKDEV(IPATH_MAJOR, minor); 2439 const dev_t dev = MKDEV(IPATH_MAJOR, minor);
2440 struct cdev *cdev = NULL; 2440 struct cdev *cdev = NULL;
2441 struct class_device *class_dev = NULL; 2441 struct device *device = NULL;
2442 int ret; 2442 int ret;
2443 2443
2444 cdev = cdev_alloc(); 2444 cdev = cdev_alloc();
@@ -2462,12 +2462,12 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops,
2462 goto err_cdev; 2462 goto err_cdev;
2463 } 2463 }
2464 2464
2465 class_dev = class_device_create(ipath_class, NULL, dev, NULL, name); 2465 device = device_create(ipath_class, NULL, dev, name);
2466 2466
2467 if (IS_ERR(class_dev)) { 2467 if (IS_ERR(device)) {
2468 ret = PTR_ERR(class_dev); 2468 ret = PTR_ERR(device);
2469 printk(KERN_ERR IPATH_DRV_NAME ": Could not create " 2469 printk(KERN_ERR IPATH_DRV_NAME ": Could not create "
2470 "class_dev for minor %d, %s (err %d)\n", 2470 "device for minor %d, %s (err %d)\n",
2471 minor, name, -ret); 2471 minor, name, -ret);
2472 goto err_cdev; 2472 goto err_cdev;
2473 } 2473 }
@@ -2481,29 +2481,29 @@ err_cdev:
2481done: 2481done:
2482 if (ret >= 0) { 2482 if (ret >= 0) {
2483 *cdevp = cdev; 2483 *cdevp = cdev;
2484 *class_devp = class_dev; 2484 *devp = device;
2485 } else { 2485 } else {
2486 *cdevp = NULL; 2486 *cdevp = NULL;
2487 *class_devp = NULL; 2487 *devp = NULL;
2488 } 2488 }
2489 2489
2490 return ret; 2490 return ret;
2491} 2491}
2492 2492
2493int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, 2493int ipath_cdev_init(int minor, char *name, const struct file_operations *fops,
2494 struct cdev **cdevp, struct class_device **class_devp) 2494 struct cdev **cdevp, struct device **devp)
2495{ 2495{
2496 return init_cdev(minor, name, fops, cdevp, class_devp); 2496 return init_cdev(minor, name, fops, cdevp, devp);
2497} 2497}
2498 2498
2499static void cleanup_cdev(struct cdev **cdevp, 2499static void cleanup_cdev(struct cdev **cdevp,
2500 struct class_device **class_devp) 2500 struct device **devp)
2501{ 2501{
2502 struct class_device *class_dev = *class_devp; 2502 struct device *dev = *devp;
2503 2503
2504 if (class_dev) { 2504 if (dev) {
2505 class_device_unregister(class_dev); 2505 device_unregister(dev);
2506 *class_devp = NULL; 2506 *devp = NULL;
2507 } 2507 }
2508 2508
2509 if (*cdevp) { 2509 if (*cdevp) {
@@ -2513,13 +2513,13 @@ static void cleanup_cdev(struct cdev **cdevp,
2513} 2513}
2514 2514
2515void ipath_cdev_cleanup(struct cdev **cdevp, 2515void ipath_cdev_cleanup(struct cdev **cdevp,
2516 struct class_device **class_devp) 2516 struct device **devp)
2517{ 2517{
2518 cleanup_cdev(cdevp, class_devp); 2518 cleanup_cdev(cdevp, devp);
2519} 2519}
2520 2520
2521static struct cdev *wildcard_cdev; 2521static struct cdev *wildcard_cdev;
2522static struct class_device *wildcard_class_dev; 2522static struct device *wildcard_dev;
2523 2523
2524static const dev_t dev = MKDEV(IPATH_MAJOR, 0); 2524static const dev_t dev = MKDEV(IPATH_MAJOR, 0);
2525 2525
@@ -2576,7 +2576,7 @@ int ipath_user_add(struct ipath_devdata *dd)
2576 goto bail; 2576 goto bail;
2577 } 2577 }
2578 ret = init_cdev(0, "ipath", &ipath_file_ops, &wildcard_cdev, 2578 ret = init_cdev(0, "ipath", &ipath_file_ops, &wildcard_cdev,
2579 &wildcard_class_dev); 2579 &wildcard_dev);
2580 if (ret < 0) { 2580 if (ret < 0) {
2581 ipath_dev_err(dd, "Could not create wildcard " 2581 ipath_dev_err(dd, "Could not create wildcard "
2582 "minor: error %d\n", -ret); 2582 "minor: error %d\n", -ret);
@@ -2589,7 +2589,7 @@ int ipath_user_add(struct ipath_devdata *dd)
2589 snprintf(name, sizeof(name), "ipath%d", dd->ipath_unit); 2589 snprintf(name, sizeof(name), "ipath%d", dd->ipath_unit);
2590 2590
2591 ret = init_cdev(dd->ipath_unit + 1, name, &ipath_file_ops, 2591 ret = init_cdev(dd->ipath_unit + 1, name, &ipath_file_ops,
2592 &dd->user_cdev, &dd->user_class_dev); 2592 &dd->user_cdev, &dd->user_dev);
2593 if (ret < 0) 2593 if (ret < 0)
2594 ipath_dev_err(dd, "Could not create user minor %d, %s\n", 2594 ipath_dev_err(dd, "Could not create user minor %d, %s\n",
2595 dd->ipath_unit + 1, name); 2595 dd->ipath_unit + 1, name);
@@ -2604,13 +2604,13 @@ bail:
2604 2604
2605void ipath_user_remove(struct ipath_devdata *dd) 2605void ipath_user_remove(struct ipath_devdata *dd)
2606{ 2606{
2607 cleanup_cdev(&dd->user_cdev, &dd->user_class_dev); 2607 cleanup_cdev(&dd->user_cdev, &dd->user_dev);
2608 2608
2609 if (atomic_dec_return(&user_count) == 0) { 2609 if (atomic_dec_return(&user_count) == 0) {
2610 if (atomic_read(&user_setup) == 0) 2610 if (atomic_read(&user_setup) == 0)
2611 goto bail; 2611 goto bail;
2612 2612
2613 cleanup_cdev(&wildcard_cdev, &wildcard_class_dev); 2613 cleanup_cdev(&wildcard_cdev, &wildcard_dev);
2614 user_cleanup(); 2614 user_cleanup();
2615 2615
2616 atomic_set(&user_setup, 0); 2616 atomic_set(&user_setup, 0);
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index 5863cbe99303..202337ae90dc 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -466,8 +466,8 @@ struct ipath_devdata {
466 struct pci_dev *pcidev; 466 struct pci_dev *pcidev;
467 struct cdev *user_cdev; 467 struct cdev *user_cdev;
468 struct cdev *diag_cdev; 468 struct cdev *diag_cdev;
469 struct class_device *user_class_dev; 469 struct device *user_dev;
470 struct class_device *diag_class_dev; 470 struct device *diag_dev;
471 /* timer used to prevent stats overflow, error throttling, etc. */ 471 /* timer used to prevent stats overflow, error throttling, etc. */
472 struct timer_list ipath_stats_timer; 472 struct timer_list ipath_stats_timer;
473 /* timer to verify interrupts work, and fallback if possible */ 473 /* timer to verify interrupts work, and fallback if possible */
@@ -854,9 +854,9 @@ void ipath_clear_freeze(struct ipath_devdata *);
854 854
855struct file_operations; 855struct file_operations;
856int ipath_cdev_init(int minor, char *name, const struct file_operations *fops, 856int ipath_cdev_init(int minor, char *name, const struct file_operations *fops,
857 struct cdev **cdevp, struct class_device **class_devp); 857 struct cdev **cdevp, struct device **devp);
858void ipath_cdev_cleanup(struct cdev **cdevp, 858void ipath_cdev_cleanup(struct cdev **cdevp,
859 struct class_device **class_devp); 859 struct device **devp);
860 860
861int ipath_diag_add(struct ipath_devdata *); 861int ipath_diag_add(struct ipath_devdata *);
862void ipath_diag_remove(struct ipath_devdata *); 862void ipath_diag_remove(struct ipath_devdata *);
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index 320a6d018de7..c38f9aa8be8d 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -2172,18 +2172,20 @@ void ipath_unregister_ib_device(struct ipath_ibdev *dev)
2172 ib_dealloc_device(ibdev); 2172 ib_dealloc_device(ibdev);
2173} 2173}
2174 2174
2175static ssize_t show_rev(struct class_device *cdev, char *buf) 2175static ssize_t show_rev(struct device *device, struct device_attribute *attr,
2176 char *buf)
2176{ 2177{
2177 struct ipath_ibdev *dev = 2178 struct ipath_ibdev *dev =
2178 container_of(cdev, struct ipath_ibdev, ibdev.class_dev); 2179 container_of(device, struct ipath_ibdev, ibdev.dev);
2179 2180
2180 return sprintf(buf, "%x\n", dev->dd->ipath_pcirev); 2181 return sprintf(buf, "%x\n", dev->dd->ipath_pcirev);
2181} 2182}
2182 2183
2183static ssize_t show_hca(struct class_device *cdev, char *buf) 2184static ssize_t show_hca(struct device *device, struct device_attribute *attr,
2185 char *buf)
2184{ 2186{
2185 struct ipath_ibdev *dev = 2187 struct ipath_ibdev *dev =
2186 container_of(cdev, struct ipath_ibdev, ibdev.class_dev); 2188 container_of(device, struct ipath_ibdev, ibdev.dev);
2187 int ret; 2189 int ret;
2188 2190
2189 ret = dev->dd->ipath_f_get_boardname(dev->dd, buf, 128); 2191 ret = dev->dd->ipath_f_get_boardname(dev->dd, buf, 128);
@@ -2196,10 +2198,11 @@ bail:
2196 return ret; 2198 return ret;
2197} 2199}
2198 2200
2199static ssize_t show_stats(struct class_device *cdev, char *buf) 2201static ssize_t show_stats(struct device *device, struct device_attribute *attr,
2202 char *buf)
2200{ 2203{
2201 struct ipath_ibdev *dev = 2204 struct ipath_ibdev *dev =
2202 container_of(cdev, struct ipath_ibdev, ibdev.class_dev); 2205 container_of(device, struct ipath_ibdev, ibdev.dev);
2203 int i; 2206 int i;
2204 int len; 2207 int len;
2205 2208
@@ -2237,16 +2240,16 @@ static ssize_t show_stats(struct class_device *cdev, char *buf)
2237 return len; 2240 return len;
2238} 2241}
2239 2242
2240static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 2243static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
2241static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 2244static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
2242static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL); 2245static DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL);
2243static CLASS_DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); 2246static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL);
2244 2247
2245static struct class_device_attribute *ipath_class_attributes[] = { 2248static struct device_attribute *ipath_class_attributes[] = {
2246 &class_device_attr_hw_rev, 2249 &dev_attr_hw_rev,
2247 &class_device_attr_hca_type, 2250 &dev_attr_hca_type,
2248 &class_device_attr_board_id, 2251 &dev_attr_board_id,
2249 &class_device_attr_stats 2252 &dev_attr_stats
2250}; 2253};
2251 2254
2252static int ipath_verbs_register_sysfs(struct ib_device *dev) 2255static int ipath_verbs_register_sysfs(struct ib_device *dev)
@@ -2255,8 +2258,8 @@ static int ipath_verbs_register_sysfs(struct ib_device *dev)
2255 int ret; 2258 int ret;
2256 2259
2257 for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i) 2260 for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i)
2258 if (class_device_create_file(&dev->class_dev, 2261 if (device_create_file(&dev->dev,
2259 ipath_class_attributes[i])) { 2262 ipath_class_attributes[i])) {
2260 ret = 1; 2263 ret = 1;
2261 goto bail; 2264 goto bail;
2262 } 2265 }
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 136c76c7b4e7..4d9b5ac42202 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -481,42 +481,51 @@ out:
481 return err; 481 return err;
482} 482}
483 483
484static ssize_t show_hca(struct class_device *cdev, char *buf) 484static ssize_t show_hca(struct device *device, struct device_attribute *attr,
485 char *buf)
485{ 486{
486 struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); 487 struct mlx4_ib_dev *dev =
488 container_of(device, struct mlx4_ib_dev, ib_dev.dev);
487 return sprintf(buf, "MT%d\n", dev->dev->pdev->device); 489 return sprintf(buf, "MT%d\n", dev->dev->pdev->device);
488} 490}
489 491
490static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 492static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
493 char *buf)
491{ 494{
492 struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); 495 struct mlx4_ib_dev *dev =
496 container_of(device, struct mlx4_ib_dev, ib_dev.dev);
493 return sprintf(buf, "%d.%d.%d\n", (int) (dev->dev->caps.fw_ver >> 32), 497 return sprintf(buf, "%d.%d.%d\n", (int) (dev->dev->caps.fw_ver >> 32),
494 (int) (dev->dev->caps.fw_ver >> 16) & 0xffff, 498 (int) (dev->dev->caps.fw_ver >> 16) & 0xffff,
495 (int) dev->dev->caps.fw_ver & 0xffff); 499 (int) dev->dev->caps.fw_ver & 0xffff);
496} 500}
497 501
498static ssize_t show_rev(struct class_device *cdev, char *buf) 502static ssize_t show_rev(struct device *device, struct device_attribute *attr,
503 char *buf)
499{ 504{
500 struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); 505 struct mlx4_ib_dev *dev =
506 container_of(device, struct mlx4_ib_dev, ib_dev.dev);
501 return sprintf(buf, "%x\n", dev->dev->rev_id); 507 return sprintf(buf, "%x\n", dev->dev->rev_id);
502} 508}
503 509
504static ssize_t show_board(struct class_device *cdev, char *buf) 510static ssize_t show_board(struct device *device, struct device_attribute *attr,
511 char *buf)
505{ 512{
506 struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev); 513 struct mlx4_ib_dev *dev =
507 return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN, dev->dev->board_id); 514 container_of(device, struct mlx4_ib_dev, ib_dev.dev);
515 return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN,
516 dev->dev->board_id);
508} 517}
509 518
510static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 519static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
511static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 520static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
512static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 521static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
513static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 522static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
514 523
515static struct class_device_attribute *mlx4_class_attributes[] = { 524static struct device_attribute *mlx4_class_attributes[] = {
516 &class_device_attr_hw_rev, 525 &dev_attr_hw_rev,
517 &class_device_attr_fw_ver, 526 &dev_attr_fw_ver,
518 &class_device_attr_hca_type, 527 &dev_attr_hca_type,
519 &class_device_attr_board_id 528 &dev_attr_board_id
520}; 529};
521 530
522static void *mlx4_ib_add(struct mlx4_dev *dev) 531static void *mlx4_ib_add(struct mlx4_dev *dev)
@@ -640,8 +649,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
640 goto err_reg; 649 goto err_reg;
641 650
642 for (i = 0; i < ARRAY_SIZE(mlx4_class_attributes); ++i) { 651 for (i = 0; i < ARRAY_SIZE(mlx4_class_attributes); ++i) {
643 if (class_device_create_file(&ibdev->ib_dev.class_dev, 652 if (device_create_file(&ibdev->ib_dev.dev,
644 mlx4_class_attributes[i])) 653 mlx4_class_attributes[i]))
645 goto err_reg; 654 goto err_reg;
646 } 655 }
647 656
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index 81b257e18bb6..696e1f302332 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -1170,23 +1170,29 @@ static int mthca_unmap_fmr(struct list_head *fmr_list)
1170 return 0; 1170 return 0;
1171} 1171}
1172 1172
1173static ssize_t show_rev(struct class_device *cdev, char *buf) 1173static ssize_t show_rev(struct device *device, struct device_attribute *attr,
1174 char *buf)
1174{ 1175{
1175 struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); 1176 struct mthca_dev *dev =
1177 container_of(device, struct mthca_dev, ib_dev.dev);
1176 return sprintf(buf, "%x\n", dev->rev_id); 1178 return sprintf(buf, "%x\n", dev->rev_id);
1177} 1179}
1178 1180
1179static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 1181static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
1182 char *buf)
1180{ 1183{
1181 struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); 1184 struct mthca_dev *dev =
1185 container_of(device, struct mthca_dev, ib_dev.dev);
1182 return sprintf(buf, "%d.%d.%d\n", (int) (dev->fw_ver >> 32), 1186 return sprintf(buf, "%d.%d.%d\n", (int) (dev->fw_ver >> 32),
1183 (int) (dev->fw_ver >> 16) & 0xffff, 1187 (int) (dev->fw_ver >> 16) & 0xffff,
1184 (int) dev->fw_ver & 0xffff); 1188 (int) dev->fw_ver & 0xffff);
1185} 1189}
1186 1190
1187static ssize_t show_hca(struct class_device *cdev, char *buf) 1191static ssize_t show_hca(struct device *device, struct device_attribute *attr,
1192 char *buf)
1188{ 1193{
1189 struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); 1194 struct mthca_dev *dev =
1195 container_of(device, struct mthca_dev, ib_dev.dev);
1190 switch (dev->pdev->device) { 1196 switch (dev->pdev->device) {
1191 case PCI_DEVICE_ID_MELLANOX_TAVOR: 1197 case PCI_DEVICE_ID_MELLANOX_TAVOR:
1192 return sprintf(buf, "MT23108\n"); 1198 return sprintf(buf, "MT23108\n");
@@ -1202,22 +1208,24 @@ static ssize_t show_hca(struct class_device *cdev, char *buf)
1202 } 1208 }
1203} 1209}
1204 1210
1205static ssize_t show_board(struct class_device *cdev, char *buf) 1211static ssize_t show_board(struct device *device, struct device_attribute *attr,
1212 char *buf)
1206{ 1213{
1207 struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev); 1214 struct mthca_dev *dev =
1215 container_of(device, struct mthca_dev, ib_dev.dev);
1208 return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id); 1216 return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id);
1209} 1217}
1210 1218
1211static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 1219static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
1212static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 1220static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
1213static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 1221static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
1214static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 1222static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
1215 1223
1216static struct class_device_attribute *mthca_class_attributes[] = { 1224static struct device_attribute *mthca_dev_attributes[] = {
1217 &class_device_attr_hw_rev, 1225 &dev_attr_hw_rev,
1218 &class_device_attr_fw_ver, 1226 &dev_attr_fw_ver,
1219 &class_device_attr_hca_type, 1227 &dev_attr_hca_type,
1220 &class_device_attr_board_id 1228 &dev_attr_board_id
1221}; 1229};
1222 1230
1223static int mthca_init_node_data(struct mthca_dev *dev) 1231static int mthca_init_node_data(struct mthca_dev *dev)
@@ -1379,9 +1387,9 @@ int mthca_register_device(struct mthca_dev *dev)
1379 if (ret) 1387 if (ret)
1380 return ret; 1388 return ret;
1381 1389
1382 for (i = 0; i < ARRAY_SIZE(mthca_class_attributes); ++i) { 1390 for (i = 0; i < ARRAY_SIZE(mthca_dev_attributes); ++i) {
1383 ret = class_device_create_file(&dev->ib_dev.class_dev, 1391 ret = device_create_file(&dev->ib_dev.dev,
1384 mthca_class_attributes[i]); 1392 mthca_dev_attributes[i]);
1385 if (ret) { 1393 if (ret) {
1386 ib_unregister_device(&dev->ib_dev); 1394 ib_unregister_device(&dev->ib_dev);
1387 return ret; 1395 return ret;
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index 7c27420c2240..f9a5d4390892 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -2800,10 +2800,11 @@ static int nes_dereg_mr(struct ib_mr *ib_mr)
2800/** 2800/**
2801 * show_rev 2801 * show_rev
2802 */ 2802 */
2803static ssize_t show_rev(struct class_device *cdev, char *buf) 2803static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
2804 char *buf)
2804{ 2805{
2805 struct nes_ib_device *nesibdev = 2806 struct nes_ib_device *nesibdev =
2806 container_of(cdev, struct nes_ib_device, ibdev.class_dev); 2807 container_of(dev, struct nes_ib_device, ibdev.dev);
2807 struct nes_vnic *nesvnic = nesibdev->nesvnic; 2808 struct nes_vnic *nesvnic = nesibdev->nesvnic;
2808 2809
2809 nes_debug(NES_DBG_INIT, "\n"); 2810 nes_debug(NES_DBG_INIT, "\n");
@@ -2814,10 +2815,11 @@ static ssize_t show_rev(struct class_device *cdev, char *buf)
2814/** 2815/**
2815 * show_fw_ver 2816 * show_fw_ver
2816 */ 2817 */
2817static ssize_t show_fw_ver(struct class_device *cdev, char *buf) 2818static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr,
2819 char *buf)
2818{ 2820{
2819 struct nes_ib_device *nesibdev = 2821 struct nes_ib_device *nesibdev =
2820 container_of(cdev, struct nes_ib_device, ibdev.class_dev); 2822 container_of(dev, struct nes_ib_device, ibdev.dev);
2821 struct nes_vnic *nesvnic = nesibdev->nesvnic; 2823 struct nes_vnic *nesvnic = nesibdev->nesvnic;
2822 2824
2823 nes_debug(NES_DBG_INIT, "\n"); 2825 nes_debug(NES_DBG_INIT, "\n");
@@ -2831,7 +2833,8 @@ static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
2831/** 2833/**
2832 * show_hca 2834 * show_hca
2833 */ 2835 */
2834static ssize_t show_hca(struct class_device *cdev, char *buf) 2836static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
2837 char *buf)
2835{ 2838{
2836 nes_debug(NES_DBG_INIT, "\n"); 2839 nes_debug(NES_DBG_INIT, "\n");
2837 return sprintf(buf, "NES020\n"); 2840 return sprintf(buf, "NES020\n");
@@ -2841,23 +2844,24 @@ static ssize_t show_hca(struct class_device *cdev, char *buf)
2841/** 2844/**
2842 * show_board 2845 * show_board
2843 */ 2846 */
2844static ssize_t show_board(struct class_device *cdev, char *buf) 2847static ssize_t show_board(struct device *dev, struct device_attribute *attr,
2848 char *buf)
2845{ 2849{
2846 nes_debug(NES_DBG_INIT, "\n"); 2850 nes_debug(NES_DBG_INIT, "\n");
2847 return sprintf(buf, "%.*s\n", 32, "NES020 Board ID"); 2851 return sprintf(buf, "%.*s\n", 32, "NES020 Board ID");
2848} 2852}
2849 2853
2850 2854
2851static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 2855static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
2852static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 2856static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
2853static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 2857static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
2854static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL); 2858static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
2855 2859
2856static struct class_device_attribute *nes_class_attributes[] = { 2860static struct device_attribute *nes_dev_attributes[] = {
2857 &class_device_attr_hw_rev, 2861 &dev_attr_hw_rev,
2858 &class_device_attr_fw_ver, 2862 &dev_attr_fw_ver,
2859 &class_device_attr_hca_type, 2863 &dev_attr_hca_type,
2860 &class_device_attr_board_id 2864 &dev_attr_board_id
2861}; 2865};
2862 2866
2863 2867
@@ -3782,7 +3786,7 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev)
3782 nesibdev->ibdev.phys_port_cnt = 1; 3786 nesibdev->ibdev.phys_port_cnt = 1;
3783 nesibdev->ibdev.num_comp_vectors = 1; 3787 nesibdev->ibdev.num_comp_vectors = 1;
3784 nesibdev->ibdev.dma_device = &nesdev->pcidev->dev; 3788 nesibdev->ibdev.dma_device = &nesdev->pcidev->dev;
3785 nesibdev->ibdev.class_dev.dev = &nesdev->pcidev->dev; 3789 nesibdev->ibdev.dev.parent = &nesdev->pcidev->dev;
3786 nesibdev->ibdev.query_device = nes_query_device; 3790 nesibdev->ibdev.query_device = nes_query_device;
3787 nesibdev->ibdev.query_port = nes_query_port; 3791 nesibdev->ibdev.query_port = nes_query_port;
3788 nesibdev->ibdev.modify_port = nes_modify_port; 3792 nesibdev->ibdev.modify_port = nes_modify_port;
@@ -3877,13 +3881,13 @@ int nes_register_ofa_device(struct nes_ib_device *nesibdev)
3877 nesibdev->max_qp = (nesadapter->max_qp-NES_FIRST_QPN) / nesadapter->port_count; 3881 nesibdev->max_qp = (nesadapter->max_qp-NES_FIRST_QPN) / nesadapter->port_count;
3878 nesibdev->max_pd = nesadapter->max_pd / nesadapter->port_count; 3882 nesibdev->max_pd = nesadapter->max_pd / nesadapter->port_count;
3879 3883
3880 for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) { 3884 for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) {
3881 ret = class_device_create_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]); 3885 ret = device_create_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]);
3882 if (ret) { 3886 if (ret) {
3883 while (i > 0) { 3887 while (i > 0) {
3884 i--; 3888 i--;
3885 class_device_remove_file(&nesibdev->ibdev.class_dev, 3889 device_remove_file(&nesibdev->ibdev.dev,
3886 nes_class_attributes[i]); 3890 nes_dev_attributes[i]);
3887 } 3891 }
3888 ib_unregister_device(&nesibdev->ibdev); 3892 ib_unregister_device(&nesibdev->ibdev);
3889 return ret; 3893 return ret;
@@ -3904,8 +3908,8 @@ static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev)
3904 struct nes_vnic *nesvnic = nesibdev->nesvnic; 3908 struct nes_vnic *nesvnic = nesibdev->nesvnic;
3905 int i; 3909 int i;
3906 3910
3907 for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) { 3911 for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) {
3908 class_device_remove_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]); 3912 device_remove_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]);
3909 } 3913 }
3910 3914
3911 if (nesvnic->of_device_registered) { 3915 if (nesvnic->of_device_registered) {
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 95bf4bac44cb..2dcbecce3f61 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1051,7 +1051,7 @@ struct ib_device {
1051 struct ib_dma_mapping_ops *dma_ops; 1051 struct ib_dma_mapping_ops *dma_ops;
1052 1052
1053 struct module *owner; 1053 struct module *owner;
1054 struct class_device class_dev; 1054 struct device dev;
1055 struct kobject *ports_parent; 1055 struct kobject *ports_parent;
1056 struct list_head port_list; 1056 struct list_head port_list;
1057 1057