aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2005-12-01 18:52:03 -0500
committerJody McIntyre <scjody@modernduck.com>2005-12-01 18:52:03 -0500
commit741854e4f9a23421e194df8d846899172ff393d6 (patch)
tree2ca98e6bcc7515eb3065ffa2be8c0c535502b493 /drivers
parent546513f9fd96cba613cc2d025ee03d32d79394b7 (diff)
ieee1394: whitespace cleanup in hosts.[ch], ieee1394_core.[ch]
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Signed-off-by: Jody McIntyre <scjody@modernduck.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ieee1394/hosts.c28
-rw-r--r--drivers/ieee1394/hosts.h162
-rw-r--r--drivers/ieee1394/ieee1394_core.c762
-rw-r--r--drivers/ieee1394/ieee1394_core.h100
4 files changed, 526 insertions, 526 deletions
diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c
index d245abe4033c..ba09741fc826 100644
--- a/drivers/ieee1394/hosts.c
+++ b/drivers/ieee1394/hosts.c
@@ -61,12 +61,12 @@ static void delayed_reset_bus(void * __reset_info)
61 61
62static int dummy_transmit_packet(struct hpsb_host *h, struct hpsb_packet *p) 62static int dummy_transmit_packet(struct hpsb_host *h, struct hpsb_packet *p)
63{ 63{
64 return 0; 64 return 0;
65} 65}
66 66
67static int dummy_devctl(struct hpsb_host *h, enum devctl_cmd c, int arg) 67static int dummy_devctl(struct hpsb_host *h, enum devctl_cmd c, int arg)
68{ 68{
69 return -1; 69 return -1;
70} 70}
71 71
72static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg) 72static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg)
@@ -75,9 +75,9 @@ static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command, unsigned
75} 75}
76 76
77static struct hpsb_host_driver dummy_driver = { 77static struct hpsb_host_driver dummy_driver = {
78 .transmit_packet = dummy_transmit_packet, 78 .transmit_packet = dummy_transmit_packet,
79 .devctl = dummy_devctl, 79 .devctl = dummy_devctl,
80 .isoctl = dummy_isoctl 80 .isoctl = dummy_isoctl
81}; 81};
82 82
83static int alloc_hostnum_cb(struct hpsb_host *host, void *__data) 83static int alloc_hostnum_cb(struct hpsb_host *host, void *__data)
@@ -110,12 +110,12 @@ static DECLARE_MUTEX(host_num_alloc);
110struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra, 110struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
111 struct device *dev) 111 struct device *dev)
112{ 112{
113 struct hpsb_host *h; 113 struct hpsb_host *h;
114 int i; 114 int i;
115 int hostnum = 0; 115 int hostnum = 0;
116 116
117 h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL); 117 h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL);
118 if (!h) 118 if (!h)
119 return NULL; 119 return NULL;
120 120
121 h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h); 121 h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h);
@@ -125,7 +125,7 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
125 } 125 }
126 126
127 h->hostdata = h + 1; 127 h->hostdata = h + 1;
128 h->driver = drv; 128 h->driver = drv;
129 129
130 skb_queue_head_init(&h->pending_packet_queue); 130 skb_queue_head_init(&h->pending_packet_queue);
131 INIT_LIST_HEAD(&h->addr_space); 131 INIT_LIST_HEAD(&h->addr_space);
@@ -145,8 +145,8 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
145 h->timeout.function = abort_timedouts; 145 h->timeout.function = abort_timedouts;
146 h->timeout_interval = HZ / 20; // 50ms by default 146 h->timeout_interval = HZ / 20; // 50ms by default
147 147
148 h->topology_map = h->csr.topology_map + 3; 148 h->topology_map = h->csr.topology_map + 3;
149 h->speed_map = (u8 *)(h->csr.speed_map + 2); 149 h->speed_map = (u8 *)(h->csr.speed_map + 2);
150 150
151 down(&host_num_alloc); 151 down(&host_num_alloc);
152 152
@@ -186,14 +186,14 @@ int hpsb_add_host(struct hpsb_host *host)
186 186
187void hpsb_remove_host(struct hpsb_host *host) 187void hpsb_remove_host(struct hpsb_host *host)
188{ 188{
189 host->is_shutdown = 1; 189 host->is_shutdown = 1;
190 190
191 cancel_delayed_work(&host->delayed_reset); 191 cancel_delayed_work(&host->delayed_reset);
192 flush_scheduled_work(); 192 flush_scheduled_work();
193 193
194 host->driver = &dummy_driver; 194 host->driver = &dummy_driver;
195 195
196 highlevel_remove_host(host); 196 highlevel_remove_host(host);
197 197
198 hpsb_remove_extra_config_roms(host); 198 hpsb_remove_extra_config_roms(host);
199 199
diff --git a/drivers/ieee1394/hosts.h b/drivers/ieee1394/hosts.h
index ae9b02cc013f..07d188ca8495 100644
--- a/drivers/ieee1394/hosts.h
+++ b/drivers/ieee1394/hosts.h
@@ -17,47 +17,47 @@ struct hpsb_packet;
17struct hpsb_iso; 17struct hpsb_iso;
18 18
19struct hpsb_host { 19struct hpsb_host {
20 struct list_head host_list; 20 struct list_head host_list;
21 21
22 void *hostdata; 22 void *hostdata;
23 23
24 atomic_t generation; 24 atomic_t generation;
25 25
26 struct sk_buff_head pending_packet_queue; 26 struct sk_buff_head pending_packet_queue;
27 27
28 struct timer_list timeout; 28 struct timer_list timeout;
29 unsigned long timeout_interval; 29 unsigned long timeout_interval;
30 30
31 unsigned char iso_listen_count[64]; 31 unsigned char iso_listen_count[64];
32 32
33 int node_count; /* number of identified nodes on this bus */ 33 int node_count; /* number of identified nodes on this bus */
34 int selfid_count; /* total number of SelfIDs received */ 34 int selfid_count; /* total number of SelfIDs received */
35 int nodes_active; /* number of nodes that are actually active */ 35 int nodes_active; /* number of nodes that are actually active */
36 36
37 nodeid_t node_id; /* node ID of this host */ 37 nodeid_t node_id; /* node ID of this host */
38 nodeid_t irm_id; /* ID of this bus' isochronous resource manager */ 38 nodeid_t irm_id; /* ID of this bus' isochronous resource manager */
39 nodeid_t busmgr_id; /* ID of this bus' bus manager */ 39 nodeid_t busmgr_id; /* ID of this bus' bus manager */
40 40
41 /* this nodes state */ 41 /* this nodes state */
42 unsigned in_bus_reset:1; 42 unsigned in_bus_reset:1;
43 unsigned is_shutdown:1; 43 unsigned is_shutdown:1;
44 unsigned resume_packet_sent:1; 44 unsigned resume_packet_sent:1;
45 45
46 /* this nodes' duties on the bus */ 46 /* this nodes' duties on the bus */
47 unsigned is_root:1; 47 unsigned is_root:1;
48 unsigned is_cycmst:1; 48 unsigned is_cycmst:1;
49 unsigned is_irm:1; 49 unsigned is_irm:1;
50 unsigned is_busmgr:1; 50 unsigned is_busmgr:1;
51 51
52 int reset_retries; 52 int reset_retries;
53 quadlet_t *topology_map; 53 quadlet_t *topology_map;
54 u8 *speed_map; 54 u8 *speed_map;
55 struct csr_control csr; 55 struct csr_control csr;
56 56
57 /* Per node tlabel pool allocation */ 57 /* Per node tlabel pool allocation */
58 struct hpsb_tlabel_pool tpool[64]; 58 struct hpsb_tlabel_pool tpool[64];
59 59
60 struct hpsb_host_driver *driver; 60 struct hpsb_host_driver *driver;
61 61
62 struct pci_dev *pdev; 62 struct pci_dev *pdev;
63 63
@@ -77,34 +77,34 @@ struct hpsb_host {
77 77
78 78
79enum devctl_cmd { 79enum devctl_cmd {
80 /* Host is requested to reset its bus and cancel all outstanding async 80 /* Host is requested to reset its bus and cancel all outstanding async
81 * requests. If arg == 1, it shall also attempt to become root on the 81 * requests. If arg == 1, it shall also attempt to become root on the
82 * bus. Return void. */ 82 * bus. Return void. */
83 RESET_BUS, 83 RESET_BUS,
84 84
85 /* Arg is void, return value is the hardware cycle counter value. */ 85 /* Arg is void, return value is the hardware cycle counter value. */
86 GET_CYCLE_COUNTER, 86 GET_CYCLE_COUNTER,
87 87
88 /* Set the hardware cycle counter to the value in arg, return void. 88 /* Set the hardware cycle counter to the value in arg, return void.
89 * FIXME - setting is probably not required. */ 89 * FIXME - setting is probably not required. */
90 SET_CYCLE_COUNTER, 90 SET_CYCLE_COUNTER,
91 91
92 /* Configure hardware for new bus ID in arg, return void. */ 92 /* Configure hardware for new bus ID in arg, return void. */
93 SET_BUS_ID, 93 SET_BUS_ID,
94 94
95 /* If arg true, start sending cycle start packets, stop if arg == 0. 95 /* If arg true, start sending cycle start packets, stop if arg == 0.
96 * Return void. */ 96 * Return void. */
97 ACT_CYCLE_MASTER, 97 ACT_CYCLE_MASTER,
98 98
99 /* Cancel all outstanding async requests without resetting the bus. 99 /* Cancel all outstanding async requests without resetting the bus.
100 * Return void. */ 100 * Return void. */
101 CANCEL_REQUESTS, 101 CANCEL_REQUESTS,
102 102
103 /* Start or stop receiving isochronous channel in arg. Return void. 103 /* Start or stop receiving isochronous channel in arg. Return void.
104 * This acts as an optimization hint, hosts are not required not to 104 * This acts as an optimization hint, hosts are not required not to
105 * listen on unrequested channels. */ 105 * listen on unrequested channels. */
106 ISO_LISTEN_CHANNEL, 106 ISO_LISTEN_CHANNEL,
107 ISO_UNLISTEN_CHANNEL 107 ISO_UNLISTEN_CHANNEL
108}; 108};
109 109
110enum isoctl_cmd { 110enum isoctl_cmd {
@@ -135,13 +135,13 @@ enum isoctl_cmd {
135}; 135};
136 136
137enum reset_types { 137enum reset_types {
138 /* 166 microsecond reset -- only type of reset available on 138 /* 166 microsecond reset -- only type of reset available on
139 non-1394a capable controllers */ 139 non-1394a capable controllers */
140 LONG_RESET, 140 LONG_RESET,
141 141
142 /* Short (arbitrated) reset -- only available on 1394a capable 142 /* Short (arbitrated) reset -- only available on 1394a capable
143 controllers */ 143 controllers */
144 SHORT_RESET, 144 SHORT_RESET,
145 145
146 /* Variants that set force_root before issueing the bus reset */ 146 /* Variants that set force_root before issueing the bus reset */
147 LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT, 147 LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT,
@@ -159,22 +159,22 @@ struct hpsb_host_driver {
159 * reads to the ConfigROM on its own. */ 159 * reads to the ConfigROM on its own. */
160 void (*set_hw_config_rom) (struct hpsb_host *host, quadlet_t *config_rom); 160 void (*set_hw_config_rom) (struct hpsb_host *host, quadlet_t *config_rom);
161 161
162 /* This function shall implement packet transmission based on 162 /* This function shall implement packet transmission based on
163 * packet->type. It shall CRC both parts of the packet (unless 163 * packet->type. It shall CRC both parts of the packet (unless
164 * packet->type == raw) and do byte-swapping as necessary or instruct 164 * packet->type == raw) and do byte-swapping as necessary or instruct
165 * the hardware to do so. It can return immediately after the packet 165 * the hardware to do so. It can return immediately after the packet
166 * was queued for sending. After sending, hpsb_sent_packet() has to be 166 * was queued for sending. After sending, hpsb_sent_packet() has to be
167 * called. Return 0 on success, negative errno on failure. 167 * called. Return 0 on success, negative errno on failure.
168 * NOTE: The function must be callable in interrupt context. 168 * NOTE: The function must be callable in interrupt context.
169 */ 169 */
170 int (*transmit_packet) (struct hpsb_host *host, 170 int (*transmit_packet) (struct hpsb_host *host,
171 struct hpsb_packet *packet); 171 struct hpsb_packet *packet);
172 172
173 /* This function requests miscellanous services from the driver, see 173 /* This function requests miscellanous services from the driver, see
174 * above for command codes and expected actions. Return -1 for unknown 174 * above for command codes and expected actions. Return -1 for unknown
175 * command, though that should never happen. 175 * command, though that should never happen.
176 */ 176 */
177 int (*devctl) (struct hpsb_host *host, enum devctl_cmd command, int arg); 177 int (*devctl) (struct hpsb_host *host, enum devctl_cmd command, int arg);
178 178
179 /* ISO transmission/reception functions. Return 0 on success, -1 179 /* ISO transmission/reception functions. Return 0 on success, -1
180 * (or -EXXX errno code) on failure. If the low-level driver does not 180 * (or -EXXX errno code) on failure. If the low-level driver does not
@@ -182,15 +182,15 @@ struct hpsb_host_driver {
182 */ 182 */
183 int (*isoctl) (struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg); 183 int (*isoctl) (struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg);
184 184
185 /* This function is mainly to redirect local CSR reads/locks to the iso 185 /* This function is mainly to redirect local CSR reads/locks to the iso
186 * management registers (bus manager id, bandwidth available, channels 186 * management registers (bus manager id, bandwidth available, channels
187 * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus 187 * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus
188 * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids 188 * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids
189 * as OHCI uses). data and compare are the new data and expected data 189 * as OHCI uses). data and compare are the new data and expected data
190 * respectively, return value is the old value. 190 * respectively, return value is the old value.
191 */ 191 */
192 quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg, 192 quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg,
193 quadlet_t data, quadlet_t compare); 193 quadlet_t data, quadlet_t compare);
194}; 194};
195 195
196 196
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index ff8a40980607..64fbbb01d52a 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -179,34 +179,34 @@ void hpsb_free_packet(struct hpsb_packet *packet)
179 179
180int hpsb_reset_bus(struct hpsb_host *host, int type) 180int hpsb_reset_bus(struct hpsb_host *host, int type)
181{ 181{
182 if (!host->in_bus_reset) { 182 if (!host->in_bus_reset) {
183 host->driver->devctl(host, RESET_BUS, type); 183 host->driver->devctl(host, RESET_BUS, type);
184 return 0; 184 return 0;
185 } else { 185 } else {
186 return 1; 186 return 1;
187 } 187 }
188} 188}
189 189
190 190
191int hpsb_bus_reset(struct hpsb_host *host) 191int hpsb_bus_reset(struct hpsb_host *host)
192{ 192{
193 if (host->in_bus_reset) { 193 if (host->in_bus_reset) {
194 HPSB_NOTICE("%s called while bus reset already in progress", 194 HPSB_NOTICE("%s called while bus reset already in progress",
195 __FUNCTION__); 195 __FUNCTION__);
196 return 1; 196 return 1;
197 } 197 }
198 198
199 abort_requests(host); 199 abort_requests(host);
200 host->in_bus_reset = 1; 200 host->in_bus_reset = 1;
201 host->irm_id = -1; 201 host->irm_id = -1;
202 host->is_irm = 0; 202 host->is_irm = 0;
203 host->busmgr_id = -1; 203 host->busmgr_id = -1;
204 host->is_busmgr = 0; 204 host->is_busmgr = 0;
205 host->is_cycmst = 0; 205 host->is_cycmst = 0;
206 host->node_count = 0; 206 host->node_count = 0;
207 host->selfid_count = 0; 207 host->selfid_count = 0;
208 208
209 return 0; 209 return 0;
210} 210}
211 211
212 212
@@ -216,47 +216,47 @@ int hpsb_bus_reset(struct hpsb_host *host)
216 */ 216 */
217static int check_selfids(struct hpsb_host *host) 217static int check_selfids(struct hpsb_host *host)
218{ 218{
219 int nodeid = -1; 219 int nodeid = -1;
220 int rest_of_selfids = host->selfid_count; 220 int rest_of_selfids = host->selfid_count;
221 struct selfid *sid = (struct selfid *)host->topology_map; 221 struct selfid *sid = (struct selfid *)host->topology_map;
222 struct ext_selfid *esid; 222 struct ext_selfid *esid;
223 int esid_seq = 23; 223 int esid_seq = 23;
224 224
225 host->nodes_active = 0; 225 host->nodes_active = 0;
226 226
227 while (rest_of_selfids--) { 227 while (rest_of_selfids--) {
228 if (!sid->extended) { 228 if (!sid->extended) {
229 nodeid++; 229 nodeid++;
230 esid_seq = 0; 230 esid_seq = 0;
231 231
232 if (sid->phy_id != nodeid) { 232 if (sid->phy_id != nodeid) {
233 HPSB_INFO("SelfIDs failed monotony check with " 233 HPSB_INFO("SelfIDs failed monotony check with "
234 "%d", sid->phy_id); 234 "%d", sid->phy_id);
235 return 0; 235 return 0;
236 } 236 }
237 237
238 if (sid->link_active) { 238 if (sid->link_active) {
239 host->nodes_active++; 239 host->nodes_active++;
240 if (sid->contender) 240 if (sid->contender)
241 host->irm_id = LOCAL_BUS | sid->phy_id; 241 host->irm_id = LOCAL_BUS | sid->phy_id;
242 } 242 }
243 } else { 243 } else {
244 esid = (struct ext_selfid *)sid; 244 esid = (struct ext_selfid *)sid;
245 245
246 if ((esid->phy_id != nodeid) 246 if ((esid->phy_id != nodeid)
247 || (esid->seq_nr != esid_seq)) { 247 || (esid->seq_nr != esid_seq)) {
248 HPSB_INFO("SelfIDs failed monotony check with " 248 HPSB_INFO("SelfIDs failed monotony check with "
249 "%d/%d", esid->phy_id, esid->seq_nr); 249 "%d/%d", esid->phy_id, esid->seq_nr);
250 return 0; 250 return 0;
251 } 251 }
252 esid_seq++; 252 esid_seq++;
253 } 253 }
254 sid++; 254 sid++;
255 } 255 }
256 256
257 esid = (struct ext_selfid *)(sid - 1); 257 esid = (struct ext_selfid *)(sid - 1);
258 while (esid->extended) { 258 while (esid->extended) {
259 if ((esid->porta == SELFID_PORT_PARENT) || 259 if ((esid->porta == SELFID_PORT_PARENT) ||
260 (esid->portb == SELFID_PORT_PARENT) || 260 (esid->portb == SELFID_PORT_PARENT) ||
261 (esid->portc == SELFID_PORT_PARENT) || 261 (esid->portc == SELFID_PORT_PARENT) ||
262 (esid->portd == SELFID_PORT_PARENT) || 262 (esid->portd == SELFID_PORT_PARENT) ||
@@ -267,47 +267,47 @@ static int check_selfids(struct hpsb_host *host)
267 HPSB_INFO("SelfIDs failed root check on " 267 HPSB_INFO("SelfIDs failed root check on "
268 "extended SelfID"); 268 "extended SelfID");
269 return 0; 269 return 0;
270 } 270 }
271 esid--; 271 esid--;
272 } 272 }
273 273
274 sid = (struct selfid *)esid; 274 sid = (struct selfid *)esid;
275 if ((sid->port0 == SELFID_PORT_PARENT) || 275 if ((sid->port0 == SELFID_PORT_PARENT) ||
276 (sid->port1 == SELFID_PORT_PARENT) || 276 (sid->port1 == SELFID_PORT_PARENT) ||
277 (sid->port2 == SELFID_PORT_PARENT)) { 277 (sid->port2 == SELFID_PORT_PARENT)) {
278 HPSB_INFO("SelfIDs failed root check"); 278 HPSB_INFO("SelfIDs failed root check");
279 return 0; 279 return 0;
280 } 280 }
281 281
282 host->node_count = nodeid + 1; 282 host->node_count = nodeid + 1;
283 return 1; 283 return 1;
284} 284}
285 285
286static void build_speed_map(struct hpsb_host *host, int nodecount) 286static void build_speed_map(struct hpsb_host *host, int nodecount)
287{ 287{
288 u8 speedcap[nodecount]; 288 u8 speedcap[nodecount];
289 u8 cldcnt[nodecount]; 289 u8 cldcnt[nodecount];
290 u8 *map = host->speed_map; 290 u8 *map = host->speed_map;
291 struct selfid *sid; 291 struct selfid *sid;
292 struct ext_selfid *esid; 292 struct ext_selfid *esid;
293 int i, j, n; 293 int i, j, n;
294 294
295 for (i = 0; i < (nodecount * 64); i += 64) { 295 for (i = 0; i < (nodecount * 64); i += 64) {
296 for (j = 0; j < nodecount; j++) { 296 for (j = 0; j < nodecount; j++) {
297 map[i+j] = IEEE1394_SPEED_MAX; 297 map[i+j] = IEEE1394_SPEED_MAX;
298 } 298 }
299 } 299 }
300 300
301 for (i = 0; i < nodecount; i++) { 301 for (i = 0; i < nodecount; i++) {
302 cldcnt[i] = 0; 302 cldcnt[i] = 0;
303 } 303 }
304 304
305 /* find direct children count and speed */ 305 /* find direct children count and speed */
306 for (sid = (struct selfid *)&host->topology_map[host->selfid_count-1], 306 for (sid = (struct selfid *)&host->topology_map[host->selfid_count-1],
307 n = nodecount - 1; 307 n = nodecount - 1;
308 (void *)sid >= (void *)host->topology_map; sid--) { 308 (void *)sid >= (void *)host->topology_map; sid--) {
309 if (sid->extended) { 309 if (sid->extended) {
310 esid = (struct ext_selfid *)sid; 310 esid = (struct ext_selfid *)sid;
311 311
312 if (esid->porta == SELFID_PORT_CHILD) cldcnt[n]++; 312 if (esid->porta == SELFID_PORT_CHILD) cldcnt[n]++;
313 if (esid->portb == SELFID_PORT_CHILD) cldcnt[n]++; 313 if (esid->portb == SELFID_PORT_CHILD) cldcnt[n]++;
@@ -322,50 +322,50 @@ static void build_speed_map(struct hpsb_host *host, int nodecount)
322 if (sid->port1 == SELFID_PORT_CHILD) cldcnt[n]++; 322 if (sid->port1 == SELFID_PORT_CHILD) cldcnt[n]++;
323 if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++; 323 if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++;
324 324
325 speedcap[n] = sid->speed; 325 speedcap[n] = sid->speed;
326 n--; 326 n--;
327 } 327 }
328 } 328 }
329 329
330 /* set self mapping */ 330 /* set self mapping */
331 for (i = 0; i < nodecount; i++) { 331 for (i = 0; i < nodecount; i++) {
332 map[64*i + i] = speedcap[i]; 332 map[64*i + i] = speedcap[i];
333 } 333 }
334 334
335 /* fix up direct children count to total children count; 335 /* fix up direct children count to total children count;
336 * also fix up speedcaps for sibling and parent communication */ 336 * also fix up speedcaps for sibling and parent communication */
337 for (i = 1; i < nodecount; i++) { 337 for (i = 1; i < nodecount; i++) {
338 for (j = cldcnt[i], n = i - 1; j > 0; j--) { 338 for (j = cldcnt[i], n = i - 1; j > 0; j--) {
339 cldcnt[i] += cldcnt[n]; 339 cldcnt[i] += cldcnt[n];
340 speedcap[n] = min(speedcap[n], speedcap[i]); 340 speedcap[n] = min(speedcap[n], speedcap[i]);
341 n -= cldcnt[n] + 1; 341 n -= cldcnt[n] + 1;
342 } 342 }
343 } 343 }
344 344
345 for (n = 0; n < nodecount; n++) { 345 for (n = 0; n < nodecount; n++) {
346 for (i = n - cldcnt[n]; i <= n; i++) { 346 for (i = n - cldcnt[n]; i <= n; i++) {
347 for (j = 0; j < (n - cldcnt[n]); j++) { 347 for (j = 0; j < (n - cldcnt[n]); j++) {
348 map[j*64 + i] = map[i*64 + j] = 348 map[j*64 + i] = map[i*64 + j] =
349 min(map[i*64 + j], speedcap[n]); 349 min(map[i*64 + j], speedcap[n]);
350 } 350 }
351 for (j = n + 1; j < nodecount; j++) { 351 for (j = n + 1; j < nodecount; j++) {
352 map[j*64 + i] = map[i*64 + j] = 352 map[j*64 + i] = map[i*64 + j] =
353 min(map[i*64 + j], speedcap[n]); 353 min(map[i*64 + j], speedcap[n]);
354 } 354 }
355 } 355 }
356 } 356 }
357} 357}
358 358
359 359
360void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid) 360void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid)
361{ 361{
362 if (host->in_bus_reset) { 362 if (host->in_bus_reset) {
363 HPSB_VERBOSE("Including SelfID 0x%x", sid); 363 HPSB_VERBOSE("Including SelfID 0x%x", sid);
364 host->topology_map[host->selfid_count++] = sid; 364 host->topology_map[host->selfid_count++] = sid;
365 } else { 365 } else {
366 HPSB_NOTICE("Spurious SelfID packet (0x%08x) received from bus %d", 366 HPSB_NOTICE("Spurious SelfID packet (0x%08x) received from bus %d",
367 sid, NODEID_TO_BUS(host->node_id)); 367 sid, NODEID_TO_BUS(host->node_id));
368 } 368 }
369} 369}
370 370
371void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot) 371void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot)
@@ -373,50 +373,50 @@ void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot)
373 if (!host->in_bus_reset) 373 if (!host->in_bus_reset)
374 HPSB_NOTICE("SelfID completion called outside of bus reset!"); 374 HPSB_NOTICE("SelfID completion called outside of bus reset!");
375 375
376 host->node_id = LOCAL_BUS | phyid; 376 host->node_id = LOCAL_BUS | phyid;
377 host->is_root = isroot; 377 host->is_root = isroot;
378 378
379 if (!check_selfids(host)) { 379 if (!check_selfids(host)) {
380 if (host->reset_retries++ < 20) { 380 if (host->reset_retries++ < 20) {
381 /* selfid stage did not complete without error */ 381 /* selfid stage did not complete without error */
382 HPSB_NOTICE("Error in SelfID stage, resetting"); 382 HPSB_NOTICE("Error in SelfID stage, resetting");
383 host->in_bus_reset = 0; 383 host->in_bus_reset = 0;
384 /* this should work from ohci1394 now... */ 384 /* this should work from ohci1394 now... */
385 hpsb_reset_bus(host, LONG_RESET); 385 hpsb_reset_bus(host, LONG_RESET);
386 return; 386 return;
387 } else { 387 } else {
388 HPSB_NOTICE("Stopping out-of-control reset loop"); 388 HPSB_NOTICE("Stopping out-of-control reset loop");
389 HPSB_NOTICE("Warning - topology map and speed map will not be valid"); 389 HPSB_NOTICE("Warning - topology map and speed map will not be valid");
390 host->reset_retries = 0; 390 host->reset_retries = 0;
391 } 391 }
392 } else { 392 } else {
393 host->reset_retries = 0; 393 host->reset_retries = 0;
394 build_speed_map(host, host->node_count); 394 build_speed_map(host, host->node_count);
395 } 395 }
396 396
397 HPSB_VERBOSE("selfid_complete called with successful SelfID stage " 397 HPSB_VERBOSE("selfid_complete called with successful SelfID stage "
398 "... irm_id: 0x%X node_id: 0x%X",host->irm_id,host->node_id); 398 "... irm_id: 0x%X node_id: 0x%X",host->irm_id,host->node_id);
399 399
400 /* irm_id is kept up to date by check_selfids() */ 400 /* irm_id is kept up to date by check_selfids() */
401 if (host->irm_id == host->node_id) { 401 if (host->irm_id == host->node_id) {
402 host->is_irm = 1; 402 host->is_irm = 1;
403 } else { 403 } else {
404 host->is_busmgr = 0; 404 host->is_busmgr = 0;
405 host->is_irm = 0; 405 host->is_irm = 0;
406 } 406 }
407 407
408 if (isroot) { 408 if (isroot) {
409 host->driver->devctl(host, ACT_CYCLE_MASTER, 1); 409 host->driver->devctl(host, ACT_CYCLE_MASTER, 1);
410 host->is_cycmst = 1; 410 host->is_cycmst = 1;
411 } 411 }
412 atomic_inc(&host->generation); 412 atomic_inc(&host->generation);
413 host->in_bus_reset = 0; 413 host->in_bus_reset = 0;
414 highlevel_host_reset(host); 414 highlevel_host_reset(host);
415} 415}
416 416
417 417
418void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet, 418void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
419 int ackcode) 419 int ackcode)
420{ 420{
421 unsigned long flags; 421 unsigned long flags;
422 422
@@ -507,13 +507,13 @@ int hpsb_send_packet(struct hpsb_packet *packet)
507{ 507{
508 struct hpsb_host *host = packet->host; 508 struct hpsb_host *host = packet->host;
509 509
510 if (host->is_shutdown) 510 if (host->is_shutdown)
511 return -EINVAL; 511 return -EINVAL;
512 if (host->in_bus_reset || 512 if (host->in_bus_reset ||
513 (packet->generation != get_hpsb_generation(host))) 513 (packet->generation != get_hpsb_generation(host)))
514 return -EAGAIN; 514 return -EAGAIN;
515 515
516 packet->state = hpsb_queued; 516 packet->state = hpsb_queued;
517 517
518 /* This just seems silly to me */ 518 /* This just seems silly to me */
519 WARN_ON(packet->no_waiter && packet->expect_response); 519 WARN_ON(packet->no_waiter && packet->expect_response);
@@ -527,42 +527,42 @@ int hpsb_send_packet(struct hpsb_packet *packet)
527 skb_queue_tail(&host->pending_packet_queue, packet->skb); 527 skb_queue_tail(&host->pending_packet_queue, packet->skb);
528 } 528 }
529 529
530 if (packet->node_id == host->node_id) { 530 if (packet->node_id == host->node_id) {
531 /* it is a local request, so handle it locally */ 531 /* it is a local request, so handle it locally */
532 532
533 quadlet_t *data; 533 quadlet_t *data;
534 size_t size = packet->data_size + packet->header_size; 534 size_t size = packet->data_size + packet->header_size;
535 535
536 data = kmalloc(size, GFP_ATOMIC); 536 data = kmalloc(size, GFP_ATOMIC);
537 if (!data) { 537 if (!data) {
538 HPSB_ERR("unable to allocate memory for concatenating header and data"); 538 HPSB_ERR("unable to allocate memory for concatenating header and data");
539 return -ENOMEM; 539 return -ENOMEM;
540 } 540 }
541 541
542 memcpy(data, packet->header, packet->header_size); 542 memcpy(data, packet->header, packet->header_size);
543 543
544 if (packet->data_size) 544 if (packet->data_size)
545 memcpy(((u8*)data) + packet->header_size, packet->data, packet->data_size); 545 memcpy(((u8*)data) + packet->header_size, packet->data, packet->data_size);
546 546
547 dump_packet("send packet local", packet->header, packet->header_size, -1); 547 dump_packet("send packet local", packet->header, packet->header_size, -1);
548 548
549 hpsb_packet_sent(host, packet, packet->expect_response ? ACK_PENDING : ACK_COMPLETE); 549 hpsb_packet_sent(host, packet, packet->expect_response ? ACK_PENDING : ACK_COMPLETE);
550 hpsb_packet_received(host, data, size, 0); 550 hpsb_packet_received(host, data, size, 0);
551 551
552 kfree(data); 552 kfree(data);
553 553
554 return 0; 554 return 0;
555 } 555 }
556 556
557 if (packet->type == hpsb_async && packet->node_id != ALL_NODES) { 557 if (packet->type == hpsb_async && packet->node_id != ALL_NODES) {
558 packet->speed_code = 558 packet->speed_code =
559 host->speed_map[NODEID_TO_NODE(host->node_id) * 64 559 host->speed_map[NODEID_TO_NODE(host->node_id) * 64
560 + NODEID_TO_NODE(packet->node_id)]; 560 + NODEID_TO_NODE(packet->node_id)];
561 } 561 }
562 562
563 dump_packet("send packet", packet->header, packet->header_size, packet->speed_code); 563 dump_packet("send packet", packet->header, packet->header_size, packet->speed_code);
564 564
565 return host->driver->transmit_packet(host, packet); 565 return host->driver->transmit_packet(host, packet);
566} 566}
567 567
568/* We could just use complete() directly as the packet complete 568/* We could just use complete() directly as the packet complete
@@ -590,81 +590,81 @@ int hpsb_send_packet_and_wait(struct hpsb_packet *packet)
590 590
591static void send_packet_nocare(struct hpsb_packet *packet) 591static void send_packet_nocare(struct hpsb_packet *packet)
592{ 592{
593 if (hpsb_send_packet(packet) < 0) { 593 if (hpsb_send_packet(packet) < 0) {
594 hpsb_free_packet(packet); 594 hpsb_free_packet(packet);
595 } 595 }
596} 596}
597 597
598 598
599static void handle_packet_response(struct hpsb_host *host, int tcode, 599static void handle_packet_response(struct hpsb_host *host, int tcode,
600 quadlet_t *data, size_t size) 600 quadlet_t *data, size_t size)
601{ 601{
602 struct hpsb_packet *packet = NULL; 602 struct hpsb_packet *packet = NULL;
603 struct sk_buff *skb; 603 struct sk_buff *skb;
604 int tcode_match = 0; 604 int tcode_match = 0;
605 int tlabel; 605 int tlabel;
606 unsigned long flags; 606 unsigned long flags;
607 607
608 tlabel = (data[0] >> 10) & 0x3f; 608 tlabel = (data[0] >> 10) & 0x3f;
609 609
610 spin_lock_irqsave(&host->pending_packet_queue.lock, flags); 610 spin_lock_irqsave(&host->pending_packet_queue.lock, flags);
611 611
612 skb_queue_walk(&host->pending_packet_queue, skb) { 612 skb_queue_walk(&host->pending_packet_queue, skb) {
613 packet = (struct hpsb_packet *)skb->data; 613 packet = (struct hpsb_packet *)skb->data;
614 if ((packet->tlabel == tlabel) 614 if ((packet->tlabel == tlabel)
615 && (packet->node_id == (data[1] >> 16))){ 615 && (packet->node_id == (data[1] >> 16))){
616 break; 616 break;
617 } 617 }
618 618
619 packet = NULL; 619 packet = NULL;
620 } 620 }
621 621
622 if (packet == NULL) { 622 if (packet == NULL) {
623 HPSB_DEBUG("unsolicited response packet received - no tlabel match"); 623 HPSB_DEBUG("unsolicited response packet received - no tlabel match");
624 dump_packet("contents", data, 16, -1); 624 dump_packet("contents", data, 16, -1);
625 spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags); 625 spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags);
626 return; 626 return;
627 } 627 }
628 628
629 switch (packet->tcode) { 629 switch (packet->tcode) {
630 case TCODE_WRITEQ: 630 case TCODE_WRITEQ:
631 case TCODE_WRITEB: 631 case TCODE_WRITEB:
632 if (tcode != TCODE_WRITE_RESPONSE) 632 if (tcode != TCODE_WRITE_RESPONSE)
633 break; 633 break;
634 tcode_match = 1; 634 tcode_match = 1;
635 memcpy(packet->header, data, 12); 635 memcpy(packet->header, data, 12);
636 break; 636 break;
637 case TCODE_READQ: 637 case TCODE_READQ:
638 if (tcode != TCODE_READQ_RESPONSE) 638 if (tcode != TCODE_READQ_RESPONSE)
639 break; 639 break;
640 tcode_match = 1; 640 tcode_match = 1;
641 memcpy(packet->header, data, 16); 641 memcpy(packet->header, data, 16);
642 break; 642 break;
643 case TCODE_READB: 643 case TCODE_READB:
644 if (tcode != TCODE_READB_RESPONSE) 644 if (tcode != TCODE_READB_RESPONSE)
645 break; 645 break;
646 tcode_match = 1; 646 tcode_match = 1;
647 BUG_ON(packet->skb->len - sizeof(*packet) < size - 16); 647 BUG_ON(packet->skb->len - sizeof(*packet) < size - 16);
648 memcpy(packet->header, data, 16); 648 memcpy(packet->header, data, 16);
649 memcpy(packet->data, data + 4, size - 16); 649 memcpy(packet->data, data + 4, size - 16);
650 break; 650 break;
651 case TCODE_LOCK_REQUEST: 651 case TCODE_LOCK_REQUEST:
652 if (tcode != TCODE_LOCK_RESPONSE) 652 if (tcode != TCODE_LOCK_RESPONSE)
653 break; 653 break;
654 tcode_match = 1; 654 tcode_match = 1;
655 size = min((size - 16), (size_t)8); 655 size = min((size - 16), (size_t)8);
656 BUG_ON(packet->skb->len - sizeof(*packet) < size); 656 BUG_ON(packet->skb->len - sizeof(*packet) < size);
657 memcpy(packet->header, data, 16); 657 memcpy(packet->header, data, 16);
658 memcpy(packet->data, data + 4, size); 658 memcpy(packet->data, data + 4, size);
659 break; 659 break;
660 } 660 }
661 661
662 if (!tcode_match) { 662 if (!tcode_match) {
663 spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags); 663 spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags);
664 HPSB_INFO("unsolicited response packet received - tcode mismatch"); 664 HPSB_INFO("unsolicited response packet received - tcode mismatch");
665 dump_packet("contents", data, 16, -1); 665 dump_packet("contents", data, 16, -1);
666 return; 666 return;
667 } 667 }
668 668
669 __skb_unlink(skb, &host->pending_packet_queue); 669 __skb_unlink(skb, &host->pending_packet_queue);
670 670
@@ -683,27 +683,27 @@ static void handle_packet_response(struct hpsb_host *host, int tcode,
683static struct hpsb_packet *create_reply_packet(struct hpsb_host *host, 683static struct hpsb_packet *create_reply_packet(struct hpsb_host *host,
684 quadlet_t *data, size_t dsize) 684 quadlet_t *data, size_t dsize)
685{ 685{
686 struct hpsb_packet *p; 686 struct hpsb_packet *p;
687 687
688 p = hpsb_alloc_packet(dsize); 688 p = hpsb_alloc_packet(dsize);
689 if (unlikely(p == NULL)) { 689 if (unlikely(p == NULL)) {
690 /* FIXME - send data_error response */ 690 /* FIXME - send data_error response */
691 return NULL; 691 return NULL;
692 } 692 }
693 693
694 p->type = hpsb_async; 694 p->type = hpsb_async;
695 p->state = hpsb_unused; 695 p->state = hpsb_unused;
696 p->host = host; 696 p->host = host;
697 p->node_id = data[1] >> 16; 697 p->node_id = data[1] >> 16;
698 p->tlabel = (data[0] >> 10) & 0x3f; 698 p->tlabel = (data[0] >> 10) & 0x3f;
699 p->no_waiter = 1; 699 p->no_waiter = 1;
700 700
701 p->generation = get_hpsb_generation(host); 701 p->generation = get_hpsb_generation(host);
702 702
703 if (dsize % 4) 703 if (dsize % 4)
704 p->data[dsize / 4] = 0; 704 p->data[dsize / 4] = 0;
705 705
706 return p; 706 return p;
707} 707}
708 708
709#define PREP_ASYNC_HEAD_RCODE(tc) \ 709#define PREP_ASYNC_HEAD_RCODE(tc) \
@@ -714,7 +714,7 @@ static struct hpsb_packet *create_reply_packet(struct hpsb_host *host,
714 packet->header[2] = 0 714 packet->header[2] = 0
715 715
716static void fill_async_readquad_resp(struct hpsb_packet *packet, int rcode, 716static void fill_async_readquad_resp(struct hpsb_packet *packet, int rcode,
717 quadlet_t data) 717 quadlet_t data)
718{ 718{
719 PREP_ASYNC_HEAD_RCODE(TCODE_READQ_RESPONSE); 719 PREP_ASYNC_HEAD_RCODE(TCODE_READQ_RESPONSE);
720 packet->header[3] = data; 720 packet->header[3] = data;
@@ -723,7 +723,7 @@ static void fill_async_readquad_resp(struct hpsb_packet *packet, int rcode,
723} 723}
724 724
725static void fill_async_readblock_resp(struct hpsb_packet *packet, int rcode, 725static void fill_async_readblock_resp(struct hpsb_packet *packet, int rcode,
726 int length) 726 int length)
727{ 727{
728 if (rcode != RCODE_COMPLETE) 728 if (rcode != RCODE_COMPLETE)
729 length = 0; 729 length = 0;
@@ -743,7 +743,7 @@ static void fill_async_write_resp(struct hpsb_packet *packet, int rcode)
743} 743}
744 744
745static void fill_async_lock_resp(struct hpsb_packet *packet, int rcode, int extcode, 745static void fill_async_lock_resp(struct hpsb_packet *packet, int rcode, int extcode,
746 int length) 746 int length)
747{ 747{
748 if (rcode != RCODE_COMPLETE) 748 if (rcode != RCODE_COMPLETE)
749 length = 0; 749 length = 0;
@@ -755,184 +755,184 @@ static void fill_async_lock_resp(struct hpsb_packet *packet, int rcode, int extc
755} 755}
756 756
757#define PREP_REPLY_PACKET(length) \ 757#define PREP_REPLY_PACKET(length) \
758 packet = create_reply_packet(host, data, length); \ 758 packet = create_reply_packet(host, data, length); \
759 if (packet == NULL) break 759 if (packet == NULL) break
760 760
761static void handle_incoming_packet(struct hpsb_host *host, int tcode, 761static void handle_incoming_packet(struct hpsb_host *host, int tcode,
762 quadlet_t *data, size_t size, int write_acked) 762 quadlet_t *data, size_t size, int write_acked)
763{ 763{
764 struct hpsb_packet *packet; 764 struct hpsb_packet *packet;
765 int length, rcode, extcode; 765 int length, rcode, extcode;
766 quadlet_t buffer; 766 quadlet_t buffer;
767 nodeid_t source = data[1] >> 16; 767 nodeid_t source = data[1] >> 16;
768 nodeid_t dest = data[0] >> 16; 768 nodeid_t dest = data[0] >> 16;
769 u16 flags = (u16) data[0]; 769 u16 flags = (u16) data[0];
770 u64 addr; 770 u64 addr;
771 771
772 /* big FIXME - no error checking is done for an out of bounds length */ 772 /* big FIXME - no error checking is done for an out of bounds length */
773 773
774 switch (tcode) { 774 switch (tcode) {
775 case TCODE_WRITEQ: 775 case TCODE_WRITEQ:
776 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; 776 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
777 rcode = highlevel_write(host, source, dest, data+3, 777 rcode = highlevel_write(host, source, dest, data+3,
778 addr, 4, flags); 778 addr, 4, flags);
779 779
780 if (!write_acked 780 if (!write_acked
781 && (NODEID_TO_NODE(data[0] >> 16) != NODE_MASK) 781 && (NODEID_TO_NODE(data[0] >> 16) != NODE_MASK)
782 && (rcode >= 0)) { 782 && (rcode >= 0)) {
783 /* not a broadcast write, reply */ 783 /* not a broadcast write, reply */
784 PREP_REPLY_PACKET(0); 784 PREP_REPLY_PACKET(0);
785 fill_async_write_resp(packet, rcode); 785 fill_async_write_resp(packet, rcode);
786 send_packet_nocare(packet); 786 send_packet_nocare(packet);
787 } 787 }
788 break; 788 break;
789 789
790 case TCODE_WRITEB: 790 case TCODE_WRITEB:
791 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; 791 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
792 rcode = highlevel_write(host, source, dest, data+4, 792 rcode = highlevel_write(host, source, dest, data+4,
793 addr, data[3]>>16, flags); 793 addr, data[3]>>16, flags);
794 794
795 if (!write_acked 795 if (!write_acked
796 && (NODEID_TO_NODE(data[0] >> 16) != NODE_MASK) 796 && (NODEID_TO_NODE(data[0] >> 16) != NODE_MASK)
797 && (rcode >= 0)) { 797 && (rcode >= 0)) {
798 /* not a broadcast write, reply */ 798 /* not a broadcast write, reply */
799 PREP_REPLY_PACKET(0); 799 PREP_REPLY_PACKET(0);
800 fill_async_write_resp(packet, rcode); 800 fill_async_write_resp(packet, rcode);
801 send_packet_nocare(packet); 801 send_packet_nocare(packet);
802 } 802 }
803 break; 803 break;
804 804
805 case TCODE_READQ: 805 case TCODE_READQ:
806 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; 806 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
807 rcode = highlevel_read(host, source, &buffer, addr, 4, flags); 807 rcode = highlevel_read(host, source, &buffer, addr, 4, flags);
808 808
809 if (rcode >= 0) { 809 if (rcode >= 0) {
810 PREP_REPLY_PACKET(0); 810 PREP_REPLY_PACKET(0);
811 fill_async_readquad_resp(packet, rcode, buffer); 811 fill_async_readquad_resp(packet, rcode, buffer);
812 send_packet_nocare(packet); 812 send_packet_nocare(packet);
813 } 813 }
814 break; 814 break;
815 815
816 case TCODE_READB: 816 case TCODE_READB:
817 length = data[3] >> 16; 817 length = data[3] >> 16;
818 PREP_REPLY_PACKET(length); 818 PREP_REPLY_PACKET(length);
819 819
820 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; 820 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
821 rcode = highlevel_read(host, source, packet->data, addr, 821 rcode = highlevel_read(host, source, packet->data, addr,
822 length, flags); 822 length, flags);
823 823
824 if (rcode >= 0) { 824 if (rcode >= 0) {
825 fill_async_readblock_resp(packet, rcode, length); 825 fill_async_readblock_resp(packet, rcode, length);
826 send_packet_nocare(packet); 826 send_packet_nocare(packet);
827 } else { 827 } else {
828 hpsb_free_packet(packet); 828 hpsb_free_packet(packet);
829 } 829 }
830 break; 830 break;
831 831
832 case TCODE_LOCK_REQUEST: 832 case TCODE_LOCK_REQUEST:
833 length = data[3] >> 16; 833 length = data[3] >> 16;
834 extcode = data[3] & 0xffff; 834 extcode = data[3] & 0xffff;
835 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; 835 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
836 836
837 PREP_REPLY_PACKET(8); 837 PREP_REPLY_PACKET(8);
838 838
839 if ((extcode == 0) || (extcode >= 7)) { 839 if ((extcode == 0) || (extcode >= 7)) {
840 /* let switch default handle error */ 840 /* let switch default handle error */
841 length = 0; 841 length = 0;
842 } 842 }
843 843
844 switch (length) { 844 switch (length) {
845 case 4: 845 case 4:
846 rcode = highlevel_lock(host, source, packet->data, addr, 846 rcode = highlevel_lock(host, source, packet->data, addr,
847 data[4], 0, extcode,flags); 847 data[4], 0, extcode,flags);
848 fill_async_lock_resp(packet, rcode, extcode, 4); 848 fill_async_lock_resp(packet, rcode, extcode, 4);
849 break; 849 break;
850 case 8: 850 case 8:
851 if ((extcode != EXTCODE_FETCH_ADD) 851 if ((extcode != EXTCODE_FETCH_ADD)
852 && (extcode != EXTCODE_LITTLE_ADD)) { 852 && (extcode != EXTCODE_LITTLE_ADD)) {
853 rcode = highlevel_lock(host, source, 853 rcode = highlevel_lock(host, source,
854 packet->data, addr, 854 packet->data, addr,
855 data[5], data[4], 855 data[5], data[4],
856 extcode, flags); 856 extcode, flags);
857 fill_async_lock_resp(packet, rcode, extcode, 4); 857 fill_async_lock_resp(packet, rcode, extcode, 4);
858 } else { 858 } else {
859 rcode = highlevel_lock64(host, source, 859 rcode = highlevel_lock64(host, source,
860 (octlet_t *)packet->data, addr, 860 (octlet_t *)packet->data, addr,
861 *(octlet_t *)(data + 4), 0ULL, 861 *(octlet_t *)(data + 4), 0ULL,
862 extcode, flags); 862 extcode, flags);
863 fill_async_lock_resp(packet, rcode, extcode, 8); 863 fill_async_lock_resp(packet, rcode, extcode, 8);
864 } 864 }
865 break; 865 break;
866 case 16: 866 case 16:
867 rcode = highlevel_lock64(host, source, 867 rcode = highlevel_lock64(host, source,
868 (octlet_t *)packet->data, addr, 868 (octlet_t *)packet->data, addr,
869 *(octlet_t *)(data + 6), 869 *(octlet_t *)(data + 6),
870 *(octlet_t *)(data + 4), 870 *(octlet_t *)(data + 4),
871 extcode, flags); 871 extcode, flags);
872 fill_async_lock_resp(packet, rcode, extcode, 8); 872 fill_async_lock_resp(packet, rcode, extcode, 8);
873 break; 873 break;
874 default: 874 default:
875 rcode = RCODE_TYPE_ERROR; 875 rcode = RCODE_TYPE_ERROR;
876 fill_async_lock_resp(packet, rcode, 876 fill_async_lock_resp(packet, rcode,
877 extcode, 0); 877 extcode, 0);
878 } 878 }
879 879
880 if (rcode >= 0) { 880 if (rcode >= 0) {
881 send_packet_nocare(packet); 881 send_packet_nocare(packet);
882 } else { 882 } else {
883 hpsb_free_packet(packet); 883 hpsb_free_packet(packet);
884 } 884 }
885 break; 885 break;
886 } 886 }
887 887
888} 888}
889#undef PREP_REPLY_PACKET 889#undef PREP_REPLY_PACKET
890 890
891 891
892void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size, 892void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
893 int write_acked) 893 int write_acked)
894{ 894{
895 int tcode; 895 int tcode;
896 896
897 if (host->in_bus_reset) { 897 if (host->in_bus_reset) {
898 HPSB_INFO("received packet during reset; ignoring"); 898 HPSB_INFO("received packet during reset; ignoring");
899 return; 899 return;
900 } 900 }
901 901
902 dump_packet("received packet", data, size, -1); 902 dump_packet("received packet", data, size, -1);
903 903
904 tcode = (data[0] >> 4) & 0xf; 904 tcode = (data[0] >> 4) & 0xf;
905 905
906 switch (tcode) { 906 switch (tcode) {
907 case TCODE_WRITE_RESPONSE: 907 case TCODE_WRITE_RESPONSE:
908 case TCODE_READQ_RESPONSE: 908 case TCODE_READQ_RESPONSE:
909 case TCODE_READB_RESPONSE: 909 case TCODE_READB_RESPONSE:
910 case TCODE_LOCK_RESPONSE: 910 case TCODE_LOCK_RESPONSE:
911 handle_packet_response(host, tcode, data, size); 911 handle_packet_response(host, tcode, data, size);
912 break; 912 break;
913 913
914 case TCODE_WRITEQ: 914 case TCODE_WRITEQ:
915 case TCODE_WRITEB: 915 case TCODE_WRITEB:
916 case TCODE_READQ: 916 case TCODE_READQ:
917 case TCODE_READB: 917 case TCODE_READB:
918 case TCODE_LOCK_REQUEST: 918 case TCODE_LOCK_REQUEST:
919 handle_incoming_packet(host, tcode, data, size, write_acked); 919 handle_incoming_packet(host, tcode, data, size, write_acked);
920 break; 920 break;
921 921
922 922
923 case TCODE_ISO_DATA: 923 case TCODE_ISO_DATA:
924 highlevel_iso_receive(host, data, size); 924 highlevel_iso_receive(host, data, size);
925 break; 925 break;
926 926
927 case TCODE_CYCLE_START: 927 case TCODE_CYCLE_START:
928 /* simply ignore this packet if it is passed on */ 928 /* simply ignore this packet if it is passed on */
929 break; 929 break;
930 930
931 default: 931 default:
932 HPSB_NOTICE("received packet with bogus transaction code %d", 932 HPSB_NOTICE("received packet with bogus transaction code %d",
933 tcode); 933 tcode);
934 break; 934 break;
935 } 935 }
936} 936}
937 937
938 938
@@ -1126,7 +1126,7 @@ static int __init ieee1394_init(void)
1126 nodemgr implements functionality required of ieee1394a-2000 1126 nodemgr implements functionality required of ieee1394a-2000
1127 IRMs */ 1127 IRMs */
1128 hpsb_disable_irm = 1; 1128 hpsb_disable_irm = 1;
1129 1129
1130 return 0; 1130 return 0;
1131 } 1131 }
1132 1132
diff --git a/drivers/ieee1394/ieee1394_core.h b/drivers/ieee1394/ieee1394_core.h
index 0b31429d0a68..b35466023f00 100644
--- a/drivers/ieee1394/ieee1394_core.h
+++ b/drivers/ieee1394/ieee1394_core.h
@@ -10,8 +10,8 @@
10 10
11 11
12struct hpsb_packet { 12struct hpsb_packet {
13 /* This struct is basically read-only for hosts with the exception of 13 /* This struct is basically read-only for hosts with the exception of
14 * the data buffer contents and xnext - see below. */ 14 * the data buffer contents and xnext - see below. */
15 15
16 /* This can be used for host driver internal linking. 16 /* This can be used for host driver internal linking.
17 * 17 *
@@ -21,47 +21,47 @@ struct hpsb_packet {
21 * driver_list when free'ing it. */ 21 * driver_list when free'ing it. */
22 struct list_head driver_list; 22 struct list_head driver_list;
23 23
24 nodeid_t node_id; 24 nodeid_t node_id;
25 25
26 /* Async and Iso types should be clear, raw means send-as-is, do not 26 /* Async and Iso types should be clear, raw means send-as-is, do not
27 * CRC! Byte swapping shall still be done in this case. */ 27 * CRC! Byte swapping shall still be done in this case. */
28 enum { hpsb_async, hpsb_iso, hpsb_raw } __attribute__((packed)) type; 28 enum { hpsb_async, hpsb_iso, hpsb_raw } __attribute__((packed)) type;
29 29
30 /* Okay, this is core internal and a no care for hosts. 30 /* Okay, this is core internal and a no care for hosts.
31 * queued = queued for sending 31 * queued = queued for sending
32 * pending = sent, waiting for response 32 * pending = sent, waiting for response
33 * complete = processing completed, successful or not 33 * complete = processing completed, successful or not
34 */ 34 */
35 enum { 35 enum {
36 hpsb_unused, hpsb_queued, hpsb_pending, hpsb_complete 36 hpsb_unused, hpsb_queued, hpsb_pending, hpsb_complete
37 } __attribute__((packed)) state; 37 } __attribute__((packed)) state;
38 38
39 /* These are core internal. */ 39 /* These are core internal. */
40 signed char tlabel; 40 signed char tlabel;
41 signed char ack_code; 41 signed char ack_code;
42 unsigned char tcode; 42 unsigned char tcode;
43 43
44 unsigned expect_response:1; 44 unsigned expect_response:1;
45 unsigned no_waiter:1; 45 unsigned no_waiter:1;
46 46
47 /* Speed to transmit with: 0 = 100Mbps, 1 = 200Mbps, 2 = 400Mbps */ 47 /* Speed to transmit with: 0 = 100Mbps, 1 = 200Mbps, 2 = 400Mbps */
48 unsigned speed_code:2; 48 unsigned speed_code:2;
49 49
50 /* 50 /*
51 * *header and *data are guaranteed to be 32-bit DMAable and may be 51 * *header and *data are guaranteed to be 32-bit DMAable and may be
52 * overwritten to allow in-place byte swapping. Neither of these is 52 * overwritten to allow in-place byte swapping. Neither of these is
53 * CRCed (the sizes also don't include CRC), but contain space for at 53 * CRCed (the sizes also don't include CRC), but contain space for at
54 * least one additional quadlet to allow in-place CRCing. The memory is 54 * least one additional quadlet to allow in-place CRCing. The memory is
55 * also guaranteed to be DMA mappable. 55 * also guaranteed to be DMA mappable.
56 */ 56 */
57 quadlet_t *header; 57 quadlet_t *header;
58 quadlet_t *data; 58 quadlet_t *data;
59 size_t header_size; 59 size_t header_size;
60 size_t data_size; 60 size_t data_size;
61 61
62 62
63 struct hpsb_host *host; 63 struct hpsb_host *host;
64 unsigned int generation; 64 unsigned int generation;
65 65
66 atomic_t refcnt; 66 atomic_t refcnt;
67 67
@@ -73,10 +73,10 @@ struct hpsb_packet {
73 /* XXX This is just a hack at the moment */ 73 /* XXX This is just a hack at the moment */
74 struct sk_buff *skb; 74 struct sk_buff *skb;
75 75
76 /* Store jiffies for implementing bus timeouts. */ 76 /* Store jiffies for implementing bus timeouts. */
77 unsigned long sendtime; 77 unsigned long sendtime;
78 78
79 quadlet_t embedded_header[5]; 79 quadlet_t embedded_header[5];
80}; 80};
81 81
82/* Set a task for when a packet completes */ 82/* Set a task for when a packet completes */
@@ -102,7 +102,7 @@ void hpsb_free_packet(struct hpsb_packet *packet);
102 */ 102 */
103static inline unsigned int get_hpsb_generation(struct hpsb_host *host) 103static inline unsigned int get_hpsb_generation(struct hpsb_host *host)
104{ 104{
105 return atomic_read(&host->generation); 105 return atomic_read(&host->generation);
106} 106}
107 107
108/* 108/*
@@ -157,7 +157,7 @@ void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot);
157 * from within a transmit packet routine. 157 * from within a transmit packet routine.
158 */ 158 */
159void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet, 159void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
160 int ackcode); 160 int ackcode);
161 161
162/* 162/*
163 * Hand over received packet to the core. The contents of data are expected to 163 * Hand over received packet to the core. The contents of data are expected to
@@ -171,7 +171,7 @@ void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
171 * packet type. 171 * packet type.
172 */ 172 */
173void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size, 173void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
174 int write_acked); 174 int write_acked);
175 175
176 176
177/* 177/*
@@ -197,20 +197,20 @@ void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
197 * Block 15 (240-255) reserved for drivers under development, etc. 197 * Block 15 (240-255) reserved for drivers under development, etc.
198 */ 198 */
199 199
200#define IEEE1394_MAJOR 171 200#define IEEE1394_MAJOR 171
201 201
202#define IEEE1394_MINOR_BLOCK_RAW1394 0 202#define IEEE1394_MINOR_BLOCK_RAW1394 0
203#define IEEE1394_MINOR_BLOCK_VIDEO1394 1 203#define IEEE1394_MINOR_BLOCK_VIDEO1394 1
204#define IEEE1394_MINOR_BLOCK_DV1394 2 204#define IEEE1394_MINOR_BLOCK_DV1394 2
205#define IEEE1394_MINOR_BLOCK_AMDTP 3 205#define IEEE1394_MINOR_BLOCK_AMDTP 3
206#define IEEE1394_MINOR_BLOCK_EXPERIMENTAL 15 206#define IEEE1394_MINOR_BLOCK_EXPERIMENTAL 15
207 207
208#define IEEE1394_CORE_DEV MKDEV(IEEE1394_MAJOR, 0) 208#define IEEE1394_CORE_DEV MKDEV(IEEE1394_MAJOR, 0)
209#define IEEE1394_RAW1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16) 209#define IEEE1394_RAW1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16)
210#define IEEE1394_VIDEO1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_VIDEO1394 * 16) 210#define IEEE1394_VIDEO1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_VIDEO1394 * 16)
211#define IEEE1394_DV1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16) 211#define IEEE1394_DV1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16)
212#define IEEE1394_AMDTP_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_AMDTP * 16) 212#define IEEE1394_AMDTP_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_AMDTP * 16)
213#define IEEE1394_EXPERIMENTAL_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16) 213#define IEEE1394_EXPERIMENTAL_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16)
214 214
215/* return the index (within a minor number block) of a file */ 215/* return the index (within a minor number block) of a file */
216static inline unsigned char ieee1394_file_to_instance(struct file *file) 216static inline unsigned char ieee1394_file_to_instance(struct file *file)