IB: convert struct class_device to struct device
authorTony Jones <tonyj@suse.de>
Thu, 21 Feb 2008 23:13:36 +0000 (00:13 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 20 Apr 2008 02:10:30 +0000 (19:10 -0700)
This converts the main ib_device to use struct device instead of struct
class_device as class_device is going away.

Signed-off-by: Tony Jones <tonyj@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Cc: Roland Dreier <rolandd@cisco.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
15 files changed:
drivers/infiniband/core/sysfs.c
drivers/infiniband/core/ucm.c
drivers/infiniband/core/user_mad.c
drivers/infiniband/core/uverbs.h
drivers/infiniband/core/uverbs_main.c
drivers/infiniband/hw/amso1100/c2_provider.c
drivers/infiniband/hw/cxgb3/iwch_provider.c
drivers/infiniband/hw/ipath/ipath_diag.c
drivers/infiniband/hw/ipath/ipath_file_ops.c
drivers/infiniband/hw/ipath/ipath_kernel.h
drivers/infiniband/hw/ipath/ipath_verbs.c
drivers/infiniband/hw/mlx4/main.c
drivers/infiniband/hw/mthca/mthca_provider.c
drivers/infiniband/hw/nes/nes_verbs.c
include/rdma/ib_verbs.h

index 5a4b2e65534b4b4fcd1fc878a0477dc5096126b1..95756551cf7c94bb9c6679168c1a6a19d2381082 100644 (file)
@@ -427,17 +427,17 @@ static struct kobj_type port_type = {
        .default_attrs = port_default_attrs
 };
 
-static void ib_device_release(struct class_device *cdev)
+static void ib_device_release(struct device *device)
 {
-       struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+       struct ib_device *dev = container_of(device, struct ib_device, dev);
 
        kfree(dev);
 }
 
-static int ib_device_uevent(struct class_device *cdev,
+static int ib_device_uevent(struct device *device,
                            struct kobj_uevent_env *env)
 {
-       struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+       struct ib_device *dev = container_of(device, struct ib_device, dev);
 
        if (add_uevent_var(env, "NAME=%s", dev->name))
                return -ENOMEM;
@@ -567,9 +567,10 @@ err_put:
        return ret;
 }
 
-static ssize_t show_node_type(struct class_device *cdev, char *buf)
+static ssize_t show_node_type(struct device *device,
+                             struct device_attribute *attr, char *buf)
 {
-       struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+       struct ib_device *dev = container_of(device, struct ib_device, dev);
 
        if (!ibdev_is_alive(dev))
                return -ENODEV;
@@ -583,9 +584,10 @@ static ssize_t show_node_type(struct class_device *cdev, char *buf)
        }
 }
 
-static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf)
+static ssize_t show_sys_image_guid(struct device *device,
+                                  struct device_attribute *dev_attr, char *buf)
 {
-       struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+       struct ib_device *dev = container_of(device, struct ib_device, dev);
        struct ib_device_attr attr;
        ssize_t ret;
 
@@ -603,9 +605,10 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf)
                       be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3]));
 }
 
-static ssize_t show_node_guid(struct class_device *cdev, char *buf)
+static ssize_t show_node_guid(struct device *device,
+                             struct device_attribute *attr, char *buf)
 {
-       struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+       struct ib_device *dev = container_of(device, struct ib_device, dev);
 
        if (!ibdev_is_alive(dev))
                return -ENODEV;
@@ -617,17 +620,19 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf)
                       be16_to_cpu(((__be16 *) &dev->node_guid)[3]));
 }
 
-static ssize_t show_node_desc(struct class_device *cdev, char *buf)
+static ssize_t show_node_desc(struct device *device,
+                             struct device_attribute *attr, char *buf)
 {
-       struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+       struct ib_device *dev = container_of(device, struct ib_device, dev);
 
        return sprintf(buf, "%.64s\n", dev->node_desc);
 }
 
-static ssize_t set_node_desc(struct class_device *cdev, const char *buf,
-                             size_t count)
+static ssize_t set_node_desc(struct device *device,
+                            struct device_attribute *attr,
+                            const char *buf, size_t count)
 {
-       struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
+       struct ib_device *dev = container_of(device, struct ib_device, dev);
        struct ib_device_modify desc = {};
        int ret;
 
@@ -642,44 +647,43 @@ static ssize_t set_node_desc(struct class_device *cdev, const char *buf,
        return count;
 }
 
-static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
-static CLASS_DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL);
-static CLASS_DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL);
-static CLASS_DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc,
-                        set_node_desc);
-
-static struct class_device_attribute *ib_class_attributes[] = {
-       &class_device_attr_node_type,
-       &class_device_attr_sys_image_guid,
-       &class_device_attr_node_guid,
-       &class_device_attr_node_desc
+static DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
+static DEVICE_ATTR(sys_image_guid, S_IRUGO, show_sys_image_guid, NULL);
+static DEVICE_ATTR(node_guid, S_IRUGO, show_node_guid, NULL);
+static DEVICE_ATTR(node_desc, S_IRUGO | S_IWUSR, show_node_desc, set_node_desc);
+
+static struct device_attribute *ib_class_attributes[] = {
+       &dev_attr_node_type,
+       &dev_attr_sys_image_guid,
+       &dev_attr_node_guid,
+       &dev_attr_node_desc
 };
 
 static struct class ib_class = {
        .name    = "infiniband",
-       .release = ib_device_release,
-       .uevent = ib_device_uevent,
+       .dev_release = ib_device_release,
+       .dev_uevent = ib_device_uevent,
 };
 
 int ib_device_register_sysfs(struct ib_device *device)
 {
-       struct class_device *class_dev = &device->class_dev;
+       struct device *class_dev = &device->dev;
        int ret;
        int i;
 
        class_dev->class      = &ib_class;
-       class_dev->class_data = device;
-       class_dev->dev        = device->dma_device;
-       strlcpy(class_dev->class_id, device->name, BUS_ID_SIZE);
+       class_dev->driver_data = device;
+       class_dev->parent     = device->dma_device;
+       strlcpy(class_dev->bus_id, device->name, BUS_ID_SIZE);
 
        INIT_LIST_HEAD(&device->port_list);
 
-       ret = class_device_register(class_dev);
+       ret = device_register(class_dev);
        if (ret)
                goto err;
 
        for (i = 0; i < ARRAY_SIZE(ib_class_attributes); ++i) {
-               ret = class_device_create_file(class_dev, ib_class_attributes[i]);
+               ret = device_create_file(class_dev, ib_class_attributes[i]);
                if (ret)
                        goto err_unregister;
        }
@@ -723,7 +727,7 @@ err_put:
        kobject_put(&class_dev->kobj);
 
 err_unregister:
-       class_device_unregister(class_dev);
+       device_unregister(class_dev);
 
 err:
        return ret;
@@ -744,7 +748,7 @@ void ib_device_unregister_sysfs(struct ib_device *device)
        }
 
        kobject_put(device->ports_parent);
-       class_device_unregister(&device->class_dev);
+       device_unregister(&device->dev);
 }
 
 int ib_sysfs_setup(void)
