aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/nodemgr.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ieee1394/nodemgr.c')
-rw-r--r--drivers/ieee1394/nodemgr.c466
1 files changed, 281 insertions, 185 deletions
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 8e7b83f84485..61307ca296ae 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -14,7 +14,9 @@
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/kthread.h> 16#include <linux/kthread.h>
17#include <linux/module.h>
17#include <linux/moduleparam.h> 18#include <linux/moduleparam.h>
19#include <linux/freezer.h>
18#include <asm/atomic.h> 20#include <asm/atomic.h>
19 21
20#include "csr.h" 22#include "csr.h"
@@ -66,7 +68,7 @@ static int nodemgr_check_speed(struct nodemgr_csr_info *ci, u64 addr,
66{ 68{
67 quadlet_t q; 69 quadlet_t q;
68 u8 i, *speed, old_speed, good_speed; 70 u8 i, *speed, old_speed, good_speed;
69 int ret; 71 int error;
70 72
71 speed = &(ci->host->speed[NODEID_TO_NODE(ci->nodeid)]); 73 speed = &(ci->host->speed[NODEID_TO_NODE(ci->nodeid)]);
72 old_speed = *speed; 74 old_speed = *speed;
@@ -78,9 +80,9 @@ static int nodemgr_check_speed(struct nodemgr_csr_info *ci, u64 addr,
78 * just finished its initialization. */ 80 * just finished its initialization. */
79 for (i = IEEE1394_SPEED_100; i <= old_speed; i++) { 81 for (i = IEEE1394_SPEED_100; i <= old_speed; i++) {
80 *speed = i; 82 *speed = i;
81 ret = hpsb_read(ci->host, ci->nodeid, ci->generation, addr, 83 error = hpsb_read(ci->host, ci->nodeid, ci->generation, addr,
82 &q, sizeof(quadlet_t)); 84 &q, sizeof(quadlet_t));
83 if (ret) 85 if (error)
84 break; 86 break;
85 *buffer = q; 87 *buffer = q;
86 good_speed = i; 88 good_speed = i;
@@ -94,19 +96,19 @@ static int nodemgr_check_speed(struct nodemgr_csr_info *ci, u64 addr,
94 return 0; 96 return 0;
95 } 97 }
96 *speed = old_speed; 98 *speed = old_speed;
97 return ret; 99 return error;
98} 100}
99 101
100static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length, 102static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
101 void *buffer, void *__ci) 103 void *buffer, void *__ci)
102{ 104{
103 struct nodemgr_csr_info *ci = (struct nodemgr_csr_info*)__ci; 105 struct nodemgr_csr_info *ci = (struct nodemgr_csr_info*)__ci;
104 int i, ret; 106 int i, error;
105 107
106 for (i = 1; ; i++) { 108 for (i = 1; ; i++) {
107 ret = hpsb_read(ci->host, ci->nodeid, ci->generation, addr, 109 error = hpsb_read(ci->host, ci->nodeid, ci->generation, addr,
108 buffer, length); 110 buffer, length);
109 if (!ret) { 111 if (!error) {
110 ci->speed_unverified = 0; 112 ci->speed_unverified = 0;
111 break; 113 break;
112 } 114 }
@@ -117,14 +119,14 @@ static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
117 /* The ieee1394_core guessed the node's speed capability from 119 /* The ieee1394_core guessed the node's speed capability from
118 * the self ID. Check whether a lower speed works. */ 120 * the self ID. Check whether a lower speed works. */
119 if (ci->speed_unverified && length == sizeof(quadlet_t)) { 121 if (ci->speed_unverified && length == sizeof(quadlet_t)) {
120 ret = nodemgr_check_speed(ci, addr, buffer); 122 error = nodemgr_check_speed(ci, addr, buffer);
121 if (!ret) 123 if (!error)
122 break; 124 break;
123 } 125 }
124 if (msleep_interruptible(334)) 126 if (msleep_interruptible(334))
125 return -EINTR; 127 return -EINTR;
126 } 128 }
127 return ret; 129 return error;
128} 130}
129 131
130static int nodemgr_get_max_rom(quadlet_t *bus_info_data, void *__ci) 132static int nodemgr_get_max_rom(quadlet_t *bus_info_data, void *__ci)
@@ -259,9 +261,20 @@ static struct device nodemgr_dev_template_ne = {
259 .release = nodemgr_release_ne, 261 .release = nodemgr_release_ne,
260}; 262};
261 263
264/* This dummy driver prevents the host devices from being scanned. We have no
265 * useful drivers for them yet, and there would be a deadlock possible if the
266 * driver core scans the host device while the host's low-level driver (i.e.
267 * the host's parent device) is being removed. */
268static struct device_driver nodemgr_mid_layer_driver = {
269 .bus = &ieee1394_bus_type,
270 .name = "nodemgr",
271 .owner = THIS_MODULE,
272};
273
262struct device nodemgr_dev_template_host = { 274struct device nodemgr_dev_template_host = {
263 .bus = &ieee1394_bus_type, 275 .bus = &ieee1394_bus_type,
264 .release = nodemgr_release_host, 276 .release = nodemgr_release_host,
277 .driver = &nodemgr_mid_layer_driver,
265}; 278};
266 279
267 280
@@ -306,8 +319,8 @@ static ssize_t fw_drv_show_##field (struct device_driver *drv, char *buf) \
306 return sprintf(buf, format_string, (type)driver->field);\ 319 return sprintf(buf, format_string, (type)driver->field);\
307} \ 320} \
308static struct driver_attribute driver_attr_drv_##field = { \ 321static struct driver_attribute driver_attr_drv_##field = { \
309 .attr = {.name = __stringify(field), .mode = S_IRUGO }, \ 322 .attr = {.name = __stringify(field), .mode = S_IRUGO }, \
310 .show = fw_drv_show_##field, \ 323 .show = fw_drv_show_##field, \
311}; 324};
312 325
313 326
@@ -361,7 +374,7 @@ static ssize_t fw_show_ne_tlabels_mask(struct device *dev,
361#endif 374#endif
362 spin_unlock_irqrestore(&hpsb_tlabel_lock, flags); 375 spin_unlock_irqrestore(&hpsb_tlabel_lock, flags);
363 376
364 return sprintf(buf, "0x%016llx\n", tm); 377 return sprintf(buf, "0x%016llx\n", (unsigned long long)tm);
365} 378}
366static DEVICE_ATTR(tlabels_mask, S_IRUGO, fw_show_ne_tlabels_mask, NULL); 379static DEVICE_ATTR(tlabels_mask, S_IRUGO, fw_show_ne_tlabels_mask, NULL);
367#endif /* HPSB_DEBUG_TLABELS */ 380#endif /* HPSB_DEBUG_TLABELS */
@@ -373,11 +386,11 @@ static ssize_t fw_set_ignore_driver(struct device *dev, struct device_attribute
373 int state = simple_strtoul(buf, NULL, 10); 386 int state = simple_strtoul(buf, NULL, 10);
374 387
375 if (state == 1) { 388 if (state == 1) {
376 down_write(&dev->bus->subsys.rwsem);
377 device_release_driver(dev);
378 ud->ignore_driver = 1; 389 ud->ignore_driver = 1;
379 up_write(&dev->bus->subsys.rwsem); 390 down_write(&ieee1394_bus_type.subsys.rwsem);
380 } else if (!state) 391 device_release_driver(dev);
392 up_write(&ieee1394_bus_type.subsys.rwsem);
393 } else if (state == 0)
381 ud->ignore_driver = 0; 394 ud->ignore_driver = 0;
382 395
383 return count; 396 return count;
@@ -412,11 +425,14 @@ static ssize_t fw_get_destroy_node(struct bus_type *bus, char *buf)
412static BUS_ATTR(destroy_node, S_IWUSR | S_IRUGO, fw_get_destroy_node, fw_set_destroy_node); 425static BUS_ATTR(destroy_node, S_IWUSR | S_IRUGO, fw_get_destroy_node, fw_set_destroy_node);
413 426
414 427
415static ssize_t fw_set_rescan(struct bus_type *bus, const char *buf, size_t count) 428static ssize_t fw_set_rescan(struct bus_type *bus, const char *buf,
429 size_t count)
416{ 430{
431 int error = 0;
432
417 if (simple_strtoul(buf, NULL, 10) == 1) 433 if (simple_strtoul(buf, NULL, 10) == 1)
418 bus_rescan_devices(&ieee1394_bus_type); 434 error = bus_rescan_devices(&ieee1394_bus_type);
419 return count; 435 return error ? error : count;
420} 436}
421static ssize_t fw_get_rescan(struct bus_type *bus, char *buf) 437static ssize_t fw_get_rescan(struct bus_type *bus, char *buf)
422{ 438{
@@ -432,7 +448,7 @@ static ssize_t fw_set_ignore_drivers(struct bus_type *bus, const char *buf, size
432 448
433 if (state == 1) 449 if (state == 1)
434 ignore_drivers = 1; 450 ignore_drivers = 1;
435 else if (!state) 451 else if (state == 0)
436 ignore_drivers = 0; 452 ignore_drivers = 0;
437 453
438 return count; 454 return count;
@@ -525,7 +541,7 @@ static ssize_t fw_show_drv_device_ids(struct device_driver *drv, char *buf)
525 int length = 0; 541 int length = 0;
526 char *scratch = buf; 542 char *scratch = buf;
527 543
528 driver = container_of(drv, struct hpsb_protocol_driver, driver); 544 driver = container_of(drv, struct hpsb_protocol_driver, driver);
529 545
530 for (id = driver->id_table; id->match_flags != 0; id++) { 546 for (id = driver->id_table; id->match_flags != 0; id++) {
531 int need_coma = 0; 547 int need_coma = 0;
@@ -582,7 +598,11 @@ static void nodemgr_create_drv_files(struct hpsb_protocol_driver *driver)
582 int i; 598 int i;
583 599
584 for (i = 0; i < ARRAY_SIZE(fw_drv_attrs); i++) 600 for (i = 0; i < ARRAY_SIZE(fw_drv_attrs); i++)
585 driver_create_file(drv, fw_drv_attrs[i]); 601 if (driver_create_file(drv, fw_drv_attrs[i]))
602 goto fail;
603 return;
604fail:
605 HPSB_ERR("Failed to add sysfs attribute for driver %s", driver->name);
586} 606}
587 607
588 608
@@ -602,7 +622,12 @@ static void nodemgr_create_ne_dev_files(struct node_entry *ne)
602 int i; 622 int i;
603 623
604 for (i = 0; i < ARRAY_SIZE(fw_ne_attrs); i++) 624 for (i = 0; i < ARRAY_SIZE(fw_ne_attrs); i++)
605 device_create_file(dev, fw_ne_attrs[i]); 625 if (device_create_file(dev, fw_ne_attrs[i]))
626 goto fail;
627 return;
628fail:
629 HPSB_ERR("Failed to add sysfs attribute for node %016Lx",
630 (unsigned long long)ne->guid);
606} 631}
607 632
608 633
@@ -612,11 +637,16 @@ static void nodemgr_create_host_dev_files(struct hpsb_host *host)
612 int i; 637 int i;
613 638
614 for (i = 0; i < ARRAY_SIZE(fw_host_attrs); i++) 639 for (i = 0; i < ARRAY_SIZE(fw_host_attrs); i++)
615 device_create_file(dev, fw_host_attrs[i]); 640 if (device_create_file(dev, fw_host_attrs[i]))
641 goto fail;
642 return;
643fail:
644 HPSB_ERR("Failed to add sysfs attribute for host %d", host->id);
616} 645}
617 646
618 647
619static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, nodeid_t nodeid); 648static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host,
649 nodeid_t nodeid);
620 650
621static void nodemgr_update_host_dev_links(struct hpsb_host *host) 651static void nodemgr_update_host_dev_links(struct hpsb_host *host)
622{ 652{
@@ -627,12 +657,18 @@ static void nodemgr_update_host_dev_links(struct hpsb_host *host)
627 sysfs_remove_link(&dev->kobj, "busmgr_id"); 657 sysfs_remove_link(&dev->kobj, "busmgr_id");
628 sysfs_remove_link(&dev->kobj, "host_id"); 658 sysfs_remove_link(&dev->kobj, "host_id");
629 659
630 if ((ne = find_entry_by_nodeid(host, host->irm_id))) 660 if ((ne = find_entry_by_nodeid(host, host->irm_id)) &&
631 sysfs_create_link(&dev->kobj, &ne->device.kobj, "irm_id"); 661 sysfs_create_link(&dev->kobj, &ne->device.kobj, "irm_id"))
632 if ((ne = find_entry_by_nodeid(host, host->busmgr_id))) 662 goto fail;
633 sysfs_create_link(&dev->kobj, &ne->device.kobj, "busmgr_id"); 663 if ((ne = find_entry_by_nodeid(host, host->busmgr_id)) &&
634 if ((ne = find_entry_by_nodeid(host, host->node_id))) 664 sysfs_create_link(&dev->kobj, &ne->device.kobj, "busmgr_id"))
635 sysfs_create_link(&dev->kobj, &ne->device.kobj, "host_id"); 665 goto fail;
666 if ((ne = find_entry_by_nodeid(host, host->node_id)) &&
667 sysfs_create_link(&dev->kobj, &ne->device.kobj, "host_id"))
668 goto fail;
669 return;
670fail:
671 HPSB_ERR("Failed to update sysfs attributes for host %d", host->id);
636} 672}
637 673
638static void nodemgr_create_ud_dev_files(struct unit_directory *ud) 674static void nodemgr_create_ud_dev_files(struct unit_directory *ud)
@@ -641,32 +677,39 @@ static void nodemgr_create_ud_dev_files(struct unit_directory *ud)
641 int i; 677 int i;
642 678
643 for (i = 0; i < ARRAY_SIZE(fw_ud_attrs); i++) 679 for (i = 0; i < ARRAY_SIZE(fw_ud_attrs); i++)
644 device_create_file(dev, fw_ud_attrs[i]); 680 if (device_create_file(dev, fw_ud_attrs[i]))
645 681 goto fail;
646 if (ud->flags & UNIT_DIRECTORY_SPECIFIER_ID) 682 if (ud->flags & UNIT_DIRECTORY_SPECIFIER_ID)
647 device_create_file(dev, &dev_attr_ud_specifier_id); 683 if (device_create_file(dev, &dev_attr_ud_specifier_id))
648 684 goto fail;
649 if (ud->flags & UNIT_DIRECTORY_VERSION) 685 if (ud->flags & UNIT_DIRECTORY_VERSION)
650 device_create_file(dev, &dev_attr_ud_version); 686 if (device_create_file(dev, &dev_attr_ud_version))
651 687 goto fail;
652 if (ud->flags & UNIT_DIRECTORY_VENDOR_ID) { 688 if (ud->flags & UNIT_DIRECTORY_VENDOR_ID) {
653 device_create_file(dev, &dev_attr_ud_vendor_id); 689 if (device_create_file(dev, &dev_attr_ud_vendor_id))
654 if (ud->vendor_name_kv) 690 goto fail;
655 device_create_file(dev, &dev_attr_ud_vendor_name_kv); 691 if (ud->vendor_name_kv &&
692 device_create_file(dev, &dev_attr_ud_vendor_name_kv))
693 goto fail;
656 } 694 }
657
658 if (ud->flags & UNIT_DIRECTORY_MODEL_ID) { 695 if (ud->flags & UNIT_DIRECTORY_MODEL_ID) {
659 device_create_file(dev, &dev_attr_ud_model_id); 696 if (device_create_file(dev, &dev_attr_ud_model_id))
660 if (ud->model_name_kv) 697 goto fail;
661 device_create_file(dev, &dev_attr_ud_model_name_kv); 698 if (ud->model_name_kv &&
699 device_create_file(dev, &dev_attr_ud_model_name_kv))
700 goto fail;
662 } 701 }
702 return;
703fail:
704 HPSB_ERR("Failed to add sysfs attributes for unit %s",
705 ud->device.bus_id);
663} 706}
664 707
665 708
666static int nodemgr_bus_match(struct device * dev, struct device_driver * drv) 709static int nodemgr_bus_match(struct device * dev, struct device_driver * drv)
667{ 710{
668 struct hpsb_protocol_driver *driver; 711 struct hpsb_protocol_driver *driver;
669 struct unit_directory *ud; 712 struct unit_directory *ud;
670 struct ieee1394_device_id *id; 713 struct ieee1394_device_id *id;
671 714
672 /* We only match unit directories */ 715 /* We only match unit directories */
@@ -674,55 +717,77 @@ static int nodemgr_bus_match(struct device * dev, struct device_driver * drv)
674 return 0; 717 return 0;
675 718
676 ud = container_of(dev, struct unit_directory, device); 719 ud = container_of(dev, struct unit_directory, device);
677 driver = container_of(drv, struct hpsb_protocol_driver, driver);
678
679 if (ud->ne->in_limbo || ud->ignore_driver) 720 if (ud->ne->in_limbo || ud->ignore_driver)
680 return 0; 721 return 0;
681 722
682 for (id = driver->id_table; id->match_flags != 0; id++) { 723 /* We only match drivers of type hpsb_protocol_driver */
683 if ((id->match_flags & IEEE1394_MATCH_VENDOR_ID) && 724 if (drv == &nodemgr_mid_layer_driver)
684 id->vendor_id != ud->vendor_id) 725 return 0;
685 continue;
686 726
687 if ((id->match_flags & IEEE1394_MATCH_MODEL_ID) && 727 driver = container_of(drv, struct hpsb_protocol_driver, driver);
688 id->model_id != ud->model_id) 728 for (id = driver->id_table; id->match_flags != 0; id++) {
689 continue; 729 if ((id->match_flags & IEEE1394_MATCH_VENDOR_ID) &&
730 id->vendor_id != ud->vendor_id)
731 continue;
690 732
691 if ((id->match_flags & IEEE1394_MATCH_SPECIFIER_ID) && 733 if ((id->match_flags & IEEE1394_MATCH_MODEL_ID) &&
692 id->specifier_id != ud->specifier_id) 734 id->model_id != ud->model_id)
693 continue; 735 continue;
694 736
695 if ((id->match_flags & IEEE1394_MATCH_VERSION) && 737 if ((id->match_flags & IEEE1394_MATCH_SPECIFIER_ID) &&
696 id->version != ud->version) 738 id->specifier_id != ud->specifier_id)
697 continue; 739 continue;
740
741 if ((id->match_flags & IEEE1394_MATCH_VERSION) &&
742 id->version != ud->version)
743 continue;
698 744
699 return 1; 745 return 1;
700 } 746 }
701 747
702 return 0; 748 return 0;
703} 749}
704 750
705 751
752static DEFINE_MUTEX(nodemgr_serialize_remove_uds);
753
706static void nodemgr_remove_uds(struct node_entry *ne) 754static void nodemgr_remove_uds(struct node_entry *ne)
707{ 755{
708 struct class_device *cdev, *next; 756 struct class_device *cdev;
709 struct unit_directory *ud; 757 struct unit_directory *tmp, *ud;
710 758
711 list_for_each_entry_safe(cdev, next, &nodemgr_ud_class.children, node) { 759 /* Iteration over nodemgr_ud_class.children has to be protected by
712 ud = container_of(cdev, struct unit_directory, class_dev); 760 * nodemgr_ud_class.sem, but class_device_unregister() will eventually
713 761 * take nodemgr_ud_class.sem too. Therefore pick out one ud at a time,
714 if (ud->ne != ne) 762 * release the semaphore, and then unregister the ud. Since this code
715 continue; 763 * may be called from other contexts besides the knodemgrds, protect the
716 764 * gap after release of the semaphore by nodemgr_serialize_remove_uds.
765 */
766 mutex_lock(&nodemgr_serialize_remove_uds);
767 for (;;) {
768 ud = NULL;
769 down(&nodemgr_ud_class.sem);
770 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
771 tmp = container_of(cdev, struct unit_directory,
772 class_dev);
773 if (tmp->ne == ne) {
774 ud = tmp;
775 break;
776 }
777 }
778 up(&nodemgr_ud_class.sem);
779 if (ud == NULL)
780 break;
717 class_device_unregister(&ud->class_dev); 781 class_device_unregister(&ud->class_dev);
718 device_unregister(&ud->device); 782 device_unregister(&ud->device);
719 } 783 }
784 mutex_unlock(&nodemgr_serialize_remove_uds);
720} 785}
721 786
722 787
723static void nodemgr_remove_ne(struct node_entry *ne) 788static void nodemgr_remove_ne(struct node_entry *ne)
724{ 789{
725 struct device *dev = &ne->device; 790 struct device *dev;
726 791
727 dev = get_device(&ne->device); 792 dev = get_device(&ne->device);
728 if (!dev) 793 if (!dev)
@@ -747,7 +812,7 @@ static int __nodemgr_remove_host_dev(struct device *dev, void *data)
747 812
748static void nodemgr_remove_host_dev(struct device *dev) 813static void nodemgr_remove_host_dev(struct device *dev)
749{ 814{
750 device_for_each_child(dev, NULL, __nodemgr_remove_host_dev); 815 WARN_ON(device_for_each_child(dev, NULL, __nodemgr_remove_host_dev));
751 sysfs_remove_link(&dev->kobj, "irm_id"); 816 sysfs_remove_link(&dev->kobj, "irm_id");
752 sysfs_remove_link(&dev->kobj, "busmgr_id"); 817 sysfs_remove_link(&dev->kobj, "busmgr_id");
753 sysfs_remove_link(&dev->kobj, "host_id"); 818 sysfs_remove_link(&dev->kobj, "host_id");
@@ -761,16 +826,16 @@ static void nodemgr_update_bus_options(struct node_entry *ne)
761#endif 826#endif
762 quadlet_t busoptions = be32_to_cpu(ne->csr->bus_info_data[2]); 827 quadlet_t busoptions = be32_to_cpu(ne->csr->bus_info_data[2]);
763 828
764 ne->busopt.irmc = (busoptions >> 31) & 1; 829 ne->busopt.irmc = (busoptions >> 31) & 1;
765 ne->busopt.cmc = (busoptions >> 30) & 1; 830 ne->busopt.cmc = (busoptions >> 30) & 1;
766 ne->busopt.isc = (busoptions >> 29) & 1; 831 ne->busopt.isc = (busoptions >> 29) & 1;
767 ne->busopt.bmc = (busoptions >> 28) & 1; 832 ne->busopt.bmc = (busoptions >> 28) & 1;
768 ne->busopt.pmc = (busoptions >> 27) & 1; 833 ne->busopt.pmc = (busoptions >> 27) & 1;
769 ne->busopt.cyc_clk_acc = (busoptions >> 16) & 0xff; 834 ne->busopt.cyc_clk_acc = (busoptions >> 16) & 0xff;
770 ne->busopt.max_rec = 1 << (((busoptions >> 12) & 0xf) + 1); 835 ne->busopt.max_rec = 1 << (((busoptions >> 12) & 0xf) + 1);
771 ne->busopt.max_rom = (busoptions >> 8) & 0x3; 836 ne->busopt.max_rom = (busoptions >> 8) & 0x3;
772 ne->busopt.generation = (busoptions >> 4) & 0xf; 837 ne->busopt.generation = (busoptions >> 4) & 0xf;
773 ne->busopt.lnkspd = busoptions & 0x7; 838 ne->busopt.lnkspd = busoptions & 0x7;
774 839
775 HPSB_VERBOSE("NodeMgr: raw=0x%08x irmc=%d cmc=%d isc=%d bmc=%d pmc=%d " 840 HPSB_VERBOSE("NodeMgr: raw=0x%08x irmc=%d cmc=%d isc=%d bmc=%d pmc=%d "
776 "cyc_clk_acc=%d max_rec=%d max_rom=%d gen=%d lspd=%d", 841 "cyc_clk_acc=%d max_rec=%d max_rom=%d gen=%d lspd=%d",
@@ -791,7 +856,7 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
791 856
792 ne = kzalloc(sizeof(*ne), GFP_KERNEL); 857 ne = kzalloc(sizeof(*ne), GFP_KERNEL);
793 if (!ne) 858 if (!ne)
794 return NULL; 859 goto fail_alloc;
795 860
796 ne->host = host; 861 ne->host = host;
797 ne->nodeid = nodeid; 862 ne->nodeid = nodeid;
@@ -814,12 +879,15 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
814 snprintf(ne->class_dev.class_id, BUS_ID_SIZE, "%016Lx", 879 snprintf(ne->class_dev.class_id, BUS_ID_SIZE, "%016Lx",
815 (unsigned long long)(ne->guid)); 880 (unsigned long long)(ne->guid));
816 881
817 device_register(&ne->device); 882 if (device_register(&ne->device))
818 class_device_register(&ne->class_dev); 883 goto fail_devreg;
884 if (class_device_register(&ne->class_dev))
885 goto fail_classdevreg;
819 get_device(&ne->device); 886 get_device(&ne->device);
820 887
821 if (ne->guid_vendor_oui) 888 if (ne->guid_vendor_oui &&
822 device_create_file(&ne->device, &dev_attr_ne_guid_vendor_oui); 889 device_create_file(&ne->device, &dev_attr_ne_guid_vendor_oui))
890 goto fail_addoiu;
823 nodemgr_create_ne_dev_files(ne); 891 nodemgr_create_ne_dev_files(ne);
824 892
825 nodemgr_update_bus_options(ne); 893 nodemgr_update_bus_options(ne);
@@ -829,17 +897,28 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
829 NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid); 897 NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid);
830 898
831 return ne; 899 return ne;
900
901fail_addoiu:
902 put_device(&ne->device);
903fail_classdevreg:
904 device_unregister(&ne->device);
905fail_devreg:
906 kfree(ne);
907fail_alloc:
908 HPSB_ERR("Failed to create node ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]",
909 NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid);
910
911 return NULL;
832} 912}
833 913
834 914
835static struct node_entry *find_entry_by_guid(u64 guid) 915static struct node_entry *find_entry_by_guid(u64 guid)
836{ 916{
837 struct class *class = &nodemgr_ne_class;
838 struct class_device *cdev; 917 struct class_device *cdev;
839 struct node_entry *ne, *ret_ne = NULL; 918 struct node_entry *ne, *ret_ne = NULL;
840 919
841 down_read(&class->subsys.rwsem); 920 down(&nodemgr_ne_class.sem);
842 list_for_each_entry(cdev, &class->children, node) { 921 list_for_each_entry(cdev, &nodemgr_ne_class.children, node) {
843 ne = container_of(cdev, struct node_entry, class_dev); 922 ne = container_of(cdev, struct node_entry, class_dev);
844 923
845 if (ne->guid == guid) { 924 if (ne->guid == guid) {
@@ -847,20 +926,20 @@ static struct node_entry *find_entry_by_guid(u64 guid)
847 break; 926 break;
848 } 927 }
849 } 928 }
850 up_read(&class->subsys.rwsem); 929 up(&nodemgr_ne_class.sem);
851 930
852 return ret_ne; 931 return ret_ne;
853} 932}
854 933
855 934
856static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, nodeid_t nodeid) 935static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host,
936 nodeid_t nodeid)
857{ 937{
858 struct class *class = &nodemgr_ne_class;
859 struct class_device *cdev; 938 struct class_device *cdev;
860 struct node_entry *ne, *ret_ne = NULL; 939 struct node_entry *ne, *ret_ne = NULL;
861 940
862 down_read(&class->subsys.rwsem); 941 down(&nodemgr_ne_class.sem);
863 list_for_each_entry(cdev, &class->children, node) { 942 list_for_each_entry(cdev, &nodemgr_ne_class.children, node) {
864 ne = container_of(cdev, struct node_entry, class_dev); 943 ne = container_of(cdev, struct node_entry, class_dev);
865 944
866 if (ne->host == host && ne->nodeid == nodeid) { 945 if (ne->host == host && ne->nodeid == nodeid) {
@@ -868,7 +947,7 @@ static struct node_entry *find_entry_by_nodeid(struct hpsb_host *host, nodeid_t
868 break; 947 break;
869 } 948 }
870 } 949 }
871 up_read(&class->subsys.rwsem); 950 up(&nodemgr_ne_class.sem);
872 951
873 return ret_ne; 952 return ret_ne;
874} 953}
@@ -890,13 +969,25 @@ static void nodemgr_register_device(struct node_entry *ne,
890 snprintf(ud->class_dev.class_id, BUS_ID_SIZE, "%s-%u", 969 snprintf(ud->class_dev.class_id, BUS_ID_SIZE, "%s-%u",
891 ne->device.bus_id, ud->id); 970 ne->device.bus_id, ud->id);
892 971
893 device_register(&ud->device); 972 if (device_register(&ud->device))
894 class_device_register(&ud->class_dev); 973 goto fail_devreg;
974 if (class_device_register(&ud->class_dev))
975 goto fail_classdevreg;
895 get_device(&ud->device); 976 get_device(&ud->device);
896 977
897 if (ud->vendor_oui) 978 if (ud->vendor_oui &&
898 device_create_file(&ud->device, &dev_attr_ud_vendor_oui); 979 device_create_file(&ud->device, &dev_attr_ud_vendor_oui))
980 goto fail_addoui;
899 nodemgr_create_ud_dev_files(ud); 981 nodemgr_create_ud_dev_files(ud);
982
983 return;
984
985fail_addoui:
986 put_device(&ud->device);
987fail_classdevreg:
988 device_unregister(&ud->device);
989fail_devreg:
990 HPSB_ERR("Failed to create unit %s", ud->device.bus_id);
900} 991}
901 992
902 993
@@ -976,10 +1067,9 @@ static struct unit_directory *nodemgr_process_unit_directory
976 /* Logical Unit Number */ 1067 /* Logical Unit Number */
977 if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { 1068 if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
978 if (ud->flags & UNIT_DIRECTORY_HAS_LUN) { 1069 if (ud->flags & UNIT_DIRECTORY_HAS_LUN) {
979 ud_child = kmalloc(sizeof(*ud_child), GFP_KERNEL); 1070 ud_child = kmemdup(ud, sizeof(*ud_child), GFP_KERNEL);
980 if (!ud_child) 1071 if (!ud_child)
981 goto unit_directory_error; 1072 goto unit_directory_error;
982 memcpy(ud_child, ud, sizeof(*ud_child));
983 nodemgr_register_device(ne, ud_child, &ne->device); 1073 nodemgr_register_device(ne, ud_child, &ne->device);
984 ud_child = NULL; 1074 ud_child = NULL;
985 1075
@@ -1093,10 +1183,16 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent
1093 last_key_id = kv->key.id; 1183 last_key_id = kv->key.id;
1094 } 1184 }
1095 1185
1096 if (ne->vendor_oui) 1186 if (ne->vendor_oui &&
1097 device_create_file(&ne->device, &dev_attr_ne_vendor_oui); 1187 device_create_file(&ne->device, &dev_attr_ne_vendor_oui))
1098 if (ne->vendor_name_kv) 1188 goto fail;
1099 device_create_file(&ne->device, &dev_attr_ne_vendor_name_kv); 1189 if (ne->vendor_name_kv &&
1190 device_create_file(&ne->device, &dev_attr_ne_vendor_name_kv))
1191 goto fail;
1192 return;
1193fail:
1194 HPSB_ERR("Failed to add sysfs attribute for node %016Lx",
1195 (unsigned long long)ne->guid);
1100} 1196}
1101 1197
1102#ifdef CONFIG_HOTPLUG 1198#ifdef CONFIG_HOTPLUG
@@ -1160,16 +1256,20 @@ static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp,
1160#endif /* CONFIG_HOTPLUG */ 1256#endif /* CONFIG_HOTPLUG */
1161 1257
1162 1258
1163int hpsb_register_protocol(struct hpsb_protocol_driver *driver) 1259int __hpsb_register_protocol(struct hpsb_protocol_driver *drv,
1260 struct module *owner)
1164{ 1261{
1165 int ret; 1262 int error;
1166 1263
1167 /* This will cause a probe for devices */ 1264 drv->driver.bus = &ieee1394_bus_type;
1168 ret = driver_register(&driver->driver); 1265 drv->driver.owner = owner;
1169 if (!ret) 1266 drv->driver.name = drv->name;
1170 nodemgr_create_drv_files(driver);
1171 1267
1172 return ret; 1268 /* This will cause a probe for devices */
1269 error = driver_register(&drv->driver);
1270 if (!error)
1271 nodemgr_create_drv_files(drv);
1272 return error;
1173} 1273}
1174 1274
1175void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver) 1275void hpsb_unregister_protocol(struct hpsb_protocol_driver *driver)
@@ -1297,26 +1397,25 @@ static void nodemgr_node_scan_one(struct host_info *hi,
1297 1397
1298static void nodemgr_node_scan(struct host_info *hi, int generation) 1398static void nodemgr_node_scan(struct host_info *hi, int generation)
1299{ 1399{
1300 int count; 1400 int count;
1301 struct hpsb_host *host = hi->host; 1401 struct hpsb_host *host = hi->host;
1302 struct selfid *sid = (struct selfid *)host->topology_map; 1402 struct selfid *sid = (struct selfid *)host->topology_map;
1303 nodeid_t nodeid = LOCAL_BUS; 1403 nodeid_t nodeid = LOCAL_BUS;
1304 1404
1305 /* Scan each node on the bus */ 1405 /* Scan each node on the bus */
1306 for (count = host->selfid_count; count; count--, sid++) { 1406 for (count = host->selfid_count; count; count--, sid++) {
1307 if (sid->extended) 1407 if (sid->extended)
1308 continue; 1408 continue;
1309 1409
1310 if (!sid->link_active) { 1410 if (!sid->link_active) {
1311 nodeid++; 1411 nodeid++;
1312 continue; 1412 continue;
1313 } 1413 }
1314 nodemgr_node_scan_one(hi, nodeid++, generation); 1414 nodemgr_node_scan_one(hi, nodeid++, generation);
1315 } 1415 }
1316} 1416}
1317 1417
1318 1418
1319/* Caller needs to hold nodemgr_ud_class.subsys.rwsem as reader. */
1320static void nodemgr_suspend_ne(struct node_entry *ne) 1419static void nodemgr_suspend_ne(struct node_entry *ne)
1321{ 1420{
1322 struct class_device *cdev; 1421 struct class_device *cdev;
@@ -1326,21 +1425,22 @@ static void nodemgr_suspend_ne(struct node_entry *ne)
1326 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid); 1425 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid);
1327 1426
1328 ne->in_limbo = 1; 1427 ne->in_limbo = 1;
1329 device_create_file(&ne->device, &dev_attr_ne_in_limbo); 1428 WARN_ON(device_create_file(&ne->device, &dev_attr_ne_in_limbo));
1330 1429
1331 down_write(&ne->device.bus->subsys.rwsem); 1430 down(&nodemgr_ud_class.sem);
1332 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 1431 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
1333 ud = container_of(cdev, struct unit_directory, class_dev); 1432 ud = container_of(cdev, struct unit_directory, class_dev);
1334
1335 if (ud->ne != ne) 1433 if (ud->ne != ne)
1336 continue; 1434 continue;
1337 1435
1436 down_write(&ieee1394_bus_type.subsys.rwsem);
1338 if (ud->device.driver && 1437 if (ud->device.driver &&
1339 (!ud->device.driver->suspend || 1438 (!ud->device.driver->suspend ||
1340 ud->device.driver->suspend(&ud->device, PMSG_SUSPEND))) 1439 ud->device.driver->suspend(&ud->device, PMSG_SUSPEND)))
1341 device_release_driver(&ud->device); 1440 device_release_driver(&ud->device);
1441 up_write(&ieee1394_bus_type.subsys.rwsem);
1342 } 1442 }
1343 up_write(&ne->device.bus->subsys.rwsem); 1443 up(&nodemgr_ud_class.sem);
1344} 1444}
1345 1445
1346 1446
@@ -1352,45 +1452,47 @@ static void nodemgr_resume_ne(struct node_entry *ne)
1352 ne->in_limbo = 0; 1452 ne->in_limbo = 0;
1353 device_remove_file(&ne->device, &dev_attr_ne_in_limbo); 1453 device_remove_file(&ne->device, &dev_attr_ne_in_limbo);
1354 1454
1355 down_read(&nodemgr_ud_class.subsys.rwsem); 1455 down(&nodemgr_ud_class.sem);
1356 down_read(&ne->device.bus->subsys.rwsem);
1357 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 1456 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
1358 ud = container_of(cdev, struct unit_directory, class_dev); 1457 ud = container_of(cdev, struct unit_directory, class_dev);
1359
1360 if (ud->ne != ne) 1458 if (ud->ne != ne)
1361 continue; 1459 continue;
1362 1460
1461 down_read(&ieee1394_bus_type.subsys.rwsem);
1363 if (ud->device.driver && ud->device.driver->resume) 1462 if (ud->device.driver && ud->device.driver->resume)
1364 ud->device.driver->resume(&ud->device); 1463 ud->device.driver->resume(&ud->device);
1464 up_read(&ieee1394_bus_type.subsys.rwsem);
1365 } 1465 }
1366 up_read(&ne->device.bus->subsys.rwsem); 1466 up(&nodemgr_ud_class.sem);
1367 up_read(&nodemgr_ud_class.subsys.rwsem);
1368 1467
1369 HPSB_DEBUG("Node resumed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]", 1468 HPSB_DEBUG("Node resumed: ID:BUS[" NODE_BUS_FMT "] GUID[%016Lx]",
1370 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid); 1469 NODE_BUS_ARGS(ne->host, ne->nodeid), (unsigned long long)ne->guid);
1371} 1470}
1372 1471
1373 1472
1374/* Caller needs to hold nodemgr_ud_class.subsys.rwsem as reader. */
1375static void nodemgr_update_pdrv(struct node_entry *ne) 1473static void nodemgr_update_pdrv(struct node_entry *ne)
1376{ 1474{
1377 struct unit_directory *ud; 1475 struct unit_directory *ud;
1378 struct hpsb_protocol_driver *pdrv; 1476 struct hpsb_protocol_driver *pdrv;
1379 struct class_device *cdev; 1477 struct class_device *cdev;
1380 1478
1479 down(&nodemgr_ud_class.sem);
1381 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) { 1480 list_for_each_entry(cdev, &nodemgr_ud_class.children, node) {
1382 ud = container_of(cdev, struct unit_directory, class_dev); 1481 ud = container_of(cdev, struct unit_directory, class_dev);
1383 if (ud->ne != ne || !ud->device.driver) 1482 if (ud->ne != ne)
1384 continue; 1483 continue;
1385 1484
1386 pdrv = container_of(ud->device.driver, struct hpsb_protocol_driver, driver); 1485 down_write(&ieee1394_bus_type.subsys.rwsem);
1387 1486 if (ud->device.driver) {
1388 if (pdrv->update && pdrv->update(ud)) { 1487 pdrv = container_of(ud->device.driver,
1389 down_write(&ud->device.bus->subsys.rwsem); 1488 struct hpsb_protocol_driver,
1390 device_release_driver(&ud->device); 1489 driver);
1391 up_write(&ud->device.bus->subsys.rwsem); 1490 if (pdrv->update && pdrv->update(ud))
1491 device_release_driver(&ud->device);
1392 } 1492 }
1493 up_write(&ieee1394_bus_type.subsys.rwsem);
1393 } 1494 }
1495 up(&nodemgr_ud_class.sem);
1394} 1496}
1395 1497
1396 1498
@@ -1404,7 +1506,7 @@ static void nodemgr_irm_write_bc(struct node_entry *ne, int generation)
1404{ 1506{
1405 const u64 bc_addr = (CSR_REGISTER_BASE | CSR_BROADCAST_CHANNEL); 1507 const u64 bc_addr = (CSR_REGISTER_BASE | CSR_BROADCAST_CHANNEL);
1406 quadlet_t bc_remote, bc_local; 1508 quadlet_t bc_remote, bc_local;
1407 int ret; 1509 int error;
1408 1510
1409 if (!ne->host->is_irm || ne->generation != generation || 1511 if (!ne->host->is_irm || ne->generation != generation ||
1410 ne->nodeid == ne->host->node_id) 1512 ne->nodeid == ne->host->node_id)
@@ -1413,16 +1515,14 @@ static void nodemgr_irm_write_bc(struct node_entry *ne, int generation)
1413 bc_local = cpu_to_be32(ne->host->csr.broadcast_channel); 1515 bc_local = cpu_to_be32(ne->host->csr.broadcast_channel);
1414 1516
1415 /* Check if the register is implemented and 1394a compliant. */ 1517 /* Check if the register is implemented and 1394a compliant. */
1416 ret = hpsb_read(ne->host, ne->nodeid, generation, bc_addr, &bc_remote, 1518 error = hpsb_read(ne->host, ne->nodeid, generation, bc_addr, &bc_remote,
1417 sizeof(bc_remote)); 1519 sizeof(bc_remote));
1418 if (!ret && bc_remote & cpu_to_be32(0x80000000) && 1520 if (!error && bc_remote & cpu_to_be32(0x80000000) &&
1419 bc_remote != bc_local) 1521 bc_remote != bc_local)
1420 hpsb_node_write(ne, bc_addr, &bc_local, sizeof(bc_local)); 1522 hpsb_node_write(ne, bc_addr, &bc_local, sizeof(bc_local));
1421} 1523}
1422 1524
1423 1525
1424/* Caller needs to hold nodemgr_ud_class.subsys.rwsem as reader because the
1425 * calls to nodemgr_update_pdrv() and nodemgr_suspend_ne() here require it. */
1426static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int generation) 1526static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int generation)
1427{ 1527{
1428 struct device *dev; 1528 struct device *dev;
@@ -1455,7 +1555,6 @@ static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int ge
1455static void nodemgr_node_probe(struct host_info *hi, int generation) 1555static void nodemgr_node_probe(struct host_info *hi, int generation)
1456{ 1556{
1457 struct hpsb_host *host = hi->host; 1557 struct hpsb_host *host = hi->host;
1458 struct class *class = &nodemgr_ne_class;
1459 struct class_device *cdev; 1558 struct class_device *cdev;
1460 struct node_entry *ne; 1559 struct node_entry *ne;
1461 1560
@@ -1468,18 +1567,18 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
1468 * while probes are time-consuming. (Well, those probes need some 1567 * while probes are time-consuming. (Well, those probes need some
1469 * improvement...) */ 1568 * improvement...) */
1470 1569
1471 down_read(&class->subsys.rwsem); 1570 down(&nodemgr_ne_class.sem);
1472 list_for_each_entry(cdev, &class->children, node) { 1571 list_for_each_entry(cdev, &nodemgr_ne_class.children, node) {
1473 ne = container_of(cdev, struct node_entry, class_dev); 1572 ne = container_of(cdev, struct node_entry, class_dev);
1474 if (!ne->needs_probe) 1573 if (!ne->needs_probe)
1475 nodemgr_probe_ne(hi, ne, generation); 1574 nodemgr_probe_ne(hi, ne, generation);
1476 } 1575 }
1477 list_for_each_entry(cdev, &class->children, node) { 1576 list_for_each_entry(cdev, &nodemgr_ne_class.children, node) {
1478 ne = container_of(cdev, struct node_entry, class_dev); 1577 ne = container_of(cdev, struct node_entry, class_dev);
1479 if (ne->needs_probe) 1578 if (ne->needs_probe)
1480 nodemgr_probe_ne(hi, ne, generation); 1579 nodemgr_probe_ne(hi, ne, generation);
1481 } 1580 }
1482 up_read(&class->subsys.rwsem); 1581 up(&nodemgr_ne_class.sem);
1483 1582
1484 1583
1485 /* If we had a bus reset while we were scanning the bus, it is 1584 /* If we had a bus reset while we were scanning the bus, it is
@@ -1497,15 +1596,14 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
1497 * just removed. */ 1596 * just removed. */
1498 1597
1499 if (generation == get_hpsb_generation(host)) 1598 if (generation == get_hpsb_generation(host))
1500 bus_rescan_devices(&ieee1394_bus_type); 1599 if (bus_rescan_devices(&ieee1394_bus_type))
1501 1600 HPSB_DEBUG("bus_rescan_devices had an error");
1502 return;
1503} 1601}
1504 1602
1505static int nodemgr_send_resume_packet(struct hpsb_host *host) 1603static int nodemgr_send_resume_packet(struct hpsb_host *host)
1506{ 1604{
1507 struct hpsb_packet *packet; 1605 struct hpsb_packet *packet;
1508 int ret = 1; 1606 int error = -ENOMEM;
1509 1607
1510 packet = hpsb_make_phypacket(host, 1608 packet = hpsb_make_phypacket(host,
1511 EXTPHYPACKET_TYPE_RESUME | 1609 EXTPHYPACKET_TYPE_RESUME |
@@ -1513,12 +1611,12 @@ static int nodemgr_send_resume_packet(struct hpsb_host *host)
1513 if (packet) { 1611 if (packet) {
1514 packet->no_waiter = 1; 1612 packet->no_waiter = 1;
1515 packet->generation = get_hpsb_generation(host); 1613 packet->generation = get_hpsb_generation(host);
1516 ret = hpsb_send_packet(packet); 1614 error = hpsb_send_packet(packet);
1517 } 1615 }
1518 if (ret) 1616 if (error)
1519 HPSB_WARN("fw-host%d: Failed to broadcast resume packet", 1617 HPSB_WARN("fw-host%d: Failed to broadcast resume packet",
1520 host->id); 1618 host->id);
1521 return ret; 1619 return error;
1522} 1620}
1523 1621
1524/* Perform a few high-level IRM responsibilities. */ 1622/* Perform a few high-level IRM responsibilities. */
@@ -1691,19 +1789,18 @@ exit:
1691 1789
1692int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *)) 1790int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *))
1693{ 1791{
1694 struct class *class = &hpsb_host_class;
1695 struct class_device *cdev; 1792 struct class_device *cdev;
1696 struct hpsb_host *host; 1793 struct hpsb_host *host;
1697 int error = 0; 1794 int error = 0;
1698 1795
1699 down_read(&class->subsys.rwsem); 1796 down(&hpsb_host_class.sem);
1700 list_for_each_entry(cdev, &class->children, node) { 1797 list_for_each_entry(cdev, &hpsb_host_class.children, node) {
1701 host = container_of(cdev, struct hpsb_host, class_dev); 1798 host = container_of(cdev, struct hpsb_host, class_dev);
1702 1799
1703 if ((error = cb(host, __data))) 1800 if ((error = cb(host, __data)))
1704 break; 1801 break;
1705 } 1802 }
1706 up_read(&class->subsys.rwsem); 1803 up(&hpsb_host_class.sem);
1707 1804
1708 return error; 1805 return error;
1709} 1806}
@@ -1725,10 +1822,10 @@ int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *))
1725 1822
1726void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *pkt) 1823void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *pkt)
1727{ 1824{
1728 pkt->host = ne->host; 1825 pkt->host = ne->host;
1729 pkt->generation = ne->generation; 1826 pkt->generation = ne->generation;
1730 barrier(); 1827 barrier();
1731 pkt->node_id = ne->nodeid; 1828 pkt->node_id = ne->nodeid;
1732} 1829}
1733 1830
1734int hpsb_node_write(struct node_entry *ne, u64 addr, 1831int hpsb_node_write(struct node_entry *ne, u64 addr,
@@ -1788,26 +1885,25 @@ static struct hpsb_highlevel nodemgr_highlevel = {
1788 1885
1789int init_ieee1394_nodemgr(void) 1886int init_ieee1394_nodemgr(void)
1790{ 1887{
1791 int ret; 1888 int error;
1792 1889
1793 ret = class_register(&nodemgr_ne_class); 1890 error = class_register(&nodemgr_ne_class);
1794 if (ret < 0) 1891 if (error)
1795 return ret; 1892 return error;
1796 1893
1797 ret = class_register(&nodemgr_ud_class); 1894 error = class_register(&nodemgr_ud_class);
1798 if (ret < 0) { 1895 if (error) {
1799 class_unregister(&nodemgr_ne_class); 1896 class_unregister(&nodemgr_ne_class);
1800 return ret; 1897 return error;
1801 } 1898 }
1802 1899 error = driver_register(&nodemgr_mid_layer_driver);
1803 hpsb_register_highlevel(&nodemgr_highlevel); 1900 hpsb_register_highlevel(&nodemgr_highlevel);
1804
1805 return 0; 1901 return 0;
1806} 1902}
1807 1903
1808void cleanup_ieee1394_nodemgr(void) 1904void cleanup_ieee1394_nodemgr(void)
1809{ 1905{
1810 hpsb_unregister_highlevel(&nodemgr_highlevel); 1906 hpsb_unregister_highlevel(&nodemgr_highlevel);
1811 1907
1812 class_unregister(&nodemgr_ud_class); 1908 class_unregister(&nodemgr_ud_class);
1813 class_unregister(&nodemgr_ne_class); 1909 class_unregister(&nodemgr_ne_class);