]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/ide/ide-disk.c
Kobject: auto-cleanup on final unref
[linux-2.6-omap-h63xx.git] / drivers / ide / ide-disk.c
index 4754769eda9781ee2531b46f8bcbf42167e41685..b1781908e1f2caffd4598a35c3037e1a60e59a85 100644 (file)
  *                and Andre Hedrick <andre@linux-ide.org>
  *
  * This is the IDE/ATA disk driver, as evolved from hd.c and ide.c.
- *
- * Version 1.00                move disk only code from ide.c to ide-disk.c
- *                     support optional byte-swapping of all data
- * Version 1.01                fix previous byte-swapping code
- * Version 1.02                remove ", LBA" from drive identification msgs
- * Version 1.03                fix display of id->buf_size for big-endian
- * Version 1.04                add /proc configurable settings and S.M.A.R.T support
- * Version 1.05                add capacity support for ATA3 >= 8GB
- * Version 1.06                get boot-up messages to show full cyl count
- * Version 1.07                disable door-locking if it fails
- * Version 1.08                fixed CHS/LBA translations for ATA4 > 8GB,
- *                     process of adding new ATA4 compliance.
- *                     fixed problems in allowing fdisk to see
- *                     the entire disk.
- * Version 1.09                added increment of rq->sector in ide_multwrite
- *                     added UDMA 3/4 reporting
- * Version 1.10                request queue changes, Ultra DMA 100
- * Version 1.11                added 48-bit lba
- * Version 1.12                adding taskfile io access method
- * Version 1.13                added standby and flush-cache for notifier
- * Version 1.14                added acoustic-wcache
- * Version 1.15                convert all calls to ide_raw_taskfile
- *                             since args will return register content.
- * Version 1.16                added suspend-resume-checkpower
- * Version 1.17                do flush on standby, do flush on ATA < ATA6
- *                     fix wcache setup.
  */
 
 #define IDEDISK_VERSION        "1.18"
@@ -169,7 +143,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
 
        nsectors.all            = (u16) rq->nr_sectors;
 
-       if (hwif->no_lba48_dma && lba48 && dma) {
+       if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && lba48 && dma) {
                if (block + rq->nr_sectors > 1ULL << 28)
                        dma = 0;
                else
@@ -593,28 +567,12 @@ static int smart_enable(ide_drive_t *drive)
        return ide_raw_taskfile(drive, &args, NULL);
 }
 