index 4291ab42a5b9c60fb78eeecdf09087b9af10f58b..d7a6881b571d990ec1fd47ba959126ac68a64b7e 100644 (file)
@@ -58,8 +58,8 @@ MODULE_LICENSE("Dual BSD/GPL");
 
 struct ib_ucm_device {
        int                     devnum;
-       struct cdev             dev;
-       struct class_device     class_dev;
+       struct cdev             cdev;
+       struct device           dev;
        struct ib_device        *ib_dev;
 };
 
@@ -1171,7 +1171,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp)
 
        filp->private_data = file;
        file->filp = filp;
-       file->device = container_of(inode->i_cdev, struct ib_ucm_device, dev);
+       file->device = container_of(inode->i_cdev, struct ib_ucm_device, cdev);
 
        return 0;
 }
@@ -1202,14 +1202,14 @@ static int ib_ucm_close(struct inode *inode, struct file *filp)
        return 0;
 }
 
-static void ucm_release_class_dev(struct class_device *class_dev)
+static void ib_ucm_release_dev(struct device *dev)
 {
-       struct ib_ucm_device *dev;
+       struct ib_ucm_device *ucm_dev;
 
-       dev = container_of(class_dev, struct ib_ucm_device, class_dev);
-       cdev_del(&dev->dev);
-       clear_bit(dev->devnum, dev_map);
-       kfree(dev);
+       ucm_dev = container_of(dev, struct ib_ucm_device, dev);
+       cdev_del(&ucm_dev->cdev);
+       clear_bit(ucm_dev->devnum, dev_map);
+       kfree(ucm_dev);
 }
 
 static const struct file_operations ucm_fops = {
@@ -1220,14 +1220,15 @@ static const struct file_operations ucm_fops = {
        .poll    = ib_ucm_poll,
 };
 
-static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
+static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
+                         char *buf)
 {
-       struct ib_ucm_device *dev;
+       struct ib_ucm_device *ucm_dev;
 
-       dev = container_of(class_dev, struct ib_ucm_device, class_dev);
-       return sprintf(buf, "%s\n", dev->ib_dev->name);
+       ucm_dev = container_of(dev, struct ib_ucm_device, dev);
+       return sprintf(buf, "%s\n", ucm_dev->ib_dev->name);
 }
