aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-21 18:49:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-21 18:49:58 -0400
commite80ab411e589e00550e2e6e5a6a02d59cc730357 (patch)
tree870225ff7b5b8d03e82a996963213a4bb9cce248 /drivers/infiniband
parent529a41e36673b518c9e091f3a8d932b6b9e3c461 (diff)
parentee959b00c335d7780136c5abda37809191fe52c3 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-2.6: (36 commits) SCSI: convert struct class_device to struct device DRM: remove unused dev_class IB: rename "dev" to "srp_dev" in srp_host structure IB: convert struct class_device to struct device memstick: convert struct class_device to struct device driver core: replace remaining __FUNCTION__ occurrences sysfs: refill attribute buffer when reading from offset 0 PM: Remove destroy_suspended_device() Firmware: add iSCSI iBFT Support PM: Remove legacy PM (fix) Kobject: Replace list_for_each() with list_for_each_entry(). SYSFS: Explicitly include required header file slab.h. Driver core: make device_is_registered() work for class devices PM: Convert wakeup flag accessors to inline functions PM: Make wakeup flags available whenever CONFIG_PM is set PM: Fix misuse of wakeup flag accessors in serial core Driver core: Call device_pm_add() after bus_add_device() in device_add() PM: Handle device registrations during suspend/resume block: send disk "change" event for rescan_partitions() sysdev: detect multiple driver registrations ... Fixed trivial conflict in include/linux/memory.h due to semaphore header file change (made irrelevant by the change to mutex).
Diffstat (limited to 'drivers/infiniband')
-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--drivers/infiniband/ulp/srp/ib_srp.c181
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h4
16 files changed, 450 insertions, 404 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 be953e87bf93..3aa2db54eae4 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/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 125765aa9d59..435145709dd6 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -139,8 +139,9 @@ static struct srp_iu *srp_alloc_iu(struct srp_host *host, size_t size,
139 if (!iu->buf) 139 if (!iu->buf)
140 goto out_free_iu; 140 goto out_free_iu;
141 141
142 iu->dma = ib_dma_map_single(host->dev->dev, iu->buf, size, direction); 142 iu->dma = ib_dma_map_single(host->srp_dev->dev, iu->buf, size,
143 if (ib_dma_mapping_error(host->dev->dev, iu->dma)) 143 direction);
144 if (ib_dma_mapping_error(host->srp_dev->dev, iu->dma))
144 goto out_free_buf; 145 goto out_free_buf;
145 146
146 iu->size = size; 147 iu->size = size;
@@ -161,7 +162,8 @@ static void srp_free_iu(struct srp_host *host, struct srp_iu *iu)
161 if (!iu) 162 if (!iu)
162 return; 163 return;
163 164
164 ib_dma_unmap_single(host->dev->dev, iu->dma, iu->size, iu->direction); 165 ib_dma_unmap_single(host->srp_dev->dev, iu->dma, iu->size,
166 iu->direction);
165 kfree(iu->buf); 167 kfree(iu->buf);
166 kfree(iu); 168 kfree(iu);
167} 169}
@@ -181,7 +183,7 @@ static int srp_init_qp(struct srp_target_port *target,
181 if (!attr) 183 if (!attr)
182 return -ENOMEM; 184 return -ENOMEM;
183 185
184 ret = ib_find_cached_pkey(target->srp_host->dev->dev, 186 ret = ib_find_cached_pkey(target->srp_host->srp_dev->dev,
185 target->srp_host->port, 187 target->srp_host->port,
186 be16_to_cpu(target->path.pkey), 188 be16_to_cpu(target->path.pkey),
187 &attr->pkey_index); 189 &attr->pkey_index);
@@ -208,7 +210,7 @@ static int srp_new_cm_id(struct srp_target_port *target)
208{ 210{
209 struct ib_cm_id *new_cm_id; 211 struct ib_cm_id *new_cm_id;
210 212
211 new_cm_id = ib_create_cm_id(target->srp_host->dev->dev, 213 new_cm_id = ib_create_cm_id(target->srp_host->srp_dev->dev,
212 srp_cm_handler, target); 214 srp_cm_handler, target);
213 if (IS_ERR(new_cm_id)) 215 if (IS_ERR(new_cm_id))
214 return PTR_ERR(new_cm_id); 216 return PTR_ERR(new_cm_id);
@@ -229,8 +231,8 @@ static int srp_create_target_ib(struct srp_target_port *target)
229 if (!init_attr) 231 if (!init_attr)
230 return -ENOMEM; 232 return -ENOMEM;
231 233
232 target->cq = ib_create_cq(target->srp_host->dev->dev, srp_completion, 234 target->cq = ib_create_cq(target->srp_host->srp_dev->dev,
233 NULL, target, SRP_CQ_SIZE, 0); 235 srp_completion, NULL, target, SRP_CQ_SIZE, 0);
234 if (IS_ERR(target->cq)) { 236 if (IS_ERR(target->cq)) {
235 ret = PTR_ERR(target->cq); 237 ret = PTR_ERR(target->cq);
236 goto out; 238 goto out;
@@ -248,7 +250,7 @@ static int srp_create_target_ib(struct srp_target_port *target)
248 init_attr->send_cq = target->cq; 250 init_attr->send_cq = target->cq;
249 init_attr->recv_cq = target->cq; 251 init_attr->recv_cq = target->cq;
250 252
251 target->qp = ib_create_qp(target->srp_host->dev->pd, init_attr); 253 target->qp = ib_create_qp(target->srp_host->srp_dev->pd, init_attr);
252 if (IS_ERR(target->qp)) { 254 if (IS_ERR(target->qp)) {
253 ret = PTR_ERR(target->qp); 255 ret = PTR_ERR(target->qp);
254 ib_destroy_cq(target->cq); 256 ib_destroy_cq(target->cq);
@@ -302,7 +304,7 @@ static int srp_lookup_path(struct srp_target_port *target)
302 init_completion(&target->done); 304 init_completion(&target->done);
303 305
304 target->path_query_id = ib_sa_path_rec_get(&srp_sa_client, 306 target->path_query_id = ib_sa_path_rec_get(&srp_sa_client,
305 target->srp_host->dev->dev, 307 target->srp_host->srp_dev->dev,
306 target->srp_host->port, 308 target->srp_host->port,
307 &target->path, 309 &target->path,
308 IB_SA_PATH_REC_SERVICE_ID | 310 IB_SA_PATH_REC_SERVICE_ID |
@@ -403,7 +405,7 @@ static int srp_send_req(struct srp_target_port *target)
403 (unsigned long long) be64_to_cpu(target->ioc_guid)); 405 (unsigned long long) be64_to_cpu(target->ioc_guid));
404 memset(req->priv.initiator_port_id, 0, 8); 406 memset(req->priv.initiator_port_id, 0, 8);
405 memcpy(req->priv.initiator_port_id + 8, 407 memcpy(req->priv.initiator_port_id + 8,
406 &target->srp_host->dev->dev->node_guid, 8); 408 &target->srp_host->srp_dev->dev->node_guid, 8);
407 } 409 }
408 410
409 status = ib_send_cm_req(target->cm_id, &req->param); 411 status = ib_send_cm_req(target->cm_id, &req->param);
@@ -520,7 +522,7 @@ static void srp_unmap_data(struct scsi_cmnd *scmnd,
520 req->fmr = NULL; 522 req->fmr = NULL;
521 } 523 }
522 524
523 ib_dma_unmap_sg(target->srp_host->dev->dev, scsi_sglist(scmnd), 525 ib_dma_unmap_sg(target->srp_host->srp_dev->dev, scsi_sglist(scmnd),
524 scsi_sg_count(scmnd), scmnd->sc_data_direction); 526 scsi_sg_count(scmnd), scmnd->sc_data_direction);
525} 527}
526 528
@@ -628,7 +630,7 @@ static int srp_map_fmr(struct srp_target_port *target, struct scatterlist *scat,
628 int page_cnt; 630 int page_cnt;
629 int i, j; 631 int i, j;
630 int ret; 632 int ret;
631 struct srp_device *dev = target->srp_host->dev; 633 struct srp_device *dev = target->srp_host->srp_dev;
632 struct ib_device *ibdev = dev->dev; 634 struct ib_device *ibdev = dev->dev;
633 struct scatterlist *sg; 635 struct scatterlist *sg;
634 636
@@ -723,7 +725,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
723 nents = scsi_sg_count(scmnd); 725 nents = scsi_sg_count(scmnd);
724 scat = scsi_sglist(scmnd); 726 scat = scsi_sglist(scmnd);
725 727
726 dev = target->srp_host->dev; 728 dev = target->srp_host->srp_dev;
727 ibdev = dev->dev; 729 ibdev = dev->dev;
728 730
729 count = ib_dma_map_sg(ibdev, scat, nents, scmnd->sc_data_direction); 731 count = ib_dma_map_sg(ibdev, scat, nents, scmnd->sc_data_direction);
@@ -779,7 +781,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_target_port *target,
779 buf->table_desc.va = 781 buf->table_desc.va =
780 cpu_to_be64(req->cmd->dma + sizeof *cmd + sizeof *buf); 782 cpu_to_be64(req->cmd->dma + sizeof *cmd + sizeof *buf);
781 buf->table_desc.key = 783 buf->table_desc.key =
782 cpu_to_be32(target->srp_host->dev->mr->rkey); 784 cpu_to_be32(target->srp_host->srp_dev->mr->rkey);
783 buf->table_desc.len = 785 buf->table_desc.len =
784 cpu_to_be32(count * sizeof (struct srp_direct_buf)); 786 cpu_to_be32(count * sizeof (struct srp_direct_buf));
785 787
@@ -855,7 +857,7 @@ static void srp_handle_recv(struct srp_target_port *target, struct ib_wc *wc)
855 857
856 iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV]; 858 iu = target->rx_ring[wc->wr_id & ~SRP_OP_RECV];
857 859
858 dev = target->srp_host->dev->dev; 860 dev = target->srp_host->srp_dev->dev;
859 ib_dma_sync_single_for_cpu(dev, iu->dma, target->max_ti_iu_len, 861 ib_dma_sync_single_for_cpu(dev, iu->dma, target->max_ti_iu_len,
860 DMA_FROM_DEVICE); 862 DMA_FROM_DEVICE);
861 863
@@ -937,7 +939,7 @@ static int __srp_post_recv(struct srp_target_port *target)
937 939
938 list.addr = iu->dma; 940 list.addr = iu->dma;
939 list.length = iu->size; 941 list.length = iu->size;
940 list.lkey = target->srp_host->dev->mr->lkey; 942 list.lkey = target->srp_host->srp_dev->mr->lkey;
941 943
942 wr.next = NULL; 944 wr.next = NULL;
943 wr.sg_list = &list; 945 wr.sg_list = &list;
@@ -996,7 +998,7 @@ static int __srp_post_send(struct srp_target_port *target,
996 998
997 list.addr = iu->dma; 999 list.addr = iu->dma;
998 list.length = len; 1000 list.length = len;
999 list.lkey = target->srp_host->dev->mr->lkey; 1001 list.lkey = target->srp_host->srp_dev->mr->lkey;
1000 1002
1001 wr.next = NULL; 1003 wr.next = NULL;
1002 wr.wr_id = target->tx_head & SRP_SQ_SIZE; 1004 wr.wr_id = target->tx_head & SRP_SQ_SIZE;
@@ -1039,7 +1041,7 @@ static int srp_queuecommand(struct scsi_cmnd *scmnd,
1039 if (!iu) 1041 if (!iu)
1040 goto err; 1042 goto err;
1041 1043
1042 dev = target->srp_host->dev->dev; 1044 dev = target->srp_host->srp_dev->dev;
1043 ib_dma_sync_single_for_cpu(dev, iu->dma, srp_max_iu_len, 1045 ib_dma_sync_single_for_cpu(dev, iu->dma, srp_max_iu_len,
1044 DMA_TO_DEVICE); 1046 DMA_TO_DEVICE);
1045 1047
@@ -1456,9 +1458,10 @@ static int srp_reset_host(struct scsi_cmnd *scmnd)
1456 return ret; 1458 return ret;
1457} 1459}
1458 1460
1459static ssize_t show_id_ext(struct class_device *cdev, char *buf) 1461static ssize_t show_id_ext(struct device *dev, struct device_attribute *attr,
1462 char *buf)
1460{ 1463{
1461 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1464 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1462 1465
1463 if (target->state == SRP_TARGET_DEAD || 1466 if (target->state == SRP_TARGET_DEAD ||
1464 target->state == SRP_TARGET_REMOVED) 1467 target->state == SRP_TARGET_REMOVED)
@@ -1468,9 +1471,10 @@ static ssize_t show_id_ext(struct class_device *cdev, char *buf)
1468 (unsigned long long) be64_to_cpu(target->id_ext)); 1471 (unsigned long long) be64_to_cpu(target->id_ext));
1469} 1472}
1470 1473
1471static ssize_t show_ioc_guid(struct class_device *cdev, char *buf) 1474static ssize_t show_ioc_guid(struct device *dev, struct device_attribute *attr,
1475 char *buf)
1472{ 1476{
1473 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1477 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1474 1478
1475 if (target->state == SRP_TARGET_DEAD || 1479 if (target->state == SRP_TARGET_DEAD ||
1476 target->state == SRP_TARGET_REMOVED) 1480 target->state == SRP_TARGET_REMOVED)
@@ -1480,9 +1484,10 @@ static ssize_t show_ioc_guid(struct class_device *cdev, char *buf)
1480 (unsigned long long) be64_to_cpu(target->ioc_guid)); 1484 (unsigned long long) be64_to_cpu(target->ioc_guid));
1481} 1485}
1482 1486
1483static ssize_t show_service_id(struct class_device *cdev, char *buf) 1487static ssize_t show_service_id(struct device *dev,
1488 struct device_attribute *attr, char *buf)
1484{ 1489{
1485 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1490 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1486 1491
1487 if (target->state == SRP_TARGET_DEAD || 1492 if (target->state == SRP_TARGET_DEAD ||
1488 target->state == SRP_TARGET_REMOVED) 1493 target->state == SRP_TARGET_REMOVED)
@@ -1492,9 +1497,10 @@ static ssize_t show_service_id(struct class_device *cdev, char *buf)
1492 (unsigned long long) be64_to_cpu(target->service_id)); 1497 (unsigned long long) be64_to_cpu(target->service_id));
1493} 1498}
1494 1499
1495static ssize_t show_pkey(struct class_device *cdev, char *buf) 1500static ssize_t show_pkey(struct device *dev, struct device_attribute *attr,
1501 char *buf)
1496{ 1502{
1497 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1503 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1498 1504
1499 if (target->state == SRP_TARGET_DEAD || 1505 if (target->state == SRP_TARGET_DEAD ||
1500 target->state == SRP_TARGET_REMOVED) 1506 target->state == SRP_TARGET_REMOVED)
@@ -1503,9 +1509,10 @@ static ssize_t show_pkey(struct class_device *cdev, char *buf)
1503 return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey)); 1509 return sprintf(buf, "0x%04x\n", be16_to_cpu(target->path.pkey));
1504} 1510}
1505 1511
1506static ssize_t show_dgid(struct class_device *cdev, char *buf) 1512static ssize_t show_dgid(struct device *dev, struct device_attribute *attr,
1513 char *buf)
1507{ 1514{
1508 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1515 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1509 1516
1510 if (target->state == SRP_TARGET_DEAD || 1517 if (target->state == SRP_TARGET_DEAD ||
1511 target->state == SRP_TARGET_REMOVED) 1518 target->state == SRP_TARGET_REMOVED)
@@ -1522,9 +1529,10 @@ static ssize_t show_dgid(struct class_device *cdev, char *buf)
1522 be16_to_cpu(((__be16 *) target->path.dgid.raw)[7])); 1529 be16_to_cpu(((__be16 *) target->path.dgid.raw)[7]));
1523} 1530}
1524 1531
1525static ssize_t show_orig_dgid(struct class_device *cdev, char *buf) 1532static ssize_t show_orig_dgid(struct device *dev,
1533 struct device_attribute *attr, char *buf)
1526{ 1534{
1527 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1535 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1528 1536
1529 if (target->state == SRP_TARGET_DEAD || 1537 if (target->state == SRP_TARGET_DEAD ||
1530 target->state == SRP_TARGET_REMOVED) 1538 target->state == SRP_TARGET_REMOVED)
@@ -1541,9 +1549,10 @@ static ssize_t show_orig_dgid(struct class_device *cdev, char *buf)
1541 be16_to_cpu(target->orig_dgid[7])); 1549 be16_to_cpu(target->orig_dgid[7]));
1542} 1550}
1543 1551
1544static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf) 1552static ssize_t show_zero_req_lim(struct device *dev,
1553 struct device_attribute *attr, char *buf)
1545{ 1554{
1546 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1555 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1547 1556
1548 if (target->state == SRP_TARGET_DEAD || 1557 if (target->state == SRP_TARGET_DEAD ||
1549 target->state == SRP_TARGET_REMOVED) 1558 target->state == SRP_TARGET_REMOVED)
@@ -1552,40 +1561,42 @@ static ssize_t show_zero_req_lim(struct class_device *cdev, char *buf)
1552 return sprintf(buf, "%d\n", target->zero_req_lim); 1561 return sprintf(buf, "%d\n", target->zero_req_lim);
1553} 1562}
1554 1563
1555static ssize_t show_local_ib_port(struct class_device *cdev, char *buf) 1564static ssize_t show_local_ib_port(struct device *dev,
1565 struct device_attribute *attr, char *buf)
1556{ 1566{
1557 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1567 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1558 1568
1559 return sprintf(buf, "%d\n", target->srp_host->port); 1569 return sprintf(buf, "%d\n", target->srp_host->port);
1560} 1570}
1561 1571
1562static ssize_t show_local_ib_device(struct class_device *cdev, char *buf) 1572static ssize_t show_local_ib_device(struct device *dev,
1573 struct device_attribute *attr, char *buf)
1563{ 1574{
1564 struct srp_target_port *target = host_to_target(class_to_shost(cdev)); 1575 struct srp_target_port *target = host_to_target(class_to_shost(dev));
1565 1576
1566 return sprintf(buf, "%s\n", target->srp_host->dev->dev->name); 1577 return sprintf(buf, "%s\n", target->srp_host->srp_dev->dev->name);
1567} 1578}
1568 1579
1569static CLASS_DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL); 1580static DEVICE_ATTR(id_ext, S_IRUGO, show_id_ext, NULL);
1570static CLASS_DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL); 1581static DEVICE_ATTR(ioc_guid, S_IRUGO, show_ioc_guid, NULL);
1571static CLASS_DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL); 1582static DEVICE_ATTR(service_id, S_IRUGO, show_service_id, NULL);
1572static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL); 1583static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
1573static CLASS_DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL); 1584static DEVICE_ATTR(dgid, S_IRUGO, show_dgid, NULL);
1574static CLASS_DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL); 1585static DEVICE_ATTR(orig_dgid, S_IRUGO, show_orig_dgid, NULL);
1575static CLASS_DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL); 1586static DEVICE_ATTR(zero_req_lim, S_IRUGO, show_zero_req_lim, NULL);
1576static CLASS_DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL); 1587static DEVICE_ATTR(local_ib_port, S_IRUGO, show_local_ib_port, NULL);
1577static CLASS_DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL); 1588static DEVICE_ATTR(local_ib_device, S_IRUGO, show_local_ib_device, NULL);
1578 1589
1579static struct class_device_attribute *srp_host_attrs[] = { 1590static struct device_attribute *srp_host_attrs[] = {
1580 &class_device_attr_id_ext, 1591 &dev_attr_id_ext,
1581 &class_device_attr_ioc_guid, 1592 &dev_attr_ioc_guid,
1582 &class_device_attr_service_id, 1593 &dev_attr_service_id,
1583 &class_device_attr_pkey, 1594 &dev_attr_pkey,
1584 &class_device_attr_dgid, 1595 &dev_attr_dgid,
1585 &class_device_attr_orig_dgid, 1596 &dev_attr_orig_dgid,
1586 &class_device_attr_zero_req_lim, 1597 &dev_attr_zero_req_lim,
1587 &class_device_attr_local_ib_port, 1598 &dev_attr_local_ib_port,
1588 &class_device_attr_local_ib_device, 1599 &dev_attr_local_ib_device,
1589 NULL 1600 NULL
1590}; 1601};
1591 1602
@@ -1613,7 +1624,7 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
1613 sprintf(target->target_name, "SRP.T10:%016llX", 1624 sprintf(target->target_name, "SRP.T10:%016llX",
1614 (unsigned long long) be64_to_cpu(target->id_ext)); 1625 (unsigned long long) be64_to_cpu(target->id_ext));
1615 1626
1616 if (scsi_add_host(target->scsi_host, host->dev->dev->dma_device)) 1627 if (scsi_add_host(target->scsi_host, host->srp_dev->dev->dma_device))
1617 return -ENODEV; 1628 return -ENODEV;
1618 1629
1619 memcpy(ids.port_id, &target->id_ext, 8); 1630 memcpy(ids.port_id, &target->id_ext, 8);
@@ -1637,17 +1648,17 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target)
1637 return 0; 1648 return 0;
1638} 1649}
1639 1650
1640static void srp_release_class_dev(struct class_device *class_dev) 1651static void srp_release_dev(struct device *dev)
1641{ 1652{
1642 struct srp_host *host = 1653 struct srp_host *host =
1643 container_of(class_dev, struct srp_host, class_dev); 1654 container_of(dev, struct srp_host, dev);
1644 1655
1645 complete(&host->released); 1656 complete(&host->released);
1646} 1657}
1647 1658
1648static struct class srp_class = { 1659static struct class srp_class = {
1649 .name = "infiniband_srp", 1660 .name = "infiniband_srp",
1650 .release = srp_release_class_dev 1661 .dev_release = srp_release_dev
1651}; 1662};
1652 1663
1653/* 1664/*
@@ -1835,11 +1846,12 @@ out:
1835 return ret; 1846 return ret;
1836} 1847}
1837 1848
1838static ssize_t srp_create_target(struct class_device *class_dev, 1849static ssize_t srp_create_target(struct device *dev,
1850 struct device_attribute *attr,
1839 const char *buf, size_t count) 1851 const char *buf, size_t count)
1840{ 1852{
1841 struct srp_host *host = 1853 struct srp_host *host =
1842 container_of(class_dev, struct srp_host, class_dev); 1854 container_of(dev, struct srp_host, dev);
1843 struct Scsi_Host *target_host; 1855 struct Scsi_Host *target_host;
1844 struct srp_target_port *target; 1856 struct srp_target_port *target;
1845 int ret; 1857 int ret;
@@ -1871,7 +1883,8 @@ static ssize_t srp_create_target(struct class_device *class_dev,
1871 if (ret) 1883 if (ret)
1872 goto err; 1884 goto err;
1873 1885
1874 ib_get_cached_gid(host->dev->dev, host->port, 0, &target->path.sgid); 1886 ib_get_cached_gid(host->srp_dev->dev, host->port, 0,
1887 &target->path.sgid);
1875 1888
1876 shost_printk(KERN_DEBUG, target->scsi_host, PFX 1889 shost_printk(KERN_DEBUG, target->scsi_host, PFX
1877 "new target: id_ext %016llx ioc_guid %016llx pkey %04x " 1890 "new target: id_ext %016llx ioc_guid %016llx pkey %04x "
@@ -1926,27 +1939,27 @@ err:
1926 return ret; 1939 return ret;
1927} 1940}
1928 1941
1929static CLASS_DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target); 1942static DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target);
1930 1943
1931static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 1944static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
1945 char *buf)
1932{ 1946{
1933 struct srp_host *host = 1947 struct srp_host *host = container_of(dev, struct srp_host, dev);
1934 container_of(class_dev, struct srp_host, class_dev);
1935 1948
1936 return sprintf(buf, "%s\n", host->dev->dev->name); 1949 return sprintf(buf, "%s\n", host->srp_dev->dev->name);
1937} 1950}
1938 1951
1939static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 1952static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
1940 1953
1941static ssize_t show_port(struct class_device *class_dev, char *buf) 1954static ssize_t show_port(struct device *dev, struct device_attribute *attr,
1955 char *buf)
1942{ 1956{
1943 struct srp_host *host = 1957 struct srp_host *host = container_of(dev, struct srp_host, dev);
1944 container_of(class_dev, struct srp_host, class_dev);
1945 1958
1946 return sprintf(buf, "%d\n", host->port); 1959 return sprintf(buf, "%d\n", host->port);
1947} 1960}
1948 1961
1949static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 1962static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
1950 1963
1951static struct srp_host *srp_add_port(struct srp_device *device, u8 port) 1964static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
1952{ 1965{
@@ -1959,27 +1972,27 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
1959 INIT_LIST_HEAD(&host->target_list); 1972 INIT_LIST_HEAD(&host->target_list);
1960 spin_lock_init(&host->target_lock); 1973 spin_lock_init(&host->target_lock);
1961 init_completion(&host->released); 1974 init_completion(&host->released);
1962 host->dev = device; 1975 host->srp_dev = device;
1963 host->port = port; 1976 host->port = port;
1964 1977
1965 host->class_dev.class = &srp_class; 1978 host->dev.class = &srp_class;
1966 host->class_dev.dev = device->dev->dma_device; 1979 host->dev.parent = device->dev->dma_device;
1967 snprintf(host->class_dev.class_id, BUS_ID_SIZE, "srp-%s-%d", 1980 snprintf(host->dev.bus_id, BUS_ID_SIZE, "srp-%s-%d",
1968 device->dev->name, port); 1981 device->dev->name, port);
1969 1982
1970 if (class_device_register(&host->class_dev)) 1983 if (device_register(&host->dev))
1971 goto free_host; 1984 goto free_host;
1972 if (class_device_create_file(&host->class_dev, &class_device_attr_add_target)) 1985 if (device_create_file(&host->dev, &dev_attr_add_target))
1973 goto err_class; 1986 goto err_class;
1974 if (class_device_create_file(&host->class_dev, &class_device_attr_ibdev)) 1987 if (device_create_file(&host->dev, &dev_attr_ibdev))
1975 goto err_class; 1988 goto err_class;
1976 if (class_device_create_file(&host->class_dev, &class_device_attr_port)) 1989 if (device_create_file(&host->dev, &dev_attr_port))
1977 goto err_class; 1990 goto err_class;
1978 1991
1979 return host; 1992 return host;
1980 1993
1981err_class: 1994err_class:
1982 class_device_unregister(&host->class_dev); 1995 device_unregister(&host->dev);
1983 1996
1984free_host: 1997free_host:
1985 kfree(host); 1998 kfree(host);
@@ -2084,7 +2097,7 @@ static void srp_remove_one(struct ib_device *device)
2084 srp_dev = ib_get_client_data(device, &srp_client); 2097 srp_dev = ib_get_client_data(device, &srp_client);
2085 2098
2086 list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) { 2099 list_for_each_entry_safe(host, tmp_host, &srp_dev->dev_list, list) {
2087 class_device_unregister(&host->class_dev); 2100 device_unregister(&host->dev);
2088 /* 2101 /*
2089 * Wait for the sysfs entry to go away, so that no new 2102 * Wait for the sysfs entry to go away, so that no new
2090 * target ports can be created. 2103 * target ports can be created.
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index cb6eb816024a..63d2ae724061 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -97,9 +97,9 @@ struct srp_device {
97}; 97};
98 98
99struct srp_host { 99struct srp_host {
100 struct srp_device *dev; 100 struct srp_device *srp_dev;
101 u8 port; 101 u8 port;
102 struct class_device class_dev; 102 struct device dev;
103 struct list_head target_list; 103 struct list_head target_list;
104 spinlock_t target_lock; 104 spinlock_t target_lock;
105 struct completion released; 105 struct completion released;