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.c61
1 files changed, 40 insertions, 21 deletions
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index dbeba45a031e..6a1a0572275e 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -16,6 +16,7 @@
16#include <linux/kthread.h> 16#include <linux/kthread.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/moduleparam.h> 18#include <linux/moduleparam.h>
19#include <linux/mutex.h>
19#include <linux/freezer.h> 20#include <linux/freezer.h>
20#include <asm/atomic.h> 21#include <asm/atomic.h>
21 22
@@ -115,7 +116,7 @@ static int nodemgr_bus_read(struct csr1212_csr *csr, u64 addr, u16 length,
115 116
116static int nodemgr_get_max_rom(quadlet_t *bus_info_data, void *__ci) 117static int nodemgr_get_max_rom(quadlet_t *bus_info_data, void *__ci)
117{ 118{
118 return (CSR1212_BE32_TO_CPU(bus_info_data[2]) >> 8) & 0x3; 119 return (be32_to_cpu(bus_info_data[2]) >> 8) & 0x3;
119} 120}
120 121
121static struct csr1212_bus_ops nodemgr_csr_ops = { 122static struct csr1212_bus_ops nodemgr_csr_ops = {
@@ -580,7 +581,7 @@ static void nodemgr_create_drv_files(struct hpsb_protocol_driver *driver)
580 goto fail; 581 goto fail;
581 return; 582 return;
582fail: 583fail:
583 HPSB_ERR("Failed to add sysfs attribute for driver %s", driver->name); 584 HPSB_ERR("Failed to add sysfs attribute");
584} 585}
585 586
586 587
@@ -604,8 +605,7 @@ static void nodemgr_create_ne_dev_files(struct node_entry *ne)
604 goto fail; 605 goto fail;
605 return; 606 return;
606fail: 607fail:
607 HPSB_ERR("Failed to add sysfs attribute for node %016Lx", 608 HPSB_ERR("Failed to add sysfs attribute");
608 (unsigned long long)ne->guid);
609} 609}
610 610
611 611
@@ -619,7 +619,7 @@ static void nodemgr_create_host_dev_files(struct hpsb_host *host)
619 goto fail; 619 goto fail;
620 return; 620 return;
621fail: 621fail:
622 HPSB_ERR("Failed to add sysfs attribute for host %d", host->id); 622 HPSB_ERR("Failed to add sysfs attribute");
623} 623}
624 624
625 625
@@ -679,8 +679,7 @@ static void nodemgr_create_ud_dev_files(struct unit_directory *ud)
679 } 679 }
680 return; 680 return;
681fail: 681fail:
682 HPSB_ERR("Failed to add sysfs attributes for unit %s", 682 HPSB_ERR("Failed to add sysfs attribute");
683 ud->device.bus_id);
684} 683}
685 684
686 685
@@ -1144,13 +1143,13 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent
1144 last_key_id = kv->key.id; 1143 last_key_id = kv->key.id;
1145 } 1144 }
1146 1145
1147 if (ne->vendor_name_kv && 1146 if (ne->vendor_name_kv) {
1148 device_create_file(&ne->device, &dev_attr_ne_vendor_name_kv)) 1147 int error = device_create_file(&ne->device,
1149 goto fail; 1148 &dev_attr_ne_vendor_name_kv);
1150 return; 1149
1151fail: 1150 if (error && error != -EEXIST)
1152 HPSB_ERR("Failed to add sysfs attribute for node %016Lx", 1151 HPSB_ERR("Failed to add sysfs attribute");
1153 (unsigned long long)ne->guid); 1152 }
1154} 1153}
1155 1154
1156#ifdef CONFIG_HOTPLUG 1155#ifdef CONFIG_HOTPLUG
@@ -1738,7 +1737,19 @@ exit:
1738 return 0; 1737 return 0;
1739} 1738}
1740 1739
1741int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *)) 1740/**
1741 * nodemgr_for_each_host - call a function for each IEEE 1394 host
1742 * @data: an address to supply to the callback
1743 * @cb: function to call for each host
1744 *
1745 * Iterate the hosts, calling a given function with supplied data for each host.
1746 * If the callback fails on a host, i.e. if it returns a non-zero value, the
1747 * iteration is stopped.
1748 *
1749 * Return value: 0 on success, non-zero on failure (same as returned by last run
1750 * of the callback).
1751 */
1752int nodemgr_for_each_host(void *data, int (*cb)(struct hpsb_host *, void *))
1742{ 1753{
1743 struct class_device *cdev; 1754 struct class_device *cdev;
1744 struct hpsb_host *host; 1755 struct hpsb_host *host;
@@ -1748,7 +1759,7 @@ int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *))
1748 list_for_each_entry(cdev, &hpsb_host_class.children, node) { 1759 list_for_each_entry(cdev, &hpsb_host_class.children, node) {
1749 host = container_of(cdev, struct hpsb_host, class_dev); 1760 host = container_of(cdev, struct hpsb_host, class_dev);
1750 1761
1751 if ((error = cb(host, __data))) 1762 if ((error = cb(host, data)))
1752 break; 1763 break;
1753 } 1764 }
1754 up(&hpsb_host_class.sem); 1765 up(&hpsb_host_class.sem);
@@ -1756,7 +1767,7 @@ int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *))
1756 return error; 1767 return error;
1757} 1768}
1758 1769
1759/* The following four convenience functions use a struct node_entry 1770/* The following two convenience functions use a struct node_entry
1760 * for addressing a node on the bus. They are intended for use by any 1771 * for addressing a node on the bus. They are intended for use by any
1761 * process context, not just the nodemgr thread, so we need to be a 1772 * process context, not just the nodemgr thread, so we need to be a
1762 * little careful when reading out the node ID and generation. The 1773 * little careful when reading out the node ID and generation. The
@@ -1771,12 +1782,20 @@ int nodemgr_for_each_host(void *__data, int (*cb)(struct hpsb_host *, void *))
1771 * ID's. 1782 * ID's.
1772 */ 1783 */
1773 1784
1774void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *pkt) 1785/**
1786 * hpsb_node_fill_packet - fill some destination information into a packet
1787 * @ne: destination node
1788 * @packet: packet to fill in
1789 *
1790 * This will fill in the given, pre-initialised hpsb_packet with the current
1791 * information from the node entry (host, node ID, bus generation number).
1792 */
1793void hpsb_node_fill_packet(struct node_entry *ne, struct hpsb_packet *packet)
1775{ 1794{
1776 pkt->host = ne->host; 1795 packet->host = ne->host;
1777 pkt->generation = ne->generation; 1796 packet->generation = ne->generation;
1778 barrier(); 1797 barrier();
1779 pkt->node_id = ne->nodeid; 1798 packet->node_id = ne->nodeid;
1780} 1799}
1781 1800
1782int hpsb_node_write(struct node_entry *ne, u64 addr, 1801int hpsb_node_write(struct node_entry *ne, u64 addr,