Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105446
b: refs/heads/master
c: 0293902
h: refs/heads/master
v: v3
  • Loading branch information
Wang Chen authored and Linus Torvalds committed Jul 24, 2008
1 parent ab19eb6 commit 8533942
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f700d6e5e5549cb9349d22043f4bd153792c621f
refs/heads/master: 0293902a4d66fab27d0ddcc0766e05dae68f004e
54 changes: 42 additions & 12 deletions trunk/drivers/message/i2o/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,36 +243,66 @@ static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry)

/* create user entries for this device */
tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
if (tmp && (tmp != i2o_dev))
sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj,
"user");
if (tmp && (tmp != i2o_dev)) {
rc = sysfs_create_link(&i2o_dev->device.kobj,
&tmp->device.kobj, "user");
if (rc)
goto unreg_dev;
}

/* create user entries refering to this device */
list_for_each_entry(tmp, &c->devices, list)
if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
&& (tmp != i2o_dev))
sysfs_create_link(&tmp->device.kobj,
&i2o_dev->device.kobj, "user");
&& (tmp != i2o_dev)) {
rc = sysfs_create_link(&tmp->device.kobj,
&i2o_dev->device.kobj, "user");
if (rc)
goto rmlink1;
}

/* create parent entries for this device */
tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
if (tmp && (tmp != i2o_dev))
sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj,
"parent");
if (tmp && (tmp != i2o_dev)) {
rc = sysfs_create_link(&i2o_dev->device.kobj,
&tmp->device.kobj, "parent");
if (rc)
goto rmlink1;
}

/* create parent entries refering to this device */
list_for_each_entry(tmp, &c->devices, list)
if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
&& (tmp != i2o_dev))
sysfs_create_link(&tmp->device.kobj,
&i2o_dev->device.kobj, "parent");
&& (tmp != i2o_dev)) {
rc = sysfs_create_link(&tmp->device.kobj,
&i2o_dev->device.kobj, "parent");
if (rc)
goto rmlink2;
}

i2o_driver_notify_device_add_all(i2o_dev);

pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id);

return 0;

rmlink2:
/* If link creating failed halfway, we loop whole list to cleanup.
* And we don't care wrong removing of link, because sysfs_remove_link
* will take care of it.
*/
list_for_each_entry(tmp, &c->devices, list) {
if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
sysfs_remove_link(&tmp->device.kobj, "parent");
}
sysfs_remove_link(&i2o_dev->device.kobj, "parent");
rmlink1:
list_for_each_entry(tmp, &c->devices, list)
if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
sysfs_remove_link(&tmp->device.kobj, "user");
sysfs_remove_link(&i2o_dev->device.kobj, "user");
unreg_dev:
list_del(&i2o_dev->list);
device_unregister(&i2o_dev->device);
err:
kfree(i2o_dev);
return rc;
Expand Down

0 comments on commit 8533942

Please sign in to comment.