1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef _LINUX_ENCLOSURE_H_
24#define _LINUX_ENCLOSURE_H_
25
26#include <linux/device.h>
27#include <linux/list.h>
28
29
30enum enclosure_component_type {
31 ENCLOSURE_COMPONENT_DEVICE = 0x01,
32 ENCLOSURE_COMPONENT_ARRAY_DEVICE = 0x17,
33};
34
35
36enum enclosure_status {
37 ENCLOSURE_STATUS_UNSUPPORTED = 0,
38 ENCLOSURE_STATUS_OK,
39 ENCLOSURE_STATUS_CRITICAL,
40 ENCLOSURE_STATUS_NON_CRITICAL,
41 ENCLOSURE_STATUS_UNRECOVERABLE,
42 ENCLOSURE_STATUS_NOT_INSTALLED,
43 ENCLOSURE_STATUS_UNKNOWN,
44 ENCLOSURE_STATUS_UNAVAILABLE,
45};
46
47
48enum enclosure_component_setting {
49 ENCLOSURE_SETTING_DISABLED = 0,
50 ENCLOSURE_SETTING_ENABLED = 1,
51 ENCLOSURE_SETTING_BLINK_A_ON_OFF = 2,
52 ENCLOSURE_SETTING_BLINK_A_OFF_ON = 3,
53 ENCLOSURE_SETTING_BLINK_B_ON_OFF = 6,
54 ENCLOSURE_SETTING_BLINK_B_OFF_ON = 7,
55};
56
57struct enclosure_device;
58struct enclosure_component;
59struct enclosure_component_callbacks {
60 void (*get_status)(struct enclosure_device *,
61 struct enclosure_component *);
62 int (*set_status)(struct enclosure_device *,
63 struct enclosure_component *,
64 enum enclosure_status);
65 void (*get_fault)(struct enclosure_device *,
66 struct enclosure_component *);
67 int (*set_fault)(struct enclosure_device *,
68 struct enclosure_component *,
69 enum enclosure_component_setting);
70 void (*get_active)(struct enclosure_device *,
71 struct enclosure_component *);
72 int (*set_active)(struct enclosure_device *,
73 struct enclosure_component *,
74 enum enclosure_component_setting);
75 void (*get_locate)(struct enclosure_device *,
76 struct enclosure_component *);
77 int (*set_locate)(struct enclosure_device *,
78 struct enclosure_component *,
79 enum enclosure_component_setting);
80};
81
82
83struct enclosure_component {
84 void *scratch;
85 struct device cdev;
86 struct device *dev;
87 enum enclosure_component_type type;
88 int number;
89 int fault;
90 int active;
91 int locate;
92 enum enclosure_status status;
93};
94
95struct enclosure_device {
96 void *scratch;
97 struct list_head node;
98 struct device edev;
99 struct enclosure_component_callbacks *cb;
100 int components;
101 struct enclosure_component component[0];
102};
103
104static inline struct enclosure_device *
105to_enclosure_device(struct device *dev)
106{
107 return container_of(dev, struct enclosure_device, edev);
108}
109
110static inline struct enclosure_component *
111to_enclosure_component(struct device *dev)
112{
113 return container_of(dev, struct enclosure_component, cdev);
114}
115
116struct enclosure_device *
117enclosure_register(struct device *, const char *, int,
118 struct enclosure_component_callbacks *);
119void enclosure_unregister(struct enclosure_device *);
120struct enclosure_component *
121enclosure_component_register(struct enclosure_device *, unsigned int,
122 enum enclosure_component_type, const char *);
123int enclosure_add_device(struct enclosure_device *enclosure, int component,
124 struct device *dev);
125int enclosure_remove_device(struct enclosure_device *, struct device *);
126struct enclosure_device *enclosure_find(struct device *dev,
127 struct enclosure_device *start);
128int enclosure_for_each_device(int (*fn)(struct enclosure_device *, void *),
129 void *data);
130
131#endif
132