diff options
author | unsik Kim <donari75@gmail.com> | 2009-07-28 02:57:33 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-07-28 02:57:33 -0400 |
commit | a85a00a699740f6f9863f88aef22060fe1534681 (patch) | |
tree | 9a9c675ef28e92b4b1a6cdd0ecedc70eacde7888 /drivers/block | |
parent | 394c6cc63c1d6900ad7498a3221a1d48fc00c4fa (diff) |
mg_disk: Add missing ready status check on mg_write()
When last sector is written, ready bit of status register should be
checked.
Signed-off-by: unsik Kim <donari75@gmail.com>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/mg_disk.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c index 19917d5481bd..6d7fbaa92248 100644 --- a/drivers/block/mg_disk.c +++ b/drivers/block/mg_disk.c | |||
@@ -524,16 +524,16 @@ static void mg_write_one(struct mg_host *host, struct request *req) | |||
524 | static void mg_write(struct request *req) | 524 | static void mg_write(struct request *req) |
525 | { | 525 | { |
526 | struct mg_host *host = req->rq_disk->private_data; | 526 | struct mg_host *host = req->rq_disk->private_data; |
527 | bool rem; | 527 | unsigned int rem = blk_rq_sectors(req); |
528 | 528 | ||
529 | if (mg_out(host, blk_rq_pos(req), blk_rq_sectors(req), | 529 | if (mg_out(host, blk_rq_pos(req), rem, |
530 | MG_CMD_WR, NULL) != MG_ERR_NONE) { | 530 | MG_CMD_WR, NULL) != MG_ERR_NONE) { |
531 | mg_bad_rw_intr(host); | 531 | mg_bad_rw_intr(host); |
532 | return; | 532 | return; |
533 | } | 533 | } |
534 | 534 | ||
535 | MG_DBG("requested %d sects (from %ld), buffer=0x%p\n", | 535 | MG_DBG("requested %d sects (from %ld), buffer=0x%p\n", |
536 | blk_rq_sectors(req), blk_rq_pos(req), req->buffer); | 536 | rem, blk_rq_pos(req), req->buffer); |
537 | 537 | ||
538 | if (mg_wait(host, ATA_DRQ, | 538 | if (mg_wait(host, ATA_DRQ, |
539 | MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) { | 539 | MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) { |
@@ -541,25 +541,23 @@ static void mg_write(struct request *req) | |||
541 | return; | 541 | return; |
542 | } | 542 | } |
543 | 543 | ||
544 | mg_write_one(host, req); | 544 | do { |
545 | mg_write_one(host, req); | ||
545 | 546 | ||
546 | outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base + MG_REG_COMMAND); | 547 | outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base + |
548 | MG_REG_COMMAND); | ||
547 | 549 | ||
548 | do { | 550 | rem--; |
549 | if (blk_rq_sectors(req) > 1 && | 551 | if (rem > 1 && mg_wait(host, ATA_DRQ, |
550 | mg_wait(host, ATA_DRQ, | 552 | MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) { |
551 | MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) { | 553 | mg_bad_rw_intr(host); |
554 | return; | ||
555 | } else if (mg_wait(host, MG_STAT_READY, | ||
556 | MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) { | ||
552 | mg_bad_rw_intr(host); | 557 | mg_bad_rw_intr(host); |
553 | return; | 558 | return; |
554 | } | 559 | } |
555 | 560 | } while (mg_end_request(host, 0, MG_SECTOR_SIZE)); | |
556 | rem = mg_end_request(host, 0, MG_SECTOR_SIZE); | ||
557 | if (rem) | ||
558 | mg_write_one(host, req); | ||
559 | |||
560 | outb(MG_CMD_WR_CONF, | ||
561 | (unsigned long)host->dev_base + MG_REG_COMMAND); | ||
562 | } while (rem); | ||
563 | } | 561 | } |
564 | 562 | ||
565 | static void mg_read_intr(struct mg_host *host) | 563 | static void mg_read_intr(struct mg_host *host) |