aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core/user_mad.c
diff options
context:
space:
mode:
authorTony Jones <tonyj@suse.de>2008-02-21 18:13:36 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-04-19 22:10:30 -0400
commitf4e91eb4a81559da87a3843758a641b5cc590b65 (patch)
tree534335821d076764cbc072586b19c4b061710e3d /drivers/infiniband/core/user_mad.c
parentc4c66cf1787d408066fbfc69209185701f5df15f (diff)
IB: convert struct class_device to struct device
This converts the main ib_device to use struct device instead of struct class_device as class_device is going away. Signed-off-by: Tony Jones <tonyj@suse.de> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Cc: Roland Dreier <rolandd@cisco.com> Cc: Sean Hefty <sean.hefty@intel.com> Cc: Hal Rosenstock <hal.rosenstock@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/infiniband/core/user_mad.c')
-rw-r--r--drivers/infiniband/core/user_mad.c109
1 files changed, 55 insertions, 54 deletions
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 4e915104ac4c..9a9d3446c6ed 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -88,11 +88,11 @@ enum {
88 */ 88 */
89 89
90struct ib_umad_port { 90struct ib_umad_port {
91 struct cdev *dev; 91 struct cdev *cdev;
92 struct class_device *class_dev; 92 struct device *dev;
93 93
94 struct cdev *sm_dev; 94 struct cdev *sm_cdev;
95 struct class_device *sm_class_dev; 95 struct device *sm_dev;
96 struct semaphore sm_sem; 96 struct semaphore sm_sem;
97 97
98 struct mutex file_mutex; 98 struct mutex file_mutex;
@@ -948,27 +948,29 @@ static struct ib_client umad_client = {
948 .remove = ib_umad_remove_one 948 .remove = ib_umad_remove_one
949}; 949};
950 950
951static ssize_t show_ibdev(struct class_device *class_dev, char *buf) 951static ssize_t show_ibdev(struct device *dev, struct device_attribute *attr,
952 char *buf)
952{ 953{
953 struct ib_umad_port *port = class_get_devdata(class_dev); 954 struct ib_umad_port *port = dev_get_drvdata(dev);
954 955
955 if (!port) 956 if (!port)
956 return -ENODEV; 957 return -ENODEV;
957 958
958 return sprintf(buf, "%s\n", port->ib_dev->name); 959 return sprintf(buf, "%s\n", port->ib_dev->name);
959} 960}
960static CLASS_DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL); 961static DEVICE_ATTR(ibdev, S_IRUGO, show_ibdev, NULL);
961 962
962static ssize_t show_port(struct class_device *class_dev, char *buf) 963static ssize_t show_port(struct device *dev, struct device_attribute *attr,
964 char *buf)
963{ 965{
964 struct ib_umad_port *port = class_get_devdata(class_dev); 966 struct ib_umad_port *port = dev_get_drvdata(dev);
965 967
966 if (!port) 968 if (!port)
967 return -ENODEV; 969 return -ENODEV;
968 970
969 return sprintf(buf, "%d\n", port->port_num); 971 return sprintf(buf, "%d\n", port->port_num);
970} 972}
971static CLASS_DEVICE_ATTR(port, S_IRUGO, show_port, NULL); 973static DEVICE_ATTR(port, S_IRUGO, show_port, NULL);
972 974
973static ssize_t show_abi_version(struct class *class, char *buf) 975static ssize_t show_abi_version(struct class *class, char *buf)
974{ 976{
@@ -994,48 +996,47 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
994 mutex_init(&port->file_mutex); 996 mutex_init(&port->file_mutex);
995 INIT_LIST_HEAD(&port->file_list); 997 INIT_LIST_HEAD(&port->file_list);
996 998
997 port->dev = cdev_alloc(); 999 port->cdev = cdev_alloc();
998 if (!port->dev) 1000 if (!port->cdev)
999 return -1; 1001 return -1;
1000 port->dev->owner = THIS_MODULE; 1002 port->cdev->owner = THIS_MODULE;
1001 port->dev->ops = &umad_fops; 1003 port->cdev->ops = &umad_fops;
1002 kobject_set_name(&port->dev->kobj, "umad%d", port->dev_num); 1004 kobject_set_name(&port->cdev->kobj, "umad%d", port->dev_num);
1003 if (cdev_add(port->dev, base_dev + port->dev_num, 1)) 1005 if (cdev_add(port->cdev, base_dev + port->dev_num, 1))
1004 goto err_cdev; 1006 goto err_cdev;
1005 1007
1006 port->class_dev = class_device_create(umad_class, NULL, port->dev->dev, 1008 port->dev = device_create(umad_class, device->dma_device,
1007 device->dma_device, 1009 port->cdev->dev, "umad%d", port->dev_num);
1008 "umad%d", port->dev_num); 1010 if (IS_ERR(port->dev))
1009 if (IS_ERR(port->class_dev))
1010 goto err_cdev; 1011 goto err_cdev;
1011 1012
1012 if (class_device_create_file(port->class_dev, &class_device_attr_ibdev)) 1013 if (device_create_file(port->dev, &dev_attr_ibdev))
1013 goto err_class; 1014 goto err_dev;
1014 if (class_device_create_file(port->class_dev, &class_device_attr_port)) 1015 if (device_create_file(port->dev, &dev_attr_port))
1015 goto err_class; 1016 goto err_dev;
1016 1017
1017 port->sm_dev = cdev_alloc(); 1018 port->sm_cdev = cdev_alloc();
1018 if (!port->sm_dev) 1019 if (!port->sm_cdev)
1019 goto err_class; 1020 goto err_dev;
1020 port->sm_dev->owner = THIS_MODULE; 1021 port->sm_cdev->owner = THIS_MODULE;
1021 port->sm_dev->ops = &umad_sm_fops; 1022 port->sm_cdev->ops = &umad_sm_fops;
1022 kobject_set_name(&port->sm_dev->kobj, "issm%d", port->dev_num); 1023 kobject_set_name(&port->sm_cdev->kobj, "issm%d", port->dev_num);
1023 if (cdev_add(port->sm_dev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) 1024 if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1))
1024 goto err_sm_cdev; 1025 goto err_sm_cdev;
1025 1026
1026 port->sm_class_dev = class_device_create(umad_class, NULL, port->sm_dev->dev, 1027 port->sm_dev = device_create(umad_class, device->dma_device,
1027 device->dma_device, 1028 port->sm_cdev->dev,
1028 "issm%d", port->dev_num); 1029 "issm%d", port->dev_num);
1029 if (IS_ERR(port->sm_class_dev)) 1030 if (IS_ERR(port->sm_dev))
1030 goto err_sm_cdev; 1031 goto err_sm_cdev;
1031 1032
1032 class_set_devdata(port->class_dev, port); 1033 dev_set_drvdata(port->dev, port);
1033 class_set_devdata(port->sm_class_dev, port); 1034 dev_set_drvdata(port->sm_dev, port);
1034 1035
1035 if (class_device_create_file(port->sm_class_dev, &class_device_attr_ibdev)) 1036 if (device_create_file(port->sm_dev, &dev_attr_ibdev))
1036 goto err_sm_class; 1037 goto err_sm_dev;
1037 if (class_device_create_file(port->sm_class_dev, &class_device_attr_port)) 1038 if (device_create_file(port->sm_dev, &dev_attr_port))
1038 goto err_sm_class; 1039 goto err_sm_dev;
1039 1040
1040 spin_lock(&port_lock); 1041 spin_lock(&port_lock);
1041 umad_port[port->dev_num] = port; 1042 umad_port[port->dev_num] = port;
@@ -1043,17 +1044,17 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
1043 1044
1044 return 0; 1045 return 0;
1045 1046
1046err_sm_class: 1047err_sm_dev:
1047 class_device_destroy(umad_class, port->sm_dev->dev); 1048 device_destroy(umad_class, port->sm_cdev->dev);
1048 1049
1049err_sm_cdev: 1050err_sm_cdev:
1050 cdev_del(port->sm_dev); 1051 cdev_del(port->sm_cdev);
1051 1052
1052err_class: 1053err_dev:
1053 class_device_destroy(umad_class, port->dev->dev); 1054 device_destroy(umad_class, port->cdev->dev);
1054 1055
1055err_cdev: 1056err_cdev:
1056 cdev_del(port->dev); 1057 cdev_del(port->cdev);
1057 clear_bit(port->dev_num, dev_map); 1058 clear_bit(port->dev_num, dev_map);
1058 1059
1059 return -1; 1060 return -1;
@@ -1065,14 +1066,14 @@ static void ib_umad_kill_port(struct ib_umad_port *port)
1065 int already_dead; 1066 int already_dead;
1066 int id; 1067 int id;
1067 1068
1068 class_set_devdata(port->class_dev, NULL); 1069 dev_set_drvdata(port->dev, NULL);
1069 class_set_devdata(port->sm_class_dev, NULL); 1070 dev_set_drvdata(port->sm_dev, NULL);
1070 1071
1071 class_device_destroy(umad_class, port->dev->dev); 1072 device_destroy(umad_class, port->cdev->dev);
1072 class_device_destroy(umad_class, port->sm_dev->dev); 1073 device_destroy(umad_class, port->sm_cdev->dev);
1073 1074
1074 cdev_del(port->dev); 1075 cdev_del(port->cdev);
1075 cdev_del(port->sm_dev); 1076 cdev_del(port->sm_cdev);
1076 1077
1077 spin_lock(&port_lock); 1078 spin_lock(&port_lock);
1078 umad_port[port->dev_num] = NULL; 1079 umad_port[port->dev_num] = NULL;