diff options
-rw-r--r-- | drivers/infiniband/core/user_mad.c | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c index 7de02969ed7d..40440ef1b31c 100644 --- a/drivers/infiniband/core/user_mad.c +++ b/drivers/infiniband/core/user_mad.c | |||
@@ -87,10 +87,10 @@ enum { | |||
87 | */ | 87 | */ |
88 | 88 | ||
89 | struct ib_umad_port { | 89 | struct ib_umad_port { |
90 | struct cdev *cdev; | 90 | struct cdev cdev; |
91 | struct device *dev; | 91 | struct device *dev; |
92 | 92 | ||
93 | struct cdev *sm_cdev; | 93 | struct cdev sm_cdev; |
94 | struct device *sm_dev; | 94 | struct device *sm_dev; |
95 | struct semaphore sm_sem; | 95 | struct semaphore sm_sem; |
96 | 96 | ||
@@ -1008,17 +1008,14 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, | |||
1008 | mutex_init(&port->file_mutex); | 1008 | mutex_init(&port->file_mutex); |
1009 | INIT_LIST_HEAD(&port->file_list); | 1009 | INIT_LIST_HEAD(&port->file_list); |
1010 | 1010 | ||
1011 | port->cdev = cdev_alloc(); | 1011 | cdev_init(&port->cdev, &umad_fops); |
1012 | if (!port->cdev) | 1012 | port->cdev.owner = THIS_MODULE; |
1013 | return -1; | 1013 | kobject_set_name(&port->cdev.kobj, "umad%d", port->dev_num); |
1014 | port->cdev->owner = THIS_MODULE; | 1014 | if (cdev_add(&port->cdev, base_dev + port->dev_num, 1)) |
1015 | port->cdev->ops = &umad_fops; | ||
1016 | kobject_set_name(&port->cdev->kobj, "umad%d", port->dev_num); | ||
1017 | if (cdev_add(port->cdev, base_dev + port->dev_num, 1)) | ||
1018 | goto err_cdev; | 1015 | goto err_cdev; |
1019 | 1016 | ||
1020 | port->dev = device_create(umad_class, device->dma_device, | 1017 | port->dev = device_create(umad_class, device->dma_device, |
1021 | port->cdev->dev, port, | 1018 | port->cdev.dev, port, |
1022 | "umad%d", port->dev_num); | 1019 | "umad%d", port->dev_num); |
1023 | if (IS_ERR(port->dev)) | 1020 | if (IS_ERR(port->dev)) |
1024 | goto err_cdev; | 1021 | goto err_cdev; |
@@ -1028,17 +1025,14 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, | |||
1028 | if (device_create_file(port->dev, &dev_attr_port)) | 1025 | if (device_create_file(port->dev, &dev_attr_port)) |
1029 | goto err_dev; | 1026 | goto err_dev; |
1030 | 1027 | ||
1031 | port->sm_cdev = cdev_alloc(); | 1028 | cdev_init(&port->sm_cdev, &umad_sm_fops); |
1032 | if (!port->sm_cdev) | 1029 | port->sm_cdev.owner = THIS_MODULE; |
1033 | goto err_dev; | 1030 | kobject_set_name(&port->sm_cdev.kobj, "issm%d", port->dev_num); |
1034 | port->sm_cdev->owner = THIS_MODULE; | 1031 | if (cdev_add(&port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) |
1035 | port->sm_cdev->ops = &umad_sm_fops; | ||
1036 | kobject_set_name(&port->sm_cdev->kobj, "issm%d", port->dev_num); | ||
1037 | if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) | ||
1038 | goto err_sm_cdev; | 1032 | goto err_sm_cdev; |
1039 | 1033 | ||
1040 | port->sm_dev = device_create(umad_class, device->dma_device, | 1034 | port->sm_dev = device_create(umad_class, device->dma_device, |
1041 | port->sm_cdev->dev, port, | 1035 | port->sm_cdev.dev, port, |
1042 | "issm%d", port->dev_num); | 1036 | "issm%d", port->dev_num); |
1043 | if (IS_ERR(port->sm_dev)) | 1037 | if (IS_ERR(port->sm_dev)) |
1044 | goto err_sm_cdev; | 1038 | goto err_sm_cdev; |
@@ -1055,16 +1049,16 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, | |||
1055 | return 0; | 1049 | return 0; |
1056 | 1050 | ||
1057 | err_sm_dev: | 1051 | err_sm_dev: |
1058 | device_destroy(umad_class, port->sm_cdev->dev); | 1052 | device_destroy(umad_class, port->sm_cdev.dev); |
1059 | 1053 | ||
1060 | err_sm_cdev: | 1054 | err_sm_cdev: |
1061 | cdev_del(port->sm_cdev); | 1055 | cdev_del(&port->sm_cdev); |
1062 | 1056 | ||
1063 | err_dev: | 1057 | err_dev: |
1064 | device_destroy(umad_class, port->cdev->dev); | 1058 | device_destroy(umad_class, port->cdev.dev); |
1065 | 1059 | ||
1066 | err_cdev: | 1060 | err_cdev: |
1067 | cdev_del(port->cdev); | 1061 | cdev_del(&port->cdev); |
1068 | clear_bit(port->dev_num, dev_map); | 1062 | clear_bit(port->dev_num, dev_map); |
1069 | 1063 | ||
1070 | return -1; | 1064 | return -1; |
@@ -1079,11 +1073,11 @@ static void ib_umad_kill_port(struct ib_umad_port *port) | |||
1079 | dev_set_drvdata(port->dev, NULL); | 1073 | dev_set_drvdata(port->dev, NULL); |
1080 | dev_set_drvdata(port->sm_dev, NULL); | 1074 | dev_set_drvdata(port->sm_dev, NULL); |
1081 | 1075 | ||
1082 | device_destroy(umad_class, port->cdev->dev); | 1076 | device_destroy(umad_class, port->cdev.dev); |
1083 | device_destroy(umad_class, port->sm_cdev->dev); | 1077 | device_destroy(umad_class, port->sm_cdev.dev); |
1084 | 1078 | ||
1085 | cdev_del(port->cdev); | 1079 | cdev_del(&port->cdev); |
1086 | cdev_del(port->sm_cdev); | 1080 | cdev_del(&port->sm_cdev); |
1087 | 1081 | ||
1088 | spin_lock(&port_lock); | 1082 | spin_lock(&port_lock); |
1089 | umad_port[port->dev_num] = NULL; | 1083 | umad_port[port->dev_num] = NULL; |