]> git.hungrycats.org Git - linux/commitdiff
[PATCH] 2.5.8 IDE 36
authorMartin Dalecki <dalecki@evision-ventures.com>
Tue, 16 Apr 2002 06:28:33 +0000 (23:28 -0700)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Tue, 16 Apr 2002 06:28:33 +0000 (23:28 -0700)
- Consolidate ide_choose_drive() and choose_drive() in to one function.

- Remove sector data byteswpapping support. Byte-swapping the data is supported
   on the file-system level where applicable.  Byte-swapped interfaces are
   supported on a lower level anyway. And finally it was used inconsistently.

- Eliminate taskfile_input_data() and taskfile_output_data(). This allowed us
   to split up ideproc and eliminate the ugly action switch as well as the
   corresponding defines.

- Remove tons of unnecessary typedefs from ide.h

- Prepate the PIO read write code for soon overhaul.

- Misc small bits here and there :-).

14 files changed:
arch/cris/drivers/ide.c
drivers/ide/ide-cd.c
drivers/ide/ide-disk.c
drivers/ide/ide-features.c
drivers/ide/ide-floppy.c
drivers/ide/ide-probe.c
drivers/ide/ide-proc.c
drivers/ide/ide-tape.c
drivers/ide/ide-taskfile.c
drivers/ide/ide.c
drivers/ide/pdc202xx.c
drivers/ide/pdc4030.c
drivers/scsi/ide-scsi.c
include/linux/ide.h

index 79a617d3890b4062cc8c2628464b27e239c950fb..1aa748ef4f38c0ce3a99b3f1846c919479481182 100644 (file)
@@ -272,13 +272,17 @@ init_e100_ide (void)
        printk("ide: ETRAX 100LX built-in ATA DMA controller\n");
 
        /* first initialize the channel interface data */
-       
+
        for(h = 0; h < MAX_HWIFS; h++) {
                struct ata_channel *hwif = &ide_hwifs[h];
+
                hwif->chipset = ide_etrax100;
                hwif->tuneproc = &tune_e100_ide;
                hwif->dmaproc = &e100_dmaproc;
-               hwif->ideproc = &e100_ideproc;
+               hwif->ata_read = e100_ide_input_data;
+               hwif->ata_write = e100_ide_input_data;
+               hwif->atapi_read = e100_atapi_read;
+               hwif->atapi_write = e100_atapi_write;
        }
        /* actually reset and configure the etrax100 ide/ata interface */
 
@@ -375,12 +379,12 @@ static etrax_dma_descr mydescr;
  * so if an odd bytecount is specified, be sure that there's at least one
  * extra byte allocated for the buffer.
  */
