aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/ide-disk.c21
-rw-r--r--include/linux/ata.h9
2 files changed, 15 insertions, 15 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 08f47cb13425..8f49bc0ecbf8 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -384,16 +384,6 @@ static unsigned long long sectors_to_MB(unsigned long long n)
384} 384}
385 385
386/* 386/*
387 * The same here.
388 */
389static inline int idedisk_supports_lba48(const u16 *id)
390{
391 return (id[ATA_ID_COMMAND_SET_2] & 0x0400) &&
392 (id[ATA_ID_CFS_ENABLE_2] & 0x0400) &&
393 ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
394}
395
396/*
397 * Some disks report total number of sectors instead of 387 * Some disks report total number of sectors instead of
398 * maximum sector address. We list them here. 388 * maximum sector address. We list them here.
399 */ 389 */
@@ -407,7 +397,7 @@ static const struct drive_list_entry hpa_list[] = {
407static void idedisk_check_hpa(ide_drive_t *drive) 397static void idedisk_check_hpa(ide_drive_t *drive)
408{ 398{
409 unsigned long long capacity, set_max; 399 unsigned long long capacity, set_max;
410 int lba48 = idedisk_supports_lba48(drive->id); 400 int lba48 = ata_id_lba48_enabled(drive->id);
411 401
412 capacity = drive->capacity64; 402 capacity = drive->capacity64;
413 403
@@ -450,7 +440,7 @@ static void init_idedisk_capacity(ide_drive_t *drive)
450 */ 440 */
451 int hpa = ata_id_hpa_enabled(id); 441 int hpa = ata_id_hpa_enabled(id);
452 442
453 if (idedisk_supports_lba48(id)) { 443 if (ata_id_lba48_enabled(id)) {
454 /* drive speaks 48-bit LBA */ 444 /* drive speaks 48-bit LBA */
455 drive->select.b.lba = 1; 445 drive->select.b.lba = 1;
456 drive->capacity64 = ata_id_u64(id, ATA_ID_LBA_CAPACITY_2); 446 drive->capacity64 = ata_id_u64(id, ATA_ID_LBA_CAPACITY_2);
@@ -754,9 +744,11 @@ static int set_lba_addressing(ide_drive_t *drive, int arg)
754 if (drive->hwif->host_flags & IDE_HFLAG_NO_LBA48) 744 if (drive->hwif->host_flags & IDE_HFLAG_NO_LBA48)
755 return 0; 745 return 0;
756 746
757 if (!idedisk_supports_lba48(drive->id)) 747 if (ata_id_lba48_enabled(drive->id) == 0)
758 return -EIO; 748 return -EIO;
749
759 drive->addressing = arg; 750 drive->addressing = arg;
751
760 return 0; 752 return 0;
761} 753}
762 754
@@ -853,8 +845,7 @@ static void idedisk_setup(ide_drive_t *drive)
853 capacity = idedisk_capacity(drive); 845 capacity = idedisk_capacity(drive);
854 846
855 if (!drive->forced_geom) { 847 if (!drive->forced_geom) {
856 848 if (ata_id_lba48_enabled(drive->id)) {
857 if (idedisk_supports_lba48(drive->id)) {
858 /* compatibility */ 849 /* compatibility */
859 drive->bios_sect = 63; 850 drive->bios_sect = 63;
860 drive->bios_head = 255; 851 drive->bios_head = 255;
diff --git a/include/linux/ata.h b/include/linux/ata.h
index d28aad991c75..8162257b474f 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -574,6 +574,15 @@ static inline int ata_id_has_lba48(const u16 *id)
574 return id[ATA_ID_COMMAND_SET_2] & (1 << 10); 574 return id[ATA_ID_COMMAND_SET_2] & (1 << 10);
575} 575}
576 576
577static inline int ata_id_lba48_enabled(const u16 *id)
578{
579 if (ata_id_has_lba48(id) == 0)
580 return 0;
581 if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000)
582 return 0;
583 return id[ATA_ID_CFS_ENABLE_2] & (1 << 10);
584}
585
577static inline int ata_id_hpa_enabled(const u16 *id) 586static inline int ata_id_hpa_enabled(const u16 *id)
578{ 587{
579 /* Yes children, word 83 valid bits cover word 82 data */ 588 /* Yes children, word 83 valid bits cover word 82 data */