-static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
+static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
 
 static void ib_ucm_add_one(struct ib_device *device)
 {
@@ -1249,32 +1250,31 @@ static void ib_ucm_add_one(struct ib_device *device)
 
        set_bit(ucm_dev->devnum, dev_map);
 
-       cdev_init(&ucm_dev->dev, &ucm_fops);
-       ucm_dev->dev.owner = THIS_MODULE;
-       kobject_set_name(&ucm_dev->dev.kobj, "ucm%d", ucm_dev->devnum);
-       if (cdev_add(&ucm_dev->dev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1))
+       cdev_init(&ucm_dev->cdev, &ucm_fops);
+       ucm_dev->cdev.owner = THIS_MODULE;
+       kobject_set_name(&ucm_dev->cdev.kobj, "ucm%d", ucm_dev->devnum);
+       if (cdev_add(&ucm_dev->cdev, IB_UCM_BASE_DEV + ucm_dev->devnum, 1))
                goto err;
 
-       ucm_dev->class_dev.class = &cm_class;
-       ucm_dev->class_dev.dev = device->dma_device;
-       ucm_dev->class_dev.devt = ucm_dev->dev.dev;
-       ucm_dev->class_dev.release = ucm_release_class_dev;
-       snprintf(ucm_dev->class_dev.class_id, BUS_ID_SIZE, "ucm%d",
+       ucm_dev->dev.class = &cm_class;
+       ucm_dev->dev.parent = device->dma_device;
+       ucm_dev->dev.devt = ucm_dev->cdev.dev;
+       ucm_dev->dev.release = ib_ucm_release_dev;
+       snprintf(ucm_dev->dev.bus_id, BUS_ID_SIZE, "ucm%d",
                 ucm_dev->devnum);
-       if (class_device_register(&ucm_dev->class_dev))
+       if (device_register(&ucm_dev->dev))
                goto err_cdev;
 
-       if (class_device_create_file(&ucm_dev->class_dev,
-                                    &class_device_attr_ibdev))
-               goto err_class;
+       if (device_create_file(&ucm_dev->dev, &dev_attr_ibdev))
+               goto err_dev;
 
        ib_set_client_data(device, &ucm_client, ucm_dev);
        return;
 
-err_class:
-       class_device_unregister(&ucm_dev->class_dev);
+err_dev:
+       device_unregister(&ucm_dev->dev);
 err_cdev:
-       cdev_del(&ucm_dev->dev);
+       cdev_del(&ucm_dev->cdev);
        clear_bit(ucm_dev->devnum, dev_map);
 err:
        kfree(ucm_dev);
@@ -1288,7 +1288,7 @@ static void ib_ucm_remove_one(struct ib_device *device)
        if (!ucm_dev)
                return;
 
-       class_device_unregister(&ucm_dev->class_dev);
+       device_unregister(&ucm_dev->dev);
 }
 
 static ssize_t show_abi_version(struct class *class, char *buf)
index 4e915104ac4ca38e70569896a746c5686fba28ac..9a9d3446c6edb0710540c6df6010c049c9bbe088 100644 (file)
@@ -88,11 +88,11 @@ enum {
  */
 
 struct ib_umad_port {
-       struct cdev           *dev;
-       struct class_device   *class_dev;
+       struct cdev           *cdev;
+       struct device         *dev;
 
-       struct cdev           *sm_dev;
-       struct class_device   *sm_class_dev;
+       struct cdev           *sm_cdev;
+       struct device         *sm_dev;
        struct semaphore       sm_sem;
 
        struct mutex           file_mutex;
@@ -948,27 +948,29 @@ static struct ib_client umad_client = {
        .remove = ib_umad_remove_one
 };
 
-static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
+static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
+                         char *buf)
 {
-       struct ib_umad_port *port = class_get_devdata(class_dev);
+       struct ib_umad_port *port = dev_get_drvdata(dev);
 
        if (!port)
                return -ENODEV;
 
        return sprintf(buf, "%s\n", port->ib_dev->name);
 }
-static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
+static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
 
-static ssize_t show_port(struct class_device *class_dev, char *buf)
+static ssize_t show_port(struct device *dev, struct device_attribute *attr,
+                        char *buf)
 {
-       struct ib_umad_port *port = class_get_devdata(class_dev);
+       struct ib_umad_port *port = dev_get_drvdata(dev);
 
        if (!port)
                return -ENODEV;
 
        return sprintf(buf, "%d\n", port->port_num);
 }
-static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
+static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
 
 static ssize_t show_abi_version(struct class *class, char *buf)
 {
@@ -994,48 +996,47 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
        mutex_init(&port->file_mutex);
        INIT_LIST_HEAD(&port->file_list);
 
-       port->dev = cdev_alloc();
-       if (!port->dev)
+       port->cdev = cdev_alloc();
+       if (!port->cdev)
                return -1;
-       port->dev->owner = THIS_MODULE;
-       port->dev->ops   = &umad_fops;
-       kobject_set_name(&port->dev->kobj, "umad%d", port->dev_num);
-       if (cdev_add(port->dev, base_dev + port->dev_num, 1))
+       port->cdev->owner = THIS_MODULE;
+       port->cdev->ops   = &umad_fops;
+       kobject_set_name(&port->cdev->kobj, "umad%d", port->dev_num);
+       if (cdev_add(port->cdev, base_dev + port->dev_num, 1))
                goto err_cdev;
 
-       port->class_dev = class_device_create(umad_class, NULL, port->dev->dev,
-                                             device->dma_device,
-                                             "umad%d", port->dev_num);
-       if (IS_ERR(port->class_dev))
+       port->dev = device_create(umad_class, device->dma_device,
+                                 port->cdev->dev, "umad%d", port->dev_num);
+       if (IS_ERR(port->dev))
                goto err_cdev;
 
-       if (class_device_create_file(port->class_dev, &class_device_attr_ibdev))
-               goto err_class;
-       if (class_device_create_file(port->class_dev, &class_device_attr_port))
-               goto err_class;
-
-       port->sm_dev = cdev_alloc();
-       if (!port->sm_dev)
-               goto err_class;
-       port->sm_dev->owner = THIS_MODULE;
-       port->sm_dev->ops   = &umad_sm_fops;
-       kobject_set_name(&port->sm_dev->kobj, "issm%d", port->dev_num);
-       if (cdev_add(port->sm_dev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1))
+       if (device_create_file(port->dev, &dev_attr_ibdev))
+               goto err_dev;
+       if (device_create_file(port->dev, &dev_attr_port))
+               goto err_dev;
+
+       port->sm_cdev = cdev_alloc();
+       if (!port->sm_cdev)
+               goto err_dev;
+       port->sm_cdev->owner = THIS_MODULE;
+       port->sm_cdev->ops   = &umad_sm_fops;
+       kobject_set_name(&port->sm_cdev->kobj, "issm%d", port->dev_num);
+       if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1))
                goto err_sm_cdev;
 
-       port->sm_class_dev = class_device_create(umad_class, NULL, port->sm_dev->dev,
-                                                device->dma_device,
-                                                "issm%d", port->dev_num);
-       if (IS_ERR(port->sm_class_dev))
+       port->sm_dev = device_create(umad_class, device->dma_device,
+                                    port->sm_cdev->dev,
+                                    "issm%d", port->dev_num);
+       if (IS_ERR(port->sm_dev))
                goto err_sm_cdev;
 
-       class_set_devdata(port->class_dev,    port);
-       class_set_devdata(port->sm_class_dev, port);
+       dev_set_drvdata(port->dev,    port);
+       dev_set_drvdata(port->sm_dev, port);
 
-       if (class_device_create_file(port->sm_class_dev, &class_device_attr_ibdev))
-               goto err_sm_class;
-       if (class_device_create_file(port->sm_class_dev, &class_device_attr_port))
-               goto err_sm_class;
+       if (device_create_file(port->sm_dev, &dev_attr_ibdev))
+               goto err_sm_dev;
+       if (device_create_file(port->sm_dev, &dev_attr_port))
+               goto err_sm_dev;
 
        spin_lock(&port_lock);
        umad_port[port->dev_num] = port;
@@ -1043,17 +1044,17 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
 
        return 0;
 
-err_sm_class:
-       class_device_destroy(umad_class, port->sm_dev->dev);
+err_sm_dev:
+       device_destroy(umad_class, port->sm_cdev->dev);
 
 err_sm_cdev:
-       cdev_del(port->sm_dev);
+       cdev_del(port->sm_cdev);
 
-err_class:
-       class_device_destroy(umad_class, port->dev->dev);
+err_dev:
+       device_destroy(umad_class, port->cdev->dev);
 
 err_cdev:
-       cdev_del(port->dev);
+       cdev_del(port->cdev);
        clear_bit(port->dev_num, dev_map);
 
        return -1;
@@ -1065,14 +1066,14 @@ static void ib_umad_kill_port(struct ib_umad_port *port)
        int already_dead;
        int id;
 
-       class_set_devdata(port->class_dev,    NULL);
-       class_set_devdata(port->sm_class_dev, NULL);
+       dev_set_drvdata(port->dev,    NULL);
+       dev_set_drvdata(port->sm_dev, NULL);
 
-       class_device_destroy(umad_class, port->dev->dev);
-       class_device_destroy(umad_class, port->sm_dev->dev);
+       device_destroy(umad_class, port->cdev->dev);
+       device_destroy(umad_class, port->sm_cdev->dev);
 
-       cdev_del(port->dev);
-       cdev_del(port->sm_dev);
+       cdev_del(port->cdev);
+       cdev_del(port->sm_cdev);
 
        spin_lock(&port_lock);
        umad_port[port->dev_num] = NULL;
index 2cad8b4b52924a1b72e61b49b42b1cad47896c34..376a57ce1b4067b1fc0e12c96f5863d0d849b741 100644 (file)
@@ -73,8 +73,8 @@ struct ib_uverbs_device {
        struct kref                             ref;
        struct completion                       comp;
        int                                     devnum;
-       struct cdev                            *dev;
-       struct class_device                    *class_dev;
+       struct cdev                            *cdev;
+       struct device                          *dev;
        struct ib_device                       *ib_dev;
        int                                     num_comp_vectors;
 };
index f49f94653a963aed973d53730bd10358282d8e1c..cc1afa28c18145839049e51c03f0a5da4f30844e 100644 (file)
@@ -690,27 +690,29 @@ static struct ib_client uverbs_client = {
        .remove = ib_uverbs_remove_one
 };
 
-static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
+static ssize_t show_ibdev(struct device *device, struct device_attribute *attr,
+                         char *buf)
 {
-       struct ib_uverbs_device *dev = class_get_devdata(class_dev);
+       struct ib_uverbs_device *dev = dev_get_drvdata(device);
 
        if (!dev)
                return -ENODEV;
 
        return sprintf(buf, "%s\n", dev->ib_dev->name);
 }
-static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
+static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
 
-static ssize_t show_dev_abi_version(struct class_device *class_dev, char *buf)
+static ssize_t show_dev_abi_version(struct device *device,
+                                   struct device_attribute *attr, char *buf)
 {
-       struct ib_uverbs_device *dev = class_get_devdata(class_dev);
+       struct ib_uverbs_device *dev = dev_get_drvdata(device);
 
        if (!dev)
                return -ENODEV;
 
        return sprintf(buf, "%d\n", dev->ib_dev->uverbs_abi_ver);
 }
-static CLASS_DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL);
+static DEVICE_ATTR(abi_version, S_IRUGO, show_dev_abi_version, NULL);
 
 static ssize_t show_abi_version(struct class *class, char *buf)
 {
@@ -744,27 +746,26 @@ static void ib_uverbs_add_one(struct ib_device *device)
        uverbs_dev->ib_dev           = device;
        uverbs_dev->num_comp_vectors = device->num_comp_vectors;
 
-       uverbs_dev->dev = cdev_alloc();
-       if (!uverbs_dev->dev)
+       uverbs_dev->cdev = cdev_alloc();
+       if (!uverbs_dev->cdev)
                goto err;
-       uverbs_dev->dev->owner = THIS_MODULE;
-       uverbs_dev->dev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops;
-       kobject_set_name(&uverbs_dev->dev->kobj, "uverbs%d", uverbs_dev->devnum);
-       if (cdev_add(uverbs_dev->dev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1))
+       uverbs_dev->cdev->owner = THIS_MODULE;
+       uverbs_dev->cdev->ops = device->mmap ? &uverbs_mmap_fops : &uverbs_fops;
+       kobject_set_name(&uverbs_dev->cdev->kobj, "uverbs%d", uverbs_dev->devnum);
+       if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1))
                goto err_cdev;
 
