diff options
author | Tejun Heo <htejun@gmail.com> | 2006-03-05 14:31:56 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2006-03-11 19:03:38 -0500 |
commit | 1da7b0d01b20bf21f3263d8d2f17fa49a214d773 (patch) | |
tree | ed68984a55447d5620adbe885d9479bf96213bd6 /drivers/scsi/libata-core.c | |
parent | 2e755f68ee23b03484fde18d978f910cc5479cb8 (diff) |
[PATCH] libata: improve xfer mask constants and update ata_mode_string()
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>
Diffstat (limited to 'drivers/scsi/libata-core.c')
-rw-r--r-- | drivers/scsi/libata-core.c | 44 |
1 files changed, 17 insertions, 27 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 | ||
234 | static const char * const xfer_mode_str[] = { | 234 | static 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 | ||
268 | static const char *ata_mode_string(unsigned int mask) | 268 | static 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 | |||
284 | out: | ||
285 | return xfer_mode_str[i]; | ||
286 | } | 276 | } |
287 | 277 | ||
288 | /** | 278 | /** |