x86: clean up arch/x86/mm/pageattr_64.c
[safe/jmp/linux-2.6] / drivers / firewire / fw-card.c
index 74aab9a..3e97199 100644 (file)
@@ -44,20 +44,20 @@ static LIST_HEAD(card_list);
 static LIST_HEAD(descriptor_list);
 static int descriptor_count;
 
-#define bib_crc(v)             ((v) <<  0)
-#define bib_crc_length(v)      ((v) << 16)
-#define bib_info_length(v)     ((v) << 24)
-
-#define bib_link_speed(v)      ((v) <<  0)
-#define bib_generation(v)      ((v) <<  4)
-#define bib_max_rom(v)         ((v) <<  8)
-#define bib_max_receive(v)     ((v) << 12)
-#define bib_cyc_clk_acc(v)     ((v) << 16)
-#define bib_pmc                        ((1) << 27)
-#define bib_bmc                        ((1) << 28)
-#define bib_isc                        ((1) << 29)
-#define bib_cmc                        ((1) << 30)
-#define bib_imc                        ((1) << 31)
+#define BIB_CRC(v)             ((v) <<  0)
+#define BIB_CRC_LENGTH(v)      ((v) << 16)
+#define BIB_INFO_LENGTH(v)     ((v) << 24)
+
+#define BIB_LINK_SPEED(v)      ((v) <<  0)
+#define BIB_GENERATION(v)      ((v) <<  4)
+#define BIB_MAX_ROM(v)         ((v) <<  8)
+#define BIB_MAX_RECEIVE(v)     ((v) << 12)
+#define BIB_CYC_CLK_ACC(v)     ((v) << 16)
+#define BIB_PMC                        ((1) << 27)
+#define BIB_BMC                        ((1) << 28)
+#define BIB_ISC                        ((1) << 29)
+#define BIB_CMC                        ((1) << 30)
+#define BIB_IMC                        ((1) << 31)
 
 static u32 *
 generate_config_rom(struct fw_card *card, size_t *config_rom_length)
@@ -75,16 +75,16 @@ generate_config_rom(struct fw_card *card, size_t *config_rom_length)
         * the version stored in the OHCI registers.
         */
 
-       memset(config_rom, 0, sizeof config_rom);
-       config_rom[0] = bib_crc_length(4) | bib_info_length(4) | bib_crc(0);
+       memset(config_rom, 0, sizeof(config_rom));
+       config_rom[0] = BIB_CRC_LENGTH(4) | BIB_INFO_LENGTH(4) | BIB_CRC(0);
        config_rom[1] = 0x31333934;
 
        config_rom[2] =
-               bib_link_speed(card->link_speed) |
-               bib_generation(card->config_rom_generation++ % 14 + 2) |
-               bib_max_rom(2) |
-               bib_max_receive(card->max_receive) |
-               bib_bmc | bib_isc | bib_cmc | bib_imc;
+               BIB_LINK_SPEED(card->link_speed) |
+               BIB_GENERATION(card->config_rom_generation++ % 14 + 2) |
+               BIB_MAX_ROM(2) |
+               BIB_MAX_RECEIVE(card->max_receive) |
+               BIB_BMC | BIB_ISC | BIB_CMC | BIB_IMC;
        config_rom[3] = card->guid >> 32;
        config_rom[4] = card->guid;
 
@@ -258,7 +258,7 @@ fw_card_bm_work(struct work_struct *work)
                fw_send_request(card, &bmd.t, TCODE_LOCK_COMPARE_SWAP,
                                irm_id, generation,
                                SCODE_100, CSR_REGISTER_BASE + CSR_BUS_MANAGER_ID,
-                               &bmd.lock, sizeof bmd.lock,
+                               &bmd.lock, sizeof(bmd.lock),
                                complete_bm_lock, &bmd);
                wait_for_completion(&bmd.done);
 
@@ -318,7 +318,7 @@ fw_card_bm_work(struct work_struct *work)
                 */
                spin_unlock_irqrestore(&card->lock, flags);
                return;
-       } else if (root->config_rom[2] & bib_cmc) {
+       } else if (root->config_rom[2] & BIB_CMC) {
                /*
                 * FIXME: I suppose we should set the cmstr bit in the
                 * STATE_CLEAR register of this node, as described in
@@ -336,8 +336,11 @@ fw_card_bm_work(struct work_struct *work)
        }
 
  pick_me:
-       /* Now figure out what gap count to set. */
-       if (card->topology_type == FW_TOPOLOGY_A &&
+       /*
+        * Pick a gap count from 1394a table E-1.  The table doesn't cover
+        * the typically much larger 1394b beta repeater delays though.
+        */
+       if (!card->beta_repeaters_present &&
            card->root_node->max_hops < ARRAY_SIZE(gap_count_table))
                gap_count = gap_count_table[card->root_node->max_hops];
        else
@@ -407,11 +410,6 @@ fw_card_add(struct fw_card *card,
        card->link_speed = link_speed;
        card->guid = guid;
 
-       /* Activate link_on bit and contender bit in our self ID packets.*/
-       if (card->driver->update_phy_reg(card, 4, 0,
-                                        PHY_LINK_ACTIVE | PHY_CONTENDER) < 0)
-               return -EIO;
-
        /*
         * The subsystem grabs a reference when the card is added and
         * drops it when the driver calls fw_core_remove_card.
@@ -512,9 +510,11 @@ fw_core_remove_card(struct fw_card *card)
        /* Set up the dummy driver. */
        card->driver = &dummy_driver;
 
-       fw_flush_transactions(card);
-
        fw_destroy_nodes(card);
+       flush_scheduled_work();
+
+       fw_flush_transactions(card);
+       del_timer_sync(&card->flush_timer);
 
        fw_card_put(card);
 }