aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r--drivers/ide/ide-disk.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 3b128dce9c3a..33d65039cce9 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -407,32 +407,24 @@ static int ide_disk_get_capacity(ide_drive_t *drive)
407 return 0; 407 return 0;
408} 408}
409 409
410static u64 ide_disk_set_capacity(ide_drive_t *drive, u64 capacity) 410static void ide_disk_unlock_native_capacity(ide_drive_t *drive)
411{ 411{
412 u64 set = min(capacity, drive->probed_capacity);
413 u16 *id = drive->id; 412 u16 *id = drive->id;
414 int lba48 = ata_id_lba48_enabled(id); 413 int lba48 = ata_id_lba48_enabled(id);
415 414
416 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 || 415 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 ||
417 ata_id_hpa_enabled(id) == 0) 416 ata_id_hpa_enabled(id) == 0)
418 goto out; 417 return;
419 418
420 /* 419 /*
421 * according to the spec the SET MAX ADDRESS command shall be 420 * according to the spec the SET MAX ADDRESS command shall be
422 * immediately preceded by a READ NATIVE MAX ADDRESS command 421 * immediately preceded by a READ NATIVE MAX ADDRESS command
423 */ 422 */
424 capacity = ide_disk_hpa_get_native_capacity(drive, lba48); 423 if (!ide_disk_hpa_get_native_capacity(drive, lba48))
425 if (capacity == 0) 424 return;
426 goto out; 425
427 426 if (ide_disk_hpa_set_capacity(drive, drive->probed_capacity, lba48))
428 set = ide_disk_hpa_set_capacity(drive, set, lba48); 427 drive->dev_flags |= IDE_DFLAG_NOHPA; /* disable HPA on resume */
429 if (set) {
430 /* needed for ->resume to disable HPA */
431 drive->dev_flags |= IDE_DFLAG_NOHPA;
432 return set;
433 }
434out:
435 return drive->capacity64;
436} 428}
437 429
438static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) 430static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
@@ -783,13 +775,13 @@ static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk,
783} 775}
784 776
785const struct ide_disk_ops ide_ata_disk_ops = { 777const struct ide_disk_ops ide_ata_disk_ops = {
786 .check = ide_disk_check, 778 .check = ide_disk_check,
787 .set_capacity = ide_disk_set_capacity, 779 .unlock_native_capacity = ide_disk_unlock_native_capacity,
788 .get_capacity = ide_disk_get_capacity, 780 .get_capacity = ide_disk_get_capacity,
789 .setup = ide_disk_setup, 781 .setup = ide_disk_setup,
790 .flush = ide_disk_flush, 782 .flush = ide_disk_flush,
791 .init_media = ide_disk_init_media, 783 .init_media = ide_disk_init_media,
792 .set_doorlock = ide_disk_set_doorlock, 784 .set_doorlock = ide_disk_set_doorlock,
793 .do_request = ide_do_rw_disk, 785 .do_request = ide_do_rw_disk,
794 .ioctl = ide_disk_ioctl, 786 .ioctl = ide_disk_ioctl,
795}; 787};