Root/
1 | /* |
2 | * raid_class.h - a generic raid visualisation class |
3 | * |
4 | * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com> |
5 | * |
6 | * This file is licensed under GPLv2 |
7 | */ |
8 | #include <linux/transport_class.h> |
9 | |
10 | struct raid_template { |
11 | struct transport_container raid_attrs; |
12 | }; |
13 | |
14 | struct raid_function_template { |
15 | void *cookie; |
16 | int (*is_raid)(struct device *); |
17 | void (*get_resync)(struct device *); |
18 | void (*get_state)(struct device *); |
19 | }; |
20 | |
21 | enum raid_state { |
22 | RAID_STATE_UNKNOWN = 0, |
23 | RAID_STATE_ACTIVE, |
24 | RAID_STATE_DEGRADED, |
25 | RAID_STATE_RESYNCING, |
26 | RAID_STATE_OFFLINE, |
27 | }; |
28 | |
29 | enum raid_level { |
30 | RAID_LEVEL_UNKNOWN = 0, |
31 | RAID_LEVEL_LINEAR, |
32 | RAID_LEVEL_0, |
33 | RAID_LEVEL_1, |
34 | RAID_LEVEL_10, |
35 | RAID_LEVEL_1E, |
36 | RAID_LEVEL_3, |
37 | RAID_LEVEL_4, |
38 | RAID_LEVEL_5, |
39 | RAID_LEVEL_50, |
40 | RAID_LEVEL_6, |
41 | }; |
42 | |
43 | struct raid_data { |
44 | struct list_head component_list; |
45 | int component_count; |
46 | enum raid_level level; |
47 | enum raid_state state; |
48 | int resync; |
49 | }; |
50 | |
51 | /* resync complete goes from 0 to this */ |
52 | #define RAID_MAX_RESYNC (10000) |
53 | |
54 | #define DEFINE_RAID_ATTRIBUTE(type, attr) \ |
55 | static inline void \ |
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; \ |
60 | BUG_ON(!device); \ |
61 | rd = dev_get_drvdata(device); \ |
62 | rd->attr = value; \ |
63 | } \ |
64 | static inline type \ |
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; \ |
69 | BUG_ON(!device); \ |
70 | rd = dev_get_drvdata(device); \ |
71 | return rd->attr; \ |
72 | } |
73 | |
74 | DEFINE_RAID_ATTRIBUTE(enum raid_level, level) |
75 | DEFINE_RAID_ATTRIBUTE(int, resync) |
76 | DEFINE_RAID_ATTRIBUTE(enum raid_state, state) |
77 | |
78 | struct raid_template *raid_class_attach(struct raid_function_template *); |
79 | void raid_class_release(struct raid_template *); |
80 | |
81 | int __must_check raid_component_add(struct raid_template *, struct device *, |
82 | struct device *); |
83 | |
84 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9