Commit 9f87abe892f899f19df8d472f937ee955cd6264b

Authored by Bartlomiej Zolnierkiewicz
1 parent 7c0daf2681

ide: add ide_pad_transfer() helper

* Add ide_pad_transfer() helper (which uses ->{in,out}put_data methods
  internally so the transfer is also padded to drive+host requirements)
  and use it instead of ide_atapi_{write_zeros,discard_data}().

* Remove no longer needed ide_atapi_{write_zeros,discard_data}().

Cc: Borislav Petkov <petkovbb@gmail.com>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

Showing 5 changed files with 24 additions and 33 deletions Side-by-side Diff

drivers/ide/ide-floppy.c
... ... @@ -262,10 +262,7 @@
262 262 if (bcount) {
263 263 printk(KERN_ERR "%s: leftover data in %s, bcount == %d\n",
264 264 drive->name, __func__, bcount);
265   - if (direction)
266   - ide_atapi_write_zeros(drive, bcount);
267   - else
268   - ide_atapi_discard_data(drive, bcount);
  265 + ide_pad_transfer(drive, direction, bcount);
269 266 }
270 267 }
271 268  
... ... @@ -491,7 +488,7 @@
491 488 printk(KERN_ERR "ide-floppy: The floppy wants "
492 489 "to send us more data than expected "
493 490 "- discarding data\n");
494   - ide_atapi_discard_data(drive, bcount);
  491 + ide_pad_transfer(drive, 0, bcount);
495 492  
496 493 ide_set_handler(drive,
497 494 &idefloppy_pc_intr,
drivers/ide/ide-io.c
... ... @@ -1642,4 +1642,19 @@
1642 1642 }
1643 1643  
1644 1644 EXPORT_SYMBOL_GPL(ide_pktcmd_tf_load);
  1645 +
  1646 +void ide_pad_transfer(ide_drive_t *drive, int write, int len)
  1647 +{
  1648 + ide_hwif_t *hwif = drive->hwif;
  1649 + u8 buf[4] = { 0 };
  1650 +
  1651 + while (len > 0) {
  1652 + if (write)
  1653 + hwif->output_data(drive, NULL, buf, min(4, len));
  1654 + else
  1655 + hwif->input_data(drive, NULL, buf, min(4, len));
  1656 + len -= 4;
  1657 + }
  1658 +}
  1659 +EXPORT_SYMBOL_GPL(ide_pad_transfer);
drivers/ide/ide-tape.c
... ... @@ -395,7 +395,7 @@
395 395 if (bh == NULL) {
396 396 printk(KERN_ERR "ide-tape: bh == NULL in "
397 397 "idetape_input_buffers\n");
398   - ide_atapi_discard_data(drive, bcount);
  398 + ide_pad_transfer(drive, 0, bcount);
399 399 return;
400 400 }
401 401 count = min(
... ... @@ -871,7 +871,7 @@
871 871 printk(KERN_ERR "ide-tape: The tape wants to "
872 872 "send us more data than expected "
873 873 "- discarding data\n");
874   - ide_atapi_discard_data(drive, bcount);
  874 + ide_pad_transfer(drive, 0, bcount);
875 875 ide_set_handler(drive, &idetape_pc_intr,
876 876 IDETAPE_WAIT_CMD, NULL);
877 877 return ide_started;
drivers/scsi/ide-scsi.c
... ... @@ -164,7 +164,7 @@
164 164  
165 165 if (bcount) {
166 166 printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n");
167   - ide_atapi_discard_data(drive, bcount);
  167 + ide_pad_transfer(drive, 0, bcount);
168 168 }
169 169 }
170 170  
... ... @@ -201,7 +201,7 @@
201 201  
202 202 if (bcount) {
203 203 printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n");
204   - ide_atapi_write_zeros(drive, bcount);
  204 + ide_pad_transfer(drive, 1, bcount);
205 205 }
206 206 }
207 207  
... ... @@ -438,7 +438,7 @@
438 438 }
439 439 pc->xferred += temp;
440 440 pc->cur_pos += temp;
441   - ide_atapi_discard_data(drive, bcount - temp);
  441 + ide_pad_transfer(drive, 0, bcount - temp);
442 442 ide_set_handler(drive, &idescsi_pc_intr, get_timeout(pc), idescsi_expiry);
443 443 return ide_started;
444 444 }
... ... @@ -827,6 +827,8 @@
827 827  
828 828 void ide_execute_pkt_cmd(ide_drive_t *);
829 829  
  830 +void ide_pad_transfer(ide_drive_t *, int, int);
  831 +
830 832 ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);
831 833  
832 834 ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);
... ... @@ -1359,28 +1361,5 @@
1359 1361  
1360 1362 return hwif->INB(hwif->io_ports.error_addr);
1361 1363 }
1362   -
1363   -/*
1364   - * Too bad. The drive wants to send us data which we are not ready to accept.
1365   - * Just throw it away.
1366   - */
1367   -static inline void ide_atapi_discard_data(ide_drive_t *drive, unsigned bcount)
1368   -{
1369   - ide_hwif_t *hwif = drive->hwif;
1370   -
1371   - /* FIXME: use ->input_data */
1372   - while (bcount--)
1373   - (void)hwif->INB(hwif->io_ports.data_addr);
1374   -}
1375   -
1376   -static inline void ide_atapi_write_zeros(ide_drive_t *drive, unsigned bcount)
1377   -{
1378   - ide_hwif_t *hwif = drive->hwif;
1379   -
1380   - /* FIXME: use ->output_data */
1381   - while (bcount--)
1382   - hwif->OUTB(0, hwif->io_ports.data_addr);
1383   -}
1384   -
1385 1364 #endif /* _IDE_H */