-static void 
-e100_atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount)
+static void
+e100_atapi_read(ide_drive_t *drive, void *buffer, unsigned int bytecount)
 {
        ide_ioreg_t data_reg = IDE_DATA_REG;
 
-       D(printk("atapi_input_bytes, dreg 0x%x, buffer 0x%x, count %d\n",
+       D(printk("atapi_read, dreg 0x%x, buffer 0x%x, count %d\n",
                 data_reg, buffer, bytecount));
        
        if(bytecount & 1) {
@@ -454,12 +458,12 @@ e100_atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount
 #endif
 }
 
-static void 
-e100_atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount)
+static void
+e100_atapi_write(ide_drive_t *drive, void *buffer, unsigned int bytecount)
 {
        ide_ioreg_t data_reg = IDE_DATA_REG;
        
-       D(printk("atapi_output_bytes, dreg 0x%x, buffer 0x%x, count %d\n",
+       D(printk("atapi_write, dreg 0x%x, buffer 0x%x, count %d\n",
                 data_reg, buffer, bytecount));
 
        if(bytecount & 1) {
@@ -544,7 +548,7 @@ e100_atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecoun
 static void 
 e100_ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
 {
-       e100_atapi_input_bytes(drive, buffer, wcount << 2);
+       e100_atapi_read(drive, buffer, wcount << 2);
 }
 
 /*
@@ -553,7 +557,7 @@ e100_ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
 static void
 e100_ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount)
 {
-       e100_atapi_output_bytes(drive, buffer, wcount << 2);
+       e100_atapi_write(drive, buffer, wcount << 2);
 }
 
 /*
@@ -570,11 +574,11 @@ e100_ideproc (ide_ide_action_t func, ide_drive_t *drive,
                case ideproc_ide_output_data:
                        e100_ide_input_data(drive, buffer, length);
                        break;
-               case ideproc_atapi_input_bytes:
-                       e100_atapi_input_bytes(drive, buffer, length);
+               case ideproc_atapi_read:
+                       e100_atapi_read(drive, buffer, length);
                        break;
-               case ideproc_atapi_output_bytes:
-                       e100_atapi_output_bytes(drive, buffer, length);
+               case ideproc_atapi_write:
+                       e100_atapi_write(drive, buffer, length);
                        break;
                default:
                        printk("e100_ideproc: unsupported func %d!\n", func);
index 8ba903287a7060f450abd44c12ce5555387e88e0..be3375dbfbf60030991ebba4f2f3e15395fa973c 100644 (file)
@@ -791,7 +791,7 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
        ide_set_handler(drive, handler, timeout, cdrom_timer_expiry);
 
        /* Send the command to the device. */
-       atapi_output_bytes(drive, cmd, CDROM_PACKET_SIZE);
+       atapi_write(drive, cmd, CDROM_PACKET_SIZE);
 
        return ide_started;
 }
@@ -830,7 +830,7 @@ static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector,
        /* Read the data into the buffer. */
        dest = info->buffer + info->nsectors_buffered * SECTOR_SIZE;
        while (sectors_to_buffer > 0) {
-               atapi_input_bytes (drive, dest, SECTOR_SIZE);
+               atapi_read(drive, dest, SECTOR_SIZE);
                --sectors_to_buffer;
                --sectors_to_transfer;
                ++info->nsectors_buffered;
@@ -840,7 +840,7 @@ static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector,
        /* Throw away any remaining data. */
        while (sectors_to_transfer > 0) {
                char dum[SECTOR_SIZE];
-               atapi_input_bytes (drive, dum, sizeof (dum));
+               atapi_read(drive, dum, sizeof (dum));
                --sectors_to_transfer;
        }
 }
@@ -866,7 +866,7 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason)
                   and quit this request. */
                while (len > 0) {
                        int dum = 0;
-                       atapi_output_bytes (drive, &dum, sizeof (dum));
+                       atapi_write(drive, &dum, sizeof (dum));
                        len -= sizeof (dum);
                }
        } else  if (ireason == 1) {
@@ -963,7 +963,7 @@ static ide_startstop_t cdrom_read_intr(ide_drive_t *drive)
        while (nskip > 0) {
                /* We need to throw away a sector. */
                char dum[SECTOR_SIZE];
-               atapi_input_bytes (drive, dum, sizeof (dum));
+               atapi_read(drive, dum, SECTOR_SIZE);
 
                --rq->current_nr_sectors;
                --nskip;
@@ -994,7 +994,7 @@ static ide_startstop_t cdrom_read_intr(ide_drive_t *drive)
                        /* Read this_transfer sectors
                           into the current buffer. */
                        while (this_transfer > 0) {
-                               atapi_input_bytes(drive, rq->buffer, SECTOR_SIZE);
+                               atapi_read(drive, rq->buffer, SECTOR_SIZE);
                                rq->buffer += SECTOR_SIZE;
                                --rq->nr_sectors;
                                --rq->current_nr_sectors;
@@ -1290,13 +1290,14 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
        /* The drive wants to be written to. */
        if ((ireason & 3) == 0) {
                /* Transfer the data. */
-               atapi_output_bytes (drive, pc->buffer, thislen);
+               atapi_write(drive, pc->buffer, thislen);
 
                /* If we haven't moved enough data to satisfy the drive,
                   add some padding. */
                while (len > thislen) {
                        int dum = 0;
-                       atapi_output_bytes (drive, &dum, sizeof (dum));
+
+                       atapi_write(drive, &dum, sizeof (dum));
                        len -= sizeof (dum);
                }
 
@@ -1307,15 +1308,14 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
 
        /* Same drill for reading. */
        else if ((ireason & 3) == 2) {
-
                /* Transfer the data. */
-               atapi_input_bytes (drive, pc->buffer, thislen);
+               atapi_read(drive, pc->buffer, thislen);
 
                /* If we haven't moved enough data to satisfy the drive,
                   add some padding. */
                while (len > thislen) {
                        int dum = 0;
-                       atapi_input_bytes (drive, &dum, sizeof (dum));
+                       atapi_read(drive, &dum, sizeof (dum));
                        len -= sizeof (dum);
                }
 
@@ -1458,7 +1458,7 @@ static inline int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ire
                   and quit this request. */
                while (len > 0) {
                        int dum = 0;
-                       atapi_output_bytes(drive, &dum, sizeof(dum));
+                       atapi_write(drive, &dum, sizeof(dum));
                        len -= sizeof(dum);
                }
        } else {
@@ -1549,7 +1549,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
                this_transfer = MIN(sectors_to_transfer,rq->current_nr_sectors);
 
                while (this_transfer > 0) {
-                       atapi_output_bytes(drive, rq->buffer, SECTOR_SIZE);
+                       atapi_write(drive, rq->buffer, SECTOR_SIZE);
                        rq->buffer += SECTOR_SIZE;
                        --rq->nr_sectors;
                        --rq->current_nr_sectors;
index d6d0ef2853af5b932245efbb56533eb759143f27..26c07c5baf9f819bfff4c4c7c6f78c072a76c38c 100644 (file)
@@ -1051,7 +1051,6 @@ static void idedisk_add_settings(ide_drive_t *drive)
        ide_add_setting(drive,  "bios_head",            SETTING_RW,                                     -1,                     -1,                     TYPE_BYTE,      0,      255,                            1,      1,      &drive->bios_head,              NULL);
        ide_add_setting(drive,  "bios_sect",            SETTING_RW,                                     -1,                     -1,                     TYPE_BYTE,      0,      63,                             1,      1,      &drive->bios_sect,              NULL);
        ide_add_setting(drive,  "address",              SETTING_RW,                                     HDIO_GET_ADDRESS,       HDIO_SET_ADDRESS,       TYPE_INTA,      0,      2,                              1,      1,      &drive->addressing,     set_lba_addressing);
-       ide_add_setting(drive,  "bswap",                SETTING_READ,                                   -1,                     -1,                     TYPE_BYTE,      0,      1,                              1,      1,      &drive->bswap,                  NULL);
        ide_add_setting(drive,  "multcount",            id ? SETTING_RW : SETTING_READ,                 HDIO_GET_MULTCOUNT,     HDIO_SET_MULTCOUNT,     TYPE_BYTE,      0,      id ? id->max_multsect : 0,      1,      1,      &drive->mult_count,             set_multcount);
        ide_add_setting(drive,  "nowerr",               SETTING_RW,                                     HDIO_GET_NOWERR,        HDIO_SET_NOWERR,        TYPE_BYTE,      0,      1,                              1,      1,      &drive->nowerr,                 set_nowerr);
        ide_add_setting(drive,  "lun",                  SETTING_RW,                                     -1,                     -1,                     TYPE_INT,       0,      7,                              1,      1,      &drive->lun,                    NULL);
@@ -1198,11 +1197,11 @@ static void idedisk_setup(ide_drive_t *drive)
        if ((capacity >= (drive->bios_cyl * drive->bios_sect * drive->bios_head)) &&
            (!drive->forced_geom) && drive->bios_sect && drive->bios_head)
                drive->bios_cyl = (capacity / drive->bios_sect) / drive->bios_head;
-       printk (KERN_INFO "%s: %ld sectors", drive->name, capacity);
+       printk(KERN_INFO "%s: %ld sectors", drive->name, capacity);
 
        /* Give size in megabytes (MB), not mebibytes (MiB). */
        /* We compute the exact rounded value, avoiding overflow. */
-       printk (" (%ld MB)", (capacity - capacity/625 + 974)/1950);
+       printk(" (%ld MB)", (capacity - capacity/625 + 974)/1950);
 
        /* Only print cache size when it was specified */
        if (id->buf_size)
@@ -1213,7 +1212,7 @@ static void idedisk_setup(ide_drive_t *drive)
 #ifdef CONFIG_BLK_DEV_IDEDMA
        if (drive->using_dma)
                (void) drive->channel->dmaproc(ide_dma_verbose, drive);
-#endif /* CONFIG_BLK_DEV_IDEDMA */
+#endif
        printk("\n");
 
        drive->mult_count = 0;
@@ -1223,15 +1222,17 @@ static void idedisk_setup(ide_drive_t *drive)
                id->multsect_valid = id->multsect ? 1 : 0;
                drive->mult_req = id->multsect_valid ? id->max_multsect : INITIAL_MULT_COUNT;
                drive->special.b.set_multmode = drive->mult_req ? 1 : 0;
-#else  /* original, pre IDE-NFG, per request of AC */
+#else
+               /* original, pre IDE-NFG, per request of AC */
                drive->mult_req = INITIAL_MULT_COUNT;
                if (drive->mult_req > id->max_multsect)
                        drive->mult_req = id->max_multsect;
                if (drive->mult_req || ((id->multsect_valid & 1) && id->multsect))
                        drive->special.b.set_multmode = 1;
-#endif /* CONFIG_IDEDISK_MULTI_MODE */
+#endif
        }
        drive->no_io_32bit = id->dword_io ? 1 : 0;
+
        if (drive->id->cfs_enable_2 & 0x3000)
                write_cache(drive, (id->cfs_enable_2 & 0x3000));
        probe_lba_addressing(drive, 1);
index a0543dc81162d681a9903be6d148c3d75429f5b2..fdede6a2d27e396a5d68059e39749d8ffc932d02 100644 (file)
@@ -130,8 +130,8 @@ int ide_driveid_update (ide_drive_t *drive)
                __restore_flags(flags); /* local CPU only */
                return 0;
        }
-       ata_input_data(drive, id, SECTOR_WORDS);
-       (void) GET_STAT();      /* clear drive IRQ */
+       ata_read(drive, id, SECTOR_WORDS);
+       GET_STAT();             /* clear drive IRQ */
        ide__sti();             /* local CPU only */
        __restore_flags(flags); /* local CPU only */
        ide_fix_driveid(id);
@@ -285,7 +285,7 @@ int ide_config_drive_speed (ide_drive_t *drive, byte speed)
        enable_irq(hwif->irq);
 
        if (error) {
-               (void) ide_dump_status(drive, "set_drive_speed_status", stat);
+               ide_dump_status(drive, "set_drive_speed_status", stat);
                return error;
        }
 
index e988e17cee6935be0c77722a3ebb6bc1fd158f32..875885b24b0c1bbe68ef6de46d54a6e530fb467d 100644 (file)
@@ -717,7 +717,7 @@ static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, uns
                        return;
                }
                count = IDEFLOPPY_MIN (bio->bi_size - pc->b_count, bcount);
-               atapi_input_bytes (drive, bio_data(bio) + pc->b_count, count);
+               atapi_read(drive, bio_data(bio) + pc->b_count, count);
                bcount -= count; pc->b_count += count;
        }
 }
@@ -744,7 +744,7 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un
                        return;
                }
                count = IDEFLOPPY_MIN (pc->b_count, bcount);
-               atapi_output_bytes (drive, pc->b_data, count);
+               atapi_write(drive, pc->b_data, count);
                bcount -= count; pc->b_data += count; pc->b_count -= count;
        }
 }
@@ -979,12 +979,12 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
        }
        if (test_bit (PC_WRITING, &pc->flags)) {
                if (pc->buffer != NULL)
-                       atapi_output_bytes (drive,pc->current_position,bcount.all);     /* Write the current buffer */
+                       atapi_write(drive,pc->current_position,bcount.all);     /* Write the current buffer */
                else
                        idefloppy_output_buffers (drive, pc, bcount.all);
        } else {
                if (pc->buffer != NULL)
-                       atapi_input_bytes (drive,pc->current_position,bcount.all);      /* Read the current buffer */
+                       atapi_read(drive,pc->current_position,bcount.all);      /* Read the current buffer */
                else
                        idefloppy_input_buffers (drive, pc, bcount.all);
        }
