aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message/i2o/device.c
diff options
context:
space:
mode:
authorMarkus Lidel <Markus.Lidel@shadowconnect.com>2006-01-06 03:19:31 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:33:54 -0500
commit24791bd48f643194d806654b587251b0f92233e8 (patch)
treec95c4db1a565146e3c1d565ba1b796e78d88d556 /drivers/message/i2o/device.c
parent793fd15d9fafe5b1c71e50d3c041f1463895dbde (diff)
[PATCH] I2O: Remove wrong I2O device class
Removed wrong I2O device class, which was only needed to add sysfs attributes. Signed-off-by: Markus Lidel <Markus.Lidel@shadowconnect.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/message/i2o/device.c')
-rw-r--r--drivers/message/i2o/device.c144
1 files changed, 61 insertions, 83 deletions
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c
index 1db26215937f..a5e260b7a3b6 100644
--- a/drivers/message/i2o/device.c
+++ b/drivers/message/i2o/device.c
@@ -142,8 +142,9 @@ static void i2o_device_release(struct device *dev)
142 142
143 143
144/** 144/**
145 * i2o_device_class_show_class_id - Displays class id of I2O device 145 * i2o_device_show_class_id - Displays class id of I2O device
146 * @cd: class device of which the class id should be displayed 146 * @dev: device of which the class id should be displayed
147 * @attr: pointer to device attribute
147 * @buf: buffer into which the class id should be printed 148 * @buf: buffer into which the class id should be printed
148 * 149 *
149 * Returns the number of bytes which are printed into the buffer. 150 * Returns the number of bytes which are printed into the buffer.
@@ -159,15 +160,15 @@ static ssize_t i2o_device_show_class_id(struct device *dev,
159} 160}
160 161
161/** 162/**
162 * i2o_device_class_show_tid - Displays TID of I2O device 163 * i2o_device_show_tid - Displays TID of I2O device
163 * @cd: class device of which the TID should be displayed 164 * @dev: device of which the TID should be displayed
164 * @buf: buffer into which the class id should be printed 165 * @attr: pointer to device attribute
166 * @buf: buffer into which the TID should be printed
165 * 167 *
166 * Returns the number of bytes which are printed into the buffer. 168 * Returns the number of bytes which are printed into the buffer.
167 */ 169 */
168static ssize_t i2o_device_show_tid(struct device *dev, 170static ssize_t i2o_device_show_tid(struct device *dev,
169 struct device_attribute *attr, 171 struct device_attribute *attr, char *buf)
170 char *buf)
171{ 172{
172 struct i2o_device *i2o_dev = to_i2o_device(dev); 173 struct i2o_device *i2o_dev = to_i2o_device(dev);
173 174
@@ -209,66 +210,6 @@ static struct i2o_device *i2o_device_alloc(void)
209} 210}
210 211
211/** 212/**
212 * i2o_setup_sysfs_links - Adds attributes to the I2O device
213 * @cd: I2O class device which is added to the I2O device class
214 *
215 * This function get called when a I2O device is added to the class. It
216 * creates the attributes for each device and creates user/parent symlink
217 * if necessary.
218 *
219 * Returns 0 on success or negative error code on failure.
220 */
221static void i2o_setup_sysfs_links(struct i2o_device *i2o_dev)
222{
223 struct i2o_controller *c = i2o_dev->iop;
224 struct i2o_device *tmp;
225
226 /* create user entries for this device */
227 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
228 if (tmp && tmp != i2o_dev)
229 sysfs_create_link(&i2o_dev->device.kobj,
230 &tmp->device.kobj, "user");
231
232 /* create user entries refering to this device */
233 list_for_each_entry(tmp, &c->devices, list)
234 if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid &&
235 tmp != i2o_dev)
236 sysfs_create_link(&tmp->device.kobj,
237 &i2o_dev->device.kobj, "user");
238
239 /* create parent entries for this device */
240 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
241 if (tmp && tmp != i2o_dev)
242 sysfs_create_link(&i2o_dev->device.kobj,
243 &tmp->device.kobj, "parent");
244
245 /* create parent entries refering to this device */
246 list_for_each_entry(tmp, &c->devices, list)
247 if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid &&
248 tmp != i2o_dev)
249 sysfs_create_link(&tmp->device.kobj,
250 &i2o_dev->device.kobj, "parent");
251}
252
253static void i2o_remove_sysfs_links(struct i2o_device *i2o_dev)
254{
255 struct i2o_controller *c = i2o_dev->iop;
256 struct i2o_device *tmp;
257
258 sysfs_remove_link(&i2o_dev->device.kobj, "parent");
259 sysfs_remove_link(&i2o_dev->device.kobj, "user");
260
261 list_for_each_entry(tmp, &c->devices, list) {
262 if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
263 sysfs_remove_link(&tmp->device.kobj, "parent");
264 if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
265 sysfs_remove_link(&tmp->device.kobj, "user");
266 }
267}
268
269
270
271/**
272 * i2o_device_add - allocate a new I2O device and add it to the IOP 213 * i2o_device_add - allocate a new I2O device and add it to the IOP
273 * @iop: I2O controller where the device is on 214 * @iop: I2O controller where the device is on
274 * @entry: LCT entry of the I2O device 215 * @entry: LCT entry of the I2O device
@@ -282,33 +223,57 @@ static void i2o_remove_sysfs_links(struct i2o_device *i2o_dev)
282static struct i2o_device *i2o_device_add(struct i2o_controller *c, 223static struct i2o_device *i2o_device_add(struct i2o_controller *c,
283 i2o_lct_entry * entry) 224 i2o_lct_entry * entry)
284{ 225{
285 struct i2o_device *dev; 226 struct i2o_device *i2o_dev, *tmp;
286 227
287 dev = i2o_device_alloc(); 228 i2o_dev = i2o_device_alloc();
288 if (IS_ERR(dev)) { 229 if (IS_ERR(i2o_dev)) {
289 printk(KERN_ERR "i2o: unable to allocate i2o device\n"); 230 printk(KERN_ERR "i2o: unable to allocate i2o device\n");
290 return dev; 231 return i2o_dev;
291 } 232 }
292 233
293 dev->lct_data = *entry; 234 i2o_dev->lct_data = *entry;
294 dev->iop = c;
295 235
296 snprintf(dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit, 236 snprintf(i2o_dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit,
297 dev->lct_data.tid); 237 i2o_dev->lct_data.tid);
298 238
299 dev->device.parent = &c->device; 239 i2o_dev->iop = c;
240 i2o_dev->device.parent = &c->device;
300 241
301 device_register(&dev->device); 242 device_register(&i2o_dev->device);
302 243
303 list_add_tail(&dev->list, &c->devices); 244 list_add_tail(&i2o_dev->list, &c->devices);
304 245
305 i2o_setup_sysfs_links(dev); 246 /* create user entries for this device */
247 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
248 if (tmp && (tmp != i2o_dev))
249 sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj,
250 "user");
306 251
307 i2o_driver_notify_device_add_all(dev); 252 /* create user entries refering to this device */
253 list_for_each_entry(tmp, &c->devices, list)
254 if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
255 && (tmp != i2o_dev))
256 sysfs_create_link(&tmp->device.kobj,
257 &i2o_dev->device.kobj, "user");
308 258
309 pr_debug("i2o: device %s added\n", dev->device.bus_id); 259 /* create parent entries for this device */
260 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
261 if (tmp && (tmp != i2o_dev))
262 sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj,
263 "parent");
310 264
311 return dev; 265 /* create parent entries refering to this device */
266 list_for_each_entry(tmp, &c->devices, list)
267 if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
268 && (tmp != i2o_dev))
269 sysfs_create_link(&tmp->device.kobj,
270 &i2o_dev->device.kobj, "parent");
271
272 i2o_driver_notify_device_add_all(i2o_dev);
273
274 pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id);
275
276 return i2o_dev;
312} 277}
313 278
314/** 279/**
@@ -321,9 +286,22 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
321 */ 286 */
322void i2o_device_remove(struct i2o_device *i2o_dev) 287void i2o_device_remove(struct i2o_device *i2o_dev)
323{ 288{
289 struct i2o_device *tmp;
290 struct i2o_controller *c = i2o_dev->iop;
291
324 i2o_driver_notify_device_remove_all(i2o_dev); 292 i2o_driver_notify_device_remove_all(i2o_dev);
325 i2o_remove_sysfs_links(i2o_dev); 293
294 sysfs_remove_link(&i2o_dev->device.kobj, "parent");
295 sysfs_remove_link(&i2o_dev->device.kobj, "user");
296
297 list_for_each_entry(tmp, &c->devices, list) {
298 if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
299 sysfs_remove_link(&tmp->device.kobj, "parent");
300 if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
301 sysfs_remove_link(&tmp->device.kobj, "user");
302 }
326 list_del(&i2o_dev->list); 303 list_del(&i2o_dev->list);
304
327 device_unregister(&i2o_dev->device); 305 device_unregister(&i2o_dev->device);
328} 306}
329 307