2 * raid_class.h - a generic raid visualisation class
4 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
6 * This file is licensed under GPLv2
8 #include <linux/transport_class.h>
10 struct raid_template
{
11 struct transport_container raid_attrs
;
14 struct raid_function_template
{
16 int (*is_raid
)(struct device
*);
17 void (*get_resync
)(struct device
*);
18 void (*get_state
)(struct device
*);
22 RAID_STATE_UNKNOWN
= 0,
30 RAID_LEVEL_UNKNOWN
= 0,
45 struct list_head component_list
;
47 enum raid_level level
;
48 enum raid_state state
;
52 /* resync complete goes from 0 to this */
53 #define RAID_MAX_RESYNC (10000)
55 #define DEFINE_RAID_ATTRIBUTE(type, attr) \
57 raid_set_##attr(struct raid_template *r, struct device *dev, type value) { \
58 struct device *device = \
59 attribute_container_find_class_device(&r->raid_attrs.ac, dev);\
60 struct raid_data *rd; \
62 rd = dev_get_drvdata(device); \
66 raid_get_##attr(struct raid_template *r, struct device *dev) { \
67 struct device *device = \
68 attribute_container_find_class_device(&r->raid_attrs.ac, dev);\
69 struct raid_data *rd; \
71 rd = dev_get_drvdata(device); \
75 DEFINE_RAID_ATTRIBUTE(enum raid_level
, level
)
76 DEFINE_RAID_ATTRIBUTE(int, resync
)
77 DEFINE_RAID_ATTRIBUTE(enum raid_state
, state
)
79 struct raid_template
*raid_class_attach(struct raid_function_template
*);
80 void raid_class_release(struct raid_template
*);
82 int __must_check
raid_component_add(struct raid_template
*, struct device
*,