@@ -1020,7 +1020,7 @@ static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive)
 
        BUG_ON(HWGROUP(drive)->handler);
        ide_set_handler (drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL);  /* Set the interrupt routine */
-       atapi_output_bytes (drive, floppy->pc->c, 12); /* Send the actual packet */
+       atapi_write(drive, floppy->pc->c, 12); /* Send the actual packet */
 
        return ide_started;
 }
@@ -1042,7 +1042,7 @@ static int idefloppy_transfer_pc2 (ide_drive_t *drive)
 {
        idefloppy_floppy_t *floppy = drive->driver_data;
 
-       atapi_output_bytes (drive, floppy->pc->c, 12); /* Send the actual packet */
+       atapi_write(drive, floppy->pc->c, 12); /* Send the actual packet */
        return IDEFLOPPY_WAIT_CMD;              /* Timeout for the packet command */
 }
 
index 20b37da028646f156580e1a952dc60ee7032497e..3bfe703e69efd89ceb82f71b78cd3dfbbbdb9047 100644 (file)
@@ -57,9 +57,18 @@ static inline void do_identify (ide_drive_t *drive, byte cmd)
                printk(KERN_WARNING "(ide-probe::do_identify) Out of memory.\n");
                goto err_kmalloc;
        }
-       /* read 512 bytes of id info */
+
+       /* Read 512 bytes of id info.
+        *
+        * Please note that it is well known that some *very* old drives are
+        * able to provide only 256 of them, since this was the amount read by
+        * DOS.
+        *
+        * However let's try to get away with this...
+        */
+
 #if 1
-       ata_input_data(drive, id, SECTOR_WORDS);                /* read 512 bytes of id info */
+       ata_read(drive, id, SECTOR_WORDS);
 #else
         {
                 unsigned long   *ptr = (unsigned long *)id ;
@@ -580,10 +589,10 @@ static void probe_hwif(struct ata_channel *hwif)
        __restore_flags(flags); /* local CPU only */
        for (unit = 0; unit < MAX_DRIVES; ++unit) {
                ide_drive_t *drive = &hwif->drives[unit];
-               if (drive->present) {
-                       ide_tuneproc_t *tuneproc = drive->channel->tuneproc;
-                       if (tuneproc != NULL && drive->autotune == 1)
-                               tuneproc(drive, 255);   /* auto-tune PIO mode */
+
+               if (drive->present && (drive->autotune == 1)) {
+                       if (drive->channel->tuneproc != NULL)
+                               drive->channel->tuneproc(drive, 255);   /* auto-tune PIO mode */
                }
        }
 }
index 3509b40371408ae05df982bc96c0ed30901c581d..e82e9415af39866749b62863c28e74eb8d9f1c89 100644 (file)
@@ -422,7 +422,6 @@ void ide_remove_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p)
 static void create_proc_ide_drives(struct ata_channel *hwif)
 {
        int     d;
-       struct proc_dir_entry *ent;
        struct proc_dir_entry *parent = hwif->proc;
        char name[64];
 
index 804c0f9dc19f6afe40e3992bdf80380bed42e6ed..4c4e1a1641c6e7b5c92676430e4b2f6caf743691 100644 (file)
@@ -1503,9 +1503,9 @@ static void idetape_input_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsigne
                        idetape_discard_data (drive, bcount);
                        return;
                }
-#endif /* IDETAPE_DEBUG_BUGS */
+#endif
                count = min(bio->bi_size - pc->b_count, bcount);
-               atapi_input_bytes (drive, bio_data(bio) + pc->b_count, count);
+               atapi_read(drive, bio_data(bio) + pc->b_count, count);
                bcount -= count;
                pc->b_count += bio->bi_size;
                if (pc->b_count == bio->bi_size) {
@@ -1530,7 +1530,7 @@ static void idetape_output_buffers (ide_drive_t *drive, idetape_pc_t *pc, unsign
                }
 #endif /* IDETAPE_DEBUG_BUGS */
                count = min(pc->b_count, bcount);
-               atapi_output_bytes (drive, bio_data(bio), count);
+               atapi_write(drive, bio_data(bio), count);
                bcount -= count;
                pc->b_data += count;
                pc->b_count -= count;
@@ -2169,12 +2169,12 @@ static ide_startstop_t idetape_pc_intr (ide_drive_t *drive)
                if (pc->bio != NULL)
                        idetape_output_buffers (drive, pc, bcount.all);
                else
-                       atapi_output_bytes (drive,pc->current_position,bcount.all);     /* Write the current buffer */
+                       atapi_write(drive,pc->current_position,bcount.all);     /* Write the current buffer */
        } else {
                if (pc->bio != NULL)
                        idetape_input_buffers (drive, pc, bcount.all);
                else
-                       atapi_input_bytes (drive,pc->current_position,bcount.all);      /* Read the current buffer */
+                       atapi_read(drive,pc->current_position,bcount.all);      /* Read the current buffer */
        }
        pc->actually_transferred += bcount.all;                                 /* Update the current position */
        pc->current_position+=bcount.all;
@@ -2259,7 +2259,7 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive)
        tape->cmd_start_time = jiffies;
        BUG_ON(HWGROUP(drive)->handler);
        ide_set_handler(drive, &idetape_pc_intr, IDETAPE_WAIT_CMD, NULL);       /* Set the interrupt routine */
-       atapi_output_bytes (drive,pc->c,12);                    /* Send the actual packet */
+       atapi_write(drive,pc->c,12);    /* Send the actual packet */
        return ide_started;
 }
 
index e86e4487fa3552e6d0f7459971390d8e37b03798..7a2d2c87e7681f326e13d1e8a4a4627545a7ff9d 100644 (file)
@@ -1,4 +1,5 @@
 /*
+ *  Copyright (C) 2002         Marcin Dalecki <martin@dalecki.de>
  *  Copyright (C) 2000         Michael Cornwell <cornwell@acm.org>
  *  Copyright (C) 2000         Andre Hedrick <andre@linux-ide.org>
  *
@@ -58,15 +59,9 @@ static inline void ide_unmap_rq(struct request *rq, char *to,
                bio_kunmap_irq(to, flags);
 }
 
-static void bswap_data (void *buffer, int wcount)
-{
-       u16 *p = buffer;
-
-       while (wcount--) {
-               *p = *p << 8 | *p >> 8; p++;
-               *p = *p << 8 | *p >> 8; p++;
-       }
-}
+/*
+ * Data transfer functions for polled IO.
+ */
 
 #if SUPPORT_VLB_SYNC
 /*
@@ -76,30 +71,88 @@ static void bswap_data (void *buffer, int wcount)
  * of the sector count register location, with interrupts disabled
  * to ensure that the reads all happen together.
  */
-static inline void task_vlb_sync(ide_drive_t *drive)
+static void ata_read_vlb(struct ata_device *drive, void *buffer, unsigned int wcount)
 {
-       ide_ioreg_t port = IDE_NSECTOR_REG;
+       unsigned long flags;
 
-       IN_BYTE(port);
-       IN_BYTE(port);
-       IN_BYTE(port);
+       __save_flags(flags);    /* local CPU only */
+       __cli();                /* local CPU only */
+       IN_BYTE(IDE_NSECTOR_REG);
+       IN_BYTE(IDE_NSECTOR_REG);
+       IN_BYTE(IDE_NSECTOR_REG);
+       insl(IDE_DATA_REG, buffer, wcount);
+       __restore_flags(flags); /* local CPU only */
+}
+
+static void ata_write_vlb(struct ata_device *drive, void *buffer, unsigned int wcount)
+{
+       unsigned long flags;
+
+       __save_flags(flags);    /* local CPU only */
+       __cli();                /* local CPU only */
+       IN_BYTE(IDE_NSECTOR_REG);
+       IN_BYTE(IDE_NSECTOR_REG);
+       IN_BYTE(IDE_NSECTOR_REG);
+       outsl(IDE_DATA_REG, buffer, wcount);
+       __restore_flags(flags); /* local CPU only */
 }
 #endif
 