-static int get_smart_values(ide_drive_t *drive, u8 *buf)
+static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd)
 {
        ide_task_t args;
 
        memset(&args, 0, sizeof(ide_task_t));
-       args.tfRegister[IDE_FEATURE_OFFSET]     = SMART_READ_VALUES;
-       args.tfRegister[IDE_NSECTOR_OFFSET]     = 0x01;
-       args.tfRegister[IDE_LCYL_OFFSET]        = SMART_LCYL_PASS;
-       args.tfRegister[IDE_HCYL_OFFSET]        = SMART_HCYL_PASS;
-       args.tfRegister[IDE_COMMAND_OFFSET]     = WIN_SMART;
-       args.command_type                       = IDE_DRIVE_TASK_IN;
-       args.data_phase                         = TASKFILE_IN;
-       args.handler                            = &task_in_intr;
-       (void) smart_enable(drive);
-       return ide_raw_taskfile(drive, &args, buf);
-}
-
-static int get_smart_thresholds(ide_drive_t *drive, u8 *buf)
-{
-       ide_task_t args;
-       memset(&args, 0, sizeof(ide_task_t));
-       args.tfRegister[IDE_FEATURE_OFFSET]     = SMART_READ_THRESHOLDS;
+       args.tfRegister[IDE_FEATURE_OFFSET]     = sub_cmd;
        args.tfRegister[IDE_NSECTOR_OFFSET]     = 0x01;
        args.tfRegister[IDE_LCYL_OFFSET]        = SMART_LCYL_PASS;
        args.tfRegister[IDE_HCYL_OFFSET]        = SMART_HCYL_PASS;
@@ -656,7 +614,7 @@ static int proc_idedisk_read_smart_thresholds
        ide_drive_t     *drive = (ide_drive_t *)data;
        int             len = 0, i = 0;
 
-       if (!get_smart_thresholds(drive, page)) {
+       if (get_smart_data(drive, page, SMART_READ_THRESHOLDS) == 0) {
                unsigned short *val = (unsigned short *) page;
                char *out = ((char *)val) + (SECTOR_WORDS * 4);
                page = out;
@@ -675,7 +633,7 @@ static int proc_idedisk_read_smart_values
        ide_drive_t     *drive = (ide_drive_t *)data;
        int             len = 0, i = 0;
 
-       if (!get_smart_values(drive, page)) {
+       if (get_smart_data(drive, page, SMART_READ_VALUES) == 0) {
                unsigned short *val = (unsigned short *) page;
                char *out = ((char *)val) + (SECTOR_WORDS * 4);
                page = out;
@@ -716,32 +674,6 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
        rq->buffer = rq->cmd;
 }
 
-static int idedisk_issue_flush(struct request_queue *q, struct gendisk *disk,
-                              sector_t *error_sector)
-{
-       ide_drive_t *drive = q->queuedata;
-       struct request *rq;
-       int ret;
-
-       if (!drive->wcache)
-               return 0;
-
-       rq = blk_get_request(q, WRITE, __GFP_WAIT);
-
-       idedisk_prepare_flush(q, rq);
-
-       ret = blk_execute_rq(q, disk, rq, 0);
-
-       /*
-        * if we failed and caller wants error offset, get it
-        */
-       if (ret && error_sector)
-               *error_sector = ide_get_error_location(drive, rq->cmd);
-
-       blk_put_request(rq);
-       return ret;
-}
-
 /*
  * This is tightly woven into the driver->do_special can not touch.
  * DON'T do it again until a total personality rewrite is committed.
@@ -781,7 +713,6 @@ static void update_ordered(ide_drive_t *drive)
        struct hd_driveid *id = drive->id;
        unsigned ordered = QUEUE_ORDERED_NONE;
        prepare_flush_fn *prep_fn = NULL;
-       issue_flush_fn *issue_fn = NULL;
 
        if (drive->wcache) {
                unsigned long long capacity;
@@ -805,13 +736,11 @@ static void update_ordered(ide_drive_t *drive)
                if (barrier) {
                        ordered = QUEUE_ORDERED_DRAIN_FLUSH;
                        prep_fn = idedisk_prepare_flush;
-                       issue_fn = idedisk_issue_flush;
                }
        } else
                ordered = QUEUE_ORDERED_DRAIN;
 
        blk_queue_ordered(drive->queue, ordered, prep_fn);
-       blk_queue_issue_flush_fn(drive->queue, issue_fn);
 }
 
 static int write_cache(ide_drive_t *drive, int arg)
@@ -885,7 +814,7 @@ static int set_lba_addressing(ide_drive_t *drive, int arg)
 
        drive->addressing =  0;
 
-       if (HWIF(drive)->no_lba48)
+       if (drive->hwif->host_flags & IDE_HFLAG_NO_LBA48)
                return 0;
 
        if (!idedisk_supports_lba48(drive->id))
@@ -918,6 +847,7 @@ static inline void idedisk_add_settings(ide_drive_t *drive) { ; }
 
 static void idedisk_setup (ide_drive_t *drive)
 {
+       ide_hwif_t *hwif = drive->hwif;
        struct hd_driveid *id = drive->id;
        unsigned long long capacity;
 
@@ -938,7 +868,6 @@ static void idedisk_setup (ide_drive_t *drive)
        (void)set_lba_addressing(drive, 1);
 
        if (drive->addressing == 1) {
-               ide_hwif_t *hwif = HWIF(drive);
                int max_s = 2048;
 
                if (max_s > hwif->rqsize)
@@ -961,7 +890,7 @@ static void idedisk_setup (ide_drive_t *drive)
                drive->capacity64 = 1ULL << 28;
        }
 
-       if (drive->hwif->no_lba48_dma && drive->addressing) {
+       if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && drive->addressing) {
                if (drive->capacity64 > 1ULL << 28) {
                        printk(KERN_INFO "%s: cannot use LBA48 DMA - PIO mode will"
                                         " be used for accessing sectors > %u\n",
@@ -1006,11 +935,8 @@ static void idedisk_setup (ide_drive_t *drive)
        if (id->buf_size)
                printk (" w/%dKiB Cache", id->buf_size/2);
 
-       printk(", CHS=%d/%d/%d", 
-              drive->bios_cyl, drive->bios_head, drive->bios_sect);
-       if (drive->using_dma)
-               ide_dma_verbose(drive);
-       printk("\n");
+       printk(KERN_CONT ", CHS=%d/%d/%d\n",
+                        drive->bios_cyl, drive->bios_head, drive->bios_sect);
 
        /* write cache enabled? */
        if ((id->csfo & 1) || (id->cfs_enable_1 & (1 << 5)))