]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
[PATCH] libata: improve xfer mask constants and update ata_mode_string()
authorTejun Heo <htejun@gmail.com>
Sun, 5 Mar 2006 19:31:56 +0000 (04:31 +0900)
committerJeff Garzik <jeff@garzik.org>
Sun, 12 Mar 2006 00:03:38 +0000 (19:03 -0500)
Add ATA_BITS_*, ATA_MASK_* macros and reorder xfer_mask fields such
that higher transfer mode is placed at higher order bit.  As thie
reordering breaks ata_mode_string(), this patch also rewrites
ata_mode_string().

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
drivers/scsi/libata-core.c
include/linux/libata.h

index 6d8aa86f2f6b0eac7827491d2218ad8d8bc43c62..18418c82d6f6355fbefe1b828557faff88e0ab87 100644 (file)
@@ -232,6 +232,14 @@ int ata_rwcmd_protocol(struct ata_queued_cmd *qc)
 }
 
 static const char * const xfer_mode_str[] = {
+       "PIO0",
+       "PIO1",
+       "PIO2",
+       "PIO3",
+       "PIO4",
+       "MWDMA0",
+       "MWDMA1",
+       "MWDMA2",
        "UDMA/16",
        "UDMA/25",
        "UDMA/33",
@@ -240,49 +248,31 @@ static const char * const xfer_mode_str[] = {
        "UDMA/100",
        "UDMA/133",
        "UDMA7",
-       "MWDMA0",
-       "MWDMA1",
-       "MWDMA2",
-       "PIO0",
-       "PIO1",
-       "PIO2",
-       "PIO3",
-       "PIO4",
 };
 
 /**
- *     ata_udma_string - convert UDMA bit offset to string
- *     @mask: mask of bits supported; only highest bit counts.
+ *     ata_mode_string - convert xfer_mask to string
+ *     @xfer_mask: mask of bits supported; only highest bit counts.
  *
  *     Determine string which represents the highest speed
- *     (highest bit in @udma_mask).
+ *     (highest bit in @modemask).
  *
  *     LOCKING:
  *     None.
  *
  *     RETURNS:
  *     Constant C string representing highest speed listed in
- *     @udma_mask, or the constant C string "<n/a>".
+ *     @mode_mask, or the constant C string "<n/a>".
  */
 
-static const char *ata_mode_string(unsigned int mask)
+static const char *ata_mode_string(unsigned int xfer_mask)
 {
-       int i;
-
-       for (i = 7; i >= 0; i--)
-               if (mask & (1 << i))
-                       goto out;
-       for (i = ATA_SHIFT_MWDMA + 2; i >= ATA_SHIFT_MWDMA; i--)
-               if (mask & (1 << i))
-                       goto out;
-       for (i = ATA_SHIFT_PIO + 4; i >= ATA_SHIFT_PIO; i--)
-               if (mask & (1 << i))
-                       goto out;
+       int highbit;
 
+       highbit = fls(xfer_mask) - 1;
+       if (highbit >= 0 && highbit < ARRAY_SIZE(xfer_mode_str))
+               return xfer_mode_str[highbit];
        return "<n/a>";
-
-out:
-       return xfer_mode_str[i];
 }
 
 /**
index 15674923cc84f2f9e01f5ffc3a3bf05d566fdeae..239408ecfddfb2d7dda2ef22d728a0c85d4c5d64 100644 (file)
@@ -188,11 +188,19 @@ enum {
        PORT_DISABLED           = 2,
 
        /* encoding various smaller bitmaps into a single
-        * unsigned long bitmap
+        * unsigned int bitmap
         */
-       ATA_SHIFT_UDMA          = 0,
-       ATA_SHIFT_MWDMA         = 8,
-       ATA_SHIFT_PIO           = 11,
+       ATA_BITS_PIO            = 5,
+       ATA_BITS_MWDMA          = 3,
+       ATA_BITS_UDMA           = 8,
+
+       ATA_SHIFT_PIO           = 0,
+       ATA_SHIFT_MWDMA         = ATA_SHIFT_PIO + ATA_BITS_PIO,
+       ATA_SHIFT_UDMA          = ATA_SHIFT_MWDMA + ATA_BITS_MWDMA,
+
+       ATA_MASK_PIO            = ((1 << ATA_BITS_PIO) - 1) << ATA_SHIFT_PIO,
+       ATA_MASK_MWDMA          = ((1 << ATA_BITS_MWDMA) - 1) << ATA_SHIFT_MWDMA,
+       ATA_MASK_UDMA           = ((1 << ATA_BITS_UDMA) - 1) << ATA_SHIFT_UDMA,
 
        /* size of buffer to pad xfers ending on unaligned boundaries */
        ATA_DMA_PAD_SZ          = 4,