diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:18 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:18 -0400 |
commit | 5b90e990928919ae411a68b865e8a6ecac09a603 (patch) | |
tree | 4c372c575eb58b971e1283c216c690f4ec719e9f /drivers/ide | |
parent | df1f8378c2fd898fa08be5d72283d68c77f519e9 (diff) |
ide: cleanup ide_fix_driveid()
Do all __le16_to_cpu() swapping in one loop.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r-- | drivers/ide/ide-iops.c | 107 |
1 files changed, 20 insertions, 87 deletions
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 2cbadffe922e..68d655e0fa47 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
@@ -400,97 +400,30 @@ const struct ide_tp_ops default_tp_ops = { | |||
400 | .output_data = ide_output_data, | 400 | .output_data = ide_output_data, |
401 | }; | 401 | }; |
402 | 402 | ||
403 | void ide_fix_driveid (struct hd_driveid *id) | 403 | void ide_fix_driveid(struct hd_driveid *driveid) |
404 | { | 404 | { |
405 | #ifndef __LITTLE_ENDIAN | 405 | #ifndef __LITTLE_ENDIAN |
406 | # ifdef __BIG_ENDIAN | 406 | # ifdef __BIG_ENDIAN |
407 | u16 *id = (u16 *)driveid; | ||
407 | int i; | 408 | int i; |
408 | u16 *stringcast; | 409 | |
409 | 410 | for (i = 0; i < 256; i++) { | |
410 | id->config = __le16_to_cpu(id->config); | 411 | /* these words are accessed as two 8-bit values */ |
411 | id->cyls = __le16_to_cpu(id->cyls); | 412 | if (i == 47 || i == 49 || i == 51 || i == 52 || i == 59) |
412 | id->reserved2 = __le16_to_cpu(id->reserved2); | 413 | continue; |
413 | id->heads = __le16_to_cpu(id->heads); | 414 | if (i == 60 || i == 61) /* ->lba_capacity is 32-bit */ |
414 | id->track_bytes = __le16_to_cpu(id->track_bytes); | 415 | continue; |
415 | id->sector_bytes = __le16_to_cpu(id->sector_bytes); | 416 | if (i == 98 || i == 99) /* ->spg is 32-bit */ |
416 | id->sectors = __le16_to_cpu(id->sectors); | 417 | continue; |
417 | id->vendor0 = __le16_to_cpu(id->vendor0); | 418 | if (i > 99 && i < 104) /* ->lba_capacity_2 is 64-bit */ |
418 | id->vendor1 = __le16_to_cpu(id->vendor1); | 419 | continue; |
419 | id->vendor2 = __le16_to_cpu(id->vendor2); | 420 | |
420 | stringcast = (u16 *)&id->serial_no[0]; | 421 | id[i] = __le16_to_cpu(id[i]); |
421 | for (i = 0; i < (20/2); i++) | 422 | } |
422 | stringcast[i] = __le16_to_cpu(stringcast[i]); | 423 | |
423 | id->buf_type = __le16_to_cpu(id->buf_type); | 424 | driveid->lba_capacity = __le32_to_cpu(driveid->lba_capacity); |
424 | id->buf_size = __le16_to_cpu(id->buf_size); | 425 | driveid->spg = __le32_to_cpu(driveid->spg); |
425 | id->ecc_bytes = __le16_to_cpu(id->ecc_bytes); | 426 | driveid->lba_capacity_2 = __le64_to_cpu(driveid->lba_capacity_2); |
426 | stringcast = (u16 *)&id->fw_rev[0]; | ||
427 | for (i = 0; i < (8/2); i++) | ||
428 | stringcast[i] = __le16_to_cpu(stringcast[i]); | ||
429 | stringcast = (u16 *)&id->model[0]; | ||
430 | for (i = 0; i < (40/2); i++) | ||
431 | stringcast[i] = __le16_to_cpu(stringcast[i]); | ||
432 | id->dword_io = __le16_to_cpu(id->dword_io); | ||
433 | id->reserved50 = __le16_to_cpu(id->reserved50); | ||
434 | id->field_valid = __le16_to_cpu(id->field_valid); | ||
435 | id->cur_cyls = __le16_to_cpu(id->cur_cyls); | ||
436 | id->cur_heads = __le16_to_cpu(id->cur_heads); | ||
437 | id->cur_sectors = __le16_to_cpu(id->cur_sectors); | ||
438 | id->cur_capacity0 = __le16_to_cpu(id->cur_capacity0); | ||
439 | id->cur_capacity1 = __le16_to_cpu(id->cur_capacity1); | ||
440 | id->lba_capacity = __le32_to_cpu(id->lba_capacity); | ||
441 | id->dma_1word = __le16_to_cpu(id->dma_1word); | ||
442 | id->dma_mword = __le16_to_cpu(id->dma_mword); | ||
443 | id->eide_pio_modes = __le16_to_cpu(id->eide_pio_modes); | ||
444 | id->eide_dma_min = __le16_to_cpu(id->eide_dma_min); | ||
445 | id->eide_dma_time = __le16_to_cpu(id->eide_dma_time); | ||
446 | id->eide_pio = __le16_to_cpu(id->eide_pio); | ||
447 | id->eide_pio_iordy = __le16_to_cpu(id->eide_pio_iordy); | ||
448 | for (i = 0; i < 2; ++i) | ||
449 | id->words69_70[i] = __le16_to_cpu(id->words69_70[i]); | ||
450 | for (i = 0; i < 4; ++i) | ||
451 | id->words71_74[i] = __le16_to_cpu(id->words71_74[i]); | ||
452 | id->queue_depth = __le16_to_cpu(id->queue_depth); | ||
453 | for (i = 0; i < 4; ++i) | ||
454 | id->words76_79[i] = __le16_to_cpu(id->words76_79[i]); | ||
455 | id->major_rev_num = __le16_to_cpu(id->major_rev_num); | ||
456 | id->minor_rev_num = __le16_to_cpu(id->minor_rev_num); | ||
457 | id->command_set_1 = __le16_to_cpu(id->command_set_1); | ||
458 | id->command_set_2 = __le16_to_cpu(id->command_set_2); | ||
459 | id->cfsse = __le16_to_cpu(id->cfsse); | ||
460 | id->cfs_enable_1 = __le16_to_cpu(id->cfs_enable_1); | ||
461 | id->cfs_enable_2 = __le16_to_cpu(id->cfs_enable_2); | ||
462 | id->csf_default = __le16_to_cpu(id->csf_default); | ||
463 | id->dma_ultra = __le16_to_cpu(id->dma_ultra); | ||
464 | id->trseuc = __le16_to_cpu(id->trseuc); | ||
465 | id->trsEuc = __le16_to_cpu(id->trsEuc); | ||
466 | id->CurAPMvalues = __le16_to_cpu(id->CurAPMvalues); | ||
467 | id->mprc = __le16_to_cpu(id->mprc); | ||
468 | id->hw_config = __le16_to_cpu(id->hw_config); | ||
469 | id->acoustic = __le16_to_cpu(id->acoustic); | ||
470 | id->msrqs = __le16_to_cpu(id->msrqs); | ||
471 | id->sxfert = __le16_to_cpu(id->sxfert); | ||
472 | id->sal = __le16_to_cpu(id->sal); | ||
473 | id->spg = __le32_to_cpu(id->spg); | ||
474 | id->lba_capacity_2 = __le64_to_cpu(id->lba_capacity_2); | ||
475 | for (i = 0; i < 22; i++) | ||
476 | id->words104_125[i] = __le16_to_cpu(id->words104_125[i]); | ||
477 | id->last_lun = __le16_to_cpu(id->last_lun); | ||
478 | id->word127 = __le16_to_cpu(id->word127); | ||
479 | id->dlf = __le16_to_cpu(id->dlf); | ||
480 | id->csfo = __le16_to_cpu(id->csfo); | ||
481 | for (i = 0; i < 26; i++) | ||
482 | id->words130_155[i] = __le16_to_cpu(id->words130_155[i]); | ||
483 | id->word156 = __le16_to_cpu(id->word156); | ||
484 | for (i = 0; i < 3; i++) | ||
485 | id->words157_159[i] = __le16_to_cpu(id->words157_159[i]); | ||
486 | id->cfa_power = __le16_to_cpu(id->cfa_power); | ||
487 | for (i = 0; i < 15; i++) | ||
488 | id->words161_175[i] = __le16_to_cpu(id->words161_175[i]); | ||
489 | for (i = 0; i < 30; i++) | ||
490 | id->words176_205[i] = __le16_to_cpu(id->words176_205[i]); | ||
491 | for (i = 0; i < 49; i++) | ||
492 | id->words206_254[i] = __le16_to_cpu(id->words206_254[i]); | ||
493 | id->integrity_word = __le16_to_cpu(id->integrity_word); | ||
494 | # else | 427 | # else |
495 | # error "Please fix <asm/byteorder.h>" | 428 | # error "Please fix <asm/byteorder.h>" |
496 | # endif | 429 | # endif |