Loading drivers/ide/ide-cd.c +46 −23 Original line number Original line Diff line number Diff line Loading @@ -279,11 +279,11 @@ static void cdrom_end_request(ide_drive_t *drive, int uptodate) ide_end_request(drive, uptodate, nsectors); ide_end_request(drive, uptodate, nsectors); } } static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 stat) static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st) { { if (stat & 0x80) if (st & 0x80) return; return; ide_dump_status(drive, msg, stat); ide_dump_status(drive, msg, st); } } /* /* Loading Loading @@ -390,7 +390,8 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) * data from cache. * data from cache. */ */ if (!rq->errors) if (!rq->errors) info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY; info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY; rq->errors = 1; rq->errors = 1; if (time_after(jiffies, info->write_timeout)) if (time_after(jiffies, info->write_timeout)) do_end_request = 1; do_end_request = 1; Loading @@ -403,7 +404,8 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) */ */ spin_lock_irqsave(&ide_lock, flags); spin_lock_irqsave(&ide_lock, flags); blk_plug_device(drive->queue); blk_plug_device(drive->queue); spin_unlock_irqrestore(&ide_lock, flags); spin_unlock_irqrestore(&ide_lock, flags); return 1; return 1; } } } } Loading @@ -430,11 +432,14 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) * No point in re-trying a zillion times on a bad * No point in re-trying a zillion times on a bad * sector. If we got here the error is not correctable. * sector. If we got here the error is not correctable. */ */ ide_dump_status_no_sense(drive, "media error (bad sector)", stat); ide_dump_status_no_sense(drive, "media error (bad sector)", stat); do_end_request = 1; do_end_request = 1; } else if (sense_key == BLANK_CHECK) { } else if (sense_key == BLANK_CHECK) { /* disk appears blank ?? */ /* disk appears blank ?? */ ide_dump_status_no_sense(drive, "media error (blank)", stat); ide_dump_status_no_sense(drive, "media error (blank)", stat); do_end_request = 1; do_end_request = 1; } else if ((err & ~ABRT_ERR) != 0) { } else if ((err & ~ABRT_ERR) != 0) { /* go to the default handler for other errors */ /* go to the default handler for other errors */ Loading Loading @@ -504,7 +509,8 @@ static int cdrom_timer_expiry(ide_drive_t *drive) break; break; default: default: if (!(rq->cmd_flags & REQ_QUIET)) if (!(rq->cmd_flags & REQ_QUIET)) printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]); printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]); wait = 0; wait = 0; break; break; } } Loading Loading @@ -545,7 +551,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, drive->waiting_for_dma = 0; drive->waiting_for_dma = 0; /* packet command */ /* packet command */ ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry); ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry); return ide_started; return ide_started; } else { } else { unsigned long flags; unsigned long flags; Loading Loading @@ -801,7 +808,8 @@ static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block) info->dma = 0; info->dma = 0; info->start_seek = jiffies; info->start_seek = jiffies; return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation); return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation); } } /* /* Loading @@ -811,13 +819,15 @@ static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block) static void restore_request(struct request *rq) static void restore_request(struct request *rq) { { if (rq->buffer != bio_data(rq->bio)) { if (rq->buffer != bio_data(rq->bio)) { sector_t n = (rq->buffer - (char *) bio_data(rq->bio)) / SECTOR_SIZE; sector_t n = (rq->buffer - (char *)bio_data(rq->bio)) / SECTOR_SIZE; rq->buffer = bio_data(rq->bio); rq->buffer = bio_data(rq->bio); rq->nr_sectors += n; rq->nr_sectors += n; rq->sector -= n; rq->sector -= n; } } rq->hard_cur_sectors = rq->current_nr_sectors = bio_cur_sectors(rq->bio); rq->current_nr_sectors = bio_cur_sectors(rq->bio); rq->hard_cur_sectors = rq->current_nr_sectors; rq->hard_nr_sectors = rq->nr_sectors; rq->hard_nr_sectors = rq->nr_sectors; rq->hard_sector = rq->sector; rq->hard_sector = rq->sector; rq->q->prep_rq_fn(rq->q, rq); rq->q->prep_rq_fn(rq->q, rq); Loading Loading @@ -1182,7 +1192,8 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) /* sg request */ /* sg request */ if (rq->bio) { if (rq->bio) { int mask = drive->queue->dma_alignment; int mask = drive->queue->dma_alignment; unsigned long addr = (unsigned long) page_address(bio_page(rq->bio)); unsigned long addr = (unsigned long)page_address(bio_page(rq->bio)); info->dma = drive->using_dma; info->dma = drive->using_dma; Loading @@ -1197,7 +1208,8 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) } } /* start sending the command to the drive */ /* start sending the command to the drive */ return cdrom_start_packet_command(drive, rq->data_len, cdrom_do_newpc_cont); return cdrom_start_packet_command(drive, rq->data_len, cdrom_do_newpc_cont); } } /* /* Loading @@ -1216,14 +1228,19 @@ ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, sector_t block) if ((stat & SEEK_STAT) != SEEK_STAT) { if ((stat & SEEK_STAT) != SEEK_STAT) { if (elapsed < IDECD_SEEK_TIMEOUT) { if (elapsed < IDECD_SEEK_TIMEOUT) { ide_stall_queue(drive, IDECD_SEEK_TIMER); ide_stall_queue(drive, IDECD_SEEK_TIMER); return ide_stopped; return ide_stopped; } } printk(KERN_ERR "%s: DSC timeout\n", drive->name); printk(KERN_ERR "%s: DSC timeout\n", drive->name); } } info->cd_flags &= ~IDE_CD_FLAG_SEEKING; info->cd_flags &= ~IDE_CD_FLAG_SEEKING; } } if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) if (rq_data_dir(rq) == READ && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) action = cdrom_start_seek(drive, block); action = cdrom_start_seek(drive, block); else else action = cdrom_start_rw(drive, rq); action = cdrom_start_rw(drive, rq); Loading Loading @@ -1355,7 +1372,8 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) /* try to allocate space */ /* try to allocate space */ toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); if (toc == NULL) { if (toc == NULL) { printk(KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name); printk(KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name); return -ENOMEM; return -ENOMEM; } } info->toc = toc; info->toc = toc; Loading Loading @@ -1598,7 +1616,8 @@ int ide_cdrom_probe_capabilities(ide_drive_t *drive) if (drive->media == ide_optical) { if (drive->media == ide_optical) { cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", drive->name); printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", drive->name); return nslots; return nslots; } } Loading Loading @@ -1897,7 +1916,8 @@ int ide_cdrom_setup(ide_drive_t *drive) drive->dsc_overlap = (drive->next != drive); drive->dsc_overlap = (drive->next != drive); if (ide_cdrom_register(drive, nslots)) { if (ide_cdrom_register(drive, nslots)) { printk(KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name); printk(KERN_ERR "%s: %s failed to register device with the" " cdrom driver.\n", drive->name, __func__); cd->devinfo.handle = NULL; cd->devinfo.handle = NULL; return 1; return 1; } } Loading Loading @@ -2094,17 +2114,20 @@ static int ide_cd_probe(ide_drive_t *drive) /* skip drives that we were told to ignore */ /* skip drives that we were told to ignore */ if (ignore != NULL) { if (ignore != NULL) { if (strstr(ignore, drive->name)) { if (strstr(ignore, drive->name)) { printk(KERN_INFO "ide-cd: ignoring drive %s\n", drive->name); printk(KERN_INFO "ide-cd: ignoring drive %s\n", drive->name); goto failed; goto failed; } } } } if (drive->scsi) { if (drive->scsi) { printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name); printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi " "emulation.\n", drive->name); goto failed; goto failed; } } info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); if (info == NULL) { if (info == NULL) { printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name); printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name); goto failed; goto failed; } } Loading Loading
drivers/ide/ide-cd.c +46 −23 Original line number Original line Diff line number Diff line Loading @@ -279,11 +279,11 @@ static void cdrom_end_request(ide_drive_t *drive, int uptodate) ide_end_request(drive, uptodate, nsectors); ide_end_request(drive, uptodate, nsectors); } } static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 stat) static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st) { { if (stat & 0x80) if (st & 0x80) return; return; ide_dump_status(drive, msg, stat); ide_dump_status(drive, msg, st); } } /* /* Loading Loading @@ -390,7 +390,8 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) * data from cache. * data from cache. */ */ if (!rq->errors) if (!rq->errors) info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY; info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY; rq->errors = 1; rq->errors = 1; if (time_after(jiffies, info->write_timeout)) if (time_after(jiffies, info->write_timeout)) do_end_request = 1; do_end_request = 1; Loading @@ -403,7 +404,8 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) */ */ spin_lock_irqsave(&ide_lock, flags); spin_lock_irqsave(&ide_lock, flags); blk_plug_device(drive->queue); blk_plug_device(drive->queue); spin_unlock_irqrestore(&ide_lock, flags); spin_unlock_irqrestore(&ide_lock, flags); return 1; return 1; } } } } Loading @@ -430,11 +432,14 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) * No point in re-trying a zillion times on a bad * No point in re-trying a zillion times on a bad * sector. If we got here the error is not correctable. * sector. If we got here the error is not correctable. */ */ ide_dump_status_no_sense(drive, "media error (bad sector)", stat); ide_dump_status_no_sense(drive, "media error (bad sector)", stat); do_end_request = 1; do_end_request = 1; } else if (sense_key == BLANK_CHECK) { } else if (sense_key == BLANK_CHECK) { /* disk appears blank ?? */ /* disk appears blank ?? */ ide_dump_status_no_sense(drive, "media error (blank)", stat); ide_dump_status_no_sense(drive, "media error (blank)", stat); do_end_request = 1; do_end_request = 1; } else if ((err & ~ABRT_ERR) != 0) { } else if ((err & ~ABRT_ERR) != 0) { /* go to the default handler for other errors */ /* go to the default handler for other errors */ Loading Loading @@ -504,7 +509,8 @@ static int cdrom_timer_expiry(ide_drive_t *drive) break; break; default: default: if (!(rq->cmd_flags & REQ_QUIET)) if (!(rq->cmd_flags & REQ_QUIET)) printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]); printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]); wait = 0; wait = 0; break; break; } } Loading Loading @@ -545,7 +551,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, drive->waiting_for_dma = 0; drive->waiting_for_dma = 0; /* packet command */ /* packet command */ ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry); ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry); return ide_started; return ide_started; } else { } else { unsigned long flags; unsigned long flags; Loading Loading @@ -801,7 +808,8 @@ static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block) info->dma = 0; info->dma = 0; info->start_seek = jiffies; info->start_seek = jiffies; return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation); return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation); } } /* /* Loading @@ -811,13 +819,15 @@ static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block) static void restore_request(struct request *rq) static void restore_request(struct request *rq) { { if (rq->buffer != bio_data(rq->bio)) { if (rq->buffer != bio_data(rq->bio)) { sector_t n = (rq->buffer - (char *) bio_data(rq->bio)) / SECTOR_SIZE; sector_t n = (rq->buffer - (char *)bio_data(rq->bio)) / SECTOR_SIZE; rq->buffer = bio_data(rq->bio); rq->buffer = bio_data(rq->bio); rq->nr_sectors += n; rq->nr_sectors += n; rq->sector -= n; rq->sector -= n; } } rq->hard_cur_sectors = rq->current_nr_sectors = bio_cur_sectors(rq->bio); rq->current_nr_sectors = bio_cur_sectors(rq->bio); rq->hard_cur_sectors = rq->current_nr_sectors; rq->hard_nr_sectors = rq->nr_sectors; rq->hard_nr_sectors = rq->nr_sectors; rq->hard_sector = rq->sector; rq->hard_sector = rq->sector; rq->q->prep_rq_fn(rq->q, rq); rq->q->prep_rq_fn(rq->q, rq); Loading Loading @@ -1182,7 +1192,8 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) /* sg request */ /* sg request */ if (rq->bio) { if (rq->bio) { int mask = drive->queue->dma_alignment; int mask = drive->queue->dma_alignment; unsigned long addr = (unsigned long) page_address(bio_page(rq->bio)); unsigned long addr = (unsigned long)page_address(bio_page(rq->bio)); info->dma = drive->using_dma; info->dma = drive->using_dma; Loading @@ -1197,7 +1208,8 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) } } /* start sending the command to the drive */ /* start sending the command to the drive */ return cdrom_start_packet_command(drive, rq->data_len, cdrom_do_newpc_cont); return cdrom_start_packet_command(drive, rq->data_len, cdrom_do_newpc_cont); } } /* /* Loading @@ -1216,14 +1228,19 @@ ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, sector_t block) if ((stat & SEEK_STAT) != SEEK_STAT) { if ((stat & SEEK_STAT) != SEEK_STAT) { if (elapsed < IDECD_SEEK_TIMEOUT) { if (elapsed < IDECD_SEEK_TIMEOUT) { ide_stall_queue(drive, IDECD_SEEK_TIMER); ide_stall_queue(drive, IDECD_SEEK_TIMER); return ide_stopped; return ide_stopped; } } printk(KERN_ERR "%s: DSC timeout\n", drive->name); printk(KERN_ERR "%s: DSC timeout\n", drive->name); } } info->cd_flags &= ~IDE_CD_FLAG_SEEKING; info->cd_flags &= ~IDE_CD_FLAG_SEEKING; } } if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) if (rq_data_dir(rq) == READ && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) action = cdrom_start_seek(drive, block); action = cdrom_start_seek(drive, block); else else action = cdrom_start_rw(drive, rq); action = cdrom_start_rw(drive, rq); Loading Loading @@ -1355,7 +1372,8 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) /* try to allocate space */ /* try to allocate space */ toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); if (toc == NULL) { if (toc == NULL) { printk(KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name); printk(KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name); return -ENOMEM; return -ENOMEM; } } info->toc = toc; info->toc = toc; Loading Loading @@ -1598,7 +1616,8 @@ int ide_cdrom_probe_capabilities(ide_drive_t *drive) if (drive->media == ide_optical) { if (drive->media == ide_optical) { cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", drive->name); printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", drive->name); return nslots; return nslots; } } Loading Loading @@ -1897,7 +1916,8 @@ int ide_cdrom_setup(ide_drive_t *drive) drive->dsc_overlap = (drive->next != drive); drive->dsc_overlap = (drive->next != drive); if (ide_cdrom_register(drive, nslots)) { if (ide_cdrom_register(drive, nslots)) { printk(KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name); printk(KERN_ERR "%s: %s failed to register device with the" " cdrom driver.\n", drive->name, __func__); cd->devinfo.handle = NULL; cd->devinfo.handle = NULL; return 1; return 1; } } Loading Loading @@ -2094,17 +2114,20 @@ static int ide_cd_probe(ide_drive_t *drive) /* skip drives that we were told to ignore */ /* skip drives that we were told to ignore */ if (ignore != NULL) { if (ignore != NULL) { if (strstr(ignore, drive->name)) { if (strstr(ignore, drive->name)) { printk(KERN_INFO "ide-cd: ignoring drive %s\n", drive->name); printk(KERN_INFO "ide-cd: ignoring drive %s\n", drive->name); goto failed; goto failed; } } } } if (drive->scsi) { if (drive->scsi) { printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name); printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi " "emulation.\n", drive->name); goto failed; goto failed; } } info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); if (info == NULL) { if (info == NULL) { printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name); printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name); goto failed; goto failed; } } Loading