-       uverbs_dev->class_dev = class_device_create(uverbs_class, NULL,
-                                                   uverbs_dev->dev->dev,
-                                                   device->dma_device,
-                                                   "uverbs%d", uverbs_dev->devnum);
-       if (IS_ERR(uverbs_dev->class_dev))
+       uverbs_dev->dev = device_create(uverbs_class, device->dma_device,
+                                       uverbs_dev->cdev->dev,
+                                       "uverbs%d", uverbs_dev->devnum);
+       if (IS_ERR(uverbs_dev->dev))
                goto err_cdev;
 
-       class_set_devdata(uverbs_dev->class_dev, uverbs_dev);
+       dev_set_drvdata(uverbs_dev->dev, uverbs_dev);
 
-       if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_ibdev))
+       if (device_create_file(uverbs_dev->dev, &dev_attr_ibdev))
                goto err_class;
-       if (class_device_create_file(uverbs_dev->class_dev, &class_device_attr_abi_version))
+       if (device_create_file(uverbs_dev->dev, &dev_attr_abi_version))
                goto err_class;
 
        spin_lock(&map_lock);
@@ -776,10 +777,10 @@ static void ib_uverbs_add_one(struct ib_device *device)
        return;
 
 err_class:
-       class_device_destroy(uverbs_class, uverbs_dev->dev->dev);
+       device_destroy(uverbs_class, uverbs_dev->cdev->dev);
 
 err_cdev:
-       cdev_del(uverbs_dev->dev);
+       cdev_del(uverbs_dev->cdev);
        clear_bit(uverbs_dev->devnum, dev_map);
 
 err:
@@ -796,9 +797,9 @@ static void ib_uverbs_remove_one(struct ib_device *device)
        if (!uverbs_dev)
                return;
 
-       class_set_devdata(uverbs_dev->class_dev, NULL);
-       class_device_destroy(uverbs_class, uverbs_dev->dev->dev);
-       cdev_del(uverbs_dev->dev);
+       dev_set_drvdata(uverbs_dev->dev, NULL);
+       device_destroy(uverbs_class, uverbs_dev->cdev->dev);
+       cdev_del(uverbs_dev->cdev);
 
        spin_lock(&map_lock);
        dev_table[uverbs_dev->devnum] = NULL;
index e10d27a6e145fe2b9b4c7f998b96e20f700badf3..6af2c0f79a677ab889685e4b54d6ed53c580850d 100644 (file)
@@ -523,45 +523,49 @@ static int c2_dereg_mr(struct ib_mr *ib_mr)
        return err;
 }
 
-static ssize_t show_rev(struct class_device *cdev, char *buf)
+static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
-       struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev);
+       struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev);
        pr_debug("%s:%u\n", __func__, __LINE__);
-       return sprintf(buf, "%x\n", dev->props.hw_ver);
+       return sprintf(buf, "%x\n", c2dev->props.hw_ver);
 }
 
-static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
+static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr,
+                          char *buf)
 {
-       struct c2_dev *dev = container_of(cdev, struct c2_dev, ibdev.class_dev);
+       struct c2_dev *c2dev = container_of(dev, struct c2_dev, ibdev.dev);
        pr_debug("%s:%u\n", __func__, __LINE__);
        return sprintf(buf, "%x.%x.%x\n",
-                      (int) (dev->props.fw_ver >> 32),
-                      (int) (dev->props.fw_ver >> 16) & 0xffff,
-                      (int) (dev->props.fw_ver & 0xffff));
+                      (int) (c2dev->props.fw_ver >> 32),
+                      (int) (c2dev->props.fw_ver >> 16) & 0xffff,
+                      (int) (c2dev->props.fw_ver & 0xffff));
 }
 
-static ssize_t show_hca(struct class_device *cdev, char *buf)
+static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
        pr_debug("%s:%u\n", __func__, __LINE__);
        return sprintf(buf, "AMSO1100\n");
 }
 
-static ssize_t show_board(struct class_device *cdev, char *buf)
+static ssize_t show_board(struct device *dev, struct device_attribute *attr,
+                         char *buf)
 {
        pr_debug("%s:%u\n", __func__, __LINE__);
        return sprintf(buf, "%.*s\n", 32, "AMSO1100 Board ID");
 }
 
-static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
-static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
-static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
+static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
+static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
+static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
+static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
 
-static struct class_device_attribute *c2_class_attributes[] = {
-       &class_device_attr_hw_rev,
-       &class_device_attr_fw_ver,
-       &class_device_attr_hca_type,
-       &class_device_attr_board_id
+static struct device_attribute *c2_dev_attributes[] = {
+       &dev_attr_hw_rev,
+       &dev_attr_fw_ver,
+       &dev_attr_hca_type,
+       &dev_attr_board_id
 };
 
 static 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)
        if (ret)
                goto out1;
 
-       for (i = 0; i < ARRAY_SIZE(c2_class_attributes); ++i) {
-               ret = class_device_create_file(&dev->ibdev.class_dev,
-                                              c2_class_attributes[i]);
+       for (i = 0; i < ARRAY_SIZE(c2_dev_attributes); ++i) {
+               ret = device_create_file(&dev->ibdev.dev,
+                                              c2_dev_attributes[i]);
                if (ret)
                        goto out0;
        }
index ca7265443c05c37cf79f5fc35811b93dd206b53d..ab4695c1dd5614b3e881ad6d03abca913621ebf6 100644 (file)
@@ -1041,61 +1041,60 @@ static int iwch_query_port(struct ib_device *ibdev,
        return 0;
 }
 
-static ssize_t show_rev(struct class_device *cdev, char *buf)
+static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
-       struct iwch_dev *dev = container_of(cdev, struct iwch_dev,
-                                           ibdev.class_dev);
-       PDBG("%s class dev 0x%p\n", __func__, cdev);
-       return sprintf(buf, "%d\n", dev->rdev.t3cdev_p->type);
+       struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
+                                                ibdev.dev);
+       PDBG("%s dev 0x%p\n", __func__, dev);
+       return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type);
 }
 