+static void ata_read_32(struct ata_device *drive, void *buffer, unsigned int wcount)
+{
+       insl(IDE_DATA_REG, buffer, wcount);
+}
+
+static void ata_write_32(struct ata_device *drive, void *buffer, unsigned int wcount)
+{
+       outsl(IDE_DATA_REG, buffer, wcount);
+}
+
+#if SUPPORT_SLOW_DATA_PORTS
+static void ata_read_slow(struct ata_device *drive, void *buffer, unsigned int wcount)
+{
+       unsigned short *ptr = (unsigned short *) buffer;
+
+       while (wcount--) {
+               *ptr++ = inw_p(IDE_DATA_REG);
+               *ptr++ = inw_p(IDE_DATA_REG);
+       }
+}
+
+static void ata_write_slow(struct ata_device *drive, void *buffer, unsigned int wcount)
+{
+       unsigned short *ptr = (unsigned short *) buffer;
+
+       while (wcount--) {
+               outw_p(*ptr++, IDE_DATA_REG);
+               outw_p(*ptr++, IDE_DATA_REG);
+       }
+}
+#endif
+
+static void ata_read_16(ide_drive_t *drive, void *buffer, unsigned int wcount)
+{
+       insw(IDE_DATA_REG, buffer, wcount<<1);
+}
+
+static void ata_write_16(ide_drive_t *drive, void *buffer, unsigned int wcount)
+{
+       outsw(IDE_DATA_REG, buffer, wcount<<1);
+}
+
 /*
- * This is used for most PIO data transfers *from* the IDE interface
+ * This is used for most PIO data transfers *from* the device.
  */
-void ata_input_data(ide_drive_t *drive, void *buffer, unsigned int wcount)
+void ata_read(ide_drive_t *drive, void *buffer, unsigned int wcount)
 {
-       byte io_32bit;
+       int io_32bit;
 
        /*
-        * first check if this controller has defined a special function
-        * for handling polled ide transfers
+        * First check if this controller has defined a special function
+        * for handling polled ide transfers.
         */
-
-       if (drive->channel->ideproc) {
-               drive->channel->ideproc(ideproc_ide_input_data, drive, buffer, wcount);
+       if (drive->channel->ata_read) {
+               drive->channel->ata_read(drive, buffer, wcount);
                return;
        }
 
@@ -107,39 +160,30 @@ void ata_input_data(ide_drive_t *drive, void *buffer, unsigned int wcount)
 
        if (io_32bit) {
 #if SUPPORT_VLB_SYNC
-               if (io_32bit & 2) {
-                       unsigned long flags;
-                       __save_flags(flags);    /* local CPU only */
-                       __cli();                /* local CPU only */
-                       task_vlb_sync(drive);
-                       insl(IDE_DATA_REG, buffer, wcount);
-                       __restore_flags(flags); /* local CPU only */
-               } else
+               if (io_32bit & 2)
+                       ata_read_vlb(drive, buffer, wcount);
+               else
 #endif
-                       insl(IDE_DATA_REG, buffer, wcount);
+                       ata_read_32(drive, buffer, wcount);
        } else {
 #if SUPPORT_SLOW_DATA_PORTS
-               if (drive->slow) {
-                       unsigned short *ptr = (unsigned short *) buffer;
-                       while (wcount--) {
-                               *ptr++ = inw_p(IDE_DATA_REG);
-                               *ptr++ = inw_p(IDE_DATA_REG);
-                       }
-               } else
+               if (drive->slow)
+                       ata_read_slow(drive, buffer, wcount);
+               else
 #endif
-                       insw(IDE_DATA_REG, buffer, wcount<<1);
+                       ata_read_16(drive, buffer, wcount);
        }
 }
 
 /*
- * This is used for most PIO data transfers *to* the IDE interface
+ * This is used for most PIO data transfers *to* the device interface.
  */
-void ata_output_data(ide_drive_t *drive, void *buffer, unsigned int wcount)
+void ata_write(ide_drive_t *drive, void *buffer, unsigned int wcount)
 {
-       byte io_32bit;
+       int io_32bit;
 
-       if (drive->channel->ideproc) {
-               drive->channel->ideproc(ideproc_ide_output_data, drive, buffer, wcount);
+       if (drive->channel->ata_write) {
+               drive->channel->ata_write(drive, buffer, wcount);
                return;
        }
 
@@ -147,27 +191,18 @@ void ata_output_data(ide_drive_t *drive, void *buffer, unsigned int wcount)
 
        if (io_32bit) {
 #if SUPPORT_VLB_SYNC
-               if (io_32bit & 2) {
-                       unsigned long flags;
-                       __save_flags(flags);    /* local CPU only */
-                       __cli();                /* local CPU only */
-                       task_vlb_sync(drive);
-                       outsl(IDE_DATA_REG, buffer, wcount);
-                       __restore_flags(flags); /* local CPU only */
-               } else
+               if (io_32bit & 2)
+                       ata_write_vlb(drive, buffer, wcount);
+               else
 #endif
-                       outsl(IDE_DATA_REG, buffer, wcount);
+                       ata_write_32(drive, buffer, wcount);
        } else {
 #if SUPPORT_SLOW_DATA_PORTS
-               if (drive->slow) {
-                       unsigned short *ptr = (unsigned short *) buffer;
-                       while (wcount--) {
-                               outw_p(*ptr++, IDE_DATA_REG);
-                               outw_p(*ptr++, IDE_DATA_REG);
-                       }
-               } else
+               if (drive->slow)
+                       ata_write_slow(drive, buffer, wcount);
+               else
 #endif
-                       outsw(IDE_DATA_REG, buffer, wcount<<1);
+                       ata_write_16(drive, buffer, wcount<<1);
        }
 }
 
@@ -178,10 +213,10 @@ void ata_output_data(ide_drive_t *drive, void *buffer, unsigned int wcount)
  * so if an odd bytecount is specified, be sure that there's at least one
  * extra byte allocated for the buffer.
  */
-void atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount)
+void atapi_read(ide_drive_t *drive, void *buffer, unsigned int bytecount)
 {
-       if (drive->channel->ideproc) {
-               drive->channel->ideproc(ideproc_atapi_input_bytes, drive, buffer, bytecount);
+       if (drive->channel->atapi_read) {
+               drive->channel->atapi_read(drive, buffer, bytecount);
                return;
        }
 
@@ -193,15 +228,15 @@ void atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount
                return;
        }
 #endif
-       ata_input_data (drive, buffer, bytecount / 4);
+       ata_read(drive, buffer, bytecount / 4);
        if ((bytecount & 0x03) >= 2)
-               insw (IDE_DATA_REG, ((byte *)buffer) + (bytecount & ~0x03), 1);
+               insw(IDE_DATA_REG, ((byte *)buffer) + (bytecount & ~0x03), 1);
 }
 
-void atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount)
+void atapi_write(ide_drive_t *drive, void *buffer, unsigned int bytecount)
 {
-       if (drive->channel->ideproc) {
-               drive->channel->ideproc(ideproc_atapi_output_bytes, drive, buffer, bytecount);
+       if (drive->channel->atapi_write) {
+               drive->channel->atapi_write(drive, buffer, bytecount);
                return;
        }
 
@@ -213,29 +248,11 @@ void atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecoun
                return;
        }
 #endif
-       ata_output_data (drive, buffer, bytecount / 4);
+       ata_write(drive, buffer, bytecount / 4);
        if ((bytecount & 0x03) >= 2)
                outsw(IDE_DATA_REG, ((byte *)buffer) + (bytecount & ~0x03), 1);
 }
 
