Commit 5191903e authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] Re: IDE cleanup for 2.5.4-pre3

The end_request() function familiy (not the global one, but the IDE
specific ones), did bear a permuted parameter ordering.  After fixing
this it turned out that at all places the huk parameter wasn't the
hwgroup, but just the drive in question itself.  I have changed this to
be more sane, which allowed to remove many unneccessary code
duplication, or rather obfuscation, in between the __ide_end_request()
and ide_end_request() functions.  This simplification is actually the
"spreading" part of the game. 
parent 2796576e
...@@ -727,7 +727,7 @@ static ide_startstop_t etrax_dma_intr (ide_drive_t *drive) ...@@ -727,7 +727,7 @@ static ide_startstop_t etrax_dma_intr (ide_drive_t *drive)
rq = HWGROUP(drive)->rq; rq = HWGROUP(drive)->rq;
for (i = rq->nr_sectors; i > 0;) { for (i = rq->nr_sectors; i > 0;) {
i -= rq->current_nr_sectors; i -= rq->current_nr_sectors;
ide_end_request(1, HWGROUP(drive)); ide_end_request(drive, 1);
} }
return ide_stopped; return ide_stopped;
} }
......
...@@ -341,7 +341,7 @@ static ide_startstop_t icside_dmaintr(ide_drive_t *drive) ...@@ -341,7 +341,7 @@ static ide_startstop_t icside_dmaintr(ide_drive_t *drive)
rq = HWGROUP(drive)->rq; rq = HWGROUP(drive)->rq;
for (i = rq->nr_sectors; i > 0;) { for (i = rq->nr_sectors; i > 0;) {
i -= rq->current_nr_sectors; i -= rq->current_nr_sectors;
ide_end_request(1, HWGROUP(drive)); ide_end_request(drive, 1);
} }
return ide_stopped; return ide_stopped;
} }
......
...@@ -540,7 +540,7 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, ...@@ -540,7 +540,7 @@ static void cdrom_queue_request_sense(ide_drive_t *drive,
} }
static void cdrom_end_request (int uptodate, ide_drive_t *drive) static void cdrom_end_request(ide_drive_t *drive, int uptodate)
{ {
struct request *rq = HWGROUP(drive)->rq; struct request *rq = HWGROUP(drive)->rq;
...@@ -554,7 +554,7 @@ static void cdrom_end_request (int uptodate, ide_drive_t *drive) ...@@ -554,7 +554,7 @@ static void cdrom_end_request (int uptodate, ide_drive_t *drive)
if ((rq->flags & REQ_CMD) && !rq->current_nr_sectors) if ((rq->flags & REQ_CMD) && !rq->current_nr_sectors)
uptodate = 1; uptodate = 1;
ide_end_request(uptodate, HWGROUP(drive)); ide_end_request(drive, uptodate);
} }
...@@ -591,7 +591,7 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive, ...@@ -591,7 +591,7 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
pc = (struct packet_command *) rq->special; pc = (struct packet_command *) rq->special;
pc->stat = 1; pc->stat = 1;
cdrom_end_request (1, drive); cdrom_end_request(drive, 1);
*startstop = ide_error (drive, "request sense failure", stat); *startstop = ide_error (drive, "request sense failure", stat);
return 1; return 1;
} else if (rq->flags & (REQ_PC | REQ_BLOCK_PC)) { } else if (rq->flags & (REQ_PC | REQ_BLOCK_PC)) {
...@@ -627,7 +627,7 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive, ...@@ -627,7 +627,7 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
} }
pc->stat = 1; pc->stat = 1;
cdrom_end_request (1, drive); cdrom_end_request(drive, 1);
if ((stat & ERR_STAT) != 0) if ((stat & ERR_STAT) != 0)
cdrom_queue_request_sense(drive, wait, pc->sense, pc); cdrom_queue_request_sense(drive, wait, pc->sense, pc);
...@@ -640,7 +640,7 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive, ...@@ -640,7 +640,7 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
/* Fail the request. */ /* Fail the request. */
printk ("%s: tray open\n", drive->name); printk ("%s: tray open\n", drive->name);
cdrom_end_request (0, drive); cdrom_end_request(drive, 0);
} else if (sense_key == UNIT_ATTENTION) { } else if (sense_key == UNIT_ATTENTION) {
/* Media change. */ /* Media change. */
cdrom_saw_media_change (drive); cdrom_saw_media_change (drive);
...@@ -649,13 +649,13 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive, ...@@ -649,13 +649,13 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
But be sure to give up if we've retried But be sure to give up if we've retried
too many times. */ too many times. */
if (++rq->errors > ERROR_MAX) if (++rq->errors > ERROR_MAX)
cdrom_end_request (0, drive); cdrom_end_request(drive, 0);
} else if (sense_key == ILLEGAL_REQUEST || } else if (sense_key == ILLEGAL_REQUEST ||
sense_key == DATA_PROTECT) { sense_key == DATA_PROTECT) {
/* No point in retrying after an illegal /* No point in retrying after an illegal
request or data protect error.*/ request or data protect error.*/
ide_dump_status (drive, "command error", stat); ide_dump_status (drive, "command error", stat);
cdrom_end_request (0, drive); cdrom_end_request(drive, 0);
} else if ((err & ~ABRT_ERR) != 0) { } else if ((err & ~ABRT_ERR) != 0) {
/* Go to the default handler /* Go to the default handler
for other errors. */ for other errors. */
...@@ -663,7 +663,7 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive, ...@@ -663,7 +663,7 @@ static int cdrom_decode_status (ide_startstop_t *startstop, ide_drive_t *drive,
return 1; return 1;
} else if ((++rq->errors > ERROR_MAX)) { } else if ((++rq->errors > ERROR_MAX)) {
/* We've racked up too many retries. Abort. */ /* We've racked up too many retries. Abort. */
cdrom_end_request (0, drive); cdrom_end_request(drive, 0);
} }
/* If we got a CHECK_CONDITION status, /* If we got a CHECK_CONDITION status,
...@@ -879,7 +879,7 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason) ...@@ -879,7 +879,7 @@ int cdrom_read_check_ireason (ide_drive_t *drive, int len, int ireason)
drive->name, ireason); drive->name, ireason);
} }
cdrom_end_request (0, drive); cdrom_end_request(drive, 0);
return -1; return -1;
} }
...@@ -908,7 +908,7 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive) ...@@ -908,7 +908,7 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
if (dma) { if (dma) {
if (!dma_error) { if (!dma_error) {
__ide_end_request(HWGROUP(drive), 1, rq->nr_sectors); __ide_end_request(drive, 1, rq->nr_sectors);
return ide_stopped; return ide_stopped;
} else } else
return ide_error (drive, "dma error", stat); return ide_error (drive, "dma error", stat);
...@@ -925,9 +925,9 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive) ...@@ -925,9 +925,9 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
if (rq->current_nr_sectors > 0) { if (rq->current_nr_sectors > 0) {
printk ("%s: cdrom_read_intr: data underrun (%u blocks)\n", printk ("%s: cdrom_read_intr: data underrun (%u blocks)\n",
drive->name, rq->current_nr_sectors); drive->name, rq->current_nr_sectors);
cdrom_end_request (0, drive); cdrom_end_request(drive, 0);
} else } else
cdrom_end_request (1, drive); cdrom_end_request(drive, 1);
return ide_stopped; return ide_stopped;
} }
...@@ -947,7 +947,7 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive) ...@@ -947,7 +947,7 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
printk (" Trying to limit transfer sizes\n"); printk (" Trying to limit transfer sizes\n");
CDROM_CONFIG_FLAGS (drive)->limit_nframes = 1; CDROM_CONFIG_FLAGS (drive)->limit_nframes = 1;
} }
cdrom_end_request (0, drive); cdrom_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
...@@ -975,7 +975,7 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive) ...@@ -975,7 +975,7 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive)
/* If we've filled the present buffer but there's another /* If we've filled the present buffer but there's another
chained buffer after it, move on. */ chained buffer after it, move on. */
if (rq->current_nr_sectors == 0 && rq->nr_sectors) if (rq->current_nr_sectors == 0 && rq->nr_sectors)
cdrom_end_request (1, drive); cdrom_end_request(drive, 1);
/* If the buffers are full, cache the rest of the data in our /* If the buffers are full, cache the rest of the data in our
internal buffer. */ internal buffer. */
...@@ -1027,7 +1027,7 @@ static int cdrom_read_from_buffer (ide_drive_t *drive) ...@@ -1027,7 +1027,7 @@ static int cdrom_read_from_buffer (ide_drive_t *drive)
rq->sector >= info->sector_buffered && rq->sector >= info->sector_buffered &&
rq->sector < info->sector_buffered + info->nsectors_buffered) { rq->sector < info->sector_buffered + info->nsectors_buffered) {
if (rq->current_nr_sectors == 0) if (rq->current_nr_sectors == 0)
cdrom_end_request (1, drive); cdrom_end_request(drive, 1);
memcpy (rq->buffer, memcpy (rq->buffer,
info->buffer + info->buffer +
...@@ -1042,13 +1042,13 @@ static int cdrom_read_from_buffer (ide_drive_t *drive) ...@@ -1042,13 +1042,13 @@ static int cdrom_read_from_buffer (ide_drive_t *drive)
/* If we've satisfied the current request, /* If we've satisfied the current request,
terminate it successfully. */ terminate it successfully. */
if (rq->nr_sectors == 0) { if (rq->nr_sectors == 0) {
cdrom_end_request (1, drive); cdrom_end_request(drive, 1);
return -1; return -1;
} }
/* Move on to the next buffer if needed. */ /* Move on to the next buffer if needed. */
if (rq->current_nr_sectors == 0) if (rq->current_nr_sectors == 0)
cdrom_end_request (1, drive); cdrom_end_request(drive, 1);
/* If this condition does not hold, then the kluge i use to /* 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 represent the number of sectors to skip at the start of a transfer
...@@ -1058,7 +1058,7 @@ static int cdrom_read_from_buffer (ide_drive_t *drive) ...@@ -1058,7 +1058,7 @@ static int cdrom_read_from_buffer (ide_drive_t *drive)
(rq->sector % SECTORS_PER_FRAME) != 0) { (rq->sector % SECTORS_PER_FRAME) != 0) {
printk ("%s: cdrom_read_from_buffer: buffer botch (%ld)\n", printk ("%s: cdrom_read_from_buffer: buffer botch (%ld)\n",
drive->name, rq->sector); drive->name, rq->sector);
cdrom_end_request (0, drive); cdrom_end_request(drive, 0);
return -1; return -1;
} }
...@@ -1097,7 +1097,7 @@ static ide_startstop_t cdrom_start_read_continuation (ide_drive_t *drive) ...@@ -1097,7 +1097,7 @@ static ide_startstop_t cdrom_start_read_continuation (ide_drive_t *drive)
(rq->sector % CD_FRAMESIZE != 0)) { (rq->sector % CD_FRAMESIZE != 0)) {
printk ("%s: cdrom_start_read_continuation: buffer botch (%u)\n", printk ("%s: cdrom_start_read_continuation: buffer botch (%u)\n",
drive->name, rq->current_nr_sectors); drive->name, rq->current_nr_sectors);
cdrom_end_request (0, drive); cdrom_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
sector -= nskip; sector -= nskip;
...@@ -1273,17 +1273,17 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive) ...@@ -1273,17 +1273,17 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive)
} }
if (pc->buflen == 0) if (pc->buflen == 0)
cdrom_end_request (1, drive); cdrom_end_request(drive, 1);
else { else {
/* Comment this out, because this always happens /* Comment this out, because this always happens
right after a reset occurs, and it is annoying to right after a reset occurs, and it is annoying to
always print expected stuff. */ always print expected stuff. */
/* /*
printk ("%s: cdrom_pc_intr: data underrun %d\n", printk ("%s: cdrom_pc_intr: data underrun %d\n",
drive->name, pc->buflen); drive->name, pc->buflen);
*/ */
pc->stat = 1; pc->stat = 1;
cdrom_end_request (1, drive); cdrom_end_request(drive, 1);
} }
return ide_stopped; return ide_stopped;
} }
...@@ -1460,7 +1460,7 @@ static inline int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ire ...@@ -1460,7 +1460,7 @@ static inline int cdrom_write_check_ireason(ide_drive_t *drive, int len, int ire
drive->name, ireason); drive->name, ireason);
} }
cdrom_end_request(0, drive); cdrom_end_request(drive, 0);
return 1; return 1;
} }
...@@ -1495,7 +1495,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive) ...@@ -1495,7 +1495,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
return ide_error(drive, "dma error", stat); return ide_error(drive, "dma error", stat);
rq = HWGROUP(drive)->rq; rq = HWGROUP(drive)->rq;
__ide_end_request(HWGROUP(drive), 1, rq->nr_sectors); __ide_end_request(drive, 1, rq->nr_sectors);
return ide_stopped; return ide_stopped;
} }
...@@ -1514,7 +1514,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive) ...@@ -1514,7 +1514,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
drive->name, rq->current_nr_sectors); drive->name, rq->current_nr_sectors);
uptodate = 0; uptodate = 0;
} }
cdrom_end_request(uptodate, drive); cdrom_end_request(drive, uptodate);
return ide_stopped; return ide_stopped;
} }
...@@ -1555,7 +1555,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive) ...@@ -1555,7 +1555,7 @@ static ide_startstop_t cdrom_write_intr(ide_drive_t *drive)
* current buffer complete, move on * current buffer complete, move on
*/ */
if (rq->current_nr_sectors == 0 && rq->nr_sectors) if (rq->current_nr_sectors == 0 && rq->nr_sectors)
cdrom_end_request (1, drive); cdrom_end_request(drive, 1);
} }
/* re-arm handler */ /* re-arm handler */
...@@ -1589,7 +1589,7 @@ static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq) ...@@ -1589,7 +1589,7 @@ static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq)
* writes *must* be 2kB frame aligned * writes *must* be 2kB frame aligned
*/ */
if ((rq->nr_sectors & 3) || (rq->sector & 3)) { if ((rq->nr_sectors & 3) || (rq->sector & 3)) {
cdrom_end_request(0, drive); cdrom_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
...@@ -1673,14 +1673,14 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, unsigned long block) ...@@ -1673,14 +1673,14 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, unsigned long block)
/* /*
* right now this can only be a reset... * right now this can only be a reset...
*/ */
cdrom_end_request(1, drive); cdrom_end_request(drive, 1);
return ide_do_reset(drive); return ide_do_reset(drive);
} else if (rq->flags & REQ_BLOCK_PC) { } else if (rq->flags & REQ_BLOCK_PC) {
return cdrom_do_block_pc(drive, rq); return cdrom_do_block_pc(drive, rq);
} }
blk_dump_rq_flags(rq, "ide-cd bad flags"); blk_dump_rq_flags(rq, "ide-cd bad flags");
cdrom_end_request(0, drive); cdrom_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
...@@ -2915,7 +2915,6 @@ int ide_cdrom_reinit (ide_drive_t *drive); ...@@ -2915,7 +2915,6 @@ int ide_cdrom_reinit (ide_drive_t *drive);
static ide_driver_t ide_cdrom_driver = { static ide_driver_t ide_cdrom_driver = {
name: "ide-cdrom", name: "ide-cdrom",
version: IDECD_VERSION,
media: ide_cdrom, media: ide_cdrom,
busy: 0, busy: 0,
supports_dma: 1, supports_dma: 1,
......
...@@ -125,7 +125,7 @@ static ide_startstop_t do_rw_disk (ide_drive_t *drive, struct request *rq, unsig ...@@ -125,7 +125,7 @@ static ide_startstop_t do_rw_disk (ide_drive_t *drive, struct request *rq, unsig
{ {
if (!(rq->flags & REQ_CMD)) { if (!(rq->flags & REQ_CMD)) {
blk_dump_rq_flags(rq, "do_rw_disk, bad command"); blk_dump_rq_flags(rq, "do_rw_disk, bad command");
ide_end_request(0, HWGROUP(drive)); ide_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
...@@ -324,7 +324,6 @@ static ide_startstop_t lba_48_rw_disk (ide_drive_t *drive, struct request *rq, u ...@@ -324,7 +324,6 @@ static ide_startstop_t lba_48_rw_disk (ide_drive_t *drive, struct request *rq, u
args.posthandler = NULL; args.posthandler = NULL;
args.rq = (struct request *) rq; args.rq = (struct request *) rq;
args.block = block; args.block = block;
rq->special = NULL;
rq->special = (ide_task_t *)&args; rq->special = (ide_task_t *)&args;
return do_rw_taskfile(drive, &args); return do_rw_taskfile(drive, &args);
...@@ -1042,7 +1041,6 @@ int idedisk_reinit(ide_drive_t *drive); ...@@ -1042,7 +1041,6 @@ int idedisk_reinit(ide_drive_t *drive);
*/ */
static ide_driver_t idedisk_driver = { static ide_driver_t idedisk_driver = {
name: "ide-disk", name: "ide-disk",
version: IDEDISK_VERSION,
media: ide_disk, media: ide_disk,
busy: 0, busy: 0,
supports_dma: 1, supports_dma: 1,
......
...@@ -215,7 +215,7 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive) ...@@ -215,7 +215,7 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive)
if (!dma_stat) { if (!dma_stat) {
struct request *rq = HWGROUP(drive)->rq; struct request *rq = HWGROUP(drive)->rq;
__ide_end_request(HWGROUP(drive), 1, rq->nr_sectors); __ide_end_request(drive, 1, rq->nr_sectors);
return ide_stopped; return ide_stopped;
} }
printk("%s: dma_intr: bad DMA status (dma_stat=%x)\n", printk("%s: dma_intr: bad DMA status (dma_stat=%x)\n",
......
...@@ -667,11 +667,10 @@ static void idefloppy_write_zeros (ide_drive_t *drive, unsigned int bcount) ...@@ -667,11 +667,10 @@ static void idefloppy_write_zeros (ide_drive_t *drive, unsigned int bcount)
* For read/write requests, we will call ide_end_request to pass to the * For read/write requests, we will call ide_end_request to pass to the
* next buffer. * next buffer.
*/ */
static void idefloppy_end_request (byte uptodate, ide_hwgroup_t *hwgroup) static int idefloppy_end_request(ide_drive_t *drive, int uptodate)
{ {
ide_drive_t *drive = hwgroup->drive;
idefloppy_floppy_t *floppy = drive->driver_data; idefloppy_floppy_t *floppy = drive->driver_data;
struct request *rq = hwgroup->rq; struct request *rq = HWGROUP(drive)->rq;
int error; int error;
#if IDEFLOPPY_DEBUG_LOG #if IDEFLOPPY_DEBUG_LOG
...@@ -687,13 +686,15 @@ static void idefloppy_end_request (byte uptodate, ide_hwgroup_t *hwgroup) ...@@ -687,13 +686,15 @@ static void idefloppy_end_request (byte uptodate, ide_hwgroup_t *hwgroup)
floppy->failed_pc = NULL; floppy->failed_pc = NULL;
/* Why does this happen? */ /* Why does this happen? */
if (!rq) if (!rq)
return; return 0;
if (!(rq->flags & IDEFLOPPY_RQ)) { if (!(rq->flags & IDEFLOPPY_RQ)) {
ide_end_request (uptodate, hwgroup); ide_end_request(drive, uptodate);
return; return 0;
} }
rq->errors = error; rq->errors = error;
ide_end_drive_cmd (drive, 0, 0); ide_end_drive_cmd (drive, 0, 0);
return 0;
} }
static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, unsigned int bcount) static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, unsigned int bcount)
...@@ -706,7 +707,7 @@ static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, uns ...@@ -706,7 +707,7 @@ static void idefloppy_input_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, uns
if (pc->b_count == bio->bi_size) { if (pc->b_count == bio->bi_size) {
rq->sector += rq->current_nr_sectors; rq->sector += rq->current_nr_sectors;
rq->nr_sectors -= rq->current_nr_sectors; rq->nr_sectors -= rq->current_nr_sectors;
idefloppy_end_request (1, HWGROUP(drive)); idefloppy_end_request(drive, 1);
if ((bio = rq->bio) != NULL) if ((bio = rq->bio) != NULL)
pc->b_count = 0; pc->b_count = 0;
} }
...@@ -731,7 +732,7 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un ...@@ -731,7 +732,7 @@ static void idefloppy_output_buffers (ide_drive_t *drive, idefloppy_pc_t *pc, un
if (!pc->b_count) { if (!pc->b_count) {
rq->sector += rq->current_nr_sectors; rq->sector += rq->current_nr_sectors;
rq->nr_sectors -= rq->current_nr_sectors; rq->nr_sectors -= rq->current_nr_sectors;
idefloppy_end_request (1, HWGROUP(drive)); idefloppy_end_request(drive, 1);
if ((bio = rq->bio) != NULL) { if ((bio = rq->bio) != NULL) {
pc->b_data = bio_data(bio); pc->b_data = bio_data(bio);
pc->b_count = bio->bi_size; pc->b_count = bio->bi_size;
...@@ -755,7 +756,7 @@ static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc) ...@@ -755,7 +756,7 @@ static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc)
struct bio *bio = rq->bio; struct bio *bio = rq->bio;
while ((bio = rq->bio) != NULL) while ((bio = rq->bio) != NULL)
idefloppy_end_request (1, HWGROUP(drive)); idefloppy_end_request(drive, 1);
} }
#endif /* CONFIG_BLK_DEV_IDEDMA */ #endif /* CONFIG_BLK_DEV_IDEDMA */
...@@ -818,10 +819,10 @@ static void idefloppy_request_sense_callback (ide_drive_t *drive) ...@@ -818,10 +819,10 @@ static void idefloppy_request_sense_callback (ide_drive_t *drive)
#endif /* IDEFLOPPY_DEBUG_LOG */ #endif /* IDEFLOPPY_DEBUG_LOG */
if (!floppy->pc->error) { if (!floppy->pc->error) {
idefloppy_analyze_error (drive,(idefloppy_request_sense_result_t *) floppy->pc->buffer); idefloppy_analyze_error (drive,(idefloppy_request_sense_result_t *) floppy->pc->buffer);
idefloppy_end_request (1,HWGROUP (drive)); idefloppy_end_request(drive, 1);
} else { } else {
printk (KERN_ERR "Error in REQUEST SENSE itself - Aborting request!\n"); printk (KERN_ERR "Error in REQUEST SENSE itself - Aborting request!\n");
idefloppy_end_request (0,HWGROUP (drive)); idefloppy_end_request(drive, 0);
} }
} }
...@@ -836,7 +837,7 @@ static void idefloppy_pc_callback (ide_drive_t *drive) ...@@ -836,7 +837,7 @@ static void idefloppy_pc_callback (ide_drive_t *drive)
printk (KERN_INFO "ide-floppy: Reached idefloppy_pc_callback\n"); printk (KERN_INFO "ide-floppy: Reached idefloppy_pc_callback\n");
#endif /* IDEFLOPPY_DEBUG_LOG */ #endif /* IDEFLOPPY_DEBUG_LOG */
idefloppy_end_request (floppy->pc->error ? 0:1, HWGROUP(drive)); idefloppy_end_request(drive, floppy->pc->error ? 0:1);
} }
/* /*
...@@ -1159,7 +1160,7 @@ static void idefloppy_rw_callback (ide_drive_t *drive) ...@@ -1159,7 +1160,7 @@ static void idefloppy_rw_callback (ide_drive_t *drive)
printk (KERN_INFO "ide-floppy: Reached idefloppy_rw_callback\n"); printk (KERN_INFO "ide-floppy: Reached idefloppy_rw_callback\n");
#endif /* IDEFLOPPY_DEBUG_LOG */ #endif /* IDEFLOPPY_DEBUG_LOG */
idefloppy_end_request(1, HWGROUP(drive)); idefloppy_end_request(drive, 1);
return; return;
} }
...@@ -1293,13 +1294,13 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request ...@@ -1293,13 +1294,13 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request
drive->name, floppy->failed_pc->c[0], floppy->sense_key, floppy->asc, floppy->ascq); drive->name, floppy->failed_pc->c[0], floppy->sense_key, floppy->asc, floppy->ascq);
else else
printk (KERN_ERR "ide-floppy: %s: I/O error\n", drive->name); printk (KERN_ERR "ide-floppy: %s: I/O error\n", drive->name);
idefloppy_end_request (0, HWGROUP(drive)); idefloppy_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
if (rq->flags & REQ_CMD) { if (rq->flags & REQ_CMD) {
if (rq->sector % floppy->bs_factor || rq->nr_sectors % floppy->bs_factor) { if (rq->sector % floppy->bs_factor || rq->nr_sectors % floppy->bs_factor) {
printk ("%s: unsupported r/w request size\n", drive->name); printk ("%s: unsupported r/w request size\n", drive->name);
idefloppy_end_request (0, HWGROUP(drive)); idefloppy_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
pc = idefloppy_next_pc_storage (drive); pc = idefloppy_next_pc_storage (drive);
...@@ -1308,7 +1309,7 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request ...@@ -1308,7 +1309,7 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request
pc = (idefloppy_pc_t *) rq->buffer; pc = (idefloppy_pc_t *) rq->buffer;
} else { } else {
blk_dump_rq_flags(rq, "ide-floppy: unsupported command in queue"); blk_dump_rq_flags(rq, "ide-floppy: unsupported command in queue");
idefloppy_end_request (0,HWGROUP (drive)); idefloppy_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
pc->rq = rq; pc->rq = rq;
...@@ -2057,7 +2058,6 @@ int idefloppy_reinit(ide_drive_t *drive); ...@@ -2057,7 +2058,6 @@ int idefloppy_reinit(ide_drive_t *drive);
*/ */
static ide_driver_t idefloppy_driver = { static ide_driver_t idefloppy_driver = {
name: "ide-floppy", name: "ide-floppy",
version: IDEFLOPPY_VERSION,
media: ide_floppy, media: ide_floppy,
busy: 0, busy: 0,
supports_dma: 1, supports_dma: 1,
......
...@@ -788,8 +788,7 @@ static int init_irq (ide_hwif_t *hwif) ...@@ -788,8 +788,7 @@ static int init_irq (ide_hwif_t *hwif)
static void init_gendisk (ide_hwif_t *hwif) static void init_gendisk (ide_hwif_t *hwif)
{ {
struct gendisk *gd; struct gendisk *gd;
unsigned int unit, units, minors; unsigned int unit, units, minors, i;
int *bs, *max_ra;
extern devfs_handle_t ide_devfs_handle; extern devfs_handle_t ide_devfs_handle;
#if 1 #if 1
...@@ -802,33 +801,25 @@ static void init_gendisk (ide_hwif_t *hwif) ...@@ -802,33 +801,25 @@ static void init_gendisk (ide_hwif_t *hwif)
} }
#endif #endif
minors = units * (1<<PARTN_BITS); minors = units * (1<<PARTN_BITS);
gd = kmalloc (sizeof(struct gendisk), GFP_KERNEL);
gd = kmalloc (sizeof(struct gendisk), GFP_KERNEL);
if (!gd) if (!gd)
goto err_kmalloc_gd; goto err_kmalloc_gd;
gd->sizes = kmalloc (minors * sizeof(int), GFP_KERNEL); gd->sizes = kmalloc (minors * sizeof(int), GFP_KERNEL);
if (!gd->sizes) if (!gd->sizes)
goto err_kmalloc_gd_sizes; goto err_kmalloc_gd_sizes;
gd->part = kmalloc (minors * sizeof(struct hd_struct), GFP_KERNEL); gd->part = kmalloc (minors * sizeof(struct hd_struct), GFP_KERNEL);
if (!gd->part) if (!gd->part)
goto err_kmalloc_gd_part; goto err_kmalloc_gd_part;
bs = kmalloc (minors*sizeof(int), GFP_KERNEL); blksize_size[hwif->major] = kmalloc (minors*sizeof(int), GFP_KERNEL);
if (!bs) if (!blksize_size[hwif->major])
goto err_kmalloc_bs; goto err_kmalloc_bs;
max_ra = kmalloc (minors*sizeof(int), GFP_KERNEL);
if (!max_ra)
goto err_kmalloc_max_ra;
memset(gd->part, 0, minors * sizeof(struct hd_struct)); memset(gd->part, 0, minors * sizeof(struct hd_struct));
/* cdroms and msdos f/s are examples of non-1024 blocksizes */ for (i = 0; i < minors; ++i)
blksize_size[hwif->major] = bs; blksize_size[hwif->major][i] = BLOCK_SIZE;
max_readahead[hwif->major] = max_ra;
for (unit = 0; unit < minors; ++unit) {
*bs++ = BLOCK_SIZE;
*max_ra++ = MAX_READAHEAD;
}
for (unit = 0; unit < units; ++unit) for (unit = 0; unit < units; ++unit)
hwif->drives[unit].part = &gd->part[unit << PARTN_BITS]; hwif->drives[unit].part = &gd->part[unit << PARTN_BITS];
...@@ -875,8 +866,6 @@ static void init_gendisk (ide_hwif_t *hwif) ...@@ -875,8 +866,6 @@ static void init_gendisk (ide_hwif_t *hwif)
} }
return; return;
err_kmalloc_max_ra:
kfree(bs);
err_kmalloc_bs: err_kmalloc_bs:
kfree(gd->part); kfree(gd->part);
err_kmalloc_gd_part: err_kmalloc_gd_part:
...@@ -937,7 +926,6 @@ static int hwif_init (ide_hwif_t *hwif) ...@@ -937,7 +926,6 @@ static int hwif_init (ide_hwif_t *hwif)
init_gendisk(hwif); init_gendisk(hwif);
blk_dev[hwif->major].data = hwif; blk_dev[hwif->major].data = hwif;
blk_dev[hwif->major].queue = ide_get_queue; blk_dev[hwif->major].queue = ide_get_queue;
read_ahead[hwif->major] = 8; /* (4kB) */
hwif->present = 1; /* success */ hwif->present = 1; /* success */
return hwif->present; return hwif->present;
......
...@@ -163,7 +163,7 @@ static struct proc_dir_entry * proc_ide_root = NULL; ...@@ -163,7 +163,7 @@ static struct proc_dir_entry * proc_ide_root = NULL;
static int proc_ide_write_config static int proc_ide_write_config
(struct file *file, const char *buffer, unsigned long count, void *data) (struct file *file, const char *buffer, unsigned long count, void *data)
{ {
ide_hwif_t *hwif = (ide_hwif_t *)data; ide_hwif_t *hwif = data;
int for_real = 0; int for_real = 0;
unsigned long startn = 0, n, flags; unsigned long startn = 0, n, flags;
const char *start = NULL, *msg = NULL; const char *start = NULL, *msg = NULL;
...@@ -338,7 +338,7 @@ static int proc_ide_read_config ...@@ -338,7 +338,7 @@ static int proc_ide_read_config
int len; int len;
#ifdef CONFIG_BLK_DEV_IDEPCI #ifdef CONFIG_BLK_DEV_IDEPCI
ide_hwif_t *hwif = (ide_hwif_t *)data; ide_hwif_t *hwif = data;
struct pci_dev *dev = hwif->pci_dev; struct pci_dev *dev = hwif->pci_dev;
if (!IDE_PCI_DEVID_EQ(hwif->pci_devid, IDE_PCI_DEVID_NULL) && dev && dev->bus) { if (!IDE_PCI_DEVID_EQ(hwif->pci_devid, IDE_PCI_DEVID_NULL) && dev && dev->bus) {
int reg = 0; int reg = 0;
...@@ -384,7 +384,7 @@ static int proc_ide_read_drivers ...@@ -384,7 +384,7 @@ static int proc_ide_read_drivers
while (p) { while (p) {
driver = (ide_driver_t *) p->info; driver = (ide_driver_t *) p->info;
if (driver) if (driver)
out += sprintf(out, "%s version %s\n", driver->name, driver->version); out += sprintf(out, "%s\n",driver->name);
p = p->next; p = p->next;
} }
len = out - page; len = out - page;
...@@ -394,7 +394,7 @@ static int proc_ide_read_drivers ...@@ -394,7 +394,7 @@ static int proc_ide_read_drivers
static int proc_ide_read_imodel static int proc_ide_read_imodel
(char *page, char **start, off_t off, int count, int *eof, void *data) (char *page, char **start, off_t off, int count, int *eof, void *data)
{ {
ide_hwif_t *hwif = (ide_hwif_t *) data; ide_hwif_t *hwif = data;
int len; int len;
const char *name; const char *name;
...@@ -424,7 +424,7 @@ static int proc_ide_read_imodel ...@@ -424,7 +424,7 @@ static int proc_ide_read_imodel
static int proc_ide_read_mate static int proc_ide_read_mate
(char *page, char **start, off_t off, int count, int *eof, void *data) (char *page, char **start, off_t off, int count, int *eof, void *data)
{ {
ide_hwif_t *hwif = (ide_hwif_t *) data; ide_hwif_t *hwif = data;
int len; int len;
if (hwif && hwif->mate && hwif->mate->present) if (hwif && hwif->mate && hwif->mate->present)
...@@ -437,7 +437,7 @@ static int proc_ide_read_mate ...@@ -437,7 +437,7 @@ static int proc_ide_read_mate
static int proc_ide_read_channel static int proc_ide_read_channel
(char *page, char **start, off_t off, int count, int *eof, void *data) (char *page, char **start, off_t off, int count, int *eof, void *data)
{ {
ide_hwif_t *hwif = (ide_hwif_t *) data; ide_hwif_t *hwif = data;
int len; int len;
page[0] = hwif->channel ? '1' : '0'; page[0] = hwif->channel ? '1' : '0';
...@@ -462,7 +462,7 @@ static int proc_ide_get_identify(ide_drive_t *drive, byte *buf) ...@@ -462,7 +462,7 @@ static int proc_ide_get_identify(ide_drive_t *drive, byte *buf)
static int proc_ide_read_identify static int proc_ide_read_identify
(char *page, char **start, off_t off, int count, int *eof, void *data) (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 = 0, i = 0; int len = 0, i = 0;
if (drive && !proc_ide_get_identify(drive, page)) { if (drive && !proc_ide_get_identify(drive, page)) {
...@@ -483,8 +483,8 @@ static int proc_ide_read_identify ...@@ -483,8 +483,8 @@ static int proc_ide_read_identify
static int proc_ide_read_settings static int proc_ide_read_settings
(char *page, char **start, off_t off, int count, int *eof, void *data) (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;
ide_settings_t *setting = (ide_settings_t *) drive->settings; ide_settings_t *setting = drive->settings;
char *out = page; char *out = page;
int len, rc, mul_factor, div_factor; int len, rc, mul_factor, div_factor;
...@@ -515,7 +515,7 @@ static int proc_ide_read_settings ...@@ -515,7 +515,7 @@ static int proc_ide_read_settings
static int proc_ide_write_settings static int proc_ide_write_settings
(struct file *file, const char *buffer, unsigned long count, void *data) (struct file *file, const char *buffer, unsigned long count, void *data)
{ {
ide_drive_t *drive = (ide_drive_t *) data; ide_drive_t *drive = data;
char name[MAX_LEN + 1]; char name[MAX_LEN + 1];
int for_real = 0, len; int for_real = 0, len;
unsigned long n; unsigned long n;
...@@ -573,7 +573,15 @@ static int proc_ide_write_settings ...@@ -573,7 +573,15 @@ static int proc_ide_write_settings
--n; --n;
++p; ++p;
} }
setting = ide_find_setting_by_name(drive, name);
/* Find setting by name */
setting = drive->settings;
while (setting) {
if (strcmp(setting->name, name) == 0)
break;
setting = setting->next;
}
if (!setting) if (!setting)
goto parse_error; goto parse_error;
...@@ -590,21 +598,21 @@ static int proc_ide_write_settings ...@@ -590,21 +598,21 @@ static int proc_ide_write_settings
int proc_ide_read_capacity int proc_ide_read_capacity
(char *page, char **start, off_t off, int count, int *eof, void *data) (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;
ide_driver_t *driver = (ide_driver_t *) drive->driver; ide_driver_t *driver = drive->driver;
int len; int len;
if (!driver) if (!driver)
len = sprintf(page, "(none)\n"); len = sprintf(page, "(none)\n");
else else
len = sprintf(page,"%llu\n", (unsigned long long) ((ide_driver_t *)drive->driver)->capacity(drive)); len = sprintf(page,"%llu\n", (unsigned long long) drive->driver->capacity(drive));
PROC_IDE_READ_RETURN(page,start,off,count,eof,len); PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
} }
int proc_ide_read_geometry int proc_ide_read_geometry
(char *page, char **start, off_t off, int count, int *eof, void *data) (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;
char *out = page; char *out = page;
int len; int len;
...@@ -617,7 +625,7 @@ int proc_ide_read_geometry ...@@ -617,7 +625,7 @@ int proc_ide_read_geometry
static int proc_ide_read_dmodel static int proc_ide_read_dmodel
(char *page, char **start, off_t off, int count, int *eof, void *data) (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;
struct hd_driveid *id = drive->id; struct hd_driveid *id = drive->id;
int len; int len;
...@@ -635,14 +643,14 @@ static int proc_ide_read_driver ...@@ -635,14 +643,14 @@ static int proc_ide_read_driver
if (!driver) if (!driver)
len = sprintf(page, "(none)\n"); len = sprintf(page, "(none)\n");
else else
len = sprintf(page, "%s version %s\n", driver->name, driver->version); len = sprintf(page, "%s\n", driver->name);
PROC_IDE_READ_RETURN(page,start,off,count,eof,len); PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
} }
static int proc_ide_write_driver static int proc_ide_write_driver
(struct file *file, const char *buffer, unsigned long count, void *data) (struct file *file, const char *buffer, unsigned long count, void *data)
{ {
ide_drive_t *drive = (ide_drive_t *) data; ide_drive_t *drive = data;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
...@@ -654,7 +662,7 @@ static int proc_ide_write_driver ...@@ -654,7 +662,7 @@ static int proc_ide_write_driver
static int proc_ide_read_media static int proc_ide_read_media
(char *page, char **start, off_t off, int count, int *eof, void *data) (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;
const char *media; const char *media;
int len; int len;
...@@ -787,7 +795,6 @@ void destroy_proc_ide_drives(ide_hwif_t *hwif) ...@@ -787,7 +795,6 @@ void destroy_proc_ide_drives(ide_hwif_t *hwif)
for (d = 0; d < MAX_DRIVES; d++) { for (d = 0; d < MAX_DRIVES; d++) {
ide_drive_t *drive = &hwif->drives[d]; ide_drive_t *drive = &hwif->drives[d];
// ide_driver_t *driver = drive->driver;
if (drive->proc) if (drive->proc)
destroy_proc_ide_device(hwif, drive); destroy_proc_ide_device(hwif, drive);
......
...@@ -1835,10 +1835,9 @@ static void idetape_remove_stage_head (ide_drive_t *drive) ...@@ -1835,10 +1835,9 @@ static void idetape_remove_stage_head (ide_drive_t *drive)
* idetape_end_request is used to finish servicing a request, and to * idetape_end_request is used to finish servicing a request, and to
* insert a pending pipeline request into the main device queue. * insert a pending pipeline request into the main device queue.
*/ */
static void idetape_end_request (byte uptodate, ide_hwgroup_t *hwgroup) static int idetape_end_request(ide_drive_t *drive, int uptodate)
{ {
ide_drive_t *drive = hwgroup->drive; struct request *rq = HWGROUP(drive)->rq;
struct request *rq = hwgroup->rq;
idetape_tape_t *tape = drive->driver_data; idetape_tape_t *tape = drive->driver_data;
unsigned long flags; unsigned long flags;
int error; int error;
...@@ -1932,6 +1931,8 @@ static void idetape_end_request (byte uptodate, ide_hwgroup_t *hwgroup) ...@@ -1932,6 +1931,8 @@ static void idetape_end_request (byte uptodate, ide_hwgroup_t *hwgroup)
if (tape->active_data_request == NULL) if (tape->active_data_request == NULL)
clear_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags); clear_bit(IDETAPE_PIPELINE_ACTIVE, &tape->flags);
spin_unlock_irqrestore(&tape->spinlock, flags); spin_unlock_irqrestore(&tape->spinlock, flags);
return 0;
} }
static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive) static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive)
...@@ -1944,10 +1945,10 @@ static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive) ...@@ -1944,10 +1945,10 @@ static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive)
#endif /* IDETAPE_DEBUG_LOG */ #endif /* IDETAPE_DEBUG_LOG */
if (!tape->pc->error) { if (!tape->pc->error) {
idetape_analyze_error (drive, (idetape_request_sense_result_t *) tape->pc->buffer); idetape_analyze_error (drive, (idetape_request_sense_result_t *) tape->pc->buffer);
idetape_end_request (1, HWGROUP (drive)); idetape_end_request(drive, 1);
} else { } else {
printk (KERN_ERR "ide-tape: Error in REQUEST SENSE itself - Aborting request!\n"); printk (KERN_ERR "ide-tape: Error in REQUEST SENSE itself - Aborting request!\n");
idetape_end_request (0, HWGROUP (drive)); idetape_end_request(drive, 0);
} }
return ide_stopped; return ide_stopped;
} }
...@@ -2012,7 +2013,7 @@ static ide_startstop_t idetape_retry_pc (ide_drive_t *drive) ...@@ -2012,7 +2013,7 @@ static ide_startstop_t idetape_retry_pc (ide_drive_t *drive)
/* /*
* idetape_postpone_request postpones the current request so that * idetape_postpone_request postpones the current request so that
* ide.c will be able to service requests from another device on * ide.c will be able to service requests from another device on
* the same hwgroup while we are polling for DSC. * the same interface while we are polling for DSC.
*/ */
static void idetape_postpone_request (ide_drive_t *drive) static void idetape_postpone_request (ide_drive_t *drive)
{ {
...@@ -2348,7 +2349,7 @@ static ide_startstop_t idetape_pc_callback (ide_drive_t *drive) ...@@ -2348,7 +2349,7 @@ static ide_startstop_t idetape_pc_callback (ide_drive_t *drive)
printk (KERN_INFO "ide-tape: Reached idetape_pc_callback\n"); printk (KERN_INFO "ide-tape: Reached idetape_pc_callback\n");
#endif /* IDETAPE_DEBUG_LOG */ #endif /* IDETAPE_DEBUG_LOG */
idetape_end_request (tape->pc->error ? 0 : 1, HWGROUP(drive)); idetape_end_request(drive, tape->pc->error ? 0 : 1);
return ide_stopped; return ide_stopped;
} }
...@@ -2397,7 +2398,7 @@ static ide_startstop_t idetape_onstream_buffer_fill_callback (ide_drive_t *drive ...@@ -2397,7 +2398,7 @@ static ide_startstop_t idetape_onstream_buffer_fill_callback (ide_drive_t *drive
if (tape->debug_level >= 1) if (tape->debug_level >= 1)
printk(KERN_INFO "ide-tape: buffer fill callback, %d/%d\n", tape->cur_frames, tape->max_frames); printk(KERN_INFO "ide-tape: buffer fill callback, %d/%d\n", tape->cur_frames, tape->max_frames);
#endif #endif
idetape_end_request (tape->pc->error ? 0 : 1, HWGROUP(drive)); idetape_end_request(drive, tape->pc->error ? 0 : 1);
return ide_stopped; return ide_stopped;
} }
...@@ -2508,7 +2509,7 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive) ...@@ -2508,7 +2509,7 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive)
tape->avg_time = jiffies; tape->avg_time = jiffies;
} }
#if IDETAPE_DEBUG_LOG #if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 4) if (tape->debug_level >= 4)
printk (KERN_INFO "ide-tape: Reached idetape_rw_callback\n"); printk (KERN_INFO "ide-tape: Reached idetape_rw_callback\n");
#endif /* IDETAPE_DEBUG_LOG */ #endif /* IDETAPE_DEBUG_LOG */
...@@ -2517,9 +2518,9 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive) ...@@ -2517,9 +2518,9 @@ static ide_startstop_t idetape_rw_callback (ide_drive_t *drive)
rq->current_nr_sectors -= blocks; rq->current_nr_sectors -= blocks;
if (!tape->pc->error) if (!tape->pc->error)
idetape_end_request (1, HWGROUP (drive)); idetape_end_request(drive, 1);
else else
idetape_end_request (tape->pc->error, HWGROUP (drive)); idetape_end_request(drive, tape->pc->error);
return ide_stopped; return ide_stopped;
} }
...@@ -2630,7 +2631,7 @@ static ide_startstop_t idetape_do_request (ide_drive_t *drive, struct request *r ...@@ -2630,7 +2631,7 @@ static ide_startstop_t idetape_do_request (ide_drive_t *drive, struct request *r
* We do not support buffer cache originated requests. * We do not support buffer cache originated requests.
*/ */
printk (KERN_NOTICE "ide-tape: %s: Unsupported command in request queue (%ld)\n", drive->name, rq->flags); printk (KERN_NOTICE "ide-tape: %s: Unsupported command in request queue (%ld)\n", drive->name, rq->flags);
ide_end_request (0, HWGROUP (drive)); /* Let the common code handle it */ ide_end_request(drive, 0); /* Let the common code handle it */
return ide_stopped; return ide_stopped;
} }
...@@ -2644,7 +2645,7 @@ static ide_startstop_t idetape_do_request (ide_drive_t *drive, struct request *r ...@@ -2644,7 +2645,7 @@ static ide_startstop_t idetape_do_request (ide_drive_t *drive, struct request *r
if (postponed_rq != NULL) if (postponed_rq != NULL)
if (rq != postponed_rq) { if (rq != postponed_rq) {
printk (KERN_ERR "ide-tape: ide-tape.c bug - Two DSC requests were queued\n"); printk (KERN_ERR "ide-tape: ide-tape.c bug - Two DSC requests were queued\n");
idetape_end_request (0, HWGROUP (drive)); idetape_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
#endif /* IDETAPE_DEBUG_BUGS */ #endif /* IDETAPE_DEBUG_BUGS */
...@@ -2772,7 +2773,7 @@ static ide_startstop_t idetape_do_request (ide_drive_t *drive, struct request *r ...@@ -2772,7 +2773,7 @@ static ide_startstop_t idetape_do_request (ide_drive_t *drive, struct request *r
break; break;
case IDETAPE_ABORTED_WRITE_RQ: case IDETAPE_ABORTED_WRITE_RQ:
rq->flags = IDETAPE_WRITE_RQ; rq->flags = IDETAPE_WRITE_RQ;
idetape_end_request (IDETAPE_ERROR_EOD, HWGROUP(drive)); idetape_end_request(drive, IDETAPE_ERROR_EOD);
return ide_stopped; return ide_stopped;
case IDETAPE_ABORTED_READ_RQ: case IDETAPE_ABORTED_READ_RQ:
#if IDETAPE_DEBUG_LOG #if IDETAPE_DEBUG_LOG
...@@ -2780,7 +2781,7 @@ static ide_startstop_t idetape_do_request (ide_drive_t *drive, struct request *r ...@@ -2780,7 +2781,7 @@ static ide_startstop_t idetape_do_request (ide_drive_t *drive, struct request *r
printk(KERN_INFO "ide-tape: %s: detected aborted read rq\n", tape->name); printk(KERN_INFO "ide-tape: %s: detected aborted read rq\n", tape->name);
#endif #endif
rq->flags = IDETAPE_READ_RQ; rq->flags = IDETAPE_READ_RQ;
idetape_end_request (IDETAPE_ERROR_EOD, HWGROUP(drive)); idetape_end_request(drive, IDETAPE_ERROR_EOD);
return ide_stopped; return ide_stopped;
case IDETAPE_PC_RQ1: case IDETAPE_PC_RQ1:
pc = (idetape_pc_t *) rq->buffer; pc = (idetape_pc_t *) rq->buffer;
...@@ -2791,7 +2792,7 @@ static ide_startstop_t idetape_do_request (ide_drive_t *drive, struct request *r ...@@ -2791,7 +2792,7 @@ static ide_startstop_t idetape_do_request (ide_drive_t *drive, struct request *r
return ide_stopped; return ide_stopped;
default: default:
printk (KERN_ERR "ide-tape: bug in IDETAPE_RQ_CMD macro\n"); printk (KERN_ERR "ide-tape: bug in IDETAPE_RQ_CMD macro\n");
idetape_end_request (0, HWGROUP (drive)); idetape_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
return idetape_issue_packet_command (drive, pc); return idetape_issue_packet_command (drive, pc);
...@@ -3118,7 +3119,7 @@ static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive) ...@@ -3118,7 +3119,7 @@ static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive)
if (result->bpu) { if (result->bpu) {
printk (KERN_INFO "ide-tape: Block location is unknown to the tape\n"); printk (KERN_INFO "ide-tape: Block location is unknown to the tape\n");
clear_bit (IDETAPE_ADDRESS_VALID, &tape->flags); clear_bit (IDETAPE_ADDRESS_VALID, &tape->flags);
idetape_end_request (0, HWGROUP (drive)); idetape_end_request(drive, 0);
} else { } else {
#if IDETAPE_DEBUG_LOG #if IDETAPE_DEBUG_LOG
if (tape->debug_level >= 2) if (tape->debug_level >= 2)
...@@ -3129,10 +3130,10 @@ static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive) ...@@ -3129,10 +3130,10 @@ static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive)
tape->last_frame_position = ntohl (result->last_block); tape->last_frame_position = ntohl (result->last_block);
tape->blocks_in_buffer = result->blocks_in_buffer[2]; tape->blocks_in_buffer = result->blocks_in_buffer[2];
set_bit (IDETAPE_ADDRESS_VALID, &tape->flags); set_bit (IDETAPE_ADDRESS_VALID, &tape->flags);
idetape_end_request (1, HWGROUP (drive)); idetape_end_request(drive, 1);
} }
} else { } else {
idetape_end_request (0, HWGROUP (drive)); idetape_end_request(drive, 0);
} }
return ide_stopped; return ide_stopped;
} }
...@@ -6143,7 +6144,6 @@ int idetape_reinit(ide_drive_t *drive); ...@@ -6143,7 +6144,6 @@ int idetape_reinit(ide_drive_t *drive);
*/ */
static ide_driver_t idetape_driver = { static ide_driver_t idetape_driver = {
name: "ide-tape", name: "ide-tape",
version: IDETAPE_VERSION,
media: ide_tape, media: ide_tape,
busy: 1, busy: 1,
supports_dma: 1, supports_dma: 1,
......
...@@ -632,7 +632,7 @@ ide_startstop_t taskfile_error (ide_drive_t *drive, const char *msg, byte stat) ...@@ -632,7 +632,7 @@ ide_startstop_t taskfile_error (ide_drive_t *drive, const char *msg, byte stat)
if (drive->driver != NULL) if (drive->driver != NULL)
DRIVER(drive)->end_request(0, HWGROUP(drive)); DRIVER(drive)->end_request(0, HWGROUP(drive));
else else
ide_end_request(0, HWGROUP(drive)); ide_end_request(drive, 0);
} else { } else {
if ((rq->errors & ERROR_RESET) == ERROR_RESET) { if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
++rq->errors; ++rq->errors;
...@@ -748,7 +748,7 @@ ide_startstop_t task_in_intr (ide_drive_t *drive) ...@@ -748,7 +748,7 @@ ide_startstop_t task_in_intr (ide_drive_t *drive)
if (--rq->current_nr_sectors <= 0) { if (--rq->current_nr_sectors <= 0) {
/* (hs): swapped next 2 lines */ /* (hs): swapped next 2 lines */
DTF("Request Ended stat: %02x\n", GET_STAT()); DTF("Request Ended stat: %02x\n", GET_STAT());
if (ide_end_request(1, HWGROUP(drive))) { if (ide_end_request(drive, 1)) {
ide_set_handler(drive, &task_in_intr, WAIT_CMD, NULL); ide_set_handler(drive, &task_in_intr, WAIT_CMD, NULL);
return ide_started; return ide_started;
} }
...@@ -851,7 +851,7 @@ ide_startstop_t task_mulin_intr (ide_drive_t *drive) ...@@ -851,7 +851,7 @@ ide_startstop_t task_mulin_intr (ide_drive_t *drive)
rq->current_nr_sectors -= nsect; rq->current_nr_sectors -= nsect;
stat = altstat_multi_poll(drive, GET_ALTSTAT(), "read"); stat = altstat_multi_poll(drive, GET_ALTSTAT(), "read");
} }
ide_end_request(1, HWGROUP(drive)); ide_end_request(drive, 1);
return ide_stopped; return ide_stopped;
} }
#endif /* ALTSTAT_SCREW_UP */ #endif /* ALTSTAT_SCREW_UP */
...@@ -873,7 +873,7 @@ ide_startstop_t task_mulin_intr (ide_drive_t *drive) ...@@ -873,7 +873,7 @@ ide_startstop_t task_mulin_intr (ide_drive_t *drive)
rq->current_nr_sectors -= nsect; rq->current_nr_sectors -= nsect;
msect -= nsect; msect -= nsect;
if (!rq->current_nr_sectors) { if (!rq->current_nr_sectors) {
if (!ide_end_request(1, HWGROUP(drive))) if (!ide_end_request(drive, 1))
return ide_stopped; return ide_stopped;
} }
} while (msect); } while (msect);
...@@ -941,7 +941,7 @@ ide_startstop_t task_out_intr (ide_drive_t *drive) ...@@ -941,7 +941,7 @@ ide_startstop_t task_out_intr (ide_drive_t *drive)
return ide_error(drive, "task_out_intr", stat); return ide_error(drive, "task_out_intr", stat);
if (!rq->current_nr_sectors) if (!rq->current_nr_sectors)
if (!ide_end_request(1, HWGROUP(drive))) if (!ide_end_request(drive, 1))
return ide_stopped; return ide_stopped;
if ((rq->current_nr_sectors==1) ^ (stat & DRQ_STAT)) { if ((rq->current_nr_sectors==1) ^ (stat & DRQ_STAT)) {
...@@ -993,7 +993,7 @@ ide_startstop_t task_mulout_intr (ide_drive_t *drive) ...@@ -993,7 +993,7 @@ ide_startstop_t task_mulout_intr (ide_drive_t *drive)
* there may be more, ide_do_request will restart it if * there may be more, ide_do_request will restart it if
* necessary * necessary
*/ */
ide_end_request(1, HWGROUP(drive)); ide_end_request(drive, 1);
return ide_stopped; return ide_stopped;
} }
...@@ -1028,7 +1028,7 @@ ide_startstop_t task_mulout_intr (ide_drive_t *drive) ...@@ -1028,7 +1028,7 @@ ide_startstop_t task_mulout_intr (ide_drive_t *drive)
rq->current_nr_sectors -= nsect; rq->current_nr_sectors -= nsect;
stat = altstat_multi_poll(drive, GET_ALTSTAT(), "write"); stat = altstat_multi_poll(drive, GET_ALTSTAT(), "write");
} }
ide_end_request(1, HWGROUP(drive)); ide_end_request(drive, 1);
return ide_stopped; return ide_stopped;
} }
#endif /* ALTSTAT_SCREW_UP */ #endif /* ALTSTAT_SCREW_UP */
...@@ -1109,7 +1109,7 @@ ide_startstop_t bio_mulout_intr (ide_drive_t *drive) ...@@ -1109,7 +1109,7 @@ ide_startstop_t bio_mulout_intr (ide_drive_t *drive)
return startstop; return startstop;
} }
__ide_end_request(HWGROUP(drive), 1, rq->hard_nr_sectors); __ide_end_request(drive, 1, rq->hard_nr_sectors);
HWGROUP(drive)->wrq.bio = NULL; HWGROUP(drive)->wrq.bio = NULL;
return ide_stopped; return ide_stopped;
} }
......
...@@ -372,15 +372,14 @@ int ide_system_bus_speed (void) ...@@ -372,15 +372,14 @@ int ide_system_bus_speed (void)
return system_bus_speed; return system_bus_speed;
} }
inline int __ide_end_request(ide_hwgroup_t *hwgroup, int uptodate, int nr_secs) int __ide_end_request(ide_drive_t *drive, int uptodate, int nr_secs)
{ {
ide_drive_t *drive = hwgroup->drive;
struct request *rq; struct request *rq;
unsigned long flags; unsigned long flags;
int ret = 1; int ret = 1;
spin_lock_irqsave(&ide_lock, flags); spin_lock_irqsave(&ide_lock, flags);
rq = hwgroup->rq; rq = HWGROUP(drive)->rq;
BUG_ON(!(rq->flags & REQ_STARTED)); BUG_ON(!(rq->flags & REQ_STARTED));
...@@ -397,13 +396,13 @@ inline int __ide_end_request(ide_hwgroup_t *hwgroup, int uptodate, int nr_secs) ...@@ -397,13 +396,13 @@ inline int __ide_end_request(ide_hwgroup_t *hwgroup, int uptodate, int nr_secs)
*/ */
if (drive->state == DMA_PIO_RETRY && drive->retry_pio <= 3) { if (drive->state == DMA_PIO_RETRY && drive->retry_pio <= 3) {
drive->state = 0; drive->state = 0;
hwgroup->hwif->dmaproc(ide_dma_on, drive); HWGROUP(drive)->hwif->dmaproc(ide_dma_on, drive);
} }
if (!end_that_request_first(rq, uptodate, nr_secs)) { if (!end_that_request_first(rq, uptodate, nr_secs)) {
add_blkdev_randomness(major(rq->rq_dev)); add_blkdev_randomness(major(rq->rq_dev));
blkdev_dequeue_request(rq); blkdev_dequeue_request(rq);
hwgroup->rq = NULL; HWGROUP(drive)->rq = NULL;
end_that_request_last(rq); end_that_request_last(rq);
ret = 0; ret = 0;
} }
...@@ -412,14 +411,6 @@ inline int __ide_end_request(ide_hwgroup_t *hwgroup, int uptodate, int nr_secs) ...@@ -412,14 +411,6 @@ inline int __ide_end_request(ide_hwgroup_t *hwgroup, int uptodate, int nr_secs)
return ret; return ret;
} }
/*
* This is our end_request replacement function.
*/
int ide_end_request (byte uptodate, ide_hwgroup_t *hwgroup)
{
return __ide_end_request(hwgroup, uptodate, 0);
}
/* /*
* This should get invoked any time we exit the driver to * This should get invoked any time we exit the driver to
* wait for an interrupt response from a drive. handler() points * wait for an interrupt response from a drive. handler() points
...@@ -909,9 +900,9 @@ ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat) ...@@ -909,9 +900,9 @@ ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat)
if (rq->errors >= ERROR_MAX) { if (rq->errors >= ERROR_MAX) {
if (drive->driver != NULL) if (drive->driver != NULL)
DRIVER(drive)->end_request(0, HWGROUP(drive)); DRIVER(drive)->end_request(drive, 0);
else else
ide_end_request(0, HWGROUP(drive)); ide_end_request(drive, 0);
} else { } else {
if ((rq->errors & ERROR_RESET) == ERROR_RESET) { if ((rq->errors & ERROR_RESET) == ERROR_RESET) {
++rq->errors; ++rq->errors;
...@@ -1212,9 +1203,9 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) ...@@ -1212,9 +1203,9 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
return do_special(drive); return do_special(drive);
kill_rq: kill_rq:
if (drive->driver != NULL) if (drive->driver != NULL)
DRIVER(drive)->end_request(0, HWGROUP(drive)); DRIVER(drive)->end_request(drive, 0);
else else
ide_end_request(0, HWGROUP(drive)); ide_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
...@@ -2126,7 +2117,6 @@ void ide_unregister (unsigned int index) ...@@ -2126,7 +2117,6 @@ void ide_unregister (unsigned int index)
*/ */
unregister_blkdev(hwif->major, hwif->name); unregister_blkdev(hwif->major, hwif->name);
kfree(blksize_size[hwif->major]); kfree(blksize_size[hwif->major]);
kfree(max_readahead[hwif->major]);
blk_dev[hwif->major].data = NULL; blk_dev[hwif->major].data = NULL;
blk_dev[hwif->major].queue = NULL; blk_dev[hwif->major].queue = NULL;
blk_clear(hwif->major); blk_clear(hwif->major);
...@@ -2279,7 +2269,8 @@ int ide_register (int arg1, int arg2, int irq) ...@@ -2279,7 +2269,8 @@ int ide_register (int arg1, int arg2, int irq)
void ide_add_setting (ide_drive_t *drive, const char *name, int rw, int read_ioctl, int write_ioctl, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set) void ide_add_setting (ide_drive_t *drive, const char *name, int rw, int read_ioctl, int write_ioctl, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set)
{ {
ide_settings_t **p = (ide_settings_t **) &drive->settings, *setting = NULL; ide_settings_t **p = &drive->settings;
ide_settings_t *setting = NULL;
while ((*p) && strcmp((*p)->name, name) < 0) while ((*p) && strcmp((*p)->name, name) < 0)
p = &((*p)->next); p = &((*p)->next);
...@@ -2305,7 +2296,7 @@ void ide_add_setting (ide_drive_t *drive, const char *name, int rw, int read_ioc ...@@ -2305,7 +2296,7 @@ void ide_add_setting (ide_drive_t *drive, const char *name, int rw, int read_ioc
void ide_remove_setting (ide_drive_t *drive, char *name) void ide_remove_setting (ide_drive_t *drive, char *name)
{ {
ide_settings_t **p = (ide_settings_t **) &drive->settings, *setting; ide_settings_t **p = &drive->settings, *setting;
while ((*p) && strcmp((*p)->name, name)) while ((*p) && strcmp((*p)->name, name))
p = &((*p)->next); p = &((*p)->next);
...@@ -2316,30 +2307,6 @@ void ide_remove_setting (ide_drive_t *drive, char *name) ...@@ -2316,30 +2307,6 @@ void ide_remove_setting (ide_drive_t *drive, char *name)
kfree(setting); kfree(setting);
} }
static ide_settings_t *ide_find_setting_by_ioctl (ide_drive_t *drive, int cmd)
{
ide_settings_t *setting = drive->settings;
while (setting) {
if (setting->read_ioctl == cmd || setting->write_ioctl == cmd)
break;
setting = setting->next;
}
return setting;
}
ide_settings_t *ide_find_setting_by_name (ide_drive_t *drive, char *name)
{
ide_settings_t *setting = drive->settings;
while (setting) {
if (strcmp(setting->name, name) == 0)
break;
setting = setting->next;
}
return setting;
}
static void auto_remove_settings (ide_drive_t *drive) static void auto_remove_settings (ide_drive_t *drive)
{ {
ide_settings_t *setting; ide_settings_t *setting;
...@@ -2614,7 +2581,17 @@ static int ide_ioctl (struct inode *inode, struct file *file, ...@@ -2614,7 +2581,17 @@ static int ide_ioctl (struct inode *inode, struct file *file,
if ((drive = get_info_ptr(inode->i_rdev)) == NULL) if ((drive = get_info_ptr(inode->i_rdev)) == NULL)
return -ENODEV; return -ENODEV;
if ((setting = ide_find_setting_by_ioctl(drive, cmd)) != NULL) { /* Find setting by ioctl */
setting = drive->settings;
while (setting) {
if (setting->read_ioctl == cmd || setting->write_ioctl == cmd)
break;
setting = setting->next;
}
if (setting != NULL) {
if (cmd == setting->read_ioctl) { if (cmd == setting->read_ioctl) {
err = ide_read_setting(drive, setting); err = ide_read_setting(drive, setting);
return err >= 0 ? put_user(err, (long *) arg) : err; return err >= 0 ? put_user(err, (long *) arg) : err;
...@@ -3481,15 +3458,16 @@ static int default_flushcache (ide_drive_t *drive) ...@@ -3481,15 +3458,16 @@ static int default_flushcache (ide_drive_t *drive)
static ide_startstop_t default_do_request(ide_drive_t *drive, struct request *rq, unsigned long block) static ide_startstop_t default_do_request(ide_drive_t *drive, struct request *rq, unsigned long block)
{ {
ide_end_request(0, HWGROUP(drive)); ide_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
static void default_end_request (byte uptodate, ide_hwgroup_t *hwgroup) /* This is the default end request function as well */
int ide_end_request(ide_drive_t *drive, int uptodate)
{ {
ide_end_request(uptodate, hwgroup); return __ide_end_request(drive, uptodate, 0);
} }
static int default_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file, static int default_ioctl (ide_drive_t *drive, struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
...@@ -3536,25 +3514,6 @@ static int default_driver_reinit (ide_drive_t *drive) ...@@ -3536,25 +3514,6 @@ static int default_driver_reinit (ide_drive_t *drive)
return 0; return 0;
} }
static void setup_driver_defaults (ide_drive_t *drive)
{
ide_driver_t *d = drive->driver;
if (d->cleanup == NULL) d->cleanup = default_cleanup;
if (d->standby == NULL) d->standby = default_standby;
if (d->flushcache == NULL) d->flushcache = default_flushcache;
if (d->do_request == NULL) d->do_request = default_do_request;
if (d->end_request == NULL) d->end_request = default_end_request;
if (d->ioctl == NULL) d->ioctl = default_ioctl;
if (d->open == NULL) d->open = default_open;
if (d->release == NULL) d->release = default_release;
if (d->media_change == NULL) d->media_change = default_check_media_change;
if (d->pre_reset == NULL) d->pre_reset = default_pre_reset;
if (d->capacity == NULL) d->capacity = default_capacity;
if (d->special == NULL) d->special = default_special;
if (d->driver_reinit == NULL) d->driver_reinit = default_driver_reinit;
}
ide_drive_t *ide_scan_devices (byte media, const char *name, ide_driver_t *driver, int n) ide_drive_t *ide_scan_devices (byte media, const char *name, ide_driver_t *driver, int n)
{ {
unsigned int unit, index, i; unsigned int unit, index, i;
...@@ -3578,15 +3537,46 @@ ide_drive_t *ide_scan_devices (byte media, const char *name, ide_driver_t *drive ...@@ -3578,15 +3537,46 @@ ide_drive_t *ide_scan_devices (byte media, const char *name, ide_driver_t *drive
int ide_register_subdriver (ide_drive_t *drive, ide_driver_t *driver, int version) int ide_register_subdriver (ide_drive_t *drive, ide_driver_t *driver, int version)
{ {
unsigned long flags; unsigned long flags;
save_flags(flags); /* all CPUs */ save_flags(flags); /* all CPUs */
cli(); /* all CPUs */ cli(); /* all CPUs */
if (version != IDE_SUBDRIVER_VERSION || !drive->present || drive->driver != NULL || drive->busy || drive->usage) { if (version != IDE_SUBDRIVER_VERSION || !drive->present || drive->driver != NULL || drive->busy || drive->usage) {
restore_flags(flags); /* all CPUs */ restore_flags(flags); /* all CPUs */
return 1; return 1;
} }
drive->driver = driver; drive->driver = driver;
setup_driver_defaults(drive);
/* Fill in the default handlers
*/
if (driver->cleanup == NULL)
driver->cleanup = default_cleanup;
if (driver->standby == NULL)
driver->standby = default_standby;
if (driver->flushcache == NULL)
driver->flushcache = default_flushcache;
if (driver->do_request == NULL)
driver->do_request = default_do_request;
if (driver->end_request == NULL)
driver->end_request = ide_end_request;
if (driver->ioctl == NULL)
driver->ioctl = default_ioctl;
if (driver->open == NULL)
driver->open = default_open;
if (driver->release == NULL)
driver->release = default_release;
if (driver->media_change == NULL)
driver->media_change = default_check_media_change;
if (driver->pre_reset == NULL)
driver->pre_reset = default_pre_reset;
if (driver->capacity == NULL)
driver->capacity = default_capacity;
if (driver->special == NULL)
driver->special = default_special;
if (driver->driver_reinit == NULL)
driver->driver_reinit = default_driver_reinit;
restore_flags(flags); /* all CPUs */ restore_flags(flags); /* all CPUs */
if (drive->autotune != 2) { if (drive->autotune != 2) {
if (driver->supports_dma && HWIF(drive)->dmaproc != NULL) { if (driver->supports_dma && HWIF(drive)->dmaproc != NULL) {
...@@ -3614,7 +3604,7 @@ int ide_register_subdriver (ide_drive_t *drive, ide_driver_t *driver, int versio ...@@ -3614,7 +3604,7 @@ int ide_register_subdriver (ide_drive_t *drive, ide_driver_t *driver, int versio
int ide_unregister_subdriver (ide_drive_t *drive) int ide_unregister_subdriver (ide_drive_t *drive)
{ {
unsigned long flags; unsigned long flags;
save_flags(flags); /* all CPUs */ save_flags(flags); /* all CPUs */
cli(); /* all CPUs */ cli(); /* all CPUs */
if (drive->usage || drive->busy || drive->driver == NULL || DRIVER(drive)->busy) { if (drive->usage || drive->busy || drive->driver == NULL || DRIVER(drive)->busy) {
...@@ -3704,8 +3694,8 @@ EXPORT_SYMBOL(restart_request); ...@@ -3704,8 +3694,8 @@ EXPORT_SYMBOL(restart_request);
EXPORT_SYMBOL(ide_init_drive_cmd); EXPORT_SYMBOL(ide_init_drive_cmd);
EXPORT_SYMBOL(ide_do_drive_cmd); EXPORT_SYMBOL(ide_do_drive_cmd);
EXPORT_SYMBOL(ide_end_drive_cmd); EXPORT_SYMBOL(ide_end_drive_cmd);
EXPORT_SYMBOL(ide_end_request);
EXPORT_SYMBOL(__ide_end_request); EXPORT_SYMBOL(__ide_end_request);
EXPORT_SYMBOL(ide_end_request);
EXPORT_SYMBOL(ide_revalidate_drive); EXPORT_SYMBOL(ide_revalidate_drive);
EXPORT_SYMBOL(ide_revalidate_disk); EXPORT_SYMBOL(ide_revalidate_disk);
EXPORT_SYMBOL(ide_cmd); EXPORT_SYMBOL(ide_cmd);
......
...@@ -345,7 +345,7 @@ static ide_startstop_t promise_read_intr (ide_drive_t *drive) ...@@ -345,7 +345,7 @@ static ide_startstop_t promise_read_intr (ide_drive_t *drive)
rq->nr_sectors -= nsect; rq->nr_sectors -= nsect;
total_remaining = rq->nr_sectors; total_remaining = rq->nr_sectors;
if ((rq->current_nr_sectors -= nsect) <= 0) { if ((rq->current_nr_sectors -= nsect) <= 0) {
ide_end_request(1, HWGROUP(drive)); ide_end_request(drive, 1);
} }
/* /*
* Now the data has been read in, do the following: * Now the data has been read in, do the following:
...@@ -407,7 +407,8 @@ static ide_startstop_t promise_complete_pollfunc(ide_drive_t *drive) ...@@ -407,7 +407,8 @@ static ide_startstop_t promise_complete_pollfunc(ide_drive_t *drive)
#ifdef DEBUG_WRITE #ifdef DEBUG_WRITE
printk(KERN_DEBUG "%s: Write complete - end_request\n", drive->name); printk(KERN_DEBUG "%s: Write complete - end_request\n", drive->name);
#endif #endif
__ide_end_request(hwgroup, 1, rq->nr_sectors); __ide_end_request(drive, 1, rq->nr_sectors);
return ide_stopped; return ide_stopped;
} }
...@@ -571,7 +572,7 @@ ide_startstop_t do_pdc4030_io (ide_drive_t *drive, ide_task_t *task) ...@@ -571,7 +572,7 @@ ide_startstop_t do_pdc4030_io (ide_drive_t *drive, ide_task_t *task)
/* Check that it's a regular command. If not, bomb out early. */ /* Check that it's a regular command. If not, bomb out early. */
if (!(rq->flags & REQ_CMD)) { if (!(rq->flags & REQ_CMD)) {
blk_dump_rq_flags(rq, "pdc4030 bad flags"); blk_dump_rq_flags(rq, "pdc4030 bad flags");
ide_end_request(0, HWGROUP(drive)); ide_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
...@@ -633,7 +634,7 @@ ide_startstop_t do_pdc4030_io (ide_drive_t *drive, ide_task_t *task) ...@@ -633,7 +634,7 @@ ide_startstop_t do_pdc4030_io (ide_drive_t *drive, ide_task_t *task)
default: default:
printk(KERN_ERR "pdc4030: command not READ or WRITE! Huh?\n"); printk(KERN_ERR "pdc4030: command not READ or WRITE! Huh?\n");
ide_end_request(0, HWGROUP(drive)); ide_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
} }
......
...@@ -259,11 +259,10 @@ static void hexdump(u8 *x, int len) ...@@ -259,11 +259,10 @@ static void hexdump(u8 *x, int len)
printk("]\n"); printk("]\n");
} }
static void idescsi_end_request (byte uptodate, ide_hwgroup_t *hwgroup) static int idescsi_end_request(ide_drive_t *drive, int uptodate)
{ {
ide_drive_t *drive = hwgroup->drive;
idescsi_scsi_t *scsi = drive->driver_data; idescsi_scsi_t *scsi = drive->driver_data;
struct request *rq = hwgroup->rq; struct request *rq = HWGROUP(drive)->rq;
idescsi_pc_t *pc = (idescsi_pc_t *) rq->special; idescsi_pc_t *pc = (idescsi_pc_t *) rq->special;
int log = test_bit(IDESCSI_LOG_CMD, &scsi->log); int log = test_bit(IDESCSI_LOG_CMD, &scsi->log);
struct Scsi_Host *host; struct Scsi_Host *host;
...@@ -271,8 +270,8 @@ static void idescsi_end_request (byte uptodate, ide_hwgroup_t *hwgroup) ...@@ -271,8 +270,8 @@ static void idescsi_end_request (byte uptodate, ide_hwgroup_t *hwgroup)
unsigned long flags; unsigned long flags;
if (!(rq->flags & REQ_SPECIAL)) { if (!(rq->flags & REQ_SPECIAL)) {
ide_end_request (uptodate, hwgroup); ide_end_request(drive, uptodate);
return; return 0;
} }
ide_end_drive_cmd (drive, 0, 0); ide_end_drive_cmd (drive, 0, 0);
if (rq->errors >= ERROR_MAX) { if (rq->errors >= ERROR_MAX) {
...@@ -302,6 +301,8 @@ static void idescsi_end_request (byte uptodate, ide_hwgroup_t *hwgroup) ...@@ -302,6 +301,8 @@ static void idescsi_end_request (byte uptodate, ide_hwgroup_t *hwgroup)
idescsi_free_bio (rq->bio); idescsi_free_bio (rq->bio);
kfree(pc); kfree(rq); kfree(pc); kfree(rq);
scsi->pc = NULL; scsi->pc = NULL;
return 0;
} }
static inline unsigned long get_timeout(idescsi_pc_t *pc) static inline unsigned long get_timeout(idescsi_pc_t *pc)
...@@ -341,7 +342,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) ...@@ -341,7 +342,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
ide__sti(); ide__sti();
if (status & ERR_STAT) if (status & ERR_STAT)
rq->errors++; rq->errors++;
idescsi_end_request (1, HWGROUP(drive)); idescsi_end_request(drive, 1);
return ide_stopped; return ide_stopped;
} }
bcount = IN_BYTE (IDE_BCOUNTH_REG) << 8 | IN_BYTE (IDE_BCOUNTL_REG); bcount = IN_BYTE (IDE_BCOUNTH_REG) << 8 | IN_BYTE (IDE_BCOUNTL_REG);
...@@ -470,7 +471,7 @@ static ide_startstop_t idescsi_do_request (ide_drive_t *drive, struct request *r ...@@ -470,7 +471,7 @@ static ide_startstop_t idescsi_do_request (ide_drive_t *drive, struct request *r
return idescsi_issue_pc (drive, (idescsi_pc_t *) rq->special); return idescsi_issue_pc (drive, (idescsi_pc_t *) rq->special);
} }
blk_dump_rq_flags(rq, "ide-scsi: unsup command"); blk_dump_rq_flags(rq, "ide-scsi: unsup command");
idescsi_end_request (0,HWGROUP (drive)); idescsi_end_request(drive, 0);
return ide_stopped; return ide_stopped;
} }
...@@ -541,7 +542,6 @@ int idescsi_reinit(ide_drive_t *drive); ...@@ -541,7 +542,6 @@ int idescsi_reinit(ide_drive_t *drive);
*/ */
static ide_driver_t idescsi_driver = { static ide_driver_t idescsi_driver = {
name: "ide-scsi", name: "ide-scsi",
version: IDESCSI_VERSION,
media: ide_scsi, media: ide_scsi,
busy: 0, busy: 0,
supports_dma: 1, supports_dma: 1,
......
...@@ -367,6 +367,8 @@ typedef union { ...@@ -367,6 +367,8 @@ typedef union {
} b; } b;
} special_t; } special_t;
struct ide_settings_s;
typedef struct ide_drive_s { typedef struct ide_drive_s {
request_queue_t queue; /* request queue */ request_queue_t queue; /* request queue */
struct ide_drive_s *next; /* circular list of hwgroup drives */ struct ide_drive_s *next; /* circular list of hwgroup drives */
...@@ -415,7 +417,7 @@ typedef struct ide_drive_s { ...@@ -415,7 +417,7 @@ typedef struct ide_drive_s {
byte nowerr; /* used for ignoring WRERR_STAT */ byte nowerr; /* used for ignoring WRERR_STAT */
byte sect0; /* offset of first sector for DM6:DDO */ byte sect0; /* offset of first sector for DM6:DDO */
unsigned int usage; /* current "open()" count for drive */ unsigned int usage; /* current "open()" count for drive */
byte head; /* "real" number of heads */ byte head; /* "real" number of heads */
byte sect; /* "real" sectors per track */ byte sect; /* "real" sectors per track */
byte bios_head; /* BIOS/fdisk/LILO number of heads */ byte bios_head; /* BIOS/fdisk/LILO number of heads */
byte bios_sect; /* BIOS/fdisk/LILO sectors per track */ byte bios_sect; /* BIOS/fdisk/LILO sectors per track */
...@@ -433,7 +435,7 @@ typedef struct ide_drive_s { ...@@ -433,7 +435,7 @@ typedef struct ide_drive_s {
void *driver_data; /* extra driver data */ void *driver_data; /* extra driver data */
devfs_handle_t de; /* directory for device */ devfs_handle_t de; /* directory for device */
struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ struct proc_dir_entry *proc; /* /proc/ide/ directory entry */
void *settings; /* /proc/ide/ drive settings */ struct ide_settings_s *settings; /* /proc/ide/ drive settings */
char driver_req[10]; /* requests specific driver */ char driver_req[10]; /* requests specific driver */
int last_lun; /* last logical unit */ int last_lun; /* last logical unit */
int forced_lun; /* if hdxlun was given at boot */ int forced_lun; /* if hdxlun was given at boot */
...@@ -652,7 +654,6 @@ typedef struct ide_settings_s { ...@@ -652,7 +654,6 @@ typedef struct ide_settings_s {
void ide_add_setting(ide_drive_t *drive, const char *name, int rw, int read_ioctl, int write_ioctl, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set); void ide_add_setting(ide_drive_t *drive, const char *name, int rw, int read_ioctl, int write_ioctl, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set);
void ide_remove_setting(ide_drive_t *drive, char *name); void ide_remove_setting(ide_drive_t *drive, char *name);
ide_settings_t *ide_find_setting_by_name(ide_drive_t *drive, char *name);
int ide_read_setting(ide_drive_t *t, ide_settings_t *setting); int ide_read_setting(ide_drive_t *t, ide_settings_t *setting);
int ide_write_setting(ide_drive_t *drive, ide_settings_t *setting, int val); int ide_write_setting(ide_drive_t *drive, ide_settings_t *setting, int val);
void ide_add_generic_settings(ide_drive_t *drive); void ide_add_generic_settings(ide_drive_t *drive);
...@@ -703,44 +704,29 @@ read_proc_t proc_ide_read_geometry; ...@@ -703,44 +704,29 @@ read_proc_t proc_ide_read_geometry;
*/ */
#define IDE_SUBDRIVER_VERSION 1 #define IDE_SUBDRIVER_VERSION 1
typedef int (ide_cleanup_proc)(ide_drive_t *);
typedef int (ide_standby_proc)(ide_drive_t *);
typedef int (ide_flushcache_proc)(ide_drive_t *);
typedef ide_startstop_t (ide_do_request_proc)(ide_drive_t *, struct request *, unsigned long);
typedef void (ide_end_request_proc)(byte, ide_hwgroup_t *);
typedef int (ide_ioctl_proc)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
typedef int (ide_open_proc)(struct inode *, struct file *, ide_drive_t *);
typedef void (ide_release_proc)(struct inode *, struct file *, ide_drive_t *);
typedef int (ide_check_media_change_proc)(ide_drive_t *);
typedef void (ide_revalidate_proc)(ide_drive_t *);
typedef void (ide_pre_reset_proc)(ide_drive_t *);
typedef unsigned long (ide_capacity_proc)(ide_drive_t *);
typedef ide_startstop_t (ide_special_proc)(ide_drive_t *);
typedef void (ide_setting_proc)(ide_drive_t *); typedef void (ide_setting_proc)(ide_drive_t *);
typedef int (ide_driver_reinit_proc)(ide_drive_t *);
typedef struct ide_driver_s { typedef struct ide_driver_s {
const char *name; const char *name;
const char *version;
byte media; byte media;
unsigned busy : 1; unsigned busy : 1;
unsigned supports_dma : 1; unsigned supports_dma : 1;
unsigned supports_dsc_overlap : 1; unsigned supports_dsc_overlap : 1;
ide_cleanup_proc *cleanup; int (*cleanup)(ide_drive_t *);
ide_standby_proc *standby; int (*standby)(ide_drive_t *);
ide_flushcache_proc *flushcache; int (*flushcache)(ide_drive_t *);
ide_do_request_proc *do_request; ide_startstop_t (*do_request)(ide_drive_t *, struct request *, unsigned long);
ide_end_request_proc *end_request; int (*end_request)(ide_drive_t *drive, int uptodate);
ide_ioctl_proc *ioctl; int (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
ide_open_proc *open; int (*open)(struct inode *, struct file *, ide_drive_t *);
ide_release_proc *release; void (*release)(struct inode *, struct file *, ide_drive_t *);
ide_check_media_change_proc *media_change; int (*media_change)(ide_drive_t *);
ide_revalidate_proc *revalidate; void (*revalidate)(ide_drive_t *);
ide_pre_reset_proc *pre_reset; void (*pre_reset)(ide_drive_t *);
ide_capacity_proc *capacity; unsigned long (*capacity)(ide_drive_t *);
ide_special_proc *special; ide_startstop_t (*special)(ide_drive_t *);
ide_proc_entry_t *proc; ide_proc_entry_t *proc;
ide_driver_reinit_proc *driver_reinit; int (*driver_reinit)(ide_drive_t *);
} ide_driver_t; } ide_driver_t;
#define DRIVER(drive) ((ide_driver_t *)((drive)->driver)) #define DRIVER(drive) ((ide_driver_t *)((drive)->driver))
...@@ -752,13 +738,12 @@ typedef struct ide_driver_s { ...@@ -752,13 +738,12 @@ typedef struct ide_driver_s {
#define IDE_PROBE_MODULE 1 #define IDE_PROBE_MODULE 1
#define IDE_DRIVER_MODULE 2 #define IDE_DRIVER_MODULE 2
typedef int (ide_module_init_proc)(void);
typedef struct ide_module_s { typedef struct ide_module_s {
int type; int type;
ide_module_init_proc *init; int (*init)(void);
void *info; void *info;
struct ide_module_s *next; struct ide_module_s *next;
} ide_module_t; } ide_module_t;
/* /*
...@@ -783,10 +768,8 @@ extern int noautodma; ...@@ -783,10 +768,8 @@ extern int noautodma;
#define LOCAL_END_REQUEST /* Don't generate end_request in blk.h */ #define LOCAL_END_REQUEST /* Don't generate end_request in blk.h */
#include <linux/blk.h> #include <linux/blk.h>
inline int __ide_end_request(ide_hwgroup_t *, int, int); extern int __ide_end_request(ide_drive_t *drive, int uptodate, int nr_secs);
int ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup); extern int ide_end_request(ide_drive_t *drive, int uptodate);
int drive_is_ready (ide_drive_t *drive);
/* /*
* This is used on exit from the driver, to designate the next irq handler * This is used on exit from the driver, to designate the next irq handler
...@@ -1142,4 +1125,6 @@ byte export_probe_for_drive (ide_drive_t *drive); ...@@ -1142,4 +1125,6 @@ byte export_probe_for_drive (ide_drive_t *drive);
extern spinlock_t ide_lock; extern spinlock_t ide_lock;
extern int drive_is_ready(ide_drive_t *drive);
#endif /* _IDE_H */ #endif /* _IDE_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment