alim15x3: remove redundant m5229_revision check
[safe/jmp/linux-2.6] / drivers / ide / ide-cd.c
index 5969cec..ca84352 100644 (file)
@@ -481,7 +481,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
                else
                        printk("  Unknown Error Type: ");
 
-               if (sense->sense_key < ARY_LEN(sense_key_texts))
+               if (sense->sense_key < ARRAY_SIZE(sense_key_texts))
                        s = sense_key_texts[sense->sense_key];
 
                printk("%s -- (Sense key=0x%02x)\n", s, sense->sense_key);
@@ -491,7 +491,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
                                 sense->ascq);
                        s = buf;
                } else {
-                       int lo = 0, mid, hi = ARY_LEN(sense_data_texts);
+                       int lo = 0, mid, hi = ARRAY_SIZE(sense_data_texts);
                        unsigned long key = (sense->sense_key << 16);
                        key |= (sense->asc << 8);
                        if (!(sense->ascq >= 0x80 && sense->ascq <= 0xdd))
@@ -524,7 +524,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
 
                if (failed_command != NULL) {
 
-                       int lo=0, mid, hi= ARY_LEN (packet_command_texts);
+                       int lo=0, mid, hi= ARRAY_SIZE(packet_command_texts);
                        s = NULL;
 
                        while (hi > lo) {
@@ -687,15 +687,8 @@ static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 sta
 static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
 {
        struct request *rq = HWGROUP(drive)->rq;
-       ide_hwif_t *hwif = HWIF(drive);
        int stat, err, sense_key;
        
-       /* We may have bogus DMA interrupts in PIO state here */
-       if (HWIF(drive)->dma_status && hwif->atapi_irq_bogon) {
-               stat = hwif->INB(hwif->dma_status);
-               /* Should we force the bit as well ? */
-               hwif->OUTB(stat, hwif->dma_status);
-       }
        /* Check for errors. */
        stat = HWIF(drive)->INB(IDE_STATUS_REG);
        if (stat_ret)
@@ -742,6 +735,15 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
                        cdrom_saw_media_change (drive);
                        /*printk("%s: media changed\n",drive->name);*/
                        return 0;
+               } else if ((sense_key == ILLEGAL_REQUEST) &&
+                          (rq->cmd[0] == GPCMD_START_STOP_UNIT)) {
+                       /*
+                        * Don't print error message for this condition--
+                        * SFF8090i indicates that 5/24/00 is the correct
+                        * response to a request to close the tray if the
+                        * drive doesn't have that capability.
+                        * cdrom_log_sense() knows this!
+                        */
                } else if (!(rq->cmd_flags & REQ_QUIET)) {
                        /* Otherwise, print an error. */
                        ide_dump_status(drive, "packet command error", stat);
@@ -930,6 +932,10 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
                HWIF(drive)->OUTB(drive->ctl, IDE_CONTROL_REG);
  
        if (CDROM_CONFIG_FLAGS (drive)->drq_interrupt) {
+               /* waiting for CDB interrupt, not DMA yet. */
+               if (info->dma)
+                       drive->waiting_for_dma = 0;
+
                /* packet command */
                ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry);
                return ide_started;
@@ -972,6 +978,10 @@ static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
                /* Check for errors. */
                if (cdrom_decode_status(drive, DRQ_STAT, NULL))
                        return ide_stopped;
+
+               /* Ok, next interrupt will be DMA interrupt. */
+               if (info->dma)
+                       drive->waiting_for_dma = 1;
        } else {
                /* Otherwise, we must wait for DRQ to get set. */
                if (ide_wait_stat(&startstop, drive, DRQ_STAT,
@@ -1103,7 +1113,7 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
        if (dma) {
                info->dma = 0;
                if ((dma_error = HWIF(drive)->ide_dma_end(drive)))
-                       __ide_dma_off(drive);
+                       ide_dma_off(drive);
        }
 
        if (cdrom_decode_status(drive, 0, &stat))
@@ -1699,7 +1709,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
        if (dma) {
                if (dma_error) {
                        printk(KERN_ERR "ide-cd: dma error\n");
-                       __ide_dma_off(drive);
+                       ide_dma_off(drive);
                        return ide_error(drive, "dma error", stat);
                }
 
@@ -1825,7 +1835,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
                info->dma = 0;
                if ((dma_error = HWIF(drive)->ide_dma_end(drive))) {
                        printk(KERN_ERR "ide-cd: write dma error\n");
-                       __ide_dma_off(drive);
+                       ide_dma_off(drive);
                }
        }
 
@@ -3049,15 +3059,19 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
        return nslots;
 }
 
+#ifdef CONFIG_IDE_PROC_FS
 static void ide_cdrom_add_settings(ide_drive_t *drive)
 {
-       ide_add_setting(drive,  "dsc_overlap",          SETTING_RW, -1, -1, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL);
+       ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL);
 }
+#else
+static inline void ide_cdrom_add_settings(ide_drive_t *drive) { ; }
+#endif
 
 /*
  * standard prep_rq_fn that builds 10 byte cmds
  */
-static int ide_cdrom_prep_fs(request_queue_t *q, struct request *rq)
+static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq)
 {
        int hard_sect = queue_hardsect_size(q);
        long block = (long)rq->hard_sector / (hard_sect >> 9);
@@ -3123,7 +3137,7 @@ static int ide_cdrom_prep_pc(struct request *rq)
        return BLKPREP_OK;
 }
 
-static int ide_cdrom_prep_fn(request_queue_t *q, struct request *rq)
+static int ide_cdrom_prep_fn(struct request_queue *q, struct request *rq)
 {
        if (blk_fs_request(rq))
                return ide_cdrom_prep_fs(q, rq);
@@ -3254,14 +3268,6 @@ int ide_cdrom_setup (ide_drive_t *drive)
        if (drive->autotune == IDE_TUNE_DEFAULT ||
            drive->autotune == IDE_TUNE_AUTO)
                drive->dsc_overlap = (drive->next != drive);
-#if 0
-       drive->dsc_overlap = (HWIF(drive)->no_dsc) ? 0 : 1;
-       if (HWIF(drive)->no_dsc) {
-               printk(KERN_INFO "ide-cd: %s: disabling DSC overlap\n",
-                       drive->name);
-               drive->dsc_overlap = 0;
-       }
-#endif
 
        if (ide_cdrom_register(drive, nslots)) {
                printk (KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name);
@@ -3272,7 +3278,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
        return 0;
 }
 
-#ifdef CONFIG_PROC_FS
+#ifdef CONFIG_IDE_PROC_FS
 static
 sector_t ide_cdrom_capacity (ide_drive_t *drive)
 {
@@ -3289,7 +3295,7 @@ static void ide_cd_remove(ide_drive_t *drive)
 {
        struct cdrom_info *info = drive->driver_data;
 
-       ide_unregister_subdriver(drive, info->driver);
+       ide_proc_unregister_driver(drive, info->driver);
 
        del_gendisk(info->disk);
 
@@ -3319,7 +3325,7 @@ static void ide_cd_release(struct kref *kref)
 
 static int ide_cd_probe(ide_drive_t *);
 
-#ifdef CONFIG_PROC_FS
+#ifdef CONFIG_IDE_PROC_FS
 static int proc_idecd_read_capacity
        (char *page, char **start, off_t off, int count, int *eof, void *data)
 {
@@ -3334,8 +3340,6 @@ static ide_proc_entry_t idecd_proc[] = {
        { "capacity", S_IFREG|S_IRUGO, proc_idecd_read_capacity, NULL },
        { NULL, 0, NULL, NULL }
 };
-#else
-# define idecd_proc    NULL
 #endif
 
 static ide_driver_t ide_cdrom_driver = {
@@ -3353,28 +3357,25 @@ static ide_driver_t ide_cdrom_driver = {
        .end_request            = ide_end_request,
        .error                  = __ide_error,
        .abort                  = __ide_abort,
+#ifdef CONFIG_IDE_PROC_FS
        .proc                   = idecd_proc,
+#endif
 };
 
 static int idecd_open(struct inode * inode, struct file * file)
 {
        struct gendisk *disk = inode->i_bdev->bd_disk;
        struct cdrom_info *info;
-       ide_drive_t *drive;
        int rc = -ENOMEM;
 
        if (!(info = ide_cd_get(disk)))
                return -ENXIO;
 
-       drive = info->drive;
-
-       drive->usage++;
-
        if (!info->buffer)
-               info->buffer = kmalloc(SECTOR_BUFFER_SIZE,
-                                       GFP_KERNEL|__GFP_REPEAT);
-        if (!info->buffer || (rc = cdrom_open(&info->devinfo, inode, file)))
-               drive->usage--;
+               info->buffer = kmalloc(SECTOR_BUFFER_SIZE, GFP_KERNEL|__GFP_REPEAT);
+
+       if (info->buffer)
+               rc = cdrom_open(&info->devinfo, inode, file);
 
        if (rc < 0)
                ide_cd_put(info);
@@ -3386,10 +3387,8 @@ static int idecd_release(struct inode * inode, struct file * file)
 {
        struct gendisk *disk = inode->i_bdev->bd_disk;
        struct cdrom_info *info = ide_cd_g(disk);
-       ide_drive_t *drive = info->drive;
 
        cdrom_release (&info->devinfo, file);
-       drive->usage--;
 
        ide_cd_put(info);
 
@@ -3522,7 +3521,7 @@ static int ide_cd_probe(ide_drive_t *drive)
 
        ide_init_disk(g, drive);
 
-       ide_register_subdriver(drive, &ide_cdrom_driver);
+       ide_proc_register_driver(drive, &ide_cdrom_driver);
 
        kref_init(&info->kref);
 
@@ -3539,7 +3538,7 @@ static int ide_cd_probe(ide_drive_t *drive)
        g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE;
        if (ide_cdrom_setup(drive)) {
                struct cdrom_device_info *devinfo = &info->devinfo;
-               ide_unregister_subdriver(drive, &ide_cdrom_driver);
+               ide_proc_unregister_driver(drive, &ide_cdrom_driver);
                kfree(info->buffer);
                kfree(info->toc);
                kfree(info->changer_info);