-void taskfile_input_data(ide_drive_t *drive, void *buffer, unsigned int wcount)
-{
-       ata_input_data(drive, buffer, wcount);
-       if (drive->bswap)
-               bswap_data(buffer, wcount);
-}
-
-void taskfile_output_data(ide_drive_t *drive, void *buffer, unsigned int wcount)
-{
-       if (drive->bswap) {
-               bswap_data(buffer, wcount);
-               ata_output_data(drive, buffer, wcount);
-               bswap_data(buffer, wcount);
-       } else {
-               ata_output_data(drive, buffer, wcount);
-       }
-}
-
 /*
  * Needed for PCI irq sharing
  */
@@ -311,8 +328,6 @@ static ide_startstop_t pre_task_mulout_intr(ide_drive_t *drive, struct request *
 static ide_startstop_t task_mulout_intr (ide_drive_t *drive)
 {
        byte stat               = GET_STAT();
-       /* FIXME: this should go possible as well */
-       byte io_32bit           = drive->io_32bit;
        struct request *rq      = &HWGROUP(drive)->wrq;
        ide_hwgroup_t *hwgroup  = HWGROUP(drive);
        int mcount              = drive->mult_count;
@@ -378,14 +393,13 @@ static ide_startstop_t task_mulout_intr (ide_drive_t *drive)
                }
 
                /*
-                * Ok, we're all setup for the interrupt
-                * re-entering us on the last transfer.
+                * Ok, we're all setup for the interrupt re-entering us on the
+                * last transfer.
                 */
-               taskfile_output_data(drive, buffer, nsect * SECTOR_WORDS);
+               ata_write(drive, buffer, nsect * SECTOR_WORDS);
                bio_kunmap_irq(buffer, &flags);
        } while (mcount);
 
-       drive->io_32bit = io_32bit;
        rq->errors = 0;
        if (hwgroup->handler == NULL)
                ide_set_handler(drive, task_mulout_intr, WAIT_CMD, NULL);
