Commit 9cd5f336 authored by Ben Collins's avatar Ben Collins

[ieee1394]: Cleanup failure handling in ieee1394 and nodemgr.

Submitted-by: default avatarWalter Harms <WHarms@bfs.de>
Submitted-by: default avatarRandy.Dunlap <rddunlap@osdl.org>
Signed-off-by: default avatarBen Collins <bcollins@debian.org>
parent eedf267e
......@@ -1042,10 +1042,11 @@ static int hpsbpkt_thread(void *__hi)
static int __init ieee1394_init(void)
{
int i;
int i, ret;
skb_queue_head_init(&hpsbpkt_queue);
/* non-fatal error */
if (hpsb_init_config_roms()) {
HPSB_ERR("Failed to initialize some config rom entries.\n");
HPSB_ERR("Some features may not be available\n");
......@@ -1054,32 +1055,85 @@ static int __init ieee1394_init(void)
khpsbpkt_pid = kernel_thread(hpsbpkt_thread, NULL, CLONE_KERNEL);
if (khpsbpkt_pid < 0) {
HPSB_ERR("Failed to start hpsbpkt thread!\n");
return -ENOMEM;
ret = -ENOMEM;
goto exit_cleanup_config_roms;
}
devfs_mk_dir("ieee1394");
if (register_chrdev_region(IEEE1394_CORE_DEV, 256, "ieee1394")) {
HPSB_ERR("unable to register character device major %d!\n", IEEE1394_MAJOR);
return -ENODEV;
ret = -ENODEV;
goto exit_release_kernel_thread;
}
devfs_mk_dir("ieee1394");
/* actually this is a non-fatal error */
ret = devfs_mk_dir("ieee1394");
if (ret < 0) {
HPSB_ERR("unable to make devfs dir for device major %d!\n", IEEE1394_MAJOR);
goto release_chrdev;
}
bus_register(&ieee1394_bus_type);
for (i = 0; fw_bus_attrs[i]; i++)
bus_create_file(&ieee1394_bus_type, fw_bus_attrs[i]);
class_register(&hpsb_host_class);
ret = bus_register(&ieee1394_bus_type);
if (ret < 0) {
HPSB_INFO("bus register failed");
goto release_devfs;
}
if (init_csr())
return -ENOMEM;
for (i = 0; fw_bus_attrs[i]; i++) {
ret = bus_create_file(&ieee1394_bus_type, fw_bus_attrs[i]);
if (ret < 0) {
while (i >= 0) {
bus_remove_file(&ieee1394_bus_type,
fw_bus_attrs[i--]);
}
bus_unregister(&ieee1394_bus_type);
goto release_devfs;
}
}
if (!disable_nodemgr)
init_ieee1394_nodemgr();
else
ret = class_register(&hpsb_host_class);
if (ret < 0)
goto release_all_bus;
ret = init_csr();
if (ret) {
HPSB_INFO("init csr failed");
ret = -ENOMEM;
goto release_class;
}
if (disable_nodemgr) {
HPSB_INFO("nodemgr functionality disabled");
return 0;
}
ret = init_ieee1394_nodemgr();
if (ret < 0) {
HPSB_INFO("init nodemgr failed");
goto cleanup_csr;
}
return 0;
cleanup_csr:
cleanup_csr();
release_class:
class_unregister(&hpsb_host_class);
release_all_bus:
for (i = 0; fw_bus_attrs[i]; i++)
bus_remove_file(&ieee1394_bus_type, fw_bus_attrs[i]);
bus_unregister(&ieee1394_bus_type);
release_devfs:
devfs_remove("ieee1394");
release_chrdev:
unregister_chrdev_region(IEEE1394_CORE_DEV, 256);
exit_release_kernel_thread:
if (khpsbpkt_pid >= 0) {
kill_proc(khpsbpkt_pid, SIGTERM, 1);
wait_for_completion(&khpsbpkt_complete);
}
exit_cleanup_config_roms:
hpsb_cleanup_config_roms();
return ret;
}
static void __exit ieee1394_cleanup(void)
......
......@@ -1706,12 +1706,23 @@ static struct hpsb_highlevel nodemgr_highlevel = {
.remove_host = nodemgr_remove_host,
};
void init_ieee1394_nodemgr(void)
int init_ieee1394_nodemgr(void)
{
class_register(&nodemgr_ne_class);
class_register(&nodemgr_ud_class);
int ret;
ret = class_register(&nodemgr_ne_class);
if (ret < 0)
return ret;
ret = class_register(&nodemgr_ud_class);
if (ret < 0) {
class_unregister(&nodemgr_ne_class);
return ret;
}
hpsb_register_highlevel(&nodemgr_highlevel);
return 0;
}
void cleanup_ieee1394_nodemgr(void)
......
......@@ -192,7 +192,7 @@ int hpsb_node_lock(struct node_entry *ne, u64 addr,
int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *));
void init_ieee1394_nodemgr(void);
int init_ieee1394_nodemgr(void);
void cleanup_ieee1394_nodemgr(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment