diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-17 12:09:14 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-17 12:09:14 -0400 |
commit | 806f80a6fc203ad0bde84e5a9e94572617d2ae45 (patch) | |
tree | 20c684323e6e9f24af96df84008f06425a67ec6a /drivers/ide/ide-disk.c | |
parent | 79cb380397c834a35952d8497651d93b543ef968 (diff) |
ide: add generic ATA/ATAPI disk driver
* Add struct ide_disk_ops containing protocol specific methods.
* Add 'struct ide_disk_ops *' to ide_drive_t.
* Convert ide-{disk,floppy} drivers to use struct ide_disk_ops.
* Merge ide-{disk,floppy} drivers into generic ide-gd driver.
While at it:
- ide_disk_init_capacity() -> ide_disk_get_capacity()
Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r-- | drivers/ide/ide-disk.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 751be7af22c2..223750c1b5a6 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -184,8 +184,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | |||
184 | * 1073741822 == 549756 MB or 48bit addressing fake drive | 184 | * 1073741822 == 549756 MB or 48bit addressing fake drive |
185 | */ | 185 | */ |
186 | 186 | ||
187 | ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq, | 187 | static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq, |
188 | sector_t block) | 188 | sector_t block) |
189 | { | 189 | { |
190 | ide_hwif_t *hwif = HWIF(drive); | 190 | ide_hwif_t *hwif = HWIF(drive); |
191 | 191 | ||
@@ -333,7 +333,7 @@ static void idedisk_check_hpa(ide_drive_t *drive) | |||
333 | } | 333 | } |
334 | } | 334 | } |
335 | 335 | ||
336 | void ide_disk_init_capacity(ide_drive_t *drive) | 336 | static int ide_disk_get_capacity(ide_drive_t *drive) |
337 | { | 337 | { |
338 | u16 *id = drive->id; | 338 | u16 *id = drive->id; |
339 | int lba; | 339 | int lba; |
@@ -382,6 +382,8 @@ void ide_disk_init_capacity(ide_drive_t *drive) | |||
382 | } else | 382 | } else |
383 | drive->dev_flags &= ~IDE_DFLAG_LBA48; | 383 | drive->dev_flags &= ~IDE_DFLAG_LBA48; |
384 | } | 384 | } |
385 | |||
386 | return 0; | ||
385 | } | 387 | } |
386 | 388 | ||
387 | static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) | 389 | static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) |
@@ -590,7 +592,12 @@ ide_ext_devset_rw(wcache, wcache); | |||
590 | 592 | ||
591 | ide_ext_devset_rw_sync(nowerr, nowerr); | 593 | ide_ext_devset_rw_sync(nowerr, nowerr); |
592 | 594 | ||
593 | void ide_disk_setup(ide_drive_t *drive) | 595 | static int ide_disk_check(ide_drive_t *drive, const char *s) |
596 | { | ||
597 | return 1; | ||
598 | } | ||
599 | |||
600 | static void ide_disk_setup(ide_drive_t *drive) | ||
594 | { | 601 | { |
595 | struct ide_disk_obj *idkp = drive->driver_data; | 602 | struct ide_disk_obj *idkp = drive->driver_data; |
596 | ide_hwif_t *hwif = drive->hwif; | 603 | ide_hwif_t *hwif = drive->hwif; |
@@ -626,7 +633,7 @@ void ide_disk_setup(ide_drive_t *drive) | |||
626 | drive->queue->max_sectors / 2); | 633 | drive->queue->max_sectors / 2); |
627 | 634 | ||
628 | /* calculate drive capacity, and select LBA if possible */ | 635 | /* calculate drive capacity, and select LBA if possible */ |
629 | ide_disk_init_capacity(drive); | 636 | ide_disk_get_capacity(drive); |
630 | 637 | ||
631 | /* | 638 | /* |
632 | * if possible, give fdisk access to more of the drive, | 639 | * if possible, give fdisk access to more of the drive, |
@@ -682,7 +689,7 @@ void ide_disk_setup(ide_drive_t *drive) | |||
682 | drive->dev_flags |= IDE_DFLAG_ATTACH; | 689 | drive->dev_flags |= IDE_DFLAG_ATTACH; |
683 | } | 690 | } |
684 | 691 | ||
685 | void ide_disk_flush(ide_drive_t *drive) | 692 | static void ide_disk_flush(ide_drive_t *drive) |
686 | { | 693 | { |
687 | if (ata_id_flush_enabled(drive->id) == 0 || | 694 | if (ata_id_flush_enabled(drive->id) == 0 || |
688 | (drive->dev_flags & IDE_DFLAG_WCACHE) == 0) | 695 | (drive->dev_flags & IDE_DFLAG_WCACHE) == 0) |
@@ -692,7 +699,13 @@ void ide_disk_flush(ide_drive_t *drive) | |||
692 | printk(KERN_INFO "%s: wcache flush failed!\n", drive->name); | 699 | printk(KERN_INFO "%s: wcache flush failed!\n", drive->name); |
693 | } | 700 | } |
694 | 701 | ||
695 | int ide_disk_set_doorlock(ide_drive_t *drive, int on) | 702 | static int ide_disk_init_media(ide_drive_t *drive, struct gendisk *disk) |
703 | { | ||
704 | return 0; | ||
705 | } | ||
706 | |||
707 | static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk, | ||
708 | int on) | ||
696 | { | 709 | { |
697 | ide_task_t task; | 710 | ide_task_t task; |
698 | int ret; | 711 | int ret; |
@@ -711,3 +724,15 @@ int ide_disk_set_doorlock(ide_drive_t *drive, int on) | |||
711 | 724 | ||
712 | return ret; | 725 | return ret; |
713 | } | 726 | } |
727 | |||
728 | const struct ide_disk_ops ide_ata_disk_ops = { | ||
729 | .check = ide_disk_check, | ||
730 | .get_capacity = ide_disk_get_capacity, | ||
731 | .setup = ide_disk_setup, | ||
732 | .flush = ide_disk_flush, | ||
733 | .init_media = ide_disk_init_media, | ||
734 | .set_doorlock = ide_disk_set_doorlock, | ||
735 | .do_request = ide_do_rw_disk, | ||
736 | .end_request = ide_end_request, | ||
737 | .ioctl = ide_disk_ioctl, | ||
738 | }; | ||