@@ -542,7 +556,6 @@ ide_startstop_t task_no_data_intr (ide_drive_t *drive)
 static ide_startstop_t task_in_intr (ide_drive_t *drive)
 {
        byte stat               = GET_STAT();
-       byte io_32bit           = drive->io_32bit;
        struct request *rq      = HWGROUP(drive)->rq;
        char *pBuf              = NULL;
        unsigned long flags;
@@ -561,10 +574,8 @@ static ide_startstop_t task_in_intr (ide_drive_t *drive)
        pBuf = ide_map_rq(rq, &flags);
        DTF("Read: %p, rq->current_nr_sectors: %d\n", pBuf, (int) rq->current_nr_sectors);
 
-       drive->io_32bit = 0;
-       taskfile_input_data(drive, pBuf, SECTOR_WORDS);
+       ata_read(drive, pBuf, SECTOR_WORDS);
        ide_unmap_rq(rq, pBuf, &flags);
-       drive->io_32bit = io_32bit;
 
        if (--rq->current_nr_sectors <= 0) {
                /* (hs): swapped next 2 lines */
@@ -597,7 +608,7 @@ static ide_startstop_t pre_task_out_intr(ide_drive_t *drive, struct request *rq)
                unsigned long flags;
                char *buf = ide_map_rq(rq, &flags);
                /* For Write_sectors we need to stuff the first sector */
-               taskfile_output_data(drive, buf, SECTOR_WORDS);
+               ata_write(drive, buf, SECTOR_WORDS);
                rq->current_nr_sectors--;
                ide_unmap_rq(rq, buf, &flags);
        } else {
@@ -613,8 +624,6 @@ static ide_startstop_t pre_task_out_intr(ide_drive_t *drive, struct request *rq)
 static ide_startstop_t task_out_intr(ide_drive_t *drive)
 {
        byte stat               = GET_STAT();
-       /* FIXME: this should go possible as well */
-       byte io_32bit           = drive->io_32bit;
        struct request *rq      = HWGROUP(drive)->rq;
        char *pBuf              = NULL;
        unsigned long flags;
@@ -631,9 +640,8 @@ static ide_startstop_t task_out_intr(ide_drive_t *drive)
                pBuf = ide_map_rq(rq, &flags);
                DTF("write: %p, rq->current_nr_sectors: %d\n", pBuf, (int) rq->current_nr_sectors);
 
-               taskfile_output_data(drive, pBuf, SECTOR_WORDS);
+               ata_write(drive, pBuf, SECTOR_WORDS);
                ide_unmap_rq(rq, pBuf, &flags);
-               drive->io_32bit = io_32bit;
                rq->errors = 0;
                rq->current_nr_sectors--;
        }
@@ -649,8 +657,6 @@ static ide_startstop_t task_mulin_intr(ide_drive_t *drive)
 {
        unsigned int            msect, nsect;
        byte stat               = GET_STAT();
-       /* FIXME: this should go possible as well */
-       byte io_32bit           = drive->io_32bit;
        struct request *rq      = HWGROUP(drive)->rq;
        char *pBuf              = NULL;
        unsigned long flags;
@@ -676,10 +682,8 @@ static ide_startstop_t task_mulin_intr(ide_drive_t *drive)
 
                DTF("Multiread: %p, nsect: %d , rq->current_nr_sectors: %d\n",
                        pBuf, nsect, rq->current_nr_sectors);
-               drive->io_32bit = 0;
-               taskfile_input_data(drive, pBuf, nsect * SECTOR_WORDS);
+               ata_read(drive, pBuf, nsect * SECTOR_WORDS);
                ide_unmap_rq(rq, pBuf, &flags);
-               drive->io_32bit = io_32bit;
                rq->errors = 0;
                rq->current_nr_sectors -= nsect;
                msect -= nsect;
@@ -1025,12 +1029,11 @@ int ide_task_ioctl(ide_drive_t *drive, unsigned long arg)
 }
 
 EXPORT_SYMBOL(drive_is_ready);
-EXPORT_SYMBOL(ata_input_data);
-EXPORT_SYMBOL(ata_output_data);
-EXPORT_SYMBOL(atapi_input_bytes);
-EXPORT_SYMBOL(atapi_output_bytes);
-EXPORT_SYMBOL(taskfile_input_data);
-EXPORT_SYMBOL(taskfile_output_data);
+
+EXPORT_SYMBOL(ata_read);
+EXPORT_SYMBOL(ata_write);
+EXPORT_SYMBOL(atapi_read);
+EXPORT_SYMBOL(atapi_write);
 
 EXPORT_SYMBOL(ata_taskfile);
 EXPORT_SYMBOL(recal_intr);
index 001fef7c93c934fc6994fc32525e9a0bb240ed2b..e2044296f97f8c6eaca649cc011d2d6d4b94f0bc 100644 (file)
@@ -383,7 +383,7 @@ void ide_end_queued_request(ide_drive_t *drive, int uptodate, struct request *rq
                spin_lock_irqsave(&ide_lock, flags);
 
                if ((jiffies - ar->ar_time > ATA_AR_MAX_TURNAROUND) && drive->queue_depth > 1) {
-                       printk("%s: exceeded max command turn-around time (%d seconds)\n", drive->name, ATA_AR_MAX_TURNAROUND / HZ);
+                       printk(KERN_INFO "%s: exceeded max command turn-around time (%d seconds)\n", drive->name, ATA_AR_MAX_TURNAROUND / HZ);
                        drive->queue_depth >>= 1;
                }
 
@@ -474,7 +474,7 @@ void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler,
        spin_unlock_irqrestore(&ide_lock, flags);
 }
 
-static void ata_pre_reset (ide_drive_t *drive)
+static void ata_pre_reset(ide_drive_t *drive)
 {
        if (ata_ops(drive) && ata_ops(drive)->pre_reset)
                ata_ops(drive)->pre_reset(drive);
@@ -528,10 +528,9 @@ static ide_startstop_t ata_special (ide_drive_t *drive)
        printk("%s: ata_special: 0x%02x\n", drive->name, s->all);
 #endif
        if (s->b.set_tune) {
-               ide_tuneproc_t *tuneproc = drive->channel->tuneproc;
                s->b.set_tune = 0;
-               if (tuneproc != NULL)
-                       tuneproc(drive, drive->tune_req);
+               if (drive->channel->tuneproc != NULL)
+                       drive->channel->tuneproc(drive, drive->tune_req);
        } else if (drive->driver != NULL) {
                if (ata_ops(drive)->special)
                        return ata_ops(drive)->special(drive);
@@ -899,23 +898,24 @@ byte ide_dump_status (ide_drive_t *drive, const char *msg, byte stat)
 }
 
 /*
- * try_to_flush_leftover_data() is invoked in response to a drive
- * unexpectedly having its DRQ_STAT bit set.  As an alternative to
- * resetting the drive, this routine tries to clear the condition
- * by read a sector's worth of data from the drive.  Of course,
+ * This gets invoked in response to a drive unexpectedly having its DRQ_STAT
+ * bit set.  As an alternative to resetting the drive, it tries to clear the
+ * condition by reading a sector's worth of data from the drive.  Of course,
  * this may not help if the drive is *waiting* for data from *us*.
  */
 static void try_to_flush_leftover_data (ide_drive_t *drive)
 {
-       int i = (drive->mult_count ? drive->mult_count : 1) * SECTOR_WORDS;
+       int i = (drive->mult_count ? drive->mult_count : 1);
 
        if (drive->type != ATA_DISK)
                return;
+
        while (i > 0) {
-               u32 buffer[16];
-               unsigned int wcount = (i > 16) ? 16 : i;
-               i -= wcount;
-               ata_input_data (drive, buffer, wcount);
+               u32 buffer[SECTOR_WORDS];
+               unsigned int count = (i > 1) ? 1 : i;
+
+               ata_read(drive, buffer, count * SECTOR_WORDS);
+               i -= count;
        }
 }
 
@@ -1002,16 +1002,18 @@ void ide_cmd(ide_drive_t *drive, byte cmd, byte nsect, ide_handler_t *handler)
 static ide_startstop_t drive_cmd_intr (ide_drive_t *drive)
 {
        struct request *rq = HWGROUP(drive)->rq;
-       byte *args = (byte *) rq->buffer;
-       byte stat = GET_STAT();
+       u8 *args = rq->buffer;
+       u8 stat = GET_STAT();
        int retries = 10;
 
        ide__sti();     /* local CPU only */
        if ((stat & DRQ_STAT) && args && args[3]) {
-               byte io_32bit = drive->io_32bit;
+               int io_32bit = drive->io_32bit;
+
                drive->io_32bit = 0;
-               ata_input_data(drive, &args[4], args[3] * SECTOR_WORDS);
+               ata_read(drive, &args[4], args[3] * SECTOR_WORDS);
                drive->io_32bit = io_32bit;
+
                while (((stat = GET_STAT()) & BUSY_STAT) && retries--)
                        udelay(100);
        }
@@ -1019,6 +1021,7 @@ static ide_startstop_t drive_cmd_intr (ide_drive_t *drive)
        if (!OK_STAT(stat, READY_STAT, BAD_STAT))
                return ide_error(drive, "drive_cmd", stat); /* calls ide_end_drive_cmd */
        ide_end_drive_cmd (drive, stat, GET_ERR());
+
        return ide_stopped;
 }
 
@@ -1266,31 +1269,26 @@ void ide_stall_queue(ide_drive_t *drive, unsigned long timeout)
 /*
  * Select the next drive which will be serviced.
  */
-static inline ide_drive_t *choose_drive(ide_hwgroup_t *hwgroup)
+static ide_drive_t *choose_drive(ide_hwgroup_t *hwgroup)
 {
-       ide_drive_t *drive, *best;
+       ide_drive_t *tmp;
+       ide_drive_t *drive = NULL;
+       unsigned long sleep = 0;
 
-       best = NULL;
-       drive = hwgroup->drive;
+       tmp = hwgroup->drive;
        do {
-               if (!list_empty(&drive->queue.queue_head)
-               && (!drive->PADAM_sleep || time_after_eq(drive->PADAM_sleep, jiffies))) {
-                       if (!best
-                        || (drive->PADAM_sleep && (!best->PADAM_sleep || time_after(best->PADAM_sleep, drive->PADAM_sleep)))
-                        || (!best->PADAM_sleep && time_after(best->PADAM_service_start + 2 * best->PADAM_service_time, drive->PADAM_service_start + 2 * drive->PADAM_service_time)))
+               if (!list_empty(&tmp->queue.queue_head)
+               && (!tmp->PADAM_sleep || time_after_eq(tmp->PADAM_sleep, jiffies))) {
+                       if (!drive
+                        || (tmp->PADAM_sleep && (!drive->PADAM_sleep || time_after(drive->PADAM_sleep, tmp->PADAM_sleep)))
+                        || (!drive->PADAM_sleep && time_after(drive->PADAM_service_start + 2 * drive->PADAM_service_time, tmp->PADAM_service_start + 2 * tmp->PADAM_service_time)))
                        {
-                               if (!blk_queue_plugged(&drive->queue))
-                                       best = drive;
+                               if (!blk_queue_plugged(&tmp->queue))
+                                       drive = tmp;
                        }
                }
-       } while ((drive = drive->next) != hwgroup->drive);
-       return best;
-}
-
-static ide_drive_t *ide_choose_drive(ide_hwgroup_t *hwgroup)
-{
-       ide_drive_t *drive = choose_drive(hwgroup);
-       unsigned long sleep = 0;
+               tmp = tmp->next;
+       } while (tmp != hwgroup->drive);
 
        if (drive)
                return drive;
@@ -1495,7 +1493,7 @@ static void ide_do_request(ide_hwgroup_t *hwgroup, int masked_irq)
                /*
                 * will clear IDE_BUSY, if appropriate
                 */
-               if ((drive = ide_choose_drive(hwgroup)) == NULL)
+               if ((drive = choose_drive(hwgroup)) == NULL)
                        break;
 
                hwif = drive->channel;
@@ -2298,7 +2296,10 @@ void ide_unregister(struct ata_channel *channel)
        channel->maskproc = old_hwif.maskproc;
        channel->quirkproc = old_hwif.quirkproc;
        channel->rwproc = old_hwif.rwproc;
-       channel->ideproc = old_hwif.ideproc;
+       channel->ata_read = old_hwif.ata_read;
+       channel->ata_write = old_hwif.ata_write;
+       channel->atapi_read = old_hwif.atapi_read;
+       channel->atapi_write = old_hwif.atapi_write;
        channel->dmaproc = old_hwif.dmaproc;
        channel->busproc = old_hwif.busproc;
        channel->bus_state = old_hwif.bus_state;
@@ -2565,13 +2566,17 @@ int ide_write_setting (ide_drive_t *drive, ide_settings_t *setting, int val)
        return 0;
 }
 
-static int set_io_32bit(ide_drive_t *drive, int arg)
+static int set_io_32bit(struct ata_device *drive, int arg)
 {
+       if (drive->no_io_32bit)
+               return -EIO;
+
        drive->io_32bit = arg;
 #ifdef CONFIG_BLK_DEV_DTC2278
        if (drive->channel->chipset == ide_dtc2278)
                drive->channel->drives[!drive->select.b.unit].io_32bit = arg;
-#endif /* CONFIG_BLK_DEV_DTC2278 */
+#endif
+
        return 0;
 }
 
@@ -3018,8 +3023,6 @@ static int __init match_parm (char *s, const char *keywords[], int vals[], int m
  * "hdx=slow"          : insert a huge pause after each access to the data
  *                             port. Should be used only as a last resort.
  *
- * "hdx=swapdata"      : when the drive is a disk, byte swap all data
- * "hdx=bswap"         : same as above..........
  * "hdxlun=xx"          : set the drive last logical unit.
  * "hdx=flash"         : allows for more than one ata_flash disk to be
  *                             registered. In most cases, only one device
@@ -3127,8 +3130,7 @@ int __init ide_setup (char *s)
        if (!strncmp(s, "hd", 2) && s[2] >= 'a' && s[2] <= max_drive) {
                const char *hd_words[] = {"none", "noprobe", "nowerr", "cdrom",
                                "serialize", "autotune", "noautotune",
-                               "slow", "swapdata", "bswap", "flash",
-                               "remap", "noremap", "scsi", NULL};
+                               "slow", "flash", "remap", "noremap", "scsi", NULL};
                unit = s[2] - 'a';
                hw   = unit / MAX_DRIVES;
                unit = unit % MAX_DRIVES;
@@ -3178,20 +3180,16 @@ int __init ide_setup (char *s)
                        case -8: /* "slow" */
                                drive->slow = 1;
                                goto done;
-                       case -9: /* "swapdata" or "bswap" */
-                       case -10:
-                               drive->bswap = 1;
-                               goto done;
-                       case -11: /* "flash" */
+                       case -9: /* "flash" */
                                drive->ata_flash = 1;
                                goto done;
-                       case -12: /* "remap" */
+                       case -10: /* "remap" */
                                drive->remap_0_to_1 = 1;
                                goto done;
-                       case -13: /* "noremap" */
+                       case -11: /* "noremap" */
                                drive->remap_0_to_1 = 2;
                                goto done;
-                       case -14: /* "scsi" */
+                       case -12: /* "scsi" */
 #if defined(CONFIG_BLK_DEV_IDESCSI) && defined(CONFIG_SCSI)
                                drive->scsi = 1;
                                goto done;
index 127e15642b3823101dae948addc42bae9f4c4b8c..716517eac8f5141c5a9e8fb4da8425a814644faa 100644 (file)
@@ -1270,9 +1270,10 @@ void __init ide_init_pdc202xx(struct ata_channel *hwif)
 #ifdef CONFIG_PDC202XX_32_UNMASK
        hwif->drives[0].io_32bit = 1;
        hwif->drives[1].io_32bit = 1;
+
        hwif->drives[0].unmask = 1;
        hwif->drives[1].unmask = 1;
-#endif /* CONFIG_PDC202XX_32_UNMASK */
+#endif
 
 #ifdef CONFIG_BLK_DEV_IDEDMA
        if (hwif->dma_base) {
@@ -1285,9 +1286,9 @@ void __init ide_init_pdc202xx(struct ata_channel *hwif)
                hwif->drives[1].autotune = 1;
                hwif->autodma = 0;
        }
-#else /* !CONFIG_BLK_DEV_IDEDMA */
+#else
        hwif->drives[0].autotune = 1;
        hwif->drives[1].autotune = 1;
        hwif->autodma = 0;
-#endif /* CONFIG_BLK_DEV_IDEDMA */
+#endif
 }
index f5763139d3c35648066af9f8ea56eef252e44fe3..deae0f2252bc49bcbadfd29565203d90005ee5f3 100644 (file)
@@ -183,7 +183,7 @@ int __init setup_pdc4030(struct ata_channel *hwif)
                        "%s: Failed Promise read config!\n",hwif->name);
                return 0;
        }
-       ata_input_data(drive, &ident, SECTOR_WORDS);
+       ata_read(drive, &ident, SECTOR_WORDS);
        if (ident.id[1] != 'P' || ident.id[0] != 'T') {
                return 0;
        }
@@ -332,7 +332,7 @@ read_next:
                nsect = sectors_avail;
        sectors_avail -= nsect;
        to = bio_kmap_irq(rq->bio, &flags) + ide_rq_offset(rq);
-       ata_input_data(drive, to, nsect * SECTOR_WORDS);
+       ata_read(drive, to, nsect * SECTOR_WORDS);
 #ifdef DEBUG_READ
        printk(KERN_DEBUG "%s:  promise_read: sectors(%ld-%ld), "
               "buf=0x%08lx, rem=%ld\n", drive->name, rq->sector,
@@ -460,7 +460,7 @@ int promise_multwrite (ide_drive_t *drive, unsigned int mcount)
                 * Ok, we're all setup for the interrupt
                 * re-entering us on the last transfer.
                 */
-               taskfile_output_data(drive, buffer, nsect<<7);
+               ata_write(drive, buffer, nsect << 7);
                bio_kunmap_irq(buffer, &flags);
        } while (mcount);
 
index c076125c87e9500fc44368f219a68fab2ce83510..46a2b1ca3f1a63f0da4c570f56f200cb631fa1dc 100644 (file)
@@ -140,7 +140,7 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne
                }
                count = min(pc->sg->length - pc->b_count, bcount);
                buf = page_address(pc->sg->page) + pc->sg->offset;
