diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-03-31 14:15:26 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-03-31 14:15:26 -0400 |
commit | d93bc4521c80e9d87767779814e88f6d725453d7 (patch) | |
tree | 6c373208132f687e4ffb31db6c60e2a8638f6080 /drivers/ide/ide-tape.c | |
parent | 9f5af4d667a6d4ebd66019b4b26b445ddbae6d6c (diff) |
ide-{floppy,tape}: fix padding for PIO transfers
* Return number of bytes left to transfer from idetape_{in,out}put_buffers()
and number of bytes done from ide_tape_io_buffers().
* Fix padding for PIO transfers in ide_pc_intr() so read/write buffers are
always completely processed and then the transfer is padded if necessary.
* Remove invalid error messages.
* Remove now superfluous padding from ide{_io_buffers,tape_input_buffers}().
While at it:
* Set pc->bh to NULL in idetape_input_buffers() after all bh-s are done.
* Cache !!(pc->flags & PC_FLAG_WRITING) in local variable in ide_pc_intr().
Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r-- | drivers/ide/ide-tape.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index cafc67d9e2e8..cb942a9b580f 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -297,19 +297,15 @@ static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i) | |||
297 | return tape; | 297 | return tape; |
298 | } | 298 | } |
299 | 299 | ||
300 | static void idetape_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | 300 | static int idetape_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, |
301 | unsigned int bcount) | 301 | unsigned int bcount) |
302 | { | 302 | { |
303 | struct idetape_bh *bh = pc->bh; | 303 | struct idetape_bh *bh = pc->bh; |
304 | int count; | 304 | int count; |
305 | 305 | ||
306 | while (bcount) { | 306 | while (bcount) { |
307 | if (bh == NULL) { | 307 | if (bh == NULL) |
308 | printk(KERN_ERR "ide-tape: bh == NULL in " | 308 | break; |
309 | "idetape_input_buffers\n"); | ||
310 | ide_pad_transfer(drive, 0, bcount); | ||
311 | return; | ||
312 | } | ||
313 | count = min( | 309 | count = min( |
314 | (unsigned int)(bh->b_size - atomic_read(&bh->b_count)), | 310 | (unsigned int)(bh->b_size - atomic_read(&bh->b_count)), |
315 | bcount); | 311 | bcount); |
@@ -323,21 +319,21 @@ static void idetape_input_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
323 | atomic_set(&bh->b_count, 0); | 319 | atomic_set(&bh->b_count, 0); |
324 | } | 320 | } |
325 | } | 321 | } |
322 | |||
326 | pc->bh = bh; | 323 | pc->bh = bh; |
324 | |||
325 | return bcount; | ||
327 | } | 326 | } |
328 | 327 | ||
329 | static void idetape_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | 328 | static int idetape_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, |
330 | unsigned int bcount) | 329 | unsigned int bcount) |
331 | { | 330 | { |
332 | struct idetape_bh *bh = pc->bh; | 331 | struct idetape_bh *bh = pc->bh; |
333 | int count; | 332 | int count; |
334 | 333 | ||
335 | while (bcount) { | 334 | while (bcount) { |
336 | if (bh == NULL) { | 335 | if (bh == NULL) |
337 | printk(KERN_ERR "ide-tape: bh == NULL in %s\n", | 336 | break; |
338 | __func__); | ||
339 | return; | ||
340 | } | ||
341 | count = min((unsigned int)pc->b_count, (unsigned int)bcount); | 337 | count = min((unsigned int)pc->b_count, (unsigned int)bcount); |
342 | drive->hwif->tp_ops->output_data(drive, NULL, pc->b_data, count); | 338 | drive->hwif->tp_ops->output_data(drive, NULL, pc->b_data, count); |
343 | bcount -= count; | 339 | bcount -= count; |
@@ -352,6 +348,8 @@ static void idetape_output_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
352 | } | 348 | } |
353 | } | 349 | } |
354 | } | 350 | } |
351 | |||
352 | return bcount; | ||
355 | } | 353 | } |
356 | 354 | ||
357 | static void idetape_update_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc) | 355 | static void idetape_update_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc) |
@@ -563,12 +561,14 @@ static void ide_tape_handle_dsc(ide_drive_t *drive) | |||
563 | static int ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | 561 | static int ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, |
564 | unsigned int bcount, int write) | 562 | unsigned int bcount, int write) |
565 | { | 563 | { |
564 | unsigned int bleft; | ||
565 | |||
566 | if (write) | 566 | if (write) |
567 | idetape_output_buffers(drive, pc, bcount); | 567 | bleft = idetape_output_buffers(drive, pc, bcount); |
568 | else | 568 | else |
569 | idetape_input_buffers(drive, pc, bcount); | 569 | bleft = idetape_input_buffers(drive, pc, bcount); |
570 | 570 | ||
571 | return bcount; | 571 | return bcount - bleft; |
572 | } | 572 | } |
573 | 573 | ||
574 | /* | 574 | /* |