-static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
+static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf)
 {
-       struct iwch_dev *dev = container_of(cdev, struct iwch_dev,
-                                           ibdev.class_dev);
+       struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
+                                                ibdev.dev);
        struct ethtool_drvinfo info;
-       struct net_device *lldev = dev->rdev.t3cdev_p->lldev;
+       struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
 
-       PDBG("%s class dev 0x%p\n", __func__, cdev);
-       rtnl_lock();
+       PDBG("%s dev 0x%p\n", __func__, dev);
        lldev->ethtool_ops->get_drvinfo(lldev, &info);
-       rtnl_unlock();
        return sprintf(buf, "%s\n", info.fw_version);
 }
 
-static ssize_t show_hca(struct class_device *cdev, char *buf)
+static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
-       struct iwch_dev *dev = container_of(cdev, struct iwch_dev,
-                                           ibdev.class_dev);
+       struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
+                                                ibdev.dev);
        struct ethtool_drvinfo info;
-       struct net_device *lldev = dev->rdev.t3cdev_p->lldev;
+       struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
 
-       PDBG("%s class dev 0x%p\n", __func__, cdev);
-       rtnl_lock();
+       PDBG("%s dev 0x%p\n", __func__, dev);
        lldev->ethtool_ops->get_drvinfo(lldev, &info);
-       rtnl_unlock();
        return sprintf(buf, "%s\n", info.driver);
 }
 
-static ssize_t show_board(struct class_device *cdev, char *buf)
+static ssize_t show_board(struct device *dev, struct device_attribute *attr,
+                         char *buf)
 {
-       struct iwch_dev *dev = container_of(cdev, struct iwch_dev,
-                                           ibdev.class_dev);
-       PDBG("%s class dev 0x%p\n", __func__, dev);
-       return sprintf(buf, "%x.%x\n", dev->rdev.rnic_info.pdev->vendor,
-                                      dev->rdev.rnic_info.pdev->device);
+       struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
+                                                ibdev.dev);
+       PDBG("%s dev 0x%p\n", __func__, dev);
+       return sprintf(buf, "%x.%x\n", iwch_dev->rdev.rnic_info.pdev->vendor,
+                      iwch_dev->rdev.rnic_info.pdev->device);
 }
 
-static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
-static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
-static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
+static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
+static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
+static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
+static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
 
-static struct class_device_attribute *iwch_class_attributes[] = {
-       &class_device_attr_hw_rev,
-       &class_device_attr_fw_ver,
-       &class_device_attr_hca_type,
-       &class_device_attr_board_id
+static struct device_attribute *iwch_class_attributes[] = {
+       &dev_attr_hw_rev,
+       &dev_attr_fw_ver,
+       &dev_attr_hca_type,
+       &dev_attr_board_id
 };
 
 int iwch_register_device(struct iwch_dev *dev)
@@ -1189,8 +1188,8 @@ int iwch_register_device(struct iwch_dev *dev)
                goto bail1;
 
        for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i) {
-               ret = class_device_create_file(&dev->ibdev.class_dev,
-                                              iwch_class_attributes[i]);
+               ret = device_create_file(&dev->ibdev.dev,
+                                        iwch_class_attributes[i]);
                if (ret) {
                        goto bail2;
                }
@@ -1208,8 +1207,8 @@ void iwch_unregister_device(struct iwch_dev *dev)
 
        PDBG("%s iwch_dev %p\n", __func__, dev);
        for (i = 0; i < ARRAY_SIZE(iwch_class_attributes); ++i)
-               class_device_remove_file(&dev->ibdev.class_dev,
-                                        iwch_class_attributes[i]);
+               device_remove_file(&dev->ibdev.dev,
+                                  iwch_class_attributes[i]);
        ib_unregister_device(&dev->ibdev);
        return;
 }
