1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * raid_class.h - a generic raid visualisation class
5 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
7 #include <linux/transport_class.h>
10 struct transport_container raid_attrs;
13 struct raid_function_template {
15 int (*is_raid)(struct device *);
16 void (*get_resync)(struct device *);
17 void (*get_state)(struct device *);
21 RAID_STATE_UNKNOWN = 0,
29 RAID_LEVEL_UNKNOWN = 0,
44 struct list_head component_list;
46 enum raid_level level;
47 enum raid_state state;
51 /* resync complete goes from 0 to this */
52 #define RAID_MAX_RESYNC (10000)
54 #define DEFINE_RAID_ATTRIBUTE(type, attr) \
56 raid_set_##attr(struct raid_template *r, struct device *dev, type value) { \
57 struct device *device = \
58 attribute_container_find_class_device(&r->raid_attrs.ac, dev);\
59 struct raid_data *rd; \
61 rd = dev_get_drvdata(device); \
65 raid_get_##attr(struct raid_template *r, struct device *dev) { \
66 struct device *device = \
67 attribute_container_find_class_device(&r->raid_attrs.ac, dev);\
68 struct raid_data *rd; \
70 rd = dev_get_drvdata(device); \
74 DEFINE_RAID_ATTRIBUTE(enum raid_level, level)
75 DEFINE_RAID_ATTRIBUTE(int, resync)
76 DEFINE_RAID_ATTRIBUTE(enum raid_state, state)
78 struct raid_template *raid_class_attach(struct raid_function_template *);
79 void raid_class_release(struct raid_template *);
81 int __must_check raid_component_add(struct raid_template *, struct device *,