-               atapi_input_bytes (drive, buf + pc->b_count, count);
+               atapi_read(drive, buf + pc->b_count, count);
                bcount -= count; pc->b_count += count;
                if (pc->b_count == pc->sg->length) {
                        pc->sg++;
@@ -162,7 +162,7 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
                }
                count = min(pc->sg->length - pc->b_count, bcount);
                buf = page_address(pc->sg->page) + pc->sg->offset;
-               atapi_output_bytes (drive, buf + pc->b_count, count);
+               atapi_write(drive, buf + pc->b_count, count);
                bcount -= count; pc->b_count += count;
                if (pc->b_count == pc->sg->length) {
                        pc->sg++;
@@ -363,7 +363,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
                                        if (pc->sg)
                                                idescsi_input_buffers(drive, pc, temp);
                                        else
-                                               atapi_input_bytes(drive, pc->current_position, temp);
+                                               atapi_read(drive, pc->current_position, temp);
                                        printk(KERN_ERR "ide-scsi: transferred %d of %d bytes\n", temp, bcount);
                                }
                                pc->actually_transferred += temp;
@@ -382,13 +382,13 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
                if (pc->sg)
                        idescsi_input_buffers (drive, pc, bcount);
                else
-                       atapi_input_bytes (drive,pc->current_position,bcount);
+                       atapi_read(drive,pc->current_position,bcount);
        } else {
                set_bit(PC_WRITING, &pc->flags);
                if (pc->sg)
                        idescsi_output_buffers (drive, pc, bcount);
                else
-                       atapi_output_bytes (drive,pc->current_position,bcount);
+                       atapi_write(drive,pc->current_position,bcount);
        }
        pc->actually_transferred+=bcount;                               /* Update the current position */
        pc->current_position+=bcount;
@@ -414,7 +414,7 @@ static ide_startstop_t idescsi_transfer_pc (ide_drive_t *drive)
                return ide_stopped;
        }
        ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), NULL);        /* Set the interrupt routine */
-       atapi_output_bytes (drive, scsi->pc->c, 12);                    /* Send the actual packet */
+       atapi_write(drive, scsi->pc->c, 12);                    /* Send the actual packet */
        return ide_started;
 }
 