index 6d49d2f18a88223df10ffd7dc0afcdaa3fd70092..d4ce8b63e19eba275cc2e11235dc751ed438e1f1 100644 (file)
@@ -79,7 +79,7 @@ static const struct file_operations diagpkt_file_ops = {
 
 static atomic_t diagpkt_count = ATOMIC_INIT(0);
 static struct cdev *diagpkt_cdev;
-static struct class_device *diagpkt_class_dev;
+static struct device *diagpkt_dev;
 
 int ipath_diag_add(struct ipath_devdata *dd)
 {
@@ -89,7 +89,7 @@ int ipath_diag_add(struct ipath_devdata *dd)
        if (atomic_inc_return(&diagpkt_count) == 1) {
                ret = ipath_cdev_init(IPATH_DIAGPKT_MINOR,
                                      "ipath_diagpkt", &diagpkt_file_ops,
-                                     &diagpkt_cdev, &diagpkt_class_dev);
+                                     &diagpkt_cdev, &diagpkt_dev);
 
                if (ret) {
                        ipath_dev_err(dd, "Couldn't create ipath_diagpkt "
@@ -102,7 +102,7 @@ int ipath_diag_add(struct ipath_devdata *dd)
 
        ret = ipath_cdev_init(IPATH_DIAG_MINOR_BASE + dd->ipath_unit, name,
                              &diag_file_ops, &dd->diag_cdev,
-                             &dd->diag_class_dev);
+                             &dd->diag_dev);
        if (ret)
                ipath_dev_err(dd, "Couldn't create %s device: %d",
                              name, ret);
@@ -114,9 +114,9 @@ done:
 void ipath_diag_remove(struct ipath_devdata *dd)
 {
        if (atomic_dec_and_test(&diagpkt_count))
-               ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_class_dev);
+               ipath_cdev_cleanup(&diagpkt_cdev, &diagpkt_dev);
 
-       ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_class_dev);
+       ipath_cdev_cleanup(&dd->diag_cdev, &dd->diag_dev);
 }
 
 /**
index 1e627aab18bf59b2b449dd8ccb141436b0e8295c..8b1752202e78a8d69c09579428a339df283bd55c 100644 (file)
@@ -2434,11 +2434,11 @@ static ssize_t ipath_writev(struct kiocb *iocb, const struct iovec *iov,
 static struct class *ipath_class;
 
 static int init_cdev(int minor, char *name, const struct file_operations *fops,
-                    struct cdev **cdevp, struct class_device **class_devp)
+                    struct cdev **cdevp, struct device **devp)
 {
        const dev_t dev = MKDEV(IPATH_MAJOR, minor);
        struct cdev *cdev = NULL;
-       struct class_device *class_dev = NULL;
+       struct device *device = NULL;
        int ret;
 
        cdev = cdev_alloc();
@@ -2462,12 +2462,12 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops,
                goto err_cdev;
        }
 
-       class_dev = class_device_create(ipath_class, NULL, dev, NULL, name);
+       device = device_create(ipath_class, NULL, dev, name);
 
-       if (IS_ERR(class_dev)) {
-               ret = PTR_ERR(class_dev);
+       if (IS_ERR(device)) {
+               ret = PTR_ERR(device);
                printk(KERN_ERR IPATH_DRV_NAME ": Could not create "
-                      "class_dev for minor %d, %s (err %d)\n",
+                      "device for minor %d, %s (err %d)\n",
                       minor, name, -ret);
                goto err_cdev;
        }
@@ -2481,29 +2481,29 @@ err_cdev:
 done:
        if (ret >= 0) {
                *cdevp = cdev;
-               *class_devp = class_dev;
+               *devp = device;
        } else {
                *cdevp = NULL;
-               *class_devp = NULL;
+               *devp = NULL;
        }
 
        return ret;
 }
 
 int ipath_cdev_init(int minor, char *name, const struct file_operations *fops,
-                   struct cdev **cdevp, struct class_device **class_devp)
+                   struct cdev **cdevp, struct device **devp)
 {
-       return init_cdev(minor, name, fops, cdevp, class_devp);
+       return init_cdev(minor, name, fops, cdevp, devp);
 }
 
 static void cleanup_cdev(struct cdev **cdevp,
-                        struct class_device **class_devp)
+                        struct device **devp)
 {
-       struct class_device *class_dev = *class_devp;
+       struct device *dev = *devp;
 
-       if (class_dev) {
-               class_device_unregister(class_dev);
-               *class_devp = NULL;
+       if (dev) {
+               device_unregister(dev);
+               *devp = NULL;
        }
 
        if (*cdevp) {
@@ -2513,13 +2513,13 @@ static void cleanup_cdev(struct cdev **cdevp,
 }
 
 void ipath_cdev_cleanup(struct cdev **cdevp,
-                       struct class_device **class_devp)
+                       struct device **devp)
 {
-       cleanup_cdev(cdevp, class_devp);
+       cleanup_cdev(cdevp, devp);
 }
 
 static struct cdev *wildcard_cdev;
-static struct class_device *wildcard_class_dev;
+static struct device *wildcard_dev;
 
 static const dev_t dev = MKDEV(IPATH_MAJOR, 0);
 
@@ -2576,7 +2576,7 @@ int ipath_user_add(struct ipath_devdata *dd)
                        goto bail;
                }
                ret = init_cdev(0, "ipath", &ipath_file_ops, &wildcard_cdev,
-                               &wildcard_class_dev);
+                               &wildcard_dev);
                if (ret < 0) {
                        ipath_dev_err(dd, "Could not create wildcard "
                                      "minor: error %d\n", -ret);
@@ -2589,7 +2589,7 @@ int ipath_user_add(struct ipath_devdata *dd)
        snprintf(name, sizeof(name), "ipath%d", dd->ipath_unit);
 
        ret = init_cdev(dd->ipath_unit + 1, name, &ipath_file_ops,
-                       &dd->user_cdev, &dd->user_class_dev);
+                       &dd->user_cdev, &dd->user_dev);
        if (ret < 0)
                ipath_dev_err(dd, "Could not create user minor %d, %s\n",
                              dd->ipath_unit + 1, name);
@@ -2604,13 +2604,13 @@ bail:
 
 void ipath_user_remove(struct ipath_devdata *dd)
 {
-       cleanup_cdev(&dd->user_cdev, &dd->user_class_dev);
+       cleanup_cdev(&dd->user_cdev, &dd->user_dev);
 
        if (atomic_dec_return(&user_count) == 0) {
                if (atomic_read(&user_setup) == 0)
                        goto bail;
 
-               cleanup_cdev(&wildcard_cdev, &wildcard_class_dev);
+               cleanup_cdev(&wildcard_cdev, &wildcard_dev);
                user_cleanup();
 
                atomic_set(&user_setup, 0);
index 5863cbe9930313a5cd16522b6806432512d4b3ff..202337ae90dc68621dc89feefe931dbb82982c37 100644 (file)
@@ -466,8 +466,8 @@ struct ipath_devdata {
        struct pci_dev *pcidev;
        struct cdev *user_cdev;
        struct cdev *diag_cdev;
-       struct class_device *user_class_dev;
-       struct class_device *diag_class_dev;
+       struct device *user_dev;
+       struct device *diag_dev;
        /* timer used to prevent stats overflow, error throttling, etc. */
        struct timer_list ipath_stats_timer;
        /* timer to verify interrupts work, and fallback if possible */
@@ -854,9 +854,9 @@ void ipath_clear_freeze(struct ipath_devdata *);
 
 struct file_operations;
 int ipath_cdev_init(int minor, char *name, const struct file_operations *fops,
-                   struct cdev **cdevp, struct class_device **class_devp);
+                   struct cdev **cdevp, struct device **devp);
 void ipath_cdev_cleanup(struct cdev **cdevp,
-                       struct class_device **class_devp);
+                       struct device **devp);
 
 int ipath_diag_add(struct ipath_devdata *);
 void ipath_diag_remove(struct ipath_devdata *);
index 320a6d018de7522cf07c5eaf9217ef666938b22e..c38f9aa8be8dc000c26124da1477759a5a20fa76 100644 (file)
@@ -2172,18 +2172,20 @@ void ipath_unregister_ib_device(struct ipath_ibdev *dev)
        ib_dealloc_device(ibdev);
 }
 
-static ssize_t show_rev(struct class_device *cdev, char *buf)
+static ssize_t show_rev(struct device *device, struct device_attribute *attr,
+                       char *buf)
 {
        struct ipath_ibdev *dev =
-               container_of(cdev, struct ipath_ibdev, ibdev.class_dev);
+               container_of(device, struct ipath_ibdev, ibdev.dev);
 
        return sprintf(buf, "%x\n", dev->dd->ipath_pcirev);
 }
 
-static ssize_t show_hca(struct class_device *cdev, char *buf)
+static ssize_t show_hca(struct device *device, struct device_attribute *attr,
+                       char *buf)
 {
        struct ipath_ibdev *dev =
-               container_of(cdev, struct ipath_ibdev, ibdev.class_dev);
+               container_of(device, struct ipath_ibdev, ibdev.dev);
        int ret;
 
        ret = dev->dd->ipath_f_get_boardname(dev->dd, buf, 128);
@@ -2196,10 +2198,11 @@ bail:
        return ret;
 }
 
-static ssize_t show_stats(struct class_device *cdev, char *buf)
+static ssize_t show_stats(struct device *device, struct device_attribute *attr,
+                         char *buf)
 {
        struct ipath_ibdev *dev =
-               container_of(cdev, struct ipath_ibdev, ibdev.class_dev);
+               container_of(device, struct ipath_ibdev, ibdev.dev);
        int i;
        int len;
 
@@ -2237,16 +2240,16 @@ static ssize_t show_stats(struct class_device *cdev, char *buf)
        return len;
 }
 
