]> www.infradead.org Git - users/willy/xarray.git/commitdiff
firewire: ohci: use inline functions to operate data of self-ID DMA
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Tue, 2 Jul 2024 22:20:33 +0000 (07:20 +0900)
committerTakashi Sakamoto <o-takashi@sakamocchi.jp>
Wed, 3 Jul 2024 23:12:48 +0000 (08:12 +0900)
The code of 1394 OHCI driver includes hard-coded magic number to operate
data of Self-ID DMA.

This commit replaces them with the inline functions added/tested in the
former commit.

Link: https://lore.kernel.org/r/20240702222034.1378764-5-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
drivers/firewire/ohci.c
drivers/firewire/ohci.h

index 5b90ca72fa6434decbbb8a25d095d7cc74842f42..c95f26c74e2b8a13fbc2214102b8e1291e9f3e3e 100644 (file)
@@ -2003,7 +2003,7 @@ static void bus_reset_work(struct work_struct *work)
        struct fw_ohci *ohci =
                container_of(work, struct fw_ohci, bus_reset_work);
        int self_id_count, generation, new_generation, i, j;
-       u32 reg;
+       u32 reg, quadlet;
        void *free_rom = NULL;
        dma_addr_t free_rom_bus = 0;
        bool is_new_root;
@@ -2028,7 +2028,7 @@ static void bus_reset_work(struct work_struct *work)
        ohci->is_root = is_new_root;
 
        reg = reg_read(ohci, OHCI1394_SelfIDCount);
-       if (reg & OHCI1394_SelfIDCount_selfIDError) {
+       if (ohci1394_self_id_count_is_error(reg)) {
                ohci_notice(ohci, "self ID receive error\n");
                return;
        }
@@ -2038,14 +2038,15 @@ static void bus_reset_work(struct work_struct *work)
         * the inverted quadlets and a header quadlet, we shift one
         * bit extra to get the actual number of self IDs.
         */
-       self_id_count = (reg >> 3) & 0xff;
+       self_id_count = ohci1394_self_id_count_get_size(reg) >> 1;
 
        if (self_id_count > 252) {
                ohci_notice(ohci, "bad selfIDSize (%08x)\n", reg);
                return;
        }
 
-       generation = (cond_le32_to_cpu(ohci->self_id[0], has_be_header_quirk(ohci)) >> 16) & 0xff;
+       quadlet = cond_le32_to_cpu(ohci->self_id[0], has_be_header_quirk(ohci));
+       generation = ohci1394_self_id_receive_q0_get_generation(quadlet);
        rmb();
 
        for (i = 1, j = 0; j < self_id_count; i += 2, j++) {
@@ -2102,7 +2103,8 @@ static void bus_reset_work(struct work_struct *work)
         * of self IDs.
         */
 
-       new_generation = (reg_read(ohci, OHCI1394_SelfIDCount) >> 16) & 0xff;
+       reg = reg_read(ohci, OHCI1394_SelfIDCount);
+       new_generation = ohci1394_self_id_count_get_generation(reg);
        if (new_generation != generation) {
                ohci_notice(ohci, "new bus reset, discarding self ids\n");
                return;
index d83fd4731d56e953d525140f379d311b47642f06..71c2ed84cafb0b220d7889e154f842c02869f332 100644 (file)
@@ -31,7 +31,6 @@
 #define  OHCI1394_HCControl_softReset          0x00010000
 #define OHCI1394_SelfIDBuffer                 0x064
 #define OHCI1394_SelfIDCount                  0x068
-#define  OHCI1394_SelfIDCount_selfIDError      0x80000000
 #define OHCI1394_IRMultiChanMaskHiSet         0x070
 #define OHCI1394_IRMultiChanMaskHiClear       0x074
 #define OHCI1394_IRMultiChanMaskLoSet         0x078