Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
raid_class.h
Go to the documentation of this file.
1 /*
2  * raid_class.h - a generic raid visualisation class
3  *
4  * Copyright (c) 2005 - James Bottomley <[email protected]>
5  *
6  * This file is licensed under GPLv2
7  */
9 
10 struct raid_template {
12 };
13 
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 {
27 };
28 
29 enum raid_level {
41 };
42 
43 struct raid_data {
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 
75 DEFINE_RAID_ATTRIBUTE(int, resync)
77 
80 
81 int __must_check raid_component_add(struct raid_template *, struct device *,
82  struct device *);
83