diff options
Diffstat (limited to 'drivers/scsi/raid_class.c')
-rw-r--r-- | drivers/scsi/raid_class.c | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/drivers/scsi/raid_class.c b/drivers/scsi/raid_class.c index 52182a744ba6..913a931176ef 100644 --- a/drivers/scsi/raid_class.c +++ b/drivers/scsi/raid_class.c | |||
@@ -24,15 +24,15 @@ struct raid_internal { | |||
24 | struct raid_template r; | 24 | struct raid_template r; |
25 | struct raid_function_template *f; | 25 | struct raid_function_template *f; |
26 | /* The actual attributes */ | 26 | /* The actual attributes */ |
27 | struct class_device_attribute private_attrs[RAID_NUM_ATTRS]; | 27 | struct device_attribute private_attrs[RAID_NUM_ATTRS]; |
28 | /* The array of null terminated pointers to attributes | 28 | /* The array of null terminated pointers to attributes |
29 | * needed by scsi_sysfs.c */ | 29 | * needed by scsi_sysfs.c */ |
30 | struct class_device_attribute *attrs[RAID_NUM_ATTRS + 1]; | 30 | struct device_attribute *attrs[RAID_NUM_ATTRS + 1]; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | struct raid_component { | 33 | struct raid_component { |
34 | struct list_head node; | 34 | struct list_head node; |
35 | struct class_device cdev; | 35 | struct device dev; |
36 | int num; | 36 | int num; |
37 | }; | 37 | }; |
38 | 38 | ||
@@ -50,9 +50,9 @@ struct raid_component { | |||
50 | tc_to_raid_internal(tc); \ | 50 | tc_to_raid_internal(tc); \ |
51 | }) | 51 | }) |
52 | 52 | ||
53 | #define class_device_to_raid_internal(cdev) ({ \ | 53 | #define device_to_raid_internal(dev) ({ \ |
54 | struct attribute_container *ac = \ | 54 | struct attribute_container *ac = \ |
55 | attribute_container_classdev_to_container(cdev); \ | 55 | attribute_container_classdev_to_container(dev); \ |
56 | ac_to_raid_internal(ac); \ | 56 | ac_to_raid_internal(ac); \ |
57 | }) | 57 | }) |
58 | 58 | ||
@@ -76,33 +76,33 @@ static int raid_match(struct attribute_container *cont, struct device *dev) | |||
76 | } | 76 | } |
77 | 77 | ||
78 | static int raid_setup(struct transport_container *tc, struct device *dev, | 78 | static int raid_setup(struct transport_container *tc, struct device *dev, |
79 | struct class_device *cdev) | 79 | struct device *cdev) |
80 | { | 80 | { |
81 | struct raid_data *rd; | 81 | struct raid_data *rd; |
82 | 82 | ||
83 | BUG_ON(class_get_devdata(cdev)); | 83 | BUG_ON(dev_get_drvdata(cdev)); |
84 | 84 | ||
85 | rd = kzalloc(sizeof(*rd), GFP_KERNEL); | 85 | rd = kzalloc(sizeof(*rd), GFP_KERNEL); |
86 | if (!rd) | 86 | if (!rd) |
87 | return -ENOMEM; | 87 | return -ENOMEM; |
88 | 88 | ||
89 | INIT_LIST_HEAD(&rd->component_list); | 89 | INIT_LIST_HEAD(&rd->component_list); |
90 | class_set_devdata(cdev, rd); | 90 | dev_set_drvdata(cdev, rd); |
91 | 91 | ||
92 | return 0; | 92 | return 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | static int raid_remove(struct transport_container *tc, struct device *dev, | 95 | static int raid_remove(struct transport_container *tc, struct device *dev, |
96 | struct class_device *cdev) | 96 | struct device *cdev) |
97 | { | 97 | { |
98 | struct raid_data *rd = class_get_devdata(cdev); | 98 | struct raid_data *rd = dev_get_drvdata(cdev); |
99 | struct raid_component *rc, *next; | 99 | struct raid_component *rc, *next; |
100 | dev_printk(KERN_ERR, dev, "RAID REMOVE\n"); | 100 | dev_printk(KERN_ERR, dev, "RAID REMOVE\n"); |
101 | class_set_devdata(cdev, NULL); | 101 | dev_set_drvdata(cdev, NULL); |
102 | list_for_each_entry_safe(rc, next, &rd->component_list, node) { | 102 | list_for_each_entry_safe(rc, next, &rd->component_list, node) { |
103 | list_del(&rc->node); | 103 | list_del(&rc->node); |
104 | dev_printk(KERN_ERR, rc->cdev.dev, "RAID COMPONENT REMOVE\n"); | 104 | dev_printk(KERN_ERR, rc->dev.parent, "RAID COMPONENT REMOVE\n"); |
105 | class_device_unregister(&rc->cdev); | 105 | device_unregister(&rc->dev); |
106 | } | 106 | } |
107 | dev_printk(KERN_ERR, dev, "RAID REMOVE DONE\n"); | 107 | dev_printk(KERN_ERR, dev, "RAID REMOVE DONE\n"); |
108 | kfree(rd); | 108 | kfree(rd); |
@@ -171,9 +171,11 @@ static const char *raid_level_name(enum raid_level level) | |||
171 | } | 171 | } |
172 | 172 | ||
173 | #define raid_attr_show_internal(attr, fmt, var, code) \ | 173 | #define raid_attr_show_internal(attr, fmt, var, code) \ |
174 | static ssize_t raid_show_##attr(struct class_device *cdev, char *buf) \ | 174 | static ssize_t raid_show_##attr(struct device *dev, \ |
175 | struct device_attribute *attr, \ | ||
176 | char *buf) \ | ||
175 | { \ | 177 | { \ |
176 | struct raid_data *rd = class_get_devdata(cdev); \ | 178 | struct raid_data *rd = dev_get_drvdata(dev); \ |
177 | code \ | 179 | code \ |
178 | return snprintf(buf, 20, #fmt "\n", var); \ | 180 | return snprintf(buf, 20, #fmt "\n", var); \ |
179 | } | 181 | } |
@@ -184,17 +186,17 @@ raid_attr_show_internal(attr, %s, name, \ | |||
184 | code \ | 186 | code \ |
185 | name = raid_##states##_name(rd->attr); \ | 187 | name = raid_##states##_name(rd->attr); \ |
186 | ) \ | 188 | ) \ |
187 | static CLASS_DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) | 189 | static DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) |
188 | 190 | ||
189 | 191 | ||
190 | #define raid_attr_ro_internal(attr, code) \ | 192 | #define raid_attr_ro_internal(attr, code) \ |
191 | raid_attr_show_internal(attr, %d, rd->attr, code) \ | 193 | raid_attr_show_internal(attr, %d, rd->attr, code) \ |
192 | static CLASS_DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) | 194 | static DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL) |
193 | 195 | ||
194 | #define ATTR_CODE(attr) \ | 196 | #define ATTR_CODE(attr) \ |
195 | struct raid_internal *i = class_device_to_raid_internal(cdev); \ | 197 | struct raid_internal *i = device_to_raid_internal(dev); \ |
196 | if (i->f->get_##attr) \ | 198 | if (i->f->get_##attr) \ |
197 | i->f->get_##attr(cdev->dev); | 199 | i->f->get_##attr(dev->parent); |
198 | 200 | ||
199 | #define raid_attr_ro(attr) raid_attr_ro_internal(attr, ) | 201 | #define raid_attr_ro(attr) raid_attr_ro_internal(attr, ) |
200 | #define raid_attr_ro_fn(attr) raid_attr_ro_internal(attr, ATTR_CODE(attr)) | 202 | #define raid_attr_ro_fn(attr) raid_attr_ro_internal(attr, ATTR_CODE(attr)) |
@@ -206,23 +208,23 @@ raid_attr_ro_state(level); | |||
206 | raid_attr_ro_fn(resync); | 208 | raid_attr_ro_fn(resync); |
207 | raid_attr_ro_state_fn(state); | 209 | raid_attr_ro_state_fn(state); |
208 | 210 | ||
209 | static void raid_component_release(struct class_device *cdev) | 211 | static void raid_component_release(struct device *dev) |
210 | { | 212 | { |
211 | struct raid_component *rc = container_of(cdev, struct raid_component, | 213 | struct raid_component *rc = |
212 | cdev); | 214 | container_of(dev, struct raid_component, dev); |
213 | dev_printk(KERN_ERR, rc->cdev.dev, "COMPONENT RELEASE\n"); | 215 | dev_printk(KERN_ERR, rc->dev.parent, "COMPONENT RELEASE\n"); |
214 | put_device(rc->cdev.dev); | 216 | put_device(rc->dev.parent); |
215 | kfree(rc); | 217 | kfree(rc); |
216 | } | 218 | } |
217 | 219 | ||
218 | int raid_component_add(struct raid_template *r,struct device *raid_dev, | 220 | int raid_component_add(struct raid_template *r,struct device *raid_dev, |
219 | struct device *component_dev) | 221 | struct device *component_dev) |
220 | { | 222 | { |
221 | struct class_device *cdev = | 223 | struct device *cdev = |
222 | attribute_container_find_class_device(&r->raid_attrs.ac, | 224 | attribute_container_find_class_device(&r->raid_attrs.ac, |
223 | raid_dev); | 225 | raid_dev); |
224 | struct raid_component *rc; | 226 | struct raid_component *rc; |
225 | struct raid_data *rd = class_get_devdata(cdev); | 227 | struct raid_data *rd = dev_get_drvdata(cdev); |
226 | int err; | 228 | int err; |
227 | 229 | ||
228 | rc = kzalloc(sizeof(*rc), GFP_KERNEL); | 230 | rc = kzalloc(sizeof(*rc), GFP_KERNEL); |
@@ -230,17 +232,16 @@ int raid_component_add(struct raid_template *r,struct device *raid_dev, | |||
230 | return -ENOMEM; | 232 | return -ENOMEM; |
231 | 233 | ||
232 | INIT_LIST_HEAD(&rc->node); | 234 | INIT_LIST_HEAD(&rc->node); |
233 | class_device_initialize(&rc->cdev); | 235 | device_initialize(&rc->dev); |
234 | rc->cdev.release = raid_component_release; | 236 | rc->dev.release = raid_component_release; |
235 | rc->cdev.dev = get_device(component_dev); | 237 | rc->dev.parent = get_device(component_dev); |
236 | rc->num = rd->component_count++; | 238 | rc->num = rd->component_count++; |
237 | 239 | ||
238 | snprintf(rc->cdev.class_id, sizeof(rc->cdev.class_id), | 240 | snprintf(rc->dev.bus_id, sizeof(rc->dev.bus_id), |
239 | "component-%d", rc->num); | 241 | "component-%d", rc->num); |
240 | list_add_tail(&rc->node, &rd->component_list); | 242 | list_add_tail(&rc->node, &rd->component_list); |
241 | rc->cdev.parent = cdev; | 243 | rc->dev.class = &raid_class.class; |
242 | rc->cdev.class = &raid_class.class; | 244 | err = device_add(&rc->dev); |
243 | err = class_device_add(&rc->cdev); | ||
244 | if (err) | 245 | if (err) |
245 | goto err_out; | 246 | goto err_out; |
246 | 247 | ||
@@ -273,9 +274,9 @@ raid_class_attach(struct raid_function_template *ft) | |||
273 | 274 | ||
274 | attribute_container_register(&i->r.raid_attrs.ac); | 275 | attribute_container_register(&i->r.raid_attrs.ac); |
275 | 276 | ||
276 | i->attrs[count++] = &class_device_attr_level; | 277 | i->attrs[count++] = &dev_attr_level; |
277 | i->attrs[count++] = &class_device_attr_resync; | 278 | i->attrs[count++] = &dev_attr_resync; |
278 | i->attrs[count++] = &class_device_attr_state; | 279 | i->attrs[count++] = &dev_attr_state; |
279 | 280 | ||
280 | i->attrs[count] = NULL; | 281 | i->attrs[count] = NULL; |
281 | BUG_ON(count > RAID_NUM_ATTRS); | 282 | BUG_ON(count > RAID_NUM_ATTRS); |