diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/ide-cd.c | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index cc9e7f40d2ea..0a45f557d338 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -279,11 +279,11 @@ static void cdrom_end_request(ide_drive_t *drive, int uptodate) | |||
279 | ide_end_request(drive, uptodate, nsectors); | 279 | ide_end_request(drive, uptodate, nsectors); |
280 | } | 280 | } |
281 | 281 | ||
282 | static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 stat) | 282 | static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st) |
283 | { | 283 | { |
284 | if (stat & 0x80) | 284 | if (st & 0x80) |
285 | return; | 285 | return; |
286 | ide_dump_status(drive, msg, stat); | 286 | ide_dump_status(drive, msg, st); |
287 | } | 287 | } |
288 | 288 | ||
289 | /* | 289 | /* |
@@ -390,7 +390,8 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
390 | * data from cache. | 390 | * data from cache. |
391 | */ | 391 | */ |
392 | if (!rq->errors) | 392 | if (!rq->errors) |
393 | info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY; | 393 | info->write_timeout = jiffies + |
394 | ATAPI_WAIT_WRITE_BUSY; | ||
394 | rq->errors = 1; | 395 | rq->errors = 1; |
395 | if (time_after(jiffies, info->write_timeout)) | 396 | if (time_after(jiffies, info->write_timeout)) |
396 | do_end_request = 1; | 397 | do_end_request = 1; |
@@ -403,7 +404,8 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
403 | */ | 404 | */ |
404 | spin_lock_irqsave(&ide_lock, flags); | 405 | spin_lock_irqsave(&ide_lock, flags); |
405 | blk_plug_device(drive->queue); | 406 | blk_plug_device(drive->queue); |
406 | spin_unlock_irqrestore(&ide_lock, flags); | 407 | spin_unlock_irqrestore(&ide_lock, |
408 | flags); | ||
407 | return 1; | 409 | return 1; |
408 | } | 410 | } |
409 | } | 411 | } |
@@ -430,11 +432,14 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
430 | * No point in re-trying a zillion times on a bad | 432 | * No point in re-trying a zillion times on a bad |
431 | * sector. If we got here the error is not correctable. | 433 | * sector. If we got here the error is not correctable. |
432 | */ | 434 | */ |
433 | ide_dump_status_no_sense(drive, "media error (bad sector)", stat); | 435 | ide_dump_status_no_sense(drive, |
436 | "media error (bad sector)", | ||
437 | stat); | ||
434 | do_end_request = 1; | 438 | do_end_request = 1; |
435 | } else if (sense_key == BLANK_CHECK) { | 439 | } else if (sense_key == BLANK_CHECK) { |
436 | /* disk appears blank ?? */ | 440 | /* disk appears blank ?? */ |
437 | ide_dump_status_no_sense(drive, "media error (blank)", stat); | 441 | ide_dump_status_no_sense(drive, "media error (blank)", |
442 | stat); | ||
438 | do_end_request = 1; | 443 | do_end_request = 1; |
439 | } else if ((err & ~ABRT_ERR) != 0) { | 444 | } else if ((err & ~ABRT_ERR) != 0) { |
440 | /* go to the default handler for other errors */ | 445 | /* go to the default handler for other errors */ |
@@ -504,7 +509,8 @@ static int cdrom_timer_expiry(ide_drive_t *drive) | |||
504 | break; | 509 | break; |
505 | default: | 510 | default: |
506 | if (!(rq->cmd_flags & REQ_QUIET)) | 511 | if (!(rq->cmd_flags & REQ_QUIET)) |
507 | printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]); | 512 | printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", |
513 | rq->cmd[0]); | ||
508 | wait = 0; | 514 | wait = 0; |
509 | break; | 515 | break; |
510 | } | 516 | } |
@@ -545,7 +551,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
545 | drive->waiting_for_dma = 0; | 551 | drive->waiting_for_dma = 0; |
546 | 552 | ||
547 | /* packet command */ | 553 | /* packet command */ |
548 | ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry); | 554 | ide_execute_command(drive, WIN_PACKETCMD, handler, |
555 | ATAPI_WAIT_PC, cdrom_timer_expiry); | ||
549 | return ide_started; | 556 | return ide_started; |
550 | } else { | 557 | } else { |
551 | unsigned long flags; | 558 | unsigned long flags; |
@@ -801,7 +808,8 @@ static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block) | |||
801 | 808 | ||
802 | info->dma = 0; | 809 | info->dma = 0; |
803 | info->start_seek = jiffies; | 810 | info->start_seek = jiffies; |
804 | return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation); | 811 | return cdrom_start_packet_command(drive, 0, |
812 | cdrom_start_seek_continuation); | ||
805 | } | 813 | } |
806 | 814 | ||
807 | /* | 815 | /* |
@@ -811,13 +819,15 @@ static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block) | |||
811 | static void restore_request(struct request *rq) | 819 | static void restore_request(struct request *rq) |
812 | { | 820 | { |
813 | if (rq->buffer != bio_data(rq->bio)) { | 821 | if (rq->buffer != bio_data(rq->bio)) { |
814 | sector_t n = (rq->buffer - (char *) bio_data(rq->bio)) / SECTOR_SIZE; | 822 | sector_t n = |
823 | (rq->buffer - (char *)bio_data(rq->bio)) / SECTOR_SIZE; | ||
815 | 824 | ||
816 | rq->buffer = bio_data(rq->bio); | 825 | rq->buffer = bio_data(rq->bio); |
817 | rq->nr_sectors += n; | 826 | rq->nr_sectors += n; |
818 | rq->sector -= n; | 827 | rq->sector -= n; |
819 | } | 828 | } |
820 | rq->hard_cur_sectors = rq->current_nr_sectors = bio_cur_sectors(rq->bio); | 829 | rq->current_nr_sectors = bio_cur_sectors(rq->bio); |
830 | rq->hard_cur_sectors = rq->current_nr_sectors; | ||
821 | rq->hard_nr_sectors = rq->nr_sectors; | 831 | rq->hard_nr_sectors = rq->nr_sectors; |
822 | rq->hard_sector = rq->sector; | 832 | rq->hard_sector = rq->sector; |
823 | rq->q->prep_rq_fn(rq->q, rq); | 833 | rq->q->prep_rq_fn(rq->q, rq); |
@@ -1182,7 +1192,8 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1182 | /* sg request */ | 1192 | /* sg request */ |
1183 | if (rq->bio) { | 1193 | if (rq->bio) { |
1184 | int mask = drive->queue->dma_alignment; | 1194 | int mask = drive->queue->dma_alignment; |
1185 | unsigned long addr = (unsigned long) page_address(bio_page(rq->bio)); | 1195 | unsigned long addr = |
1196 | (unsigned long)page_address(bio_page(rq->bio)); | ||
1186 | 1197 | ||
1187 | info->dma = drive->using_dma; | 1198 | info->dma = drive->using_dma; |
1188 | 1199 | ||
@@ -1197,7 +1208,8 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1197 | } | 1208 | } |
1198 | 1209 | ||
1199 | /* start sending the command to the drive */ | 1210 | /* start sending the command to the drive */ |
1200 | return cdrom_start_packet_command(drive, rq->data_len, cdrom_do_newpc_cont); | 1211 | return cdrom_start_packet_command(drive, rq->data_len, |
1212 | cdrom_do_newpc_cont); | ||
1201 | } | 1213 | } |
1202 | 1214 | ||
1203 | /* | 1215 | /* |
@@ -1216,14 +1228,19 @@ ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, sector_t block) | |||
1216 | 1228 | ||
1217 | if ((stat & SEEK_STAT) != SEEK_STAT) { | 1229 | if ((stat & SEEK_STAT) != SEEK_STAT) { |
1218 | if (elapsed < IDECD_SEEK_TIMEOUT) { | 1230 | if (elapsed < IDECD_SEEK_TIMEOUT) { |
1219 | ide_stall_queue(drive, IDECD_SEEK_TIMER); | 1231 | ide_stall_queue(drive, |
1232 | IDECD_SEEK_TIMER); | ||
1220 | return ide_stopped; | 1233 | return ide_stopped; |
1221 | } | 1234 | } |
1222 | printk(KERN_ERR "%s: DSC timeout\n", drive->name); | 1235 | printk(KERN_ERR "%s: DSC timeout\n", |
1236 | drive->name); | ||
1223 | } | 1237 | } |
1224 | info->cd_flags &= ~IDE_CD_FLAG_SEEKING; | 1238 | info->cd_flags &= ~IDE_CD_FLAG_SEEKING; |
1225 | } | 1239 | } |
1226 | if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) | 1240 | if (rq_data_dir(rq) == READ && |
1241 | IDE_LARGE_SEEK(info->last_block, block, | ||
1242 | IDECD_SEEK_THRESHOLD) && | ||
1243 | drive->dsc_overlap) | ||
1227 | action = cdrom_start_seek(drive, block); | 1244 | action = cdrom_start_seek(drive, block); |
1228 | else | 1245 | else |
1229 | action = cdrom_start_rw(drive, rq); | 1246 | action = cdrom_start_rw(drive, rq); |
@@ -1355,7 +1372,8 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense) | |||
1355 | /* try to allocate space */ | 1372 | /* try to allocate space */ |
1356 | toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); | 1373 | toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); |
1357 | if (toc == NULL) { | 1374 | if (toc == NULL) { |
1358 | printk(KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name); | 1375 | printk(KERN_ERR "%s: No cdrom TOC buffer!\n", |
1376 | drive->name); | ||
1359 | return -ENOMEM; | 1377 | return -ENOMEM; |
1360 | } | 1378 | } |
1361 | info->toc = toc; | 1379 | info->toc = toc; |
@@ -1598,7 +1616,8 @@ int ide_cdrom_probe_capabilities(ide_drive_t *drive) | |||
1598 | 1616 | ||
1599 | if (drive->media == ide_optical) { | 1617 | if (drive->media == ide_optical) { |
1600 | cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); | 1618 | cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); |
1601 | printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", drive->name); | 1619 | printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", |
1620 | drive->name); | ||
1602 | return nslots; | 1621 | return nslots; |
1603 | } | 1622 | } |
1604 | 1623 | ||
@@ -1897,7 +1916,8 @@ int ide_cdrom_setup(ide_drive_t *drive) | |||
1897 | drive->dsc_overlap = (drive->next != drive); | 1916 | drive->dsc_overlap = (drive->next != drive); |
1898 | 1917 | ||
1899 | if (ide_cdrom_register(drive, nslots)) { | 1918 | if (ide_cdrom_register(drive, nslots)) { |
1900 | printk(KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name); | 1919 | printk(KERN_ERR "%s: %s failed to register device with the" |
1920 | " cdrom driver.\n", drive->name, __func__); | ||
1901 | cd->devinfo.handle = NULL; | 1921 | cd->devinfo.handle = NULL; |
1902 | return 1; | 1922 | return 1; |
1903 | } | 1923 | } |
@@ -2094,17 +2114,20 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
2094 | /* skip drives that we were told to ignore */ | 2114 | /* skip drives that we were told to ignore */ |
2095 | if (ignore != NULL) { | 2115 | if (ignore != NULL) { |
2096 | if (strstr(ignore, drive->name)) { | 2116 | if (strstr(ignore, drive->name)) { |
2097 | printk(KERN_INFO "ide-cd: ignoring drive %s\n", drive->name); | 2117 | printk(KERN_INFO "ide-cd: ignoring drive %s\n", |
2118 | drive->name); | ||
2098 | goto failed; | 2119 | goto failed; |
2099 | } | 2120 | } |
2100 | } | 2121 | } |
2101 | if (drive->scsi) { | 2122 | if (drive->scsi) { |
2102 | printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name); | 2123 | printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi " |
2124 | "emulation.\n", drive->name); | ||
2103 | goto failed; | 2125 | goto failed; |
2104 | } | 2126 | } |
2105 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); | 2127 | info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); |
2106 | if (info == NULL) { | 2128 | if (info == NULL) { |
2107 | printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name); | 2129 | printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", |
2130 | drive->name); | ||
2108 | goto failed; | 2131 | goto failed; |
2109 | } | 2132 | } |
2110 | 2133 | ||