aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/libata-core.c44
-rw-r--r--include/linux/libata.h16
2 files changed, 29 insertions, 31 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 6d8aa86f2f6b..18418c82d6f6 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -232,6 +232,14 @@ int ata_rwcmd_protocol(struct ata_queued_cmd *qc)
232} 232}
233 233
234static const char * const xfer_mode_str[] = { 234static const char * const xfer_mode_str[] = {
235 "PIO0",
236 "PIO1",
237 "PIO2",
238 "PIO3",
239 "PIO4",
240 "MWDMA0",
241 "MWDMA1",
242 "MWDMA2",
235 "UDMA/16", 243 "UDMA/16",
236 "UDMA/25", 244 "UDMA/25",
237 "UDMA/33", 245 "UDMA/33",
@@ -240,49 +248,31 @@ static const char * const xfer_mode_str[] = {
240 "UDMA/100", 248 "UDMA/100",
241 "UDMA/133", 249 "UDMA/133",
242 "UDMA7", 250 "UDMA7",
243 "MWDMA0",
244 "MWDMA1",
245 "MWDMA2",
246 "PIO0",
247 "PIO1",
248 "PIO2",
249 "PIO3",
250 "PIO4",
251}; 251};
252 252
253/** 253/**
254 * ata_udma_string - convert UDMA bit offset to string 254 * ata_mode_string - convert xfer_mask to string
255 * @mask: mask of bits supported; only highest bit counts. 255 * @xfer_mask: mask of bits supported; only highest bit counts.
256 * 256 *
257 * Determine string which represents the highest speed 257 * Determine string which represents the highest speed
258 * (highest bit in @udma_mask). 258 * (highest bit in @modemask).
259 * 259 *
260 * LOCKING: 260 * LOCKING:
261 * None. 261 * None.
262 * 262 *
263 * RETURNS: 263 * RETURNS:
264 * Constant C string representing highest speed listed in 264 * Constant C string representing highest speed listed in
265 * @udma_mask, or the constant C string "<n/a>". 265 * @mode_mask, or the constant C string "<n/a>".
266 */ 266 */
267 267
268static const char *ata_mode_string(unsigned int mask) 268static const char *ata_mode_string(unsigned int xfer_mask)
269{ 269{
270 int i; 270 int highbit;
271
272 for (i = 7; i >= 0; i--)
273 if (mask & (1 << i))
274 goto out;
275 for (i = ATA_SHIFT_MWDMA + 2; i >= ATA_SHIFT_MWDMA; i--)
276 if (mask & (1 << i))
277 goto out;
278 for (i = ATA_SHIFT_PIO + 4; i >= ATA_SHIFT_PIO; i--)
279 if (mask & (1 << i))
280 goto out;
281 271
272 highbit = fls(xfer_mask) - 1;
273 if (highbit >= 0 && highbit < ARRAY_SIZE(xfer_mode_str))
274 return xfer_mode_str[highbit];
282 return "<n/a>"; 275 return "<n/a>";
283
284out:
285 return xfer_mode_str[i];
286} 276}
287 277
288/** 278/**
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 15674923cc84..239408ecfddf 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -188,11 +188,19 @@ enum {
188 PORT_DISABLED = 2, 188 PORT_DISABLED = 2,
189 189
190 /* encoding various smaller bitmaps into a single 190 /* encoding various smaller bitmaps into a single
191 * unsigned long bitmap 191 * unsigned int bitmap
192 */ 192 */
193 ATA_SHIFT_UDMA = 0, 193 ATA_BITS_PIO = 5,
194 ATA_SHIFT_MWDMA = 8, 194 ATA_BITS_MWDMA = 3,
195 ATA_SHIFT_PIO = 11, 195 ATA_BITS_UDMA = 8,
196
197 ATA_SHIFT_PIO = 0,
198 ATA_SHIFT_MWDMA = ATA_SHIFT_PIO + ATA_BITS_PIO,
199 ATA_SHIFT_UDMA = ATA_SHIFT_MWDMA + ATA_BITS_MWDMA,
200
201 ATA_MASK_PIO = ((1 << ATA_BITS_PIO) - 1) << ATA_SHIFT_PIO,
202 ATA_MASK_MWDMA = ((1 << ATA_BITS_MWDMA) - 1) << ATA_SHIFT_MWDMA,
203 ATA_MASK_UDMA = ((1 << ATA_BITS_UDMA) - 1) << ATA_SHIFT_UDMA,
196 204
197 /* size of buffer to pad xfers ending on unaligned boundaries */ 205 /* size of buffer to pad xfers ending on unaligned boundaries */
198 ATA_DMA_PAD_SZ = 4, 206 ATA_DMA_PAD_SZ = 4,