|
@@ -13,8 +13,8 @@
|
|
|
*
|
|
|
* Suggestions are welcome. Patches that work are more welcome though. ;-)
|
|
|
* For those wishing to work on this driver, please be sure you download
|
|
|
- * and comply with the latest Mt. Fuji (SFF8090 version 4) and ATAPI
|
|
|
- * (SFF-8020i rev 2.6) standards. These documents can be obtained by
|
|
|
+ * and comply with the latest Mt. Fuji (SFF8090 version 4) and ATAPI
|
|
|
+ * (SFF-8020i rev 2.6) standards. These documents can be obtained by
|
|
|
* anonymous ftp from:
|
|
|
* ftp://fission.dt.wdc.com/pub/standards/SFF_atapi/spec/SFF8020-r2.6/PS/8020r26.ps
|
|
|
* ftp://ftp.avc-pioneer.com/Mtfuji4/Spec/Fuji4r10.pdf
|
|
@@ -51,7 +51,7 @@
|
|
|
|
|
|
static DEFINE_MUTEX(idecd_ref_mutex);
|
|
|
|
|
|
-#define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref)
|
|
|
+#define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref)
|
|
|
|
|
|
#define ide_cd_g(disk) \
|
|
|
container_of((disk)->private_data, struct cdrom_info, driver)
|
|
@@ -83,13 +83,12 @@ static void ide_cd_put(struct cdrom_info *cd)
|
|
|
|
|
|
/* Mark that we've seen a media change, and invalidate our internal
|
|
|
buffers. */
|
|
|
-static void cdrom_saw_media_change (ide_drive_t *drive)
|
|
|
+static void cdrom_saw_media_change(ide_drive_t *drive)
|
|
|
{
|
|
|
struct cdrom_info *cd = drive->driver_data;
|
|
|
|
|
|
cd->cd_flags |= IDE_CD_FLAG_MEDIA_CHANGED;
|
|
|
cd->cd_flags &= ~IDE_CD_FLAG_TOC_VALID;
|
|
|
- cd->nsectors_buffered = 0;
|
|
|
}
|
|
|
|
|
|
static int cdrom_log_sense(ide_drive_t *drive, struct request *rq,
|
|
@@ -101,38 +100,39 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq,
|
|
|
return 0;
|
|
|
|
|
|
switch (sense->sense_key) {
|
|
|
- case NO_SENSE: case RECOVERED_ERROR:
|
|
|
- break;
|
|
|
- case NOT_READY:
|
|
|
- /*
|
|
|
- * don't care about tray state messages for
|
|
|
- * e.g. capacity commands or in-progress or
|
|
|
- * becoming ready
|
|
|
- */
|
|
|
- if (sense->asc == 0x3a || sense->asc == 0x04)
|
|
|
- break;
|
|
|
- log = 1;
|
|
|
- break;
|
|
|
- case ILLEGAL_REQUEST:
|
|
|
- /*
|
|
|
- * don't log START_STOP unit with LoEj set, since
|
|
|
- * we cannot reliably check if drive can auto-close
|
|
|
- */
|
|
|
- if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24)
|
|
|
- break;
|
|
|
- log = 1;
|
|
|
- break;
|
|
|
- case UNIT_ATTENTION:
|
|
|
- /*
|
|
|
- * Make good and sure we've seen this potential media
|
|
|
- * change. Some drives (i.e. Creative) fail to present
|
|
|
- * the correct sense key in the error register.
|
|
|
- */
|
|
|
- cdrom_saw_media_change(drive);
|
|
|
+ case NO_SENSE:
|
|
|
+ case RECOVERED_ERROR:
|
|
|
+ break;
|
|
|
+ case NOT_READY:
|
|
|
+ /*
|
|
|
+ * don't care about tray state messages for
|
|
|
+ * e.g. capacity commands or in-progress or
|
|
|
+ * becoming ready
|
|
|
+ */
|
|
|
+ if (sense->asc == 0x3a || sense->asc == 0x04)
|
|
|
break;
|
|
|
- default:
|
|
|
- log = 1;
|
|
|
+ log = 1;
|
|
|
+ break;
|
|
|
+ case ILLEGAL_REQUEST:
|
|
|
+ /*
|
|
|
+ * don't log START_STOP unit with LoEj set, since
|
|
|
+ * we cannot reliably check if drive can auto-close
|
|
|
+ */
|
|
|
+ if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24)
|
|
|
break;
|
|
|
+ log = 1;
|
|
|
+ break;
|
|
|
+ case UNIT_ATTENTION:
|
|
|
+ /*
|
|
|
+ * Make good and sure we've seen this potential media
|
|
|
+ * change. Some drives (i.e. Creative) fail to present
|
|
|
+ * the correct sense key in the error register.
|
|
|
+ */
|
|
|
+ cdrom_saw_media_change(drive);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ log = 1;
|
|
|
+ break;
|
|
|
}
|
|
|
return log;
|
|
|
}
|
|
@@ -159,8 +159,8 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
|
|
|
if (sense->sense_key == 0x05 && sense->asc == 0x24)
|
|
|
return;
|
|
|
|
|
|
- if (sense->error_code == 0x70) { /* Current Error */
|
|
|
- switch(sense->sense_key) {
|
|
|
+ if (sense->error_code == 0x70) { /* Current Error */
|
|
|
+ switch (sense->sense_key) {
|
|
|
case MEDIUM_ERROR:
|
|
|
case VOLUME_OVERFLOW:
|
|
|
case ILLEGAL_REQUEST:
|
|
@@ -179,7 +179,7 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
|
|
|
bio_sectors = 4;
|
|
|
if (drive->queue->hardsect_size == 2048)
|
|
|
sector <<= 2; /* Device sector size is 2K */
|
|
|
- sector &= ~(bio_sectors -1);
|
|
|
+ sector &= ~(bio_sectors - 1);
|
|
|
valid = (sector - failed_command->sector) << 9;
|
|
|
|
|
|
if (valid < 0)
|
|
@@ -188,8 +188,8 @@ void cdrom_analyze_sense_data(ide_drive_t *drive,
|
|
|
drive->probed_capacity - sector < 4 * 75) {
|
|
|
set_capacity(info->disk, sector);
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
ide_cd_log_error(drive->name, failed_command, sense);
|
|
|
}
|
|
@@ -230,7 +230,7 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
|
|
|
(void) ide_do_drive_cmd(drive, rq, ide_preempt);
|
|
|
}
|
|
|
|
|
|
-static void cdrom_end_request (ide_drive_t *drive, int uptodate)
|
|
|
+static void cdrom_end_request(ide_drive_t *drive, int uptodate)
|
|
|
{
|
|
|
struct request *rq = HWGROUP(drive)->rq;
|
|
|
int nsectors = rq->hard_cur_sectors;
|
|
@@ -293,7 +293,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
|
|
|
{
|
|
|
struct request *rq = HWGROUP(drive)->rq;
|
|
|
int stat, err, sense_key;
|
|
|
-
|
|
|
+
|
|
|
/* Check for errors. */
|
|
|
stat = ide_read_status(drive);
|
|
|
|
|
@@ -334,26 +334,26 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
|
|
|
|
|
|
/* Check for tray open. */
|
|
|
if (sense_key == NOT_READY) {
|
|
|
- cdrom_saw_media_change (drive);
|
|
|
+ cdrom_saw_media_change(drive);
|
|
|
} else if (sense_key == UNIT_ATTENTION) {
|
|
|
/* Check for media change. */
|
|
|
- cdrom_saw_media_change (drive);
|
|
|
+ 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 (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);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
rq->cmd_flags |= REQ_FAILED;
|
|
|
|
|
|
/*
|
|
@@ -374,10 +374,10 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
|
|
|
if (sense_key == NOT_READY) {
|
|
|
/* Tray open. */
|
|
|
if (rq_data_dir(rq) == READ) {
|
|
|
- cdrom_saw_media_change (drive);
|
|
|
+ cdrom_saw_media_change(drive);
|
|
|
|
|
|
/* Fail the request. */
|
|
|
- printk ("%s: tray open\n", drive->name);
|
|
|
+ printk("%s: tray open\n", drive->name);
|
|
|
do_end_request = 1;
|
|
|
} else {
|
|
|
struct cdrom_info *info = drive->driver_data;
|
|
@@ -399,7 +399,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
|
|
|
*/
|
|
|
spin_lock_irqsave(&ide_lock, flags);
|
|
|
blk_plug_device(drive->queue);
|
|
|
- spin_unlock_irqrestore(&ide_lock,flags);
|
|
|
+ spin_unlock_irqrestore(&ide_lock, flags);
|
|
|
return 1;
|
|
|
}
|
|
|
}
|
|
@@ -407,25 +407,31 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
|
|
|
/* Media change. */
|
|
|
cdrom_saw_media_change (drive);
|
|
|
|
|
|
- /* Arrange to retry the request.
|
|
|
- But be sure to give up if we've retried
|
|
|
- too many times. */
|
|
|
+ /*
|
|
|
+ * Arrange to retry the request.
|
|
|
+ * But be sure to give up if we've retried
|
|
|
+ * too many times.
|
|
|
+ */
|
|
|
if (++rq->errors > ERROR_MAX)
|
|
|
do_end_request = 1;
|
|
|
} else if (sense_key == ILLEGAL_REQUEST ||
|
|
|
sense_key == DATA_PROTECT) {
|
|
|
- /* No point in retrying after an illegal
|
|
|
- request or data protect error.*/
|
|
|
- ide_dump_status_no_sense (drive, "command error", stat);
|
|
|
+ /*
|
|
|
+ * No point in retrying after an illegal
|
|
|
+ * request or data protect error.
|
|
|
+ */
|
|
|
+ ide_dump_status_no_sense(drive, "command error", stat);
|
|
|
do_end_request = 1;
|
|
|
} else if (sense_key == MEDIUM_ERROR) {
|
|
|
- /* No point in re-trying a zillion times on a bad
|
|
|
- * sector... If we got here the error is not correctable */
|
|
|
- ide_dump_status_no_sense (drive, "media error (bad sector)", stat);
|
|
|
+ /*
|
|
|
+ * No point in re-trying a zillion times on a bad
|
|
|
+ * sector... If we got here the error is not correctable
|
|
|
+ */
|
|
|
+ ide_dump_status_no_sense(drive, "media error (bad sector)", stat);
|
|
|
do_end_request = 1;
|
|
|
} else if (sense_key == BLANK_CHECK) {
|
|
|
/* 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;
|
|
|
} else if ((err & ~ABRT_ERR) != 0) {
|
|
|
/* Go to the default handler
|
|
@@ -486,18 +492,18 @@ static int cdrom_timer_expiry(ide_drive_t *drive)
|
|
|
* ide_timer_expiry keep polling us for these.
|
|
|
*/
|
|
|
switch (rq->cmd[0]) {
|
|
|
- case GPCMD_BLANK:
|
|
|
- case GPCMD_FORMAT_UNIT:
|
|
|
- case GPCMD_RESERVE_RZONE_TRACK:
|
|
|
- case GPCMD_CLOSE_TRACK:
|
|
|
- case GPCMD_FLUSH_CACHE:
|
|
|
- wait = ATAPI_WAIT_PC;
|
|
|
- break;
|
|
|
- default:
|
|
|
- if (!(rq->cmd_flags & REQ_QUIET))
|
|
|
- printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]);
|
|
|
- wait = 0;
|
|
|
- break;
|
|
|
+ case GPCMD_BLANK:
|
|
|
+ case GPCMD_FORMAT_UNIT:
|
|
|
+ case GPCMD_RESERVE_RZONE_TRACK:
|
|
|
+ case GPCMD_CLOSE_TRACK:
|
|
|
+ case GPCMD_FLUSH_CACHE:
|
|
|
+ wait = ATAPI_WAIT_PC;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ if (!(rq->cmd_flags & REQ_QUIET))
|
|
|
+ printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]);
|
|
|
+ wait = 0;
|
|
|
+ break;
|
|
|
}
|
|
|
return wait;
|
|
|
}
|
|
@@ -557,7 +563,7 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
|
|
|
HANDLER is the interrupt handler to call when the command completes
|
|
|
or there's data ready. */
|
|
|
#define ATAPI_MIN_CDB_BYTES 12
|
|
|
-static ide_startstop_t cdrom_transfer_packet_command (ide_drive_t *drive,
|
|
|
+static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,
|
|
|
struct request *rq,
|
|
|
ide_handler_t *handler)
|
|
|
{
|
|
@@ -625,47 +631,6 @@ static void ide_cd_drain_data(ide_drive_t *drive, int nsects)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
- * Buffer up to SECTORS_TO_TRANSFER sectors from the drive in our sector
|
|
|
- * buffer. Once the first sector is added, any subsequent sectors are
|
|
|
- * assumed to be continuous (until the buffer is cleared). For the first
|
|
|
- * sector added, SECTOR is its sector number. (SECTOR is then ignored until
|
|
|
- * the buffer is cleared.)
|
|
|
- */
|
|
|
-static void cdrom_buffer_sectors (ide_drive_t *drive, unsigned long sector,
|
|
|
- int sectors_to_transfer)
|
|
|
-{
|
|
|
- struct cdrom_info *info = drive->driver_data;
|
|
|
-
|
|
|
- /* Number of sectors to read into the buffer. */
|
|
|
- int sectors_to_buffer = min_t(int, sectors_to_transfer,
|
|
|
- (SECTOR_BUFFER_SIZE >> SECTOR_BITS) -
|
|
|
- info->nsectors_buffered);
|
|
|
-
|
|
|
- char *dest;
|
|
|
-
|
|
|
- /* If we couldn't get a buffer, don't try to buffer anything... */
|
|
|
- if (info->buffer == NULL)
|
|
|
- sectors_to_buffer = 0;
|
|
|
-
|
|
|
- /* If this is the first sector in the buffer, remember its number. */
|
|
|
- if (info->nsectors_buffered == 0)
|
|
|
- info->sector_buffered = sector;
|
|
|
-
|
|
|
- /* Read the data into the buffer. */
|
|
|
- dest = info->buffer + info->nsectors_buffered * SECTOR_SIZE;
|
|
|
- while (sectors_to_buffer > 0) {
|
|
|
- HWIF(drive)->atapi_input_bytes(drive, dest, SECTOR_SIZE);
|
|
|
- --sectors_to_buffer;
|
|
|
- --sectors_to_transfer;
|
|
|
- ++info->nsectors_buffered;
|
|
|
- dest += SECTOR_SIZE;
|
|
|
- }
|
|
|
-
|
|
|
- /* Throw away any remaining data. */
|
|
|
- ide_cd_drain_data(drive, sectors_to_transfer);
|
|
|
-}
|
|
|
-
|
|
|
/*
|
|
|
* Check the contents of the interrupt reason register from the cdrom
|
|
|
* and attempt to recover if there are problems. Returns 0 if everything's
|
|
@@ -686,7 +651,7 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq,
|
|
|
|
|
|
/* Whoops... */
|
|
|
printk(KERN_ERR "%s: %s: wrong transfer direction!\n",
|
|
|
- drive->name, __FUNCTION__);
|
|
|
+ drive->name, __func__);
|
|
|
|
|
|
xf = rw ? hwif->atapi_output_bytes : hwif->atapi_input_bytes;
|
|
|
ide_cd_pad_transfer(drive, xf, len);
|
|
@@ -699,7 +664,7 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq,
|
|
|
} else {
|
|
|
/* Drive wants a command packet, or invalid ireason... */
|
|
|
printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n",
|
|
|
- drive->name, __FUNCTION__, ireason);
|
|
|
+ drive->name, __func__, ireason);
|
|
|
}
|
|
|
|
|
|
if (rq->cmd_type == REQ_TYPE_ATA_PC)
|
|
@@ -721,7 +686,7 @@ static int ide_cd_check_transfer_size(ide_drive_t *drive, int len)
|
|
|
return 0;
|
|
|
|
|
|
printk(KERN_ERR "%s: %s: Bad transfer size %d\n",
|
|
|
- drive->name, __FUNCTION__, len);
|
|
|
+ drive->name, __func__, len);
|
|
|
|
|
|
if (cd->cd_flags & IDE_CD_FLAG_LIMIT_NFRAMES)
|
|
|
printk(KERN_ERR " This drive is not supported by "
|
|
@@ -734,65 +699,6 @@ static int ide_cd_check_transfer_size(ide_drive_t *drive, int len)
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
- * Try to satisfy some of the current read request from our cached data.
|
|
|
- * Returns nonzero if the request has been completed, zero otherwise.
|
|
|
- */
|
|
|
-static int cdrom_read_from_buffer (ide_drive_t *drive)
|
|
|
-{
|
|
|
- struct cdrom_info *info = drive->driver_data;
|
|
|
- struct request *rq = HWGROUP(drive)->rq;
|
|
|
- unsigned short sectors_per_frame;
|
|
|
-
|
|
|
- sectors_per_frame = queue_hardsect_size(drive->queue) >> SECTOR_BITS;
|
|
|
-
|
|
|
- /* Can't do anything if there's no buffer. */
|
|
|
- if (info->buffer == NULL) return 0;
|
|
|
-
|
|
|
- /* Loop while this request needs data and the next block is present
|
|
|
- in our cache. */
|
|
|
- while (rq->nr_sectors > 0 &&
|
|
|
- rq->sector >= info->sector_buffered &&
|
|
|
- rq->sector < info->sector_buffered + info->nsectors_buffered) {
|
|
|
- if (rq->current_nr_sectors == 0)
|
|
|
- cdrom_end_request(drive, 1);
|
|
|
-
|
|
|
- memcpy (rq->buffer,
|
|
|
- info->buffer +
|
|
|
- (rq->sector - info->sector_buffered) * SECTOR_SIZE,
|
|
|
- SECTOR_SIZE);
|
|
|
- rq->buffer += SECTOR_SIZE;
|
|
|
- --rq->current_nr_sectors;
|
|
|
- --rq->nr_sectors;
|
|
|
- ++rq->sector;
|
|
|
- }
|
|
|
-
|
|
|
- /* If we've satisfied the current request,
|
|
|
- terminate it successfully. */
|
|
|
- if (rq->nr_sectors == 0) {
|
|
|
- cdrom_end_request(drive, 1);
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- /* Move on to the next buffer if needed. */
|
|
|
- if (rq->current_nr_sectors == 0)
|
|
|
- cdrom_end_request(drive, 1);
|
|
|
-
|
|
|
- /* If this condition does not hold, then the kluge i use to
|
|
|
- represent the number of sectors to skip at the start of a transfer
|
|
|
- will fail. I think that this will never happen, but let's be
|
|
|
- paranoid and check. */
|
|
|
- if (rq->current_nr_sectors < bio_cur_sectors(rq->bio) &&
|
|
|
- (rq->sector & (sectors_per_frame - 1))) {
|
|
|
- printk(KERN_ERR "%s: cdrom_read_from_buffer: buffer botch (%ld)\n",
|
|
|
- drive->name, (long)rq->sector);
|
|
|
- cdrom_end_request(drive, 0);
|
|
|
- return -1;
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
-}
|
|
|
-
|
|
|
static ide_startstop_t cdrom_newpc_intr(ide_drive_t *);
|
|
|
|
|
|
/*
|
|
@@ -825,7 +731,7 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
|
|
|
if (rq->current_nr_sectors !=
|
|
|
bio_cur_sectors(rq->bio)) {
|
|
|
printk(KERN_ERR "%s: %s: buffer botch (%u)\n",
|
|
|
- drive->name, __FUNCTION__,
|
|
|
+ drive->name, __func__,
|
|
|
rq->current_nr_sectors);
|
|
|
cdrom_end_request(drive, 0);
|
|
|
return ide_stopped;
|
|
@@ -849,7 +755,7 @@ static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive)
|
|
|
#define IDECD_SEEK_TIMER (5 * WAIT_MIN_SLEEP) /* 100 ms */
|
|
|
#define IDECD_SEEK_TIMEOUT (2 * WAIT_CMD) /* 20 sec */
|
|
|
|
|
|
-static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive)
|
|
|
+static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive)
|
|
|
{
|
|
|
struct cdrom_info *info = drive->driver_data;
|
|
|
int stat;
|
|
@@ -866,14 +772,14 @@ static ide_startstop_t cdrom_seek_intr (ide_drive_t *drive)
|
|
|
* this condition is far too common, to bother
|
|
|
* users about it
|
|
|
*/
|
|
|
- /* printk("%s: disabled DSC seek overlap\n", drive->name);*/
|
|
|
+ /* printk("%s: disabled DSC seek overlap\n", drive->name);*/
|
|
|
drive->dsc_overlap = 0;
|
|
|
}
|
|
|
}
|
|
|
return ide_stopped;
|
|
|
}
|
|
|
|
|
|
-static ide_startstop_t cdrom_start_seek_continuation (ide_drive_t *drive)
|
|
|
+static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive)
|
|
|
{
|
|
|
struct request *rq = HWGROUP(drive)->rq;
|
|
|
sector_t frame = rq->sector;
|
|
@@ -888,7 +794,7 @@ static ide_startstop_t cdrom_start_seek_continuation (ide_drive_t *drive)
|
|
|
return cdrom_transfer_packet_command(drive, rq, &cdrom_seek_intr);
|
|
|
}
|
|
|
|
|
|
-static ide_startstop_t cdrom_start_seek (ide_drive_t *drive, unsigned int block)
|
|
|
+static ide_startstop_t cdrom_start_seek(ide_drive_t *drive, unsigned int block)
|
|
|
{
|
|
|
struct cdrom_info *info = drive->driver_data;
|
|
|
|
|
@@ -897,9 +803,11 @@ static ide_startstop_t cdrom_start_seek (ide_drive_t *drive, unsigned int block)
|
|
|
return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation);
|
|
|
}
|
|
|
|
|
|
-/* Fix up a possibly partially-processed request so that we can
|
|
|
- start it over entirely, or even put it back on the request queue. */
|
|
|
-static void restore_request (struct request *rq)
|
|
|
+/*
|
|
|
+ * Fix up a possibly partially-processed request so that we can
|
|
|
+ * start it over entirely, or even put it back on the request queue.
|
|
|
+ */
|
|
|
+static void restore_request(struct request *rq)
|
|
|
{
|
|
|
if (rq->buffer != bio_data(rq->bio)) {
|
|
|
sector_t n = (rq->buffer - (char *) bio_data(rq->bio)) / SECTOR_SIZE;
|
|
@@ -950,7 +858,7 @@ int ide_cd_queue_pc(ide_drive_t *drive, struct request *rq)
|
|
|
error = ide_do_drive_cmd(drive, rq, ide_wait);
|
|
|
time = jiffies - time;
|
|
|
|
|
|
- /* FIXME: we should probably abort/retry or something
|
|
|
+ /* FIXME: we should probably abort/retry or something
|
|
|
* in case of failure */
|
|
|
if (rq->cmd_flags & REQ_FAILED) {
|
|
|
/* The request failed. Retry if it was due to a unit
|
|
@@ -1057,7 +965,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
|
|
|
if (rq->current_nr_sectors > 0) {
|
|
|
printk(KERN_ERR "%s: %s: data underrun "
|
|
|
"(%d blocks)\n",
|
|
|
- drive->name, __FUNCTION__,
|
|
|
+ drive->name, __func__,
|
|
|
rq->current_nr_sectors);
|
|
|
if (!write)
|
|
|
rq->cmd_flags |= REQ_FAILED;
|
|
@@ -1134,11 +1042,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
|
|
|
if (!ptr) {
|
|
|
if (blk_fs_request(rq) && !write)
|
|
|
/*
|
|
|
- * If the buffers are full, cache the rest
|
|
|
- * of the data in our internal buffer.
|
|
|
- */
|
|
|
- cdrom_buffer_sectors(drive, rq->sector,
|
|
|
- thislen >> 9);
|
|
|
+ * If the buffers are full, pipe the rest into
|
|
|
+ * oblivion. */
|
|
|
+ ide_cd_drain_data(drive, thislen >> 9);
|
|
|
else {
|
|
|
printk(KERN_ERR "%s: confused, missing data\n",
|
|
|
drive->name);
|
|
@@ -1243,10 +1149,6 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
|
|
|
* weirdness which might be present in the request packet.
|
|
|
*/
|
|
|
restore_request(rq);
|
|
|
-
|
|
|
- /* Satisfy whatever we can of this request from our cache. */
|
|
|
- if (cdrom_read_from_buffer(drive))
|
|
|
- return ide_stopped;
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -1262,9 +1164,6 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
|
|
|
} else
|
|
|
cd->dma = drive->using_dma;
|
|
|
|
|
|
- /* Clear the local sector buffer. */
|
|
|
- cd->nsectors_buffered = 0;
|
|
|
-
|
|
|
if (write)
|
|
|
cd->devinfo.media_written = 1;
|
|
|
|
|
@@ -1320,7 +1219,7 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
|
|
|
* cdrom driver request routine.
|
|
|
*/
|
|
|
static ide_startstop_t
|
|
|
-ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block)
|
|
|
+ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, sector_t block)
|
|
|
{
|
|
|
ide_startstop_t action;
|
|
|
struct cdrom_info *info = drive->driver_data;
|
|
@@ -1335,13 +1234,13 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block)
|
|
|
ide_stall_queue(drive, IDECD_SEEK_TIMER);
|
|
|
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;
|
|
|
}
|
|
|
- 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);
|
|
|
- } else
|
|
|
+ else
|
|
|
action = cdrom_start_rw(drive, rq);
|
|
|
info->last_block = block;
|
|
|
return action;
|
|
@@ -1374,7 +1273,7 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block)
|
|
|
*/
|
|
|
|
|
|
static
|
|
|
-void msf_from_bcd (struct atapi_msf *msf)
|
|
|
+void msf_from_bcd(struct atapi_msf *msf)
|
|
|
{
|
|
|
msf->minute = BCD2BIN(msf->minute);
|
|
|
msf->second = BCD2BIN(msf->second);
|
|
@@ -1474,7 +1373,7 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
|
|
|
/* Try to allocate space. */
|
|
|
toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL);
|
|
|
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;
|
|
|
}
|
|
|
info->toc = toc;
|
|
@@ -1569,9 +1468,9 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
|
|
|
toc->ent[i].track = BCD2BIN(toc->ent[i].track);
|
|
|
msf_from_bcd(&toc->ent[i].addr.msf);
|
|
|
}
|
|
|
- toc->ent[i].addr.lba = msf_to_lba (toc->ent[i].addr.msf.minute,
|
|
|
- toc->ent[i].addr.msf.second,
|
|
|
- toc->ent[i].addr.msf.frame);
|
|
|
+ toc->ent[i].addr.lba = msf_to_lba(toc->ent[i].addr.msf.minute,
|
|
|
+ toc->ent[i].addr.msf.second,
|
|
|
+ toc->ent[i].addr.msf.frame);
|
|
|
}
|
|
|
|
|
|
/* Read the multisession information. */
|
|
@@ -1595,9 +1494,9 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
|
|
|
if (stat)
|
|
|
return stat;
|
|
|
|
|
|
- msf_from_bcd (&ms_tmp.ent.addr.msf);
|
|
|
+ msf_from_bcd(&ms_tmp.ent.addr.msf);
|
|
|
toc->last_session_lba = msf_to_lba(ms_tmp.ent.addr.msf.minute,
|
|
|
- ms_tmp.ent.addr.msf.second,
|
|
|
+ ms_tmp.ent.addr.msf.second,
|
|
|
ms_tmp.ent.addr.msf.frame);
|
|
|
}
|
|
|
|
|
@@ -1679,7 +1578,7 @@ static struct cdrom_device_ops ide_cdrom_dops = {
|
|
|
.generic_packet = ide_cdrom_packet,
|
|
|
};
|
|
|
|
|
|
-static int ide_cdrom_register (ide_drive_t *drive, int nslots)
|
|
|
+static int ide_cdrom_register(ide_drive_t *drive, int nslots)
|
|
|
{
|
|
|
struct cdrom_info *info = drive->driver_data;
|
|
|
struct cdrom_device_info *devinfo = &info->devinfo;
|
|
@@ -1698,7 +1597,7 @@ static int ide_cdrom_register (ide_drive_t *drive, int nslots)
|
|
|
}
|
|
|
|
|
|
static
|
|
|
-int ide_cdrom_probe_capabilities (ide_drive_t *drive)
|
|
|
+int ide_cdrom_probe_capabilities(ide_drive_t *drive)
|
|
|
{
|
|
|
struct cdrom_info *cd = drive->driver_data;
|
|
|
struct cdrom_device_info *cdi = &cd->devinfo;
|
|
@@ -1870,7 +1769,7 @@ static int ide_cdrom_prep_pc(struct request *rq)
|
|
|
rq->errors = ILLEGAL_REQUEST;
|
|
|
return BLKPREP_KILL;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return BLKPREP_OK;
|
|
|
}
|
|
|
|
|
@@ -1948,7 +1847,7 @@ static unsigned int ide_cd_flags(struct hd_driveid *id)
|
|
|
}
|
|
|
|
|
|
static
|
|
|
-int ide_cdrom_setup (ide_drive_t *drive)
|
|
|
+int ide_cdrom_setup(ide_drive_t *drive)
|
|
|
{
|
|
|
struct cdrom_info *cd = drive->driver_data;
|
|
|
struct cdrom_device_info *cdi = &cd->devinfo;
|
|
@@ -1979,7 +1878,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
|
|
|
else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD)
|
|
|
cdi->sanyo_slot = 3; /* 3 => use CD in slot 0 */
|
|
|
|
|
|
- nslots = ide_cdrom_probe_capabilities (drive);
|
|
|
+ nslots = ide_cdrom_probe_capabilities(drive);
|
|
|
|
|
|
/*
|
|
|
* set correct block size
|
|
@@ -1991,7 +1890,7 @@ int ide_cdrom_setup (ide_drive_t *drive)
|
|
|
drive->dsc_overlap = (drive->next != drive);
|
|
|
|
|
|
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: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name);
|
|
|
cd->devinfo.handle = NULL;
|
|
|
return 1;
|
|
|
}
|
|
@@ -1999,19 +1898,6 @@ int ide_cdrom_setup (ide_drive_t *drive)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-#ifdef CONFIG_IDE_PROC_FS
|
|
|
-static
|
|
|
-sector_t ide_cdrom_capacity (ide_drive_t *drive)
|
|
|
-{
|
|
|
- unsigned long capacity, sectors_per_frame;
|
|
|
-
|
|
|
- if (cdrom_read_capacity(drive, &capacity, §ors_per_frame, NULL))
|
|
|
- return 0;
|
|
|
-
|
|
|
- return capacity * sectors_per_frame;
|
|
|
-}
|
|
|
-#endif
|
|
|
-
|
|
|
static void ide_cd_remove(ide_drive_t *drive)
|
|
|
{
|
|
|
struct cdrom_info *info = drive->driver_data;
|
|
@@ -2030,7 +1916,6 @@ static void ide_cd_release(struct kref *kref)
|
|
|
ide_drive_t *drive = info->drive;
|
|
|
struct gendisk *g = info->disk;
|
|
|
|
|
|
- kfree(info->buffer);
|
|
|
kfree(info->toc);
|
|
|
if (devinfo->handle == drive)
|
|
|
unregister_cdrom(devinfo);
|
|
@@ -2045,14 +1930,24 @@ static void ide_cd_release(struct kref *kref)
|
|
|
static int ide_cd_probe(ide_drive_t *);
|
|
|
|
|
|
#ifdef CONFIG_IDE_PROC_FS
|
|
|
+static sector_t ide_cdrom_capacity(ide_drive_t *drive)
|
|
|
+{
|
|
|
+ unsigned long capacity, sectors_per_frame;
|
|
|
+
|
|
|
+ if (cdrom_read_capacity(drive, &capacity, §ors_per_frame, NULL))
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ return capacity * sectors_per_frame;
|
|
|
+}
|
|
|
+
|
|
|
static int proc_idecd_read_capacity
|
|
|
(char *page, char **start, off_t off, int count, int *eof, void *data)
|
|
|
{
|
|
|
ide_drive_t *drive = data;
|
|
|
int len;
|
|
|
|
|
|
- len = sprintf(page,"%llu\n", (long long)ide_cdrom_capacity(drive));
|
|
|
- PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
|
|
|
+ len = sprintf(page, "%llu\n", (long long)ide_cdrom_capacity(drive));
|
|
|
+ PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
|
|
|
}
|
|
|
|
|
|
static ide_proc_entry_t idecd_proc[] = {
|
|
@@ -2081,20 +1976,17 @@ static ide_driver_t ide_cdrom_driver = {
|
|
|
#endif
|
|
|
};
|
|
|
|
|
|
-static int idecd_open(struct inode * inode, struct file * file)
|
|
|
+static int idecd_open(struct inode *inode, struct file *file)
|
|
|
{
|
|
|
struct gendisk *disk = inode->i_bdev->bd_disk;
|
|
|
struct cdrom_info *info;
|
|
|
int rc = -ENOMEM;
|
|
|
|
|
|
- if (!(info = ide_cd_get(disk)))
|
|
|
+ info = ide_cd_get(disk);
|
|
|
+ if (!info)
|
|
|
return -ENXIO;
|
|
|
|
|
|
- if (!info->buffer)
|
|
|
- info->buffer = kmalloc(SECTOR_BUFFER_SIZE, GFP_KERNEL|__GFP_REPEAT);
|
|
|
-
|
|
|
- if (info->buffer)
|
|
|
- rc = cdrom_open(&info->devinfo, inode, file);
|
|
|
+ rc = cdrom_open(&info->devinfo, inode, file);
|
|
|
|
|
|
if (rc < 0)
|
|
|
ide_cd_put(info);
|
|
@@ -2102,12 +1994,12 @@ static int idecd_open(struct inode * inode, struct file * file)
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
-static int idecd_release(struct inode * inode, struct file * file)
|
|
|
+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);
|
|
|
|
|
|
- cdrom_release (&info->devinfo, file);
|
|
|
+ cdrom_release(&info->devinfo, file);
|
|
|
|
|
|
ide_cd_put(info);
|
|
|
|
|
@@ -2139,7 +2031,7 @@ static int idecd_get_spindown(struct cdrom_device_info *cdi, unsigned long arg)
|
|
|
struct packet_command cgc;
|
|
|
char buffer[16];
|
|
|
int stat;
|
|
|
- char spindown;
|
|
|
+ char spindown;
|
|
|
|
|
|
init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN);
|
|
|
|
|
@@ -2148,12 +2040,12 @@ static int idecd_get_spindown(struct cdrom_device_info *cdi, unsigned long arg)
|
|
|
return stat;
|
|
|
|
|
|
spindown = buffer[11] & 0x0f;
|
|
|
- if (copy_to_user((void __user *)arg, &spindown, sizeof (char)))
|
|
|
+ if (copy_to_user((void __user *)arg, &spindown, sizeof(char)))
|
|
|
return -EFAULT;
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static int idecd_ioctl (struct inode *inode, struct file *file,
|
|
|
+static int idecd_ioctl(struct inode *inode, struct file *file,
|
|
|
unsigned int cmd, unsigned long arg)
|
|
|
{
|
|
|
struct block_device *bdev = inode->i_bdev;
|
|
@@ -2161,13 +2053,13 @@ static int idecd_ioctl (struct inode *inode, struct file *file,
|
|
|
int err;
|
|
|
|
|
|
switch (cmd) {
|
|
|
- case CDROMSETSPINDOWN:
|
|
|
+ case CDROMSETSPINDOWN:
|
|
|
return idecd_set_spindown(&info->devinfo, arg);
|
|
|
- case CDROMGETSPINDOWN:
|
|
|
+ case CDROMGETSPINDOWN:
|
|
|
return idecd_get_spindown(&info->devinfo, arg);
|
|
|
default:
|
|
|
break;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg);
|
|
|
if (err == -EINVAL)
|
|
@@ -2193,16 +2085,16 @@ static int idecd_revalidate_disk(struct gendisk *disk)
|
|
|
}
|
|
|
|
|
|
static struct block_device_operations idecd_ops = {
|
|
|
- .owner = THIS_MODULE,
|
|
|
- .open = idecd_open,
|
|
|
- .release = idecd_release,
|
|
|
- .ioctl = idecd_ioctl,
|
|
|
- .media_changed = idecd_media_changed,
|
|
|
- .revalidate_disk= idecd_revalidate_disk
|
|
|
+ .owner = THIS_MODULE,
|
|
|
+ .open = idecd_open,
|
|
|
+ .release = idecd_release,
|
|
|
+ .ioctl = idecd_ioctl,
|
|
|
+ .media_changed = idecd_media_changed,
|
|
|
+ .revalidate_disk = idecd_revalidate_disk
|
|
|
};
|
|
|
|
|
|
/* options */
|
|
|
-static char *ignore = NULL;
|
|
|
+static char *ignore;
|
|
|
|
|
|
module_param(ignore, charp, 0400);
|
|
|
MODULE_DESCRIPTION("ATAPI CD-ROM Driver");
|