]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - drivers/ide/ide-cd.c
[BLOCK] add @uptodate to end_that_request_last() and @error to rq_end_io_fn()
[linux-2.6.git] / drivers / ide / ide-cd.c
index 7130939c7f914e6b5817de821832663aff0c4176..d31117eb95aacfe75b42c44f05861961640d4c3f 100644 (file)
@@ -614,7 +614,7 @@ static void cdrom_end_request (ide_drive_t *drive, int uptodate)
                         */
                        spin_lock_irqsave(&ide_lock, flags);
                        end_that_request_chunk(failed, 0, failed->data_len);
-                       end_that_request_last(failed);
+                       end_that_request_last(failed, 0);
                        spin_unlock_irqrestore(&ide_lock, flags);
                }
 
@@ -1292,7 +1292,6 @@ static ide_startstop_t cdrom_start_seek (ide_drive_t *drive, unsigned int block)
        struct cdrom_info *info = drive->driver_data;
 
        info->dma = 0;
-       info->cmd = 0;
        info->start_seek = jiffies;
        return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation);
 }
@@ -1344,8 +1343,6 @@ static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int block)
            (rq->nr_sectors & (sectors_per_frame - 1)))
                info->dma = 0;
 
-       info->cmd = READ;
-
        /* Start sending the read request to the drive. */
        return cdrom_start_packet_command(drive, 32768, cdrom_start_read_continuation);
 }
@@ -1484,7 +1481,6 @@ static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive)
        struct cdrom_info *info = drive->driver_data;
 
        info->dma = 0;
-       info->cmd = 0;
        rq->flags &= ~REQ_FAILED;
        len = rq->data_len;
 
@@ -1739,7 +1735,7 @@ end_request:
 
        spin_lock_irqsave(&ide_lock, flags);
        blkdev_dequeue_request(rq);
-       end_that_request_last(rq);
+       end_that_request_last(rq, 1);
        HWGROUP(drive)->rq = NULL;
        spin_unlock_irqrestore(&ide_lock, flags);
        return ide_stopped;
@@ -1891,7 +1887,6 @@ static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq)
        /* use dma, if possible. we don't need to check more, since we
         * know that the transfer is always (at least!) frame aligned */
        info->dma = drive->using_dma ? 1 : 0;
-       info->cmd = WRITE;
 
        info->devinfo.media_written = 1;
 
@@ -1916,7 +1911,6 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
        rq->flags |= REQ_QUIET;
 
        info->dma = 0;
-       info->cmd = 0;
 
        /*
         * sg request
@@ -1925,7 +1919,6 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
                int mask = drive->queue->dma_alignment;
                unsigned long addr = (unsigned long) page_address(bio_page(rq->bio));
 
-               info->cmd = rq_data_dir(rq);
                info->dma = drive->using_dma;
 
                /*
@@ -2211,13 +2204,12 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
 
        if (toc == NULL) {
                /* Try to allocate space. */
-               toc = (struct atapi_toc *) kmalloc (sizeof (struct atapi_toc),
-                                                   GFP_KERNEL);
-               info->toc = toc;
+               toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL);
                if (toc == NULL) {
                        printk (KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name);
                        return -ENOMEM;
                }
+               info->toc = toc;
        }
 
        /* Check to see if the existing data is still valid.
@@ -2240,7 +2232,8 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
        /* First read just the header, so we know how long the TOC is. */
        stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr,
                                    sizeof(struct atapi_toc_header), sense);
-       if (stat) return stat;
+       if (stat)
+               return stat;
 
 #if ! STANDARD_ATAPI
        if (CDROM_CONFIG_FLAGS(drive)->toctracks_as_bcd) {
@@ -2324,7 +2317,8 @@ static int cdrom_read_toc(ide_drive_t *drive, struct request_sense *sense)
                /* Read the multisession information. */
                stat = cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp,
                                           sizeof(ms_tmp), sense);
