0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef _LINUX_ENCLOSURE_H_
0013 #define _LINUX_ENCLOSURE_H_
0014
0015 #include <linux/device.h>
0016 #include <linux/list.h>
0017
0018
0019 enum enclosure_component_type {
0020 ENCLOSURE_COMPONENT_DEVICE = 0x01,
0021 ENCLOSURE_COMPONENT_CONTROLLER_ELECTRONICS = 0x07,
0022 ENCLOSURE_COMPONENT_SCSI_TARGET_PORT = 0x14,
0023 ENCLOSURE_COMPONENT_SCSI_INITIATOR_PORT = 0x15,
0024 ENCLOSURE_COMPONENT_ARRAY_DEVICE = 0x17,
0025 ENCLOSURE_COMPONENT_SAS_EXPANDER = 0x18,
0026 };
0027
0028
0029 enum enclosure_status {
0030 ENCLOSURE_STATUS_UNSUPPORTED = 0,
0031 ENCLOSURE_STATUS_OK,
0032 ENCLOSURE_STATUS_CRITICAL,
0033 ENCLOSURE_STATUS_NON_CRITICAL,
0034 ENCLOSURE_STATUS_UNRECOVERABLE,
0035 ENCLOSURE_STATUS_NOT_INSTALLED,
0036 ENCLOSURE_STATUS_UNKNOWN,
0037 ENCLOSURE_STATUS_UNAVAILABLE,
0038
0039 ENCLOSURE_STATUS_MAX
0040 };
0041
0042
0043 enum enclosure_component_setting {
0044 ENCLOSURE_SETTING_DISABLED = 0,
0045 ENCLOSURE_SETTING_ENABLED = 1,
0046 ENCLOSURE_SETTING_BLINK_A_ON_OFF = 2,
0047 ENCLOSURE_SETTING_BLINK_A_OFF_ON = 3,
0048 ENCLOSURE_SETTING_BLINK_B_ON_OFF = 6,
0049 ENCLOSURE_SETTING_BLINK_B_OFF_ON = 7,
0050 };
0051
0052 struct enclosure_device;
0053 struct enclosure_component;
0054 struct enclosure_component_callbacks {
0055 void (*get_status)(struct enclosure_device *,
0056 struct enclosure_component *);
0057 int (*set_status)(struct enclosure_device *,
0058 struct enclosure_component *,
0059 enum enclosure_status);
0060 void (*get_fault)(struct enclosure_device *,
0061 struct enclosure_component *);
0062 int (*set_fault)(struct enclosure_device *,
0063 struct enclosure_component *,
0064 enum enclosure_component_setting);
0065 void (*get_active)(struct enclosure_device *,
0066 struct enclosure_component *);
0067 int (*set_active)(struct enclosure_device *,
0068 struct enclosure_component *,
0069 enum enclosure_component_setting);
0070 void (*get_locate)(struct enclosure_device *,
0071 struct enclosure_component *);
0072 int (*set_locate)(struct enclosure_device *,
0073 struct enclosure_component *,
0074 enum enclosure_component_setting);
0075 void (*get_power_status)(struct enclosure_device *,
0076 struct enclosure_component *);
0077 int (*set_power_status)(struct enclosure_device *,
0078 struct enclosure_component *,
0079 int);
0080 int (*show_id)(struct enclosure_device *, char *buf);
0081 };
0082
0083
0084 struct enclosure_component {
0085 void *scratch;
0086 struct device cdev;
0087 struct device *dev;
0088 enum enclosure_component_type type;
0089 int number;
0090 int fault;
0091 int active;
0092 int locate;
0093 int slot;
0094 enum enclosure_status status;
0095 int power_status;
0096 };
0097
0098 struct enclosure_device {
0099 void *scratch;
0100 struct list_head node;
0101 struct device edev;
0102 struct enclosure_component_callbacks *cb;
0103 int components;
0104 struct enclosure_component component[];
0105 };
0106
0107 static inline struct enclosure_device *
0108 to_enclosure_device(struct device *dev)
0109 {
0110 return container_of(dev, struct enclosure_device, edev);
0111 }
0112
0113 static inline struct enclosure_component *
0114 to_enclosure_component(struct device *dev)
0115 {
0116 return container_of(dev, struct enclosure_component, cdev);
0117 }
0118
0119 struct enclosure_device *
0120 enclosure_register(struct device *, const char *, int,
0121 struct enclosure_component_callbacks *);
0122 void enclosure_unregister(struct enclosure_device *);
0123 struct enclosure_component *
0124 enclosure_component_alloc(struct enclosure_device *, unsigned int,
0125 enum enclosure_component_type, const char *);
0126 int enclosure_component_register(struct enclosure_component *);
0127 int enclosure_add_device(struct enclosure_device *enclosure, int component,
0128 struct device *dev);
0129 int enclosure_remove_device(struct enclosure_device *, struct device *);
0130 struct enclosure_device *enclosure_find(struct device *dev,
0131 struct enclosure_device *start);
0132 int enclosure_for_each_device(int (*fn)(struct enclosure_device *, void *),
0133 void *data);
0134
0135 #endif