aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-17 18:46:26 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-04-17 18:46:26 -0400
commit7616c0ad2087c7d244b8985390c63059a6223c45 (patch)
treec65d7e5dce8b6ec314b56ad2903c8760e2659753
parent3ad6776cca21f2456b7288f44f224b344ac3c4d0 (diff)
ide: add ide_atapi_{discard_data,write_zeros} inline helpers
Add ide_atapi_{discard_data,write_zeros} inline helpers to <linux/ide.h> and use them instead of home-brewn helpers in ide-{floppy,tape,scsi}. There should be no functional changes caused by this patch. Cc: Borislav Petkov <petkovbb@gmail.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/ide-floppy.c24
-rw-r--r--drivers/ide/ide-tape.c14
-rw-r--r--drivers/scsi/ide-scsi.c18
-rw-r--r--include/linux/ide.h22
4 files changed, 30 insertions, 48 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 973f5f6c815..170c60d93f5 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -230,23 +230,6 @@ static void ide_floppy_put(struct ide_floppy_obj *floppy)
230} 230}
231 231
232/* 232/*
233 * Too bad. The drive wants to send us data which we are not ready to accept.
234 * Just throw it away.
235 */
236static void idefloppy_discard_data(ide_drive_t *drive, unsigned int bcount)
237{
238 while (bcount--)
239 (void) HWIF(drive)->INB(IDE_DATA_REG);
240}
241
242static void idefloppy_write_zeros(ide_drive_t *drive, unsigned int bcount)
243{
244 while (bcount--)
245 HWIF(drive)->OUTB(0, IDE_DATA_REG);
246}
247
248
249/*
250 * Used to finish servicing a request. For read/write requests, we will call 233 * Used to finish servicing a request. For read/write requests, we will call
251 * ide_end_request to pass to the next buffer. 234 * ide_end_request to pass to the next buffer.
252 */ 235 */
@@ -313,10 +296,9 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, idefloppy_pc_t *pc,
313 printk(KERN_ERR "%s: leftover data in %s, bcount == %d\n", 296 printk(KERN_ERR "%s: leftover data in %s, bcount == %d\n",
314 drive->name, __func__, bcount); 297 drive->name, __func__, bcount);
315 if (direction) 298 if (direction)
316 idefloppy_write_zeros(drive, bcount); 299 ide_atapi_write_zeros(drive, bcount);
317 else 300 else
318 idefloppy_discard_data(drive, bcount); 301 ide_atapi_discard_data(drive, bcount);
319
320 } 302 }
321} 303}
322 304
@@ -541,7 +523,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
541 printk(KERN_ERR "ide-floppy: The floppy wants " 523 printk(KERN_ERR "ide-floppy: The floppy wants "
542 "to send us more data than expected " 524 "to send us more data than expected "
543 "- discarding data\n"); 525 "- discarding data\n");
544 idefloppy_discard_data(drive, bcount); 526 ide_atapi_discard_data(drive, bcount);
545 527
546 ide_set_handler(drive, 528 ide_set_handler(drive,
547 &idefloppy_pc_intr, 529 &idefloppy_pc_intr,
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 0598ecfd5f3..bfdc4f44979 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -518,16 +518,6 @@ static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i)
518 return tape; 518 return tape;
519} 519}
520 520
521/*
522 * Too bad. The drive wants to send us data which we are not ready to accept.
523 * Just throw it away.
524 */
525static void idetape_discard_data(ide_drive_t *drive, unsigned int bcount)
526{
527 while (bcount--)
528 (void) HWIF(drive)->INB(IDE_DATA_REG);
529}
530
531static void idetape_input_buffers(ide_drive_t *drive, idetape_pc_t *pc, 521static void idetape_input_buffers(ide_drive_t *drive, idetape_pc_t *pc,
532 unsigned int bcount) 522 unsigned int bcount)
533{ 523{
@@ -538,7 +528,7 @@ static void idetape_input_buffers(ide_drive_t *drive, idetape_pc_t *pc,
538 if (bh == NULL) { 528 if (bh == NULL) {
539 printk(KERN_ERR "ide-tape: bh == NULL in " 529 printk(KERN_ERR "ide-tape: bh == NULL in "
540 "idetape_input_buffers\n"); 530 "idetape_input_buffers\n");
541 idetape_discard_data(drive, bcount); 531 ide_atapi_discard_data(drive, bcount);
542 return; 532 return;
543 } 533 }
544 count = min( 534 count = min(
@@ -1152,7 +1142,7 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive)
1152 printk(KERN_ERR "ide-tape: The tape wants to " 1142 printk(KERN_ERR "ide-tape: The tape wants to "
1153 "send us more data than expected " 1143 "send us more data than expected "
1154 "- discarding data\n"); 1144 "- discarding data\n");
1155 idetape_discard_data(drive, bcount); 1145 ide_atapi_discard_data(drive, bcount);
1156 ide_set_handler(drive, &idetape_pc_intr, 1146 ide_set_handler(drive, &idetape_pc_intr,
1157 IDETAPE_WAIT_CMD, NULL); 1147 IDETAPE_WAIT_CMD, NULL);
1158 return ide_started; 1148 return ide_started;
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 68e5c632c5d..3c3b3502c4d 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -152,18 +152,6 @@ static inline idescsi_scsi_t *drive_to_idescsi(ide_drive_t *ide_drive)
152 */ 152 */
153#define IDESCSI_PC_RQ 90 153#define IDESCSI_PC_RQ 90
154 154
155static void idescsi_discard_data (ide_drive_t *drive, unsigned int bcount)
156{
157 while (bcount--)
158 (void) HWIF(drive)->INB(IDE_DATA_REG);
159}
160
161static void idescsi_output_zeros (ide_drive_t *drive, unsigned int bcount)
162{
163 while (bcount--)
164 HWIF(drive)->OUTB(0, IDE_DATA_REG);
165}
166
167/* 155/*
168 * PIO data transfer routines using the scatter gather table. 156 * PIO data transfer routines using the scatter gather table.
169 */ 157 */
@@ -200,7 +188,7 @@ static void idescsi_input_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsigne
200 188
201 if (bcount) { 189 if (bcount) {
202 printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n"); 190 printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n");
203 idescsi_discard_data (drive, bcount); 191 ide_atapi_discard_data(drive, bcount);
204 } 192 }
205} 193}
206 194
@@ -237,7 +225,7 @@ static void idescsi_output_buffers (ide_drive_t *drive, idescsi_pc_t *pc, unsign
237 225
238 if (bcount) { 226 if (bcount) {
239 printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n"); 227 printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n");
240 idescsi_output_zeros (drive, bcount); 228 ide_atapi_write_zeros(drive, bcount);
241 } 229 }
242} 230}
243 231
@@ -463,7 +451,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive)
463 } 451 }
464 pc->actually_transferred += temp; 452 pc->actually_transferred += temp;
465 pc->current_position += temp; 453 pc->current_position += temp;
466 idescsi_discard_data(drive, bcount - temp); 454 ide_atapi_discard_data(drive, bcount - temp);
467 ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry); 455 ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
468 return ide_started; 456 return ide_started;
469 } 457 }
diff --git a/include/linux/ide.h b/include/linux/ide.h
index f4c7db572a1..2eb99cab4a3 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1297,4 +1297,26 @@ static inline u8 ide_read_error(ide_drive_t *drive)
1297 return hwif->INB(hwif->io_ports[IDE_ERROR_OFFSET]); 1297 return hwif->INB(hwif->io_ports[IDE_ERROR_OFFSET]);
1298} 1298}
1299 1299
1300/*
1301 * Too bad. The drive wants to send us data which we are not ready to accept.
1302 * Just throw it away.
1303 */
1304static inline void ide_atapi_discard_data(ide_drive_t *drive, unsigned bcount)
1305{
1306 ide_hwif_t *hwif = drive->hwif;
1307
1308 /* FIXME: use ->atapi_input_bytes */
1309 while (bcount--)
1310 (void)hwif->INB(hwif->io_ports[IDE_DATA_OFFSET]);
1311}
1312
1313static inline void ide_atapi_write_zeros(ide_drive_t *drive, unsigned bcount)
1314{
1315 ide_hwif_t *hwif = drive->hwif;
1316
1317 /* FIXME: use ->atapi_output_bytes */
1318 while (bcount--)
1319 hwif->OUTB(0, hwif->io_ports[IDE_DATA_OFFSET]);
1320}
1321
1300#endif /* _IDE_H */ 1322#endif /* _IDE_H */