aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-card.c
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2007-05-07 20:33:32 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2007-05-10 12:24:13 -0400
commitc781c06d119d04601727f2fbc30151e6760d536d (patch)
tree1faf19acc6bc2a2a3b3bdae8368e395e75cd7518 /drivers/firewire/fw-card.c
parente175569c4639872b5cf242c9d4a71cc40c5f3c29 (diff)
firewire: Clean up comment style.
Drop filenames from file preamble, drop editor annotations and use standard indent style for block comments. Signed-off-by: Kristian Hoegsberg <krh@redhat.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (fixed typo)
Diffstat (limited to 'drivers/firewire/fw-card.c')
-rw-r--r--drivers/firewire/fw-card.c105
1 files changed, 66 insertions, 39 deletions
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index 216965615ee8..b2aa85555a7a 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -1,8 +1,5 @@
1/* -*- c-basic-offset: 8 -*- 1/*
2 * 2 * Copyright (C) 2005-2007 Kristian Hoegsberg <krh@bitplanet.net>
3 * fw-card.c - card level functions
4 *
5 * Copyright (C) 2005-2006 Kristian Hoegsberg <krh@bitplanet.net>
6 * 3 *
7 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 5 * it under the terms of the GNU General Public License as published by
@@ -69,12 +66,14 @@ generate_config_rom (struct fw_card *card, size_t *config_rom_length)
69 static u32 config_rom[256]; 66 static u32 config_rom[256];
70 int i, j, length; 67 int i, j, length;
71 68
72 /* Initialize contents of config rom buffer. On the OHCI 69 /*
70 * Initialize contents of config rom buffer. On the OHCI
73 * controller, block reads to the config rom accesses the host 71 * controller, block reads to the config rom accesses the host
74 * memory, but quadlet read access the hardware bus info block 72 * memory, but quadlet read access the hardware bus info block
75 * registers. That's just crack, but it means we should make 73 * registers. That's just crack, but it means we should make
76 * sure the contents of bus info block in host memory mathces 74 * sure the contents of bus info block in host memory mathces
77 * the version stored in the OHCI registers. */ 75 * the version stored in the OHCI registers.
76 */
78 77
79 memset(config_rom, 0, sizeof config_rom); 78 memset(config_rom, 0, sizeof config_rom);
80 config_rom[0] = bib_crc_length(4) | bib_info_length(4) | bib_crc(0); 79 config_rom[0] = bib_crc_length(4) | bib_info_length(4) | bib_crc(0);
@@ -143,9 +142,11 @@ fw_core_add_descriptor (struct fw_descriptor *desc)
143{ 142{
144 size_t i; 143 size_t i;
145 144
146 /* Check descriptor is valid; the length of all blocks in the 145 /*
146 * Check descriptor is valid; the length of all blocks in the
147 * descriptor has to add up to exactly the length of the 147 * descriptor has to add up to exactly the length of the
148 * block. */ 148 * block.
149 */
149 i = 0; 150 i = 0;
150 while (i < desc->length) 151 while (i < desc->length)
151 i += (desc->data[i] >> 16) + 1; 152 i += (desc->data[i] >> 16) + 1;
@@ -228,7 +229,8 @@ fw_card_bm_work(struct work_struct *work)
228 229
229 if (card->bm_generation + 1 == generation || 230 if (card->bm_generation + 1 == generation ||
230 (card->bm_generation != generation && grace)) { 231 (card->bm_generation != generation && grace)) {
231 /* This first step is to figure out who is IRM and 232 /*
233 * This first step is to figure out who is IRM and
232 * then try to become bus manager. If the IRM is not 234 * then try to become bus manager. If the IRM is not
233 * well defined (e.g. does not have an active link 235 * well defined (e.g. does not have an active link
234 * layer or does not responds to our lock request, we 236 * layer or does not responds to our lock request, we
@@ -236,7 +238,8 @@ fw_card_bm_work(struct work_struct *work)
236 * In that case, we do a goto into the gap count logic 238 * In that case, we do a goto into the gap count logic
237 * so that when we do the reset, we still optimize the 239 * so that when we do the reset, we still optimize the
238 * gap count. That could well save a reset in the 240 * gap count. That could well save a reset in the
239 * next generation. */ 241 * next generation.
242 */
240 243
241 irm_id = card->irm_node->node_id; 244 irm_id = card->irm_node->node_id;
242 if (!card->irm_node->link_on) { 245 if (!card->irm_node->link_on) {
@@ -260,8 +263,10 @@ fw_card_bm_work(struct work_struct *work)
260 wait_for_completion(&bmd.done); 263 wait_for_completion(&bmd.done);
261 264
262 if (bmd.rcode == RCODE_GENERATION) { 265 if (bmd.rcode == RCODE_GENERATION) {
263 /* Another bus reset happened. Just return, 266 /*
264 * the BM work has been rescheduled. */ 267 * Another bus reset happened. Just return,
268 * the BM work has been rescheduled.
269 */
265 return; 270 return;
266 } 271 }
267 272
@@ -271,48 +276,62 @@ fw_card_bm_work(struct work_struct *work)
271 276
272 spin_lock_irqsave(&card->lock, flags); 277 spin_lock_irqsave(&card->lock, flags);
273 if (bmd.rcode != RCODE_COMPLETE) { 278 if (bmd.rcode != RCODE_COMPLETE) {
274 /* The lock request failed, maybe the IRM 279 /*
280 * The lock request failed, maybe the IRM
275 * isn't really IRM capable after all. Let's 281 * isn't really IRM capable after all. Let's
276 * do a bus reset and pick the local node as 282 * do a bus reset and pick the local node as
277 * root, and thus, IRM. */ 283 * root, and thus, IRM.
284 */
278 new_root_id = card->local_node->node_id; 285 new_root_id = card->local_node->node_id;
279 fw_notify("BM lock failed, making local node (%02x) root.\n", 286 fw_notify("BM lock failed, making local node (%02x) root.\n",
280 new_root_id); 287 new_root_id);
281 goto pick_me; 288 goto pick_me;
282 } 289 }
283 } else if (card->bm_generation != generation) { 290 } else if (card->bm_generation != generation) {
284 /* OK, we weren't BM in the last generation, and it's 291 /*
292 * OK, we weren't BM in the last generation, and it's
285 * less than 100ms since last bus reset. Reschedule 293 * less than 100ms since last bus reset. Reschedule
286 * this task 100ms from now. */ 294 * this task 100ms from now.
295 */
287 spin_unlock_irqrestore(&card->lock, flags); 296 spin_unlock_irqrestore(&card->lock, flags);
288 schedule_delayed_work(&card->work, DIV_ROUND_UP(HZ, 10)); 297 schedule_delayed_work(&card->work, DIV_ROUND_UP(HZ, 10));
289 return; 298 return;
290 } 299 }
291 300
292 /* We're bus manager for this generation, so next step is to 301 /*
302 * We're bus manager for this generation, so next step is to
293 * make sure we have an active cycle master and do gap count 303 * make sure we have an active cycle master and do gap count
294 * optimization. */ 304 * optimization.
305 */
295 card->bm_generation = generation; 306 card->bm_generation = generation;
296 307
297 if (root == NULL) { 308 if (root == NULL) {
298 /* Either link_on is false, or we failed to read the 309 /*
299 * config rom. In either case, pick another root. */ 310 * Either link_on is false, or we failed to read the
311 * config rom. In either case, pick another root.
312 */
300 new_root_id = card->local_node->node_id; 313 new_root_id = card->local_node->node_id;
301 } else if (atomic_read(&root->state) != FW_DEVICE_RUNNING) { 314 } else if (atomic_read(&root->state) != FW_DEVICE_RUNNING) {
302 /* If we haven't probed this device yet, bail out now 315 /*
303 * and let's try again once that's done. */ 316 * If we haven't probed this device yet, bail out now
317 * and let's try again once that's done.
318 */
304 spin_unlock_irqrestore(&card->lock, flags); 319 spin_unlock_irqrestore(&card->lock, flags);
305 return; 320 return;
306 } else if (root->config_rom[2] & bib_cmc) { 321 } else if (root->config_rom[2] & bib_cmc) {
307 /* FIXME: I suppose we should set the cmstr bit in the 322 /*
323 * FIXME: I suppose we should set the cmstr bit in the
308 * STATE_CLEAR register of this node, as described in 324 * STATE_CLEAR register of this node, as described in
309 * 1394-1995, 8.4.2.6. Also, send out a force root 325 * 1394-1995, 8.4.2.6. Also, send out a force root
310 * packet for this node. */ 326 * packet for this node.
327 */
311 new_root_id = root_id; 328 new_root_id = root_id;
312 } else { 329 } else {
313 /* Current root has an active link layer and we 330 /*
331 * Current root has an active link layer and we
314 * successfully read the config rom, but it's not 332 * successfully read the config rom, but it's not
315 * cycle master capable. */ 333 * cycle master capable.
334 */
316 new_root_id = card->local_node->node_id; 335 new_root_id = card->local_node->node_id;
317 } 336 }
318 337
@@ -324,9 +343,11 @@ fw_card_bm_work(struct work_struct *work)
324 else 343 else
325 gap_count = 63; 344 gap_count = 63;
326 345
327 /* Finally, figure out if we should do a reset or not. If we've 346 /*
347 * Finally, figure out if we should do a reset or not. If we've
328 * done less that 5 resets with the same physical topology and we 348 * done less that 5 resets with the same physical topology and we
329 * have either a new root or a new gap count setting, let's do it. */ 349 * have either a new root or a new gap count setting, let's do it.
350 */
330 351
331 if (card->bm_retries++ < 5 && 352 if (card->bm_retries++ < 5 &&
332 (card->gap_count != gap_count || new_root_id != root_id)) 353 (card->gap_count != gap_count || new_root_id != root_id))
@@ -391,8 +412,10 @@ fw_card_add(struct fw_card *card,
391 PHY_LINK_ACTIVE | PHY_CONTENDER) < 0) 412 PHY_LINK_ACTIVE | PHY_CONTENDER) < 0)
392 return -EIO; 413 return -EIO;
393 414
394 /* The subsystem grabs a reference when the card is added and 415 /*
395 * drops it when the driver calls fw_core_remove_card. */ 416 * The subsystem grabs a reference when the card is added and
417 * drops it when the driver calls fw_core_remove_card.
418 */
396 fw_card_get(card); 419 fw_card_get(card);
397 420
398 down_write(&card_rwsem); 421 down_write(&card_rwsem);
@@ -405,11 +428,13 @@ fw_card_add(struct fw_card *card,
405EXPORT_SYMBOL(fw_card_add); 428EXPORT_SYMBOL(fw_card_add);
406 429
407 430
408/* The next few functions implements a dummy driver that use once a 431/*
432 * The next few functions implements a dummy driver that use once a
409 * card driver shuts down an fw_card. This allows the driver to 433 * card driver shuts down an fw_card. This allows the driver to
410 * cleanly unload, as all IO to the card will be handled by the dummy 434 * cleanly unload, as all IO to the card will be handled by the dummy
411 * driver instead of calling into the (possibly) unloaded module. The 435 * driver instead of calling into the (possibly) unloaded module. The
412 * dummy driver just fails all IO. */ 436 * dummy driver just fails all IO.
437 */
413 438
414static int 439static int
415dummy_enable(struct fw_card *card, u32 *config_rom, size_t length) 440dummy_enable(struct fw_card *card, u32 *config_rom, size_t length)
@@ -429,8 +454,10 @@ static int
429dummy_set_config_rom(struct fw_card *card, 454dummy_set_config_rom(struct fw_card *card,
430 u32 *config_rom, size_t length) 455 u32 *config_rom, size_t length)
431{ 456{
432 /* We take the card out of card_list before setting the dummy 457 /*
433 * driver, so this should never get called. */ 458 * We take the card out of card_list before setting the dummy
459 * driver, so this should never get called.
460 */
434 BUG(); 461 BUG();
435 return -1; 462 return -1;
436} 463}
@@ -510,9 +537,11 @@ release_card(struct kref *kref)
510 kfree(card); 537 kfree(card);
511} 538}
512 539
513/* An assumption for fw_card_put() is that the card driver allocates 540/*
541 * An assumption for fw_card_put() is that the card driver allocates
514 * the fw_card struct with kalloc and that it has been shut down 542 * the fw_card struct with kalloc and that it has been shut down
515 * before the last ref is dropped. */ 543 * before the last ref is dropped.
544 */
516void 545void
517fw_card_put(struct fw_card *card) 546fw_card_put(struct fw_card *card)
518{ 547{
@@ -524,8 +553,6 @@ int
524fw_core_initiate_bus_reset(struct fw_card *card, int short_reset) 553fw_core_initiate_bus_reset(struct fw_card *card, int short_reset)
525{ 554{
526 int reg = short_reset ? 5 : 1; 555 int reg = short_reset ? 5 : 1;
527 /* The following values happen to be the same bit. However be
528 * explicit for clarity. */
529 int bit = short_reset ? PHY_BUS_SHORT_RESET : PHY_BUS_RESET; 556 int bit = short_reset ? PHY_BUS_SHORT_RESET : PHY_BUS_RESET;
530 557
531 return card->driver->update_phy_reg(card, reg, 0, bit); 558 return card->driver->update_phy_reg(card, reg, 0, bit);