diff options
Diffstat (limited to 'drivers/message/i2o/i2o_config.c')
-rw-r--r-- | drivers/message/i2o/i2o_config.c | 118 |
1 files changed, 114 insertions, 4 deletions
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c index 46d373287a30..383e89a5c9f0 100644 --- a/drivers/message/i2o/i2o_config.c +++ b/drivers/message/i2o/i2o_config.c | |||
@@ -80,13 +80,123 @@ struct i2o_cfg_info { | |||
80 | static struct i2o_cfg_info *open_files = NULL; | 80 | static struct i2o_cfg_info *open_files = NULL; |
81 | static ulong i2o_cfg_info_id = 0; | 81 | static ulong i2o_cfg_info_id = 0; |
82 | 82 | ||
83 | /* | 83 | /** |
84 | * Each of these describes an i2o message handler. They are | 84 | * i2o_config_read_hrt - Returns the HRT of the controller |
85 | * multiplexed by the i2o_core code | 85 | * @kob: kernel object handle |
86 | * @buf: buffer into which the HRT should be copied | ||
87 | * @off: file offset | ||
88 | * @count: number of bytes to read | ||
89 | * | ||
90 | * Put @count bytes starting at @off into @buf from the HRT of the I2O | ||
91 | * controller corresponding to @kobj. | ||
92 | * | ||
93 | * Returns number of bytes copied into buffer. | ||
94 | */ | ||
95 | static ssize_t i2o_config_read_hrt(struct kobject *kobj, char *buf, | ||
96 | loff_t offset, size_t count) | ||
97 | { | ||
98 | struct i2o_controller *c = to_i2o_controller(container_of(kobj, | ||
99 | struct device, | ||
100 | kobj)); | ||
101 | i2o_hrt *hrt = c->hrt.virt; | ||
102 | |||
103 | u32 size = (hrt->num_entries * hrt->entry_len + 2) * 4; | ||
104 | |||
105 | if(offset > size) | ||
106 | return 0; | ||
107 | |||
108 | if(offset + count > size) | ||
109 | count = size - offset; | ||
110 | |||
111 | memcpy(buf, (u8 *) hrt + offset, count); | ||
112 | |||
113 | return count; | ||
114 | }; | ||
115 | |||
116 | /** | ||
117 | * i2o_config_read_lct - Returns the LCT of the controller | ||
118 | * @kob: kernel object handle | ||
119 | * @buf: buffer into which the LCT should be copied | ||
120 | * @off: file offset | ||
121 | * @count: number of bytes to read | ||
122 | * | ||
123 | * Put @count bytes starting at @off into @buf from the LCT of the I2O | ||
124 | * controller corresponding to @kobj. | ||
125 | * | ||
126 | * Returns number of bytes copied into buffer. | ||
127 | */ | ||
128 | static ssize_t i2o_config_read_lct(struct kobject *kobj, char *buf, | ||
129 | loff_t offset, size_t count) | ||
130 | { | ||
131 | struct i2o_controller *c = to_i2o_controller(container_of(kobj, | ||
132 | struct device, | ||
133 | kobj)); | ||
134 | u32 size = c->lct->table_size * 4; | ||
135 | |||
136 | if(offset > size) | ||
137 | return 0; | ||
138 | |||
139 | if(offset + count > size) | ||
140 | count = size - offset; | ||
141 | |||
142 | memcpy(buf, (u8 *) c->lct + offset, count); | ||
143 | |||
144 | return count; | ||
145 | }; | ||
146 | |||
147 | /* attribute for HRT in sysfs */ | ||
148 | static struct bin_attribute i2o_config_hrt_attr = { | ||
149 | .attr = { | ||
150 | .name = "hrt", | ||
151 | .mode = S_IRUGO, | ||
152 | .owner = THIS_MODULE | ||
153 | }, | ||
154 | .size = 0, | ||
155 | .read = i2o_config_read_hrt | ||
156 | }; | ||
157 | |||
158 | /* attribute for LCT in sysfs */ | ||
159 | static struct bin_attribute i2o_config_lct_attr = { | ||
160 | .attr = { | ||
161 | .name = "lct", | ||
162 | .mode = S_IRUGO, | ||
163 | .owner = THIS_MODULE | ||
164 | }, | ||
165 | .size = 0, | ||
166 | .read = i2o_config_read_lct | ||
167 | }; | ||
168 | |||
169 | /** | ||
170 | * i2o_config_notify_controller_add - Notify of added controller | ||
171 | * @c: the controller which was added | ||
172 | * | ||
173 | * If a I2O controller is added, we catch the notification to add sysfs | ||
174 | * entries. | ||
175 | */ | ||
176 | static void i2o_config_notify_controller_add(struct i2o_controller *c) | ||
177 | { | ||
178 | sysfs_create_bin_file(&(c->device.kobj), &i2o_config_hrt_attr); | ||
179 | sysfs_create_bin_file(&(c->device.kobj), &i2o_config_lct_attr); | ||
180 | }; | ||
181 | |||
182 | /** | ||
183 | * i2o_config_notify_controller_remove - Notify of removed controller | ||
184 | * @c: the controller which was removed | ||
185 | * | ||
186 | * If a I2O controller is removed, we catch the notification to remove the | ||
187 | * sysfs entries. | ||
86 | */ | 188 | */ |
189 | static void i2o_config_notify_controller_remove(struct i2o_controller *c) | ||
190 | { | ||
191 | sysfs_remove_bin_file(&c->device.kobj, &i2o_config_lct_attr); | ||
192 | sysfs_remove_bin_file(&c->device.kobj, &i2o_config_hrt_attr); | ||
193 | }; | ||
87 | 194 | ||
195 | /* Config OSM driver struct */ | ||
88 | static struct i2o_driver i2o_config_driver = { | 196 | static struct i2o_driver i2o_config_driver = { |
89 | .name = OSM_NAME | 197 | .name = OSM_NAME, |
198 | .notify_controller_add = i2o_config_notify_controller_add, | ||
199 | .notify_controller_remove = i2o_config_notify_controller_remove | ||
90 | }; | 200 | }; |
91 | 201 | ||
92 | static int i2o_cfg_getiops(unsigned long arg) | 202 | static int i2o_cfg_getiops(unsigned long arg) |