-               if (stat) return stat;
+               if (stat)
+                       return stat;
 
                toc->last_session_lba = be32_to_cpu(ms_tmp.ent.addr.lba);
        } else {
@@ -2460,7 +2454,7 @@ static int ide_cdrom_packet(struct cdrom_device_info *cdi,
                            struct packet_command *cgc)
 {
        struct request req;
-       ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+       ide_drive_t *drive = cdi->handle;
 
        if (cgc->timeout <= 0)
                cgc->timeout = ATAPI_WAIT_PC;
@@ -2537,7 +2531,7 @@ int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
                           unsigned int cmd, void *arg)
                           
 {
-       ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+       ide_drive_t *drive = cdi->handle;
        struct cdrom_info *info = drive->driver_data;
        int stat;
 
@@ -2548,7 +2542,7 @@ int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
         */
        case CDROMPLAYTRKIND: {
                unsigned long lba_start, lba_end;
-               struct cdrom_ti *ti = (struct cdrom_ti *)arg;
+               struct cdrom_ti *ti = arg;
                struct atapi_toc_entry *first_toc, *last_toc;
 
                stat = cdrom_get_toc_entry(drive, ti->cdti_trk0, &first_toc);
@@ -2571,12 +2565,13 @@ int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
        }
 
        case CDROMREADTOCHDR: {
-               struct cdrom_tochdr *tochdr = (struct cdrom_tochdr *) arg;
+               struct cdrom_tochdr *tochdr = arg;
                struct atapi_toc *toc;
 
                /* Make sure our saved TOC is valid. */
                stat = cdrom_read_toc(drive, NULL);
-               if (stat) return stat;
+               if (stat)
+                       return stat;
 
                toc = info->toc;
                tochdr->cdth_trk0 = toc->hdr.first_track;
@@ -2586,11 +2581,12 @@ int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
        }
 
        case CDROMREADTOCENTRY: {
-               struct cdrom_tocentry *tocentry = (struct cdrom_tocentry*) arg;
+               struct cdrom_tocentry *tocentry = arg;
                struct atapi_toc_entry *toce;
 
                stat = cdrom_get_toc_entry(drive, tocentry->cdte_track, &toce);
-               if (stat) return stat;
+               if (stat)
+                       return stat;
 
                tocentry->cdte_ctrl = toce->control;
                tocentry->cdte_adr  = toce->adr;
@@ -2613,7 +2609,7 @@ int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
 static
 int ide_cdrom_reset (struct cdrom_device_info *cdi)
 {
-       ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+       ide_drive_t *drive = cdi->handle;
        struct request_sense sense;
        struct request req;
        int ret;
@@ -2636,12 +2632,13 @@ int ide_cdrom_reset (struct cdrom_device_info *cdi)
 static
 int ide_cdrom_tray_move (struct cdrom_device_info *cdi, int position)
 {
-       ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+       ide_drive_t *drive = cdi->handle;
        struct request_sense sense;
 
        if (position) {
                int stat = cdrom_lockdoor(drive, 0, &sense);
-               if (stat) return stat;
+               if (stat)
+                       return stat;
        }
 
        return cdrom_eject(drive, !position, &sense);
@@ -2650,7 +2647,7 @@ int ide_cdrom_tray_move (struct cdrom_device_info *cdi, int position)
 static
 int ide_cdrom_lock_door (struct cdrom_device_info *cdi, int lock)
 {
-       ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+       ide_drive_t *drive = cdi->handle;
        return cdrom_lockdoor(drive, lock, NULL);
 }
 
@@ -2700,7 +2697,7 @@ void ide_cdrom_update_speed (ide_drive_t *drive, struct atapi_capabilities_page
 static
 int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed)
 {
-       ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+       ide_drive_t *drive = cdi->handle;
        struct request_sense sense;
        struct atapi_capabilities_page cap;
        int stat;
@@ -2723,7 +2720,7 @@ int ide_cdrom_select_speed (struct cdrom_device_info *cdi, int speed)
 static
 int ide_cdrom_drive_status (struct cdrom_device_info *cdi, int slot_nr)
 {
-       ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+       ide_drive_t *drive = cdi->handle;
        struct media_event_desc med;
        struct request_sense sense;
        int stat;
@@ -2769,7 +2766,7 @@ int ide_cdrom_get_last_session (struct cdrom_device_info *cdi,
                                struct cdrom_multisession *ms_info)
 {
        struct atapi_toc *toc;
-       ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+       ide_drive_t *drive = cdi->handle;
        struct cdrom_info *info = drive->driver_data;
        struct request_sense sense;
        int ret;
@@ -2791,7 +2788,7 @@ int ide_cdrom_get_mcn (struct cdrom_device_info *cdi,
 {
        int stat;
        char mcnbuf[24];
-       ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+       ide_drive_t *drive = cdi->handle;
 
 /* get MCN */
        if ((stat = cdrom_read_subchannel(drive, 2, mcnbuf, sizeof (mcnbuf), NULL)))
@@ -2815,7 +2812,7 @@ static
 int ide_cdrom_check_media_change_real (struct cdrom_device_info *cdi,
                                       int slot_nr)
 {
-       ide_drive_t *drive = (ide_drive_t*) cdi->handle;
+       ide_drive_t *drive = cdi->handle;
        int retval;
        
        if (slot_nr == CDSL_CURRENT) {
@@ -2886,7 +2883,7 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots)
        devinfo->mask = 0;
        devinfo->speed = CDROM_STATE_FLAGS(drive)->current_speed;
        devinfo->capacity = nslots;
-       devinfo->handle = (void *) drive;
+       devinfo->handle = drive;
        strcpy(devinfo->name, drive->name);
        
        /* set capability mask to match the probe. */
@@ -2942,7 +2939,7 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
         * registered with the Uniform layer yet, it can't do this.
         * Same goes for cdi->ops.
         */
-       cdi->handle = (ide_drive_t *) drive;
+       cdi->handle = drive;
        cdi->ops = &ide_cdrom_dops;
 
        if (ide_cdrom_get_capabilities(drive, &cap))
@@ -3288,12 +3285,9 @@ static void ide_cd_release(struct kref *kref)
        ide_drive_t *drive = info->drive;
        struct gendisk *g = info->disk;
 
-       if (info->buffer != NULL)
-               kfree(info->buffer);
-       if (info->toc != NULL)
-               kfree(info->toc);
-       if (info->changer_info != NULL)
-               kfree(info->changer_info);
+       kfree(info->buffer);
+       kfree(info->toc);
+       kfree(info->changer_info);
        if (devinfo->handle == drive && unregister_cdrom(devinfo))
                printk(KERN_ERR "%s: %s failed to unregister device from the cdrom "
                                "driver.\n", __FUNCTION__, drive->name);
@@ -3311,7 +3305,7 @@ static int ide_cd_probe(struct device *);
 static int proc_idecd_read_capacity
        (char *page, char **start, off_t off, int count, int *eof, void *data)
 {
-       ide_drive_t*drive = (ide_drive_t *)data;
+       ide_drive_t *drive = data;
        int len;
 
        len = sprintf(page,"%llu\n", (long long)ide_cdrom_capacity(drive));
@@ -3327,8 +3321,8 @@ static ide_proc_entry_t idecd_proc[] = {
 #endif
 
 static ide_driver_t ide_cdrom_driver = {
-       .owner                  = THIS_MODULE,
        .gen_driver = {
+               .owner          = THIS_MODULE,
                .name           = "ide-cdrom",
                .bus            = &ide_bus_type,
                .probe          = ide_cd_probe,
@@ -3451,7 +3445,7 @@ static int ide_cd_probe(struct device *dev)
                printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name);
                goto failed;
        }
-       info = (struct cdrom_info *) kmalloc (sizeof (struct cdrom_info), GFP_KERNEL);
+       info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL);
        if (info == NULL) {
                printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name);
                goto failed;
@@ -3465,8 +3459,6 @@ static int ide_cd_probe(struct device *dev)
 
        ide_register_subdriver(drive, &ide_cdrom_driver);
 
-       memset(info, 0, sizeof (struct cdrom_info));
-
        kref_init(&info->kref);
 
        info->drive = drive;
@@ -3485,12 +3477,9 @@ static int ide_cd_probe(struct device *dev)
        if (ide_cdrom_setup(drive)) {
                struct cdrom_device_info *devinfo = &info->devinfo;
                ide_unregister_subdriver(drive, &ide_cdrom_driver);
-               if (info->buffer != NULL)
-                       kfree(info->buffer);
-               if (info->toc != NULL)
-                       kfree(info->toc);
-               if (info->changer_info != NULL)
-                       kfree(info->changer_info);
+               kfree(info->buffer);
+               kfree(info->toc);
+               kfree(info->changer_info);
                if (devinfo->handle == drive && unregister_cdrom(devinfo))
                        printk (KERN_ERR "%s: ide_cdrom_cleanup failed to unregister device from the cdrom driver.\n", drive->name);
                kfree(info);
@@ -3514,12 +3503,13 @@ static void __exit ide_cdrom_exit(void)
 {
        driver_unregister(&ide_cdrom_driver.gen_driver);
 }
-static int ide_cdrom_init(void)
+
+static int __init ide_cdrom_init(void)
 {
        return driver_register(&ide_cdrom_driver.gen_driver);
 }
 
+MODULE_ALIAS("ide:*m-cdrom*");
 module_init(ide_cdrom_init);
 module_exit(ide_cdrom_exit);
 MODULE_LICENSE("GPL");