ide/legacy/gayle.c: add MODULE_LICENSE
[safe/jmp/linux-2.6] / drivers / ide / legacy / hd.c
index aebecd8..0b0d867 100644 (file)
@@ -130,7 +130,7 @@ struct hd_i_struct {
        
 #ifdef HD_TYPE
 static struct hd_i_struct hd_info[] = { HD_TYPE };
-static int NR_HD = ((sizeof (hd_info))/(sizeof (struct hd_i_struct)));
+static int NR_HD = ARRAY_SIZE(hd_info);
 #else
 static struct hd_i_struct hd_info[MAX_HD];
 static int NR_HD;
@@ -421,11 +421,14 @@ static void bad_rw_intr(void)
 
 static inline int wait_DRQ(void)
 {
-       int retries = 100000, stat;
+       int retries;
+       int stat;
 
-       while (--retries > 0)
-               if ((stat = inb_p(HD_STATUS)) & DRQ_STAT)
+       for (retries = 0; retries < 100000; retries++) {
+               stat = inb_p(HD_STATUS);
+               if (stat & DRQ_STAT)
                        return 0;
+       }
        dump_status("wait_DRQ", stat);
        return -1;
 }
@@ -459,7 +462,7 @@ ok_to_read:
 #ifdef DEBUG
        printk("%s: read: sector %ld, remaining = %ld, buffer=%p\n",
                req->rq_disk->disk_name, req->sector, req->nr_sectors,
-               req->buffer+512));
+               req->buffer+512);
 #endif
        if (req->current_nr_sectors <= 0)
                end_request(req, 1);
@@ -623,10 +626,11 @@ repeat:
        cyl   = track / disk->head;
 #ifdef DEBUG
        printk("%s: %sing: CHS=%d/%d/%d, sectors=%d, buffer=%p\n",
-               req->rq_disk->disk_name, (req->cmd == READ)?"read":"writ",
+               req->rq_disk->disk_name,
+               req_data_dir(req) == READ ? "read" : "writ",
                cyl, head, sec, nsect, req->buffer);
 #endif
-       if (req->flags & REQ_CMD) {
+       if (blk_fs_request(req)) {
                switch (rq_data_dir(req)) {
                case READ:
                        hd_out(disk,nsect,sec,head,cyl,WIN_READ,&read_intr);
@@ -651,7 +655,7 @@ repeat:
        }
 }
 
-static void do_hd_request (request_queue_t * q)
+static void do_hd_request (struct request_queue * q)
 {
        disable_irq(HD_IRQ);
        hd_request();
@@ -673,7 +677,7 @@ static int hd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
  * be forgotten about...
  */
 
-static irqreturn_t hd_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t hd_interrupt(int irq, void *dev_id)
 {
        void (*handler)(void) = do_hd;
 
@@ -718,74 +722,25 @@ static int __init hd_init(void)
        device_timer.function = hd_times_out;
        blk_queue_hardsect_size(hd_queue, 512);
 
-#ifdef __i386__
        if (!NR_HD) {
-               extern struct drive_info drive_info;
-               unsigned char *BIOS = (unsigned char *) &drive_info;
-               unsigned long flags;
-               int cmos_disks;
-
-               for (drive=0 ; drive<2 ; drive++) {
-                       hd_info[drive].cyl = *(unsigned short *) BIOS;
-                       hd_info[drive].head = *(2+BIOS);
-                       hd_info[drive].wpcom = *(unsigned short *) (5+BIOS);
-                       hd_info[drive].ctl = *(8+BIOS);
-                       hd_info[drive].lzone = *(unsigned short *) (12+BIOS);
-                       hd_info[drive].sect = *(14+BIOS);
-#ifdef does_not_work_for_everybody_with_scsi_but_helps_ibm_vp
-                       if (hd_info[drive].cyl && NR_HD == drive)
-                               NR_HD++;
-#endif
-                       BIOS += 16;
-               }
-
-       /*
-               We query CMOS about hard disks : it could be that 
-               we have a SCSI/ESDI/etc controller that is BIOS
-               compatible with ST-506, and thus showing up in our
-               BIOS table, but not register compatible, and therefore
-               not present in CMOS.
-
-               Furthermore, we will assume that our ST-506 drives
-               <if any> are the primary drives in the system, and 
-               the ones reflected as drive 1 or 2.
-
-               The first drive is stored in the high nibble of CMOS
-               byte 0x12, the second in the low nibble.  This will be
-               either a 4 bit drive type or 0xf indicating use byte 0x19 
-               for an 8 bit type, drive 1, 0x1a for drive 2 in CMOS.
-
-               Needless to say, a non-zero value means we have 
-               an AT controller hard disk for that drive.
-
-               Currently the rtc_lock is a bit academic since this
-               driver is non-modular, but someday... ?         Paul G.
-       */
-
-               spin_lock_irqsave(&rtc_lock, flags);
-               cmos_disks = CMOS_READ(0x12);
-               spin_unlock_irqrestore(&rtc_lock, flags);
-
-               if (cmos_disks & 0xf0) {
-                       if (cmos_disks & 0x0f)
-                               NR_HD = 2;
-                       else
-                               NR_HD = 1;
-               }
-       }
-#endif /* __i386__ */
-#ifdef __arm__
-       if (!NR_HD) {
-               /* We don't know anything about the drive.  This means
+               /*
+                * We don't know anything about the drive.  This means
                 * that you *MUST* specify the drive parameters to the
                 * kernel yourself.
+                *
+                * If we were on an i386, we used to read this info from
+                * the BIOS or CMOS.  This doesn't work all that well,
+                * since this assumes that this is a primary or secondary
+                * drive, and if we're using this legacy driver, it's
+                * probably an auxilliary controller added to recover
+                * legacy data off an ST-506 drive.  Either way, it's
+                * definitely safest to have the user explicitly specify
+                * the information.
                 */
                printk("hd: no drives specified - use hd=cyl,head,sectors"
                        " on kernel command line\n");
-       }
-#endif
-       if (!NR_HD)
                goto out;
+       }
 
        for (drive=0 ; drive < NR_HD ; drive++) {
                struct gendisk *disk = alloc_disk(64);