-static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
-static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL);
-static CLASS_DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL);
+static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
+static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
+static DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL);
+static DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL);
 
-static struct class_device_attribute *ipath_class_attributes[] = {
-       &class_device_attr_hw_rev,
-       &class_device_attr_hca_type,
-       &class_device_attr_board_id,
-       &class_device_attr_stats
+static struct device_attribute *ipath_class_attributes[] = {
+       &dev_attr_hw_rev,
+       &dev_attr_hca_type,
+       &dev_attr_board_id,
+       &dev_attr_stats
 };
 
 static int ipath_verbs_register_sysfs(struct ib_device *dev)
@@ -2255,8 +2258,8 @@ static int ipath_verbs_register_sysfs(struct ib_device *dev)
        int ret;
 
        for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i)
-               if (class_device_create_file(&dev->class_dev,
-                                            ipath_class_attributes[i])) {
+               if (device_create_file(&dev->dev,
+                                      ipath_class_attributes[i])) {
                        ret = 1;
                        goto bail;
                }
index 136c76c7b4e78ac394ebc73442d6ba587200427a..4d9b5ac42202cc3df5b81961068f18e65beb00ac 100644 (file)
@@ -481,42 +481,51 @@ out:
        return err;
 }
 
-static ssize_t show_hca(struct class_device *cdev, char *buf)
+static ssize_t show_hca(struct device *device, struct device_attribute *attr,
+                       char *buf)
 {
-       struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev);
+       struct mlx4_ib_dev *dev =
+               container_of(device, struct mlx4_ib_dev, ib_dev.dev);
        return sprintf(buf, "MT%d\n", dev->dev->pdev->device);
 }
 
-static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
+static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
+                          char *buf)
 {
-       struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev);
+       struct mlx4_ib_dev *dev =
+               container_of(device, struct mlx4_ib_dev, ib_dev.dev);
        return sprintf(buf, "%d.%d.%d\n", (int) (dev->dev->caps.fw_ver >> 32),
                       (int) (dev->dev->caps.fw_ver >> 16) & 0xffff,
                       (int) dev->dev->caps.fw_ver & 0xffff);
 }
 
-static ssize_t show_rev(struct class_device *cdev, char *buf)
+static ssize_t show_rev(struct device *device, struct device_attribute *attr,
+                       char *buf)
 {
-       struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev);
+       struct mlx4_ib_dev *dev =
+               container_of(device, struct mlx4_ib_dev, ib_dev.dev);
        return sprintf(buf, "%x\n", dev->dev->rev_id);
 }
 
-static ssize_t show_board(struct class_device *cdev, char *buf)
+static ssize_t show_board(struct device *device, struct device_attribute *attr,
+                         char *buf)
 {
-       struct mlx4_ib_dev *dev = container_of(cdev, struct mlx4_ib_dev, ib_dev.class_dev);
-       return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN, dev->dev->board_id);
+       struct mlx4_ib_dev *dev =
+               container_of(device, struct mlx4_ib_dev, ib_dev.dev);
+       return sprintf(buf, "%.*s\n", MLX4_BOARD_ID_LEN,
+                      dev->dev->board_id);
 }
 
-static CLASS_DEVICE_ATTR(hw_rev,   S_IRUGO, show_rev,    NULL);
-static CLASS_DEVICE_ATTR(fw_ver,   S_IRUGO, show_fw_ver, NULL);
-static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca,    NULL);
-static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board,  NULL);
+static DEVICE_ATTR(hw_rev,   S_IRUGO, show_rev,    NULL);
+static DEVICE_ATTR(fw_ver,   S_IRUGO, show_fw_ver, NULL);
+static DEVICE_ATTR(hca_type, S_IRUGO, show_hca,    NULL);
+static DEVICE_ATTR(board_id, S_IRUGO, show_board,  NULL);
 
-static struct class_device_attribute *mlx4_class_attributes[] = {
-       &class_device_attr_hw_rev,
-       &class_device_attr_fw_ver,
-       &class_device_attr_hca_type,
-       &class_device_attr_board_id
+static struct device_attribute *mlx4_class_attributes[] = {
+       &dev_attr_hw_rev,
+       &dev_attr_fw_ver,
+       &dev_attr_hca_type,
+       &dev_attr_board_id
 };
 
 static void *mlx4_ib_add(struct mlx4_dev *dev)
@@ -640,8 +649,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
                goto err_reg;
 
        for (i = 0; i < ARRAY_SIZE(mlx4_class_attributes); ++i) {
-               if (class_device_create_file(&ibdev->ib_dev.class_dev,
-                                              mlx4_class_attributes[i]))
+               if (device_create_file(&ibdev->ib_dev.dev,
+                                      mlx4_class_attributes[i]))
                        goto err_reg;
        }
 
index 81b257e18bb6b0bff96a47a991378390db850785..696e1f30233268a6f69261ca10dd4fb0beadef28 100644 (file)
@@ -1170,23 +1170,29 @@ static int mthca_unmap_fmr(struct list_head *fmr_list)
        return 0;
 }
 
-static ssize_t show_rev(struct class_device *cdev, char *buf)
+static ssize_t show_rev(struct device *device, struct device_attribute *attr,
+                       char *buf)
 {
-       struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev);
+       struct mthca_dev *dev =
+               container_of(device, struct mthca_dev, ib_dev.dev);
        return sprintf(buf, "%x\n", dev->rev_id);
 }
 
-static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
+static ssize_t show_fw_ver(struct device *device, struct device_attribute *attr,
+                          char *buf)
 {
-       struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev);
+       struct mthca_dev *dev =
+               container_of(device, struct mthca_dev, ib_dev.dev);
        return sprintf(buf, "%d.%d.%d\n", (int) (dev->fw_ver >> 32),
                       (int) (dev->fw_ver >> 16) & 0xffff,
                       (int) dev->fw_ver & 0xffff);
 }
 
-static ssize_t show_hca(struct class_device *cdev, char *buf)
+static ssize_t show_hca(struct device *device, struct device_attribute *attr,
+                       char *buf)
 {
-       struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev);
+       struct mthca_dev *dev =
+               container_of(device, struct mthca_dev, ib_dev.dev);
        switch (dev->pdev->device) {
        case PCI_DEVICE_ID_MELLANOX_TAVOR:
                return sprintf(buf, "MT23108\n");
@@ -1202,22 +1208,24 @@ static ssize_t show_hca(struct class_device *cdev, char *buf)
        }
 }
 
-static ssize_t show_board(struct class_device *cdev, char *buf)
+static ssize_t show_board(struct device *device, struct device_attribute *attr,
+                         char *buf)
 {
-       struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev);
+       struct mthca_dev *dev =
+               container_of(device, struct mthca_dev, ib_dev.dev);
        return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id);
 }
 
