13 #include <linux/module.h>
14 #include <linux/list.h>
15 #include <linux/slab.h>
16 #include <linux/string.h>
21 #define RAID_NUM_ATTRS 3
39 #define to_raid_internal(tmpl) container_of(tmpl, struct raid_internal, r)
41 #define tc_to_raid_internal(tcont) ({ \
42 struct raid_template *r = \
43 container_of(tcont, struct raid_template, raid_attrs); \
44 to_raid_internal(r); \
47 #define ac_to_raid_internal(acont) ({ \
48 struct transport_container *tc = \
49 container_of(acont, struct transport_container, ac); \
50 tc_to_raid_internal(tc); \
53 #define device_to_raid_internal(dev) ({ \
54 struct attribute_container *ac = \
55 attribute_container_classdev_to_container(dev); \
56 ac_to_raid_internal(ac); \
66 #if defined(CONFIG_SCSI) || defined(CONFIG_SCSI_MODULE)
70 if (i->
f->cookie != sdev->
host->hostt)
73 return i->
f->is_raid(dev);
102 dev_printk(
KERN_ERR, dev,
"RAID REMOVE\n");
106 dev_printk(
KERN_ERR, rc->
dev.parent,
"RAID COMPONENT REMOVE\n");
109 dev_printk(
KERN_ERR, dev,
"RAID REMOVE DONE\n");
120 static const struct {
136 for (i = 0; i <
ARRAY_SIZE(raid_states); i++) {
137 if (raid_states[i].
value == state) {
138 name = raid_states[
i].name;
167 for (i = 0; i <
ARRAY_SIZE(raid_levels); i++) {
168 if (raid_levels[i].
value == level) {
169 name = raid_levels[
i].name;
176 #define raid_attr_show_internal(attr, fmt, var, code) \
177 static ssize_t raid_show_##attr(struct device *dev, \
178 struct device_attribute *attr, \
181 struct raid_data *rd = dev_get_drvdata(dev); \
183 return snprintf(buf, 20, #fmt "\n", var); \
186 #define raid_attr_ro_states(attr, states, code) \
187 raid_attr_show_internal(attr, %s, name, \
190 name = raid_##states##_name(rd->attr); \
192 static DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL)
195 #define raid_attr_ro_internal(attr, code) \
196 raid_attr_show_internal(attr, %d, rd->attr, code) \
197 static DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL)
199 #define ATTR_CODE(attr) \
200 struct raid_internal *i = device_to_raid_internal(dev); \
201 if (i->f->get_##attr) \
202 i->f->get_##attr(dev->parent);
204 #define raid_attr_ro(attr) raid_attr_ro_internal(attr, )
205 #define raid_attr_ro_fn(attr) raid_attr_ro_internal(attr, ATTR_CODE(attr))
206 #define raid_attr_ro_state(attr) raid_attr_ro_states(attr, attr, )
207 #define raid_attr_ro_state_fn(attr) raid_attr_ro_states(attr, attr, ATTR_CODE(attr))
214 static void raid_component_release(
struct device *dev)
218 dev_printk(
KERN_ERR, rc->
dev.parent,
"COMPONENT RELEASE\n");
224 struct device *component_dev)
237 INIT_LIST_HEAD(&rc->
node);
239 rc->
dev.release = raid_component_release;
245 rc->
dev.class = &raid_class.class;
273 i->
r.raid_attrs.ac.class = &raid_class.class;
274 i->
r.raid_attrs.ac.match = raid_match;
275 i->
r.raid_attrs.ac.attrs = &i->
attrs[0];
279 i->
attrs[count++] = &dev_attr_level;
280 i->
attrs[count++] = &dev_attr_resync;
281 i->
attrs[count++] = &dev_attr_state;
301 static __init int raid_init(
void)
306 static __exit void raid_exit(
void)