index 92ee18d5b00ce711459ee3308ce787ac6cb363f9..dafbf3d4fe175bd5577b5d3b2b2ec53933f91091 100644 (file)
@@ -313,9 +313,11 @@ typedef struct ide_tag_info_s {
 #define IDE_CUR_AR(drive)      (HWGROUP((drive))->rq->special)
 
 struct ide_settings_s;
-
-typedef struct ide_drive_s {
-       struct ata_channel *channel;    /* parent pointer to the channel we are attached to  */
+/* structure describing an ATA/ATAPI device */
+typedef
+struct ata_device {
+       struct ata_channel *    channel;
+       char                    name[6];        /* device name */
 
        unsigned int usage;             /* current "open()" count for drive */
        char type; /* distingiush different devices: disk, cdrom, tape, floppy, ... */
@@ -324,11 +326,11 @@ typedef struct ide_drive_s {
         * could move this to the channel and many sync problems would
         * magically just go away.
         */
-       request_queue_t queue;  /* per device request queue */
+       request_queue_t queue;          /* per device request queue */
 
-       struct list_head free_req; /* free ata requests */
+       struct list_head free_req;      /* free ata requests */
 
-       struct ide_drive_s      *next;  /* circular list of hwgroup drives */
+       struct ata_device *next;        /* circular list of hwgroup drives */
 
        /* Those are directly injected jiffie values. They should go away and
         * we should use generic timers instead!!!
@@ -346,8 +348,6 @@ typedef struct ide_drive_s {
        byte     retry_pio;             /* retrying dma capable host in pio */
        byte     state;                 /* retry state */
        byte     unmask;                /* flag: okay to unmask other irqs */
-       byte     slow;                  /* flag: slow data port */
-       byte     bswap;                 /* flag: byte swap data */
        byte     dsc_overlap;           /* flag: DSC overlap */
 
        unsigned waiting_for_dma: 1;    /* dma currently in progress */
@@ -359,7 +359,6 @@ typedef struct ide_drive_s {
        unsigned removable      : 1;    /* 1 if need to do check_media_change */
        unsigned forced_geom    : 1;    /* 1 if hdx=c,h,s was given at boot */
        unsigned no_unmask      : 1;    /* disallow setting unmask bit */
-       unsigned no_io_32bit    : 1;    /* disallow enabling 32bit I/O */
        unsigned nobios         : 1;    /* flag: do not probe bios for drive */
        unsigned revalidate     : 1;    /* request revalidation */
        unsigned atapi_overlap  : 1;    /* flag: ATAPI overlap (not supported) */
@@ -376,7 +375,6 @@ typedef struct ide_drive_s {
        byte            mult_count;     /* current multiple sector setting */
        byte            mult_req;       /* requested multiple sector setting */
        byte            tune_req;       /* requested drive tuning setting */
-       byte            io_32bit;       /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
        byte            bad_wstat;      /* used for ignoring WRERR_STAT */
        byte            nowerr;         /* used for ignoring WRERR_STAT */
        byte            sect0;          /* offset of first sector for DM6:DDO */
@@ -390,12 +388,18 @@ typedef struct ide_drive_s {
        unsigned long long capacity48;  /* total number of sectors */
        unsigned int    drive_data;     /* for use by tuneproc/selectproc as needed */
 
+       /* FIXME: Those are properties of a channel and not a drive!  Move them
+        * later there.
+        */
+       byte            slow;           /* flag: slow data port */
+       unsigned no_io_32bit    : 1;    /* disallow enabling 32bit I/O */
+       byte            io_32bit;       /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
+
        wait_queue_head_t wqueue;       /* used to wait for drive in open() */
 
        struct hd_driveid *id;          /* drive model identification info */
        struct hd_struct  *part;        /* drive partition table */
 
-       char            name[6];        /* drive name, such as "hda" */
        struct ata_operations *driver;
 
        void            *driver_data;   /* extra driver data */
@@ -447,47 +451,6 @@ typedef enum {     ide_dma_read,   ide_dma_write,          ide_dma_begin,
 
 typedef int (ide_dmaproc_t)(ide_dma_action_t, ide_drive_t *);
 
-/*
- * An ide_ideproc_t() performs CPU-polled transfers to/from a drive.
- * Arguments are: the drive, the buffer pointer, and the length (in bytes or
- * words depending on if it's an IDE or ATAPI call).
- *
- * If it is not defined for a controller, standard-code is used from ide.c.
- *
- * Controllers which are not memory-mapped in the standard way need to
- * override that mechanism using this function to work.
- *
- */
-typedef enum { ideproc_ide_input_data,    ideproc_ide_output_data,
-              ideproc_atapi_input_bytes, ideproc_atapi_output_bytes
-} ide_ide_action_t;
-
-typedef void (ide_ideproc_t)(ide_ide_action_t, ide_drive_t *, void *, unsigned int);
-
-/*
- * An ide_tuneproc_t() is used to set the speed of an IDE interface
- * to a particular PIO mode.  The "byte" parameter is used
- * to select the PIO mode by number (0,1,2,3,4,5), and a value of 255
- * indicates that the interface driver should "auto-tune" the PIO mode
- * according to the drive capabilities in drive->id;
- *
- * Not all interface types support tuning, and not all of those
- * support all possible PIO settings.  They may silently ignore
- * or round values as they see fit.
- */
-typedef void (ide_tuneproc_t) (ide_drive_t *, byte);
-typedef int (ide_speedproc_t) (ide_drive_t *, byte);
-
-/*
- * This is used to provide support for strange interfaces
- */
-typedef void (ide_selectproc_t) (ide_drive_t *);
-typedef void (ide_resetproc_t) (ide_drive_t *);
-typedef int (ide_quirkproc_t) (ide_drive_t *);
-typedef void (ide_intrproc_t) (ide_drive_t *);
-typedef void (ide_maskproc_t) (ide_drive_t *, int);
-typedef void (ide_rw_proc_t) (ide_drive_t *, ide_dma_action_t);
-
 enum {
        ATA_PRIMARY     = 0,
        ATA_SECONDARY   = 1
@@ -507,15 +470,40 @@ struct ata_channel {
 #endif
        ide_drive_t     drives[MAX_DRIVES];     /* drive info */
        struct gendisk  *gd;            /* gendisk structure */
-       ide_tuneproc_t  *tuneproc;      /* routine to tune PIO mode for drives */
-       ide_speedproc_t *speedproc;     /* routine to retune DMA modes for drives */
-       ide_selectproc_t *selectproc;   /* tweaks hardware to select drive */
-       ide_resetproc_t *resetproc;     /* routine to reset controller after a disk reset */
-       ide_intrproc_t  *intrproc;      /* special interrupt handling for shared pci interrupts */
-       ide_maskproc_t  *maskproc;      /* special host masking for drive selection */
-       ide_quirkproc_t *quirkproc;     /* check host's drive quirk list */
-       ide_rw_proc_t   *rwproc;        /* adjust timing based upon rq->cmd direction */
-       ide_ideproc_t   *ideproc;       /* CPU-polled transfer routine */
+
+       /*
+        * Routines to tune PIO and DMA mode for drives.
+        *
+        * A value of 255 indicates that the function should choose the optimal
+        * mode itself.
+        */
+       void (*tuneproc) (ide_drive_t *, byte pio);
+       int (*speedproc) (ide_drive_t *, byte pio);
+
+       /* tweaks hardware to select drive */
+       void (*selectproc) (ide_drive_t *);
+
+       /* routine to reset controller after a disk reset */
+       void (*resetproc) (ide_drive_t *);
+
+       /* special interrupt handling for shared pci interrupts */
+       void (*intrproc) (ide_drive_t *);
+
+       /* special host masking for drive selection */
+       void (*maskproc) (ide_drive_t *, int);
+
+       /* adjust timing based upon rq->cmd direction */
+       void (*rwproc) (ide_drive_t *, ide_dma_action_t);
+
+       /* check host's drive quirk list */
+       int (*quirkproc) (ide_drive_t *);
+
+       /* CPU-polled transfer routines */
+       void (*ata_read)(ide_drive_t *, void *, unsigned int);
+       void (*ata_write)(ide_drive_t *, void *, unsigned int);
+       void (*atapi_read)(ide_drive_t *, void *, unsigned int);
+       void (*atapi_write)(ide_drive_t *, void *, unsigned int);
+
        ide_dmaproc_t   *dmaproc;       /* dma read/write/abort routine */
        unsigned long   dma_base;       /* base addr for dma ports */
        unsigned        dma_extra;      /* extra addr for dma ports */
@@ -829,7 +817,7 @@ struct ata_taskfile {
  */
 struct ata_request {
        struct request          *ar_rq;         /* real request */
-       struct ide_drive_s      *ar_drive;      /* associated drive */
+       struct ata_device       *ar_drive;      /* associated drive */
        unsigned long           ar_flags;       /* ATA_AR_* flags */
        int                     ar_tag;         /* tag number, if any */
        struct list_head        ar_queue;       /* pending list */
@@ -848,12 +836,11 @@ struct ata_request {
 
 #define AR_TASK_CMD(ar)        ((ar)->ar_task.taskfile.command)
 
-void ata_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount);
-void ata_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount);
-void atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount);
-void atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount);
-void taskfile_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount);
-void taskfile_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount);
+extern void ata_read(ide_drive_t *drive, void *buffer, unsigned int wcount);
+extern void ata_write(ide_drive_t *drive, void *buffer, unsigned int wcount);
+
+extern void atapi_read(ide_drive_t *drive, void *buffer, unsigned int bytecount);
+extern void atapi_write(ide_drive_t *drive, void *buffer, unsigned int bytecount);
 
 extern ide_startstop_t ata_taskfile(ide_drive_t *drive,
                struct ata_taskfile *args, struct request *rq);