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