-static CLASS_DEVICE_ATTR(hw_rev,   S_IRUGO, show_rev,    NULL);
-static CLASS_DEVICE_ATTR(fw_ver,   S_IRUGO, show_fw_ver, NULL);
-static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca,    NULL);
-static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board,  NULL);
+static DEVICE_ATTR(hw_rev,   S_IRUGO, show_rev,    NULL);
+static DEVICE_ATTR(fw_ver,   S_IRUGO, show_fw_ver, NULL);
+static DEVICE_ATTR(hca_type, S_IRUGO, show_hca,    NULL);
+static DEVICE_ATTR(board_id, S_IRUGO, show_board,  NULL);
 
-static struct class_device_attribute *mthca_class_attributes[] = {
-       &class_device_attr_hw_rev,
-       &class_device_attr_fw_ver,
-       &class_device_attr_hca_type,
-       &class_device_attr_board_id
+static struct device_attribute *mthca_dev_attributes[] = {
+       &dev_attr_hw_rev,
+       &dev_attr_fw_ver,
+       &dev_attr_hca_type,
+       &dev_attr_board_id
 };
 
 static int mthca_init_node_data(struct mthca_dev *dev)
@@ -1379,9 +1387,9 @@ int mthca_register_device(struct mthca_dev *dev)
        if (ret)
                return ret;
 
-       for (i = 0; i < ARRAY_SIZE(mthca_class_attributes); ++i) {
-               ret = class_device_create_file(&dev->ib_dev.class_dev,
-                                              mthca_class_attributes[i]);
+       for (i = 0; i < ARRAY_SIZE(mthca_dev_attributes); ++i) {
+               ret = device_create_file(&dev->ib_dev.dev,
+                                        mthca_dev_attributes[i]);
                if (ret) {
                        ib_unregister_device(&dev->ib_dev);
                        return ret;
index 7c27420c22405a0bfd1faaa9549915dd7f37e6ea..f9a5d43908923081526b50e4eed3a709c5b4b8e0 100644 (file)
@@ -2800,10 +2800,11 @@ static int nes_dereg_mr(struct ib_mr *ib_mr)
 /**
  * show_rev
  */
-static ssize_t show_rev(struct class_device *cdev, char *buf)
+static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
        struct nes_ib_device *nesibdev =
-                       container_of(cdev, struct nes_ib_device, ibdev.class_dev);
+                       container_of(dev, struct nes_ib_device, ibdev.dev);
        struct nes_vnic *nesvnic = nesibdev->nesvnic;
 
        nes_debug(NES_DBG_INIT, "\n");
@@ -2814,10 +2815,11 @@ static ssize_t show_rev(struct class_device *cdev, char *buf)
 /**
  * show_fw_ver
  */
-static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
+static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr,
+                          char *buf)
 {
        struct nes_ib_device *nesibdev =
-                       container_of(cdev, struct nes_ib_device, ibdev.class_dev);
+                       container_of(dev, struct nes_ib_device, ibdev.dev);
        struct nes_vnic *nesvnic = nesibdev->nesvnic;
 
        nes_debug(NES_DBG_INIT, "\n");
@@ -2831,7 +2833,8 @@ static ssize_t show_fw_ver(struct class_device *cdev, char *buf)
 /**
  * show_hca
  */
-static ssize_t show_hca(struct class_device *cdev, char *buf)
+static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
+                       char *buf)
 {
        nes_debug(NES_DBG_INIT, "\n");
        return sprintf(buf, "NES020\n");
@@ -2841,23 +2844,24 @@ static ssize_t show_hca(struct class_device *cdev, char *buf)
 /**
  * show_board
  */
-static ssize_t show_board(struct class_device *cdev, char *buf)
+static ssize_t show_board(struct device *dev, struct device_attribute *attr,
+                         char *buf)
 {
        nes_debug(NES_DBG_INIT, "\n");
        return sprintf(buf, "%.*s\n", 32, "NES020 Board ID");
 }
 
 
-static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
-static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
-static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
-static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
+static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
+static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
+static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
+static DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
 
-static struct class_device_attribute *nes_class_attributes[] = {
-       &class_device_attr_hw_rev,
-       &class_device_attr_fw_ver,
-       &class_device_attr_hca_type,
-       &class_device_attr_board_id
+static struct device_attribute *nes_dev_attributes[] = {
+       &dev_attr_hw_rev,
+       &dev_attr_fw_ver,
+       &dev_attr_hca_type,
+       &dev_attr_board_id
 };
 
 
@@ -3782,7 +3786,7 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev)
        nesibdev->ibdev.phys_port_cnt = 1;
        nesibdev->ibdev.num_comp_vectors = 1;
        nesibdev->ibdev.dma_device = &nesdev->pcidev->dev;
-       nesibdev->ibdev.class_dev.dev = &nesdev->pcidev->dev;
+       nesibdev->ibdev.dev.parent = &nesdev->pcidev->dev;
        nesibdev->ibdev.query_device = nes_query_device;
        nesibdev->ibdev.query_port = nes_query_port;
        nesibdev->ibdev.modify_port = nes_modify_port;
@@ -3877,13 +3881,13 @@ int nes_register_ofa_device(struct nes_ib_device *nesibdev)
        nesibdev->max_qp = (nesadapter->max_qp-NES_FIRST_QPN) / nesadapter->port_count;
        nesibdev->max_pd = nesadapter->max_pd / nesadapter->port_count;
 
-       for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) {
-               ret = class_device_create_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]);
+       for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) {
+               ret = device_create_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]);
                if (ret) {
                        while (i > 0) {
                                i--;
-                               class_device_remove_file(&nesibdev->ibdev.class_dev,
-                                               nes_class_attributes[i]);
+                               device_remove_file(&nesibdev->ibdev.dev,
+                                                  nes_dev_attributes[i]);
                        }
                        ib_unregister_device(&nesibdev->ibdev);
                        return ret;
@@ -3904,8 +3908,8 @@ static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev)
        struct nes_vnic *nesvnic = nesibdev->nesvnic;
        int i;
 
-       for (i = 0; i < ARRAY_SIZE(nes_class_attributes); ++i) {
-               class_device_remove_file(&nesibdev->ibdev.class_dev, nes_class_attributes[i]);
+       for (i = 0; i < ARRAY_SIZE(nes_dev_attributes); ++i) {
+               device_remove_file(&nesibdev->ibdev.dev, nes_dev_attributes[i]);
        }
 
        if (nesvnic->of_device_registered) {
index 95bf4bac44cb3babc459fb0f0e7313d15a91069e..2dcbecce3f61201a13710d104bc69f746f265823 100644 (file)
@@ -1051,7 +1051,7 @@ struct ib_device {
        struct ib_dma_mapping_ops   *dma_ops;
 
        struct module               *owner;
-       struct class_device          class_dev;
+       struct device                dev;
        struct kobject               *ports_parent;
        struct list_head             port_list;