diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-06-13 06:00:54 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-06-13 06:00:54 -0400 |
commit | 8dcce4081305d3d1629190edd112e6473c315cbc (patch) | |
tree | 343c7167f6a3d2a77b01d50cf54c67bdd6faccd1 | |
parent | f3ad116588151b3371ae4e092290e4f48e62b8bb (diff) | |
parent | 103f7033bd0f7b65ff3e0a5ea72449d08010b031 (diff) |
Merge branch 'bp-remove-pc-buf' into for-next
Conflicts:
drivers/ide/ide-tape.c
-rw-r--r-- | drivers/ide/ide-atapi.c | 138 | ||||
-rw-r--r-- | drivers/ide/ide-cd.c | 68 | ||||
-rw-r--r-- | drivers/ide/ide-floppy.c | 50 | ||||
-rw-r--r-- | drivers/ide/ide-floppy_ioctl.c | 43 | ||||
-rw-r--r-- | drivers/ide/ide-tape.c | 174 | ||||
-rw-r--r-- | include/linux/ide.h | 18 |
6 files changed, 230 insertions, 261 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index bbdd2547f12a..6c73421c608b 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
@@ -10,6 +10,9 @@ | |||
10 | 10 | ||
11 | #include <scsi/scsi.h> | 11 | #include <scsi/scsi.h> |
12 | 12 | ||
13 | #define DRV_NAME "ide-atapi" | ||
14 | #define PFX DRV_NAME ": " | ||
15 | |||
13 | #ifdef DEBUG | 16 | #ifdef DEBUG |
14 | #define debug_log(fmt, args...) \ | 17 | #define debug_log(fmt, args...) \ |
15 | printk(KERN_INFO "ide: " fmt, ## args) | 18 | printk(KERN_INFO "ide: " fmt, ## args) |
@@ -74,8 +77,6 @@ EXPORT_SYMBOL_GPL(ide_check_atapi_device); | |||
74 | void ide_init_pc(struct ide_atapi_pc *pc) | 77 | void ide_init_pc(struct ide_atapi_pc *pc) |
75 | { | 78 | { |
76 | memset(pc, 0, sizeof(*pc)); | 79 | memset(pc, 0, sizeof(*pc)); |
77 | pc->buf = pc->pc_buf; | ||
78 | pc->buf_size = IDE_PC_BUFFER_SIZE; | ||
79 | } | 80 | } |
80 | EXPORT_SYMBOL_GPL(ide_init_pc); | 81 | EXPORT_SYMBOL_GPL(ide_init_pc); |
81 | 82 | ||
@@ -84,7 +85,7 @@ EXPORT_SYMBOL_GPL(ide_init_pc); | |||
84 | * and wait for it to be serviced. | 85 | * and wait for it to be serviced. |
85 | */ | 86 | */ |
86 | int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk, | 87 | int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk, |
87 | struct ide_atapi_pc *pc) | 88 | struct ide_atapi_pc *pc, void *buf, unsigned int bufflen) |
88 | { | 89 | { |
89 | struct request *rq; | 90 | struct request *rq; |
90 | int error; | 91 | int error; |
@@ -93,8 +94,8 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk, | |||
93 | rq->cmd_type = REQ_TYPE_SPECIAL; | 94 | rq->cmd_type = REQ_TYPE_SPECIAL; |
94 | rq->special = (char *)pc; | 95 | rq->special = (char *)pc; |
95 | 96 | ||
96 | if (pc->req_xfer) { | 97 | if (buf && bufflen) { |
97 | error = blk_rq_map_kern(drive->queue, rq, pc->buf, pc->req_xfer, | 98 | error = blk_rq_map_kern(drive->queue, rq, buf, bufflen, |
98 | GFP_NOIO); | 99 | GFP_NOIO); |
99 | if (error) | 100 | if (error) |
100 | goto put_req; | 101 | goto put_req; |
@@ -117,7 +118,7 @@ int ide_do_test_unit_ready(ide_drive_t *drive, struct gendisk *disk) | |||
117 | ide_init_pc(&pc); | 118 | ide_init_pc(&pc); |
118 | pc.c[0] = TEST_UNIT_READY; | 119 | pc.c[0] = TEST_UNIT_READY; |
119 | 120 | ||
120 | return ide_queue_pc_tail(drive, disk, &pc); | 121 | return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
121 | } | 122 | } |
122 | EXPORT_SYMBOL_GPL(ide_do_test_unit_ready); | 123 | EXPORT_SYMBOL_GPL(ide_do_test_unit_ready); |
123 | 124 | ||
@@ -132,7 +133,7 @@ int ide_do_start_stop(ide_drive_t *drive, struct gendisk *disk, int start) | |||
132 | if (drive->media == ide_tape) | 133 | if (drive->media == ide_tape) |
133 | pc.flags |= PC_FLAG_WAIT_FOR_DSC; | 134 | pc.flags |= PC_FLAG_WAIT_FOR_DSC; |
134 | 135 | ||
135 | return ide_queue_pc_tail(drive, disk, &pc); | 136 | return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
136 | } | 137 | } |
137 | EXPORT_SYMBOL_GPL(ide_do_start_stop); | 138 | EXPORT_SYMBOL_GPL(ide_do_start_stop); |
138 | 139 | ||
@@ -147,7 +148,7 @@ int ide_set_media_lock(ide_drive_t *drive, struct gendisk *disk, int on) | |||
147 | pc.c[0] = ALLOW_MEDIUM_REMOVAL; | 148 | pc.c[0] = ALLOW_MEDIUM_REMOVAL; |
148 | pc.c[4] = on; | 149 | pc.c[4] = on; |
149 | 150 | ||
150 | return ide_queue_pc_tail(drive, disk, &pc); | 151 | return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
151 | } | 152 | } |
152 | EXPORT_SYMBOL_GPL(ide_set_media_lock); | 153 | EXPORT_SYMBOL_GPL(ide_set_media_lock); |
153 | 154 | ||
@@ -172,8 +173,6 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq) | |||
172 | unsigned int cmd_len, sense_len; | 173 | unsigned int cmd_len, sense_len; |
173 | int err; | 174 | int err; |
174 | 175 | ||
175 | debug_log("%s: enter\n", __func__); | ||
176 | |||
177 | switch (drive->media) { | 176 | switch (drive->media) { |
178 | case ide_floppy: | 177 | case ide_floppy: |
179 | cmd_len = 255; | 178 | cmd_len = 255; |
@@ -201,8 +200,8 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq) | |||
201 | GFP_NOIO); | 200 | GFP_NOIO); |
202 | if (unlikely(err)) { | 201 | if (unlikely(err)) { |
203 | if (printk_ratelimit()) | 202 | if (printk_ratelimit()) |
204 | printk(KERN_WARNING "%s: failed to map sense buffer\n", | 203 | printk(KERN_WARNING PFX "%s: failed to map sense " |
205 | drive->name); | 204 | "buffer\n", drive->name); |
206 | return; | 205 | return; |
207 | } | 206 | } |
208 | 207 | ||
@@ -223,7 +222,7 @@ int ide_queue_sense_rq(ide_drive_t *drive, void *special) | |||
223 | { | 222 | { |
224 | /* deferred failure from ide_prep_sense() */ | 223 | /* deferred failure from ide_prep_sense() */ |
225 | if (!drive->sense_rq_armed) { | 224 | if (!drive->sense_rq_armed) { |
226 | printk(KERN_WARNING "%s: failed queue sense request\n", | 225 | printk(KERN_WARNING PFX "%s: error queuing a sense request\n", |
227 | drive->name); | 226 | drive->name); |
228 | return -ENOMEM; | 227 | return -ENOMEM; |
229 | } | 228 | } |
@@ -255,8 +254,6 @@ void ide_retry_pc(ide_drive_t *drive) | |||
255 | /* init pc from sense_rq */ | 254 | /* init pc from sense_rq */ |
256 | ide_init_pc(pc); | 255 | ide_init_pc(pc); |
257 | memcpy(pc->c, sense_rq->cmd, 12); | 256 | memcpy(pc->c, sense_rq->cmd, 12); |
258 | pc->buf = bio_data(sense_rq->bio); /* pointer to mapped address */ | ||
259 | pc->req_xfer = blk_rq_bytes(sense_rq); | ||
260 | 257 | ||
261 | if (drive->media == ide_tape) | 258 | if (drive->media == ide_tape) |
262 | drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC; | 259 | drive->atapi_flags |= IDE_AFLAG_IGNORE_DSC; |
@@ -298,7 +295,7 @@ int ide_cd_expiry(ide_drive_t *drive) | |||
298 | break; | 295 | break; |
299 | default: | 296 | default: |
300 | if (!(rq->cmd_flags & REQ_QUIET)) | 297 | if (!(rq->cmd_flags & REQ_QUIET)) |
301 | printk(KERN_INFO "cmd 0x%x timed out\n", | 298 | printk(KERN_INFO PFX "cmd 0x%x timed out\n", |
302 | rq->cmd[0]); | 299 | rq->cmd[0]); |
303 | wait = 0; | 300 | wait = 0; |
304 | break; | 301 | break; |
@@ -332,6 +329,55 @@ void ide_read_bcount_and_ireason(ide_drive_t *drive, u16 *bcount, u8 *ireason) | |||
332 | EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason); | 329 | EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason); |
333 | 330 | ||
334 | /* | 331 | /* |
332 | * Check the contents of the interrupt reason register and attempt to recover if | ||
333 | * there are problems. | ||
334 | * | ||
335 | * Returns: | ||
336 | * - 0 if everything's ok | ||
337 | * - 1 if the request has to be terminated. | ||
338 | */ | ||
339 | int ide_check_ireason(ide_drive_t *drive, struct request *rq, int len, | ||
340 | int ireason, int rw) | ||
341 | { | ||
342 | ide_hwif_t *hwif = drive->hwif; | ||
343 | |||
344 | debug_log("ireason: 0x%x, rw: 0x%x\n", ireason, rw); | ||
345 | |||
346 | if (ireason == (!rw << 1)) | ||
347 | return 0; | ||
348 | else if (ireason == (rw << 1)) { | ||
349 | printk(KERN_ERR PFX "%s: %s: wrong transfer direction!\n", | ||
350 | drive->name, __func__); | ||
351 | |||
352 | if (dev_is_idecd(drive)) | ||
353 | ide_pad_transfer(drive, rw, len); | ||
354 | } else if (!rw && ireason == ATAPI_COD) { | ||
355 | if (dev_is_idecd(drive)) { | ||
356 | /* | ||
357 | * Some drives (ASUS) seem to tell us that status info | ||
358 | * is available. Just get it and ignore. | ||
359 | */ | ||
360 | (void)hwif->tp_ops->read_status(hwif); | ||
361 | return 0; | ||
362 | } | ||
363 | } else { | ||
364 | if (ireason & ATAPI_COD) | ||
365 | printk(KERN_ERR PFX "%s: CoD != 0 in %s\n", drive->name, | ||
366 | __func__); | ||
367 | |||
368 | /* drive wants a command packet, or invalid ireason... */ | ||
369 | printk(KERN_ERR PFX "%s: %s: bad interrupt reason 0x%02x\n", | ||
370 | drive->name, __func__, ireason); | ||
371 | } | ||
372 | |||
373 | if (dev_is_idecd(drive) && rq->cmd_type == REQ_TYPE_ATA_PC) | ||
374 | rq->cmd_flags |= REQ_FAILED; | ||
375 | |||
376 | return 1; | ||
377 | } | ||
378 | EXPORT_SYMBOL_GPL(ide_check_ireason); | ||
379 | |||
380 | /* | ||
335 | * This is the usual interrupt handler which will be called during a packet | 381 | * This is the usual interrupt handler which will be called during a packet |
336 | * command. We will transfer some of the data (as requested by the drive) | 382 | * command. We will transfer some of the data (as requested by the drive) |
337 | * and will re-point interrupt handler to us. | 383 | * and will re-point interrupt handler to us. |
@@ -365,12 +411,12 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
365 | 411 | ||
366 | if (rc || (drive->media == ide_tape && (stat & ATA_ERR))) { | 412 | if (rc || (drive->media == ide_tape && (stat & ATA_ERR))) { |
367 | if (drive->media == ide_floppy) | 413 | if (drive->media == ide_floppy) |
368 | printk(KERN_ERR "%s: DMA %s error\n", | 414 | printk(KERN_ERR PFX "%s: DMA %s error\n", |
369 | drive->name, rq_data_dir(pc->rq) | 415 | drive->name, rq_data_dir(pc->rq) |
370 | ? "write" : "read"); | 416 | ? "write" : "read"); |
371 | pc->flags |= PC_FLAG_DMA_ERROR; | 417 | pc->flags |= PC_FLAG_DMA_ERROR; |
372 | } else | 418 | } else |
373 | pc->xferred = pc->req_xfer; | 419 | rq->resid_len = 0; |
374 | debug_log("%s: DMA finished\n", drive->name); | 420 | debug_log("%s: DMA finished\n", drive->name); |
375 | } | 421 | } |
376 | 422 | ||
@@ -379,7 +425,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
379 | int uptodate, error; | 425 | int uptodate, error; |
380 | 426 | ||
381 | debug_log("Packet command completed, %d bytes transferred\n", | 427 | debug_log("Packet command completed, %d bytes transferred\n", |
382 | pc->xferred); | 428 | blk_rq_bytes(rq)); |
383 | 429 | ||
384 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | 430 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; |
385 | 431 | ||
@@ -397,8 +443,8 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
397 | pc->rq->errors++; | 443 | pc->rq->errors++; |
398 | 444 | ||
399 | if (rq->cmd[0] == REQUEST_SENSE) { | 445 | if (rq->cmd[0] == REQUEST_SENSE) { |
400 | printk(KERN_ERR "%s: I/O error in request sense" | 446 | printk(KERN_ERR PFX "%s: I/O error in request " |
401 | " command\n", drive->name); | 447 | "sense command\n", drive->name); |
402 | return ide_do_reset(drive); | 448 | return ide_do_reset(drive); |
403 | } | 449 | } |
404 | 450 | ||
@@ -446,8 +492,8 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
446 | 492 | ||
447 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | 493 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { |
448 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | 494 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; |
449 | printk(KERN_ERR "%s: The device wants to issue more interrupts " | 495 | printk(KERN_ERR PFX "%s: The device wants to issue more " |
450 | "in DMA mode\n", drive->name); | 496 | "interrupts in DMA mode\n", drive->name); |
451 | ide_dma_off(drive); | 497 | ide_dma_off(drive); |
452 | return ide_do_reset(drive); | 498 | return ide_do_reset(drive); |
453 | } | 499 | } |
@@ -455,33 +501,22 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive) | |||
455 | /* Get the number of bytes to transfer on this interrupt. */ | 501 | /* Get the number of bytes to transfer on this interrupt. */ |
456 | ide_read_bcount_and_ireason(drive, &bcount, &ireason); | 502 | ide_read_bcount_and_ireason(drive, &bcount, &ireason); |
457 | 503 | ||
458 | if (ireason & ATAPI_COD) { | 504 | if (ide_check_ireason(drive, rq, bcount, ireason, write)) |
459 | printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__); | ||
460 | return ide_do_reset(drive); | 505 | return ide_do_reset(drive); |
461 | } | ||
462 | |||
463 | if (((ireason & ATAPI_IO) == ATAPI_IO) == write) { | ||
464 | /* Hopefully, we will never get here */ | ||
465 | printk(KERN_ERR "%s: We wanted to %s, but the device wants us " | ||
466 | "to %s!\n", drive->name, | ||
467 | (ireason & ATAPI_IO) ? "Write" : "Read", | ||
468 | (ireason & ATAPI_IO) ? "Read" : "Write"); | ||
469 | return ide_do_reset(drive); | ||
470 | } | ||
471 | 506 | ||
472 | done = min_t(unsigned int, bcount, cmd->nleft); | 507 | done = min_t(unsigned int, bcount, cmd->nleft); |
473 | ide_pio_bytes(drive, cmd, write, done); | 508 | ide_pio_bytes(drive, cmd, write, done); |
474 | 509 | ||
475 | /* Update transferred byte count */ | 510 | /* Update transferred byte count */ |
476 | pc->xferred += done; | 511 | rq->resid_len -= done; |
477 | 512 | ||
478 | bcount -= done; | 513 | bcount -= done; |
479 | 514 | ||
480 | if (bcount) | 515 | if (bcount) |
481 | ide_pad_transfer(drive, write, bcount); | 516 | ide_pad_transfer(drive, write, bcount); |
482 | 517 | ||
483 | debug_log("[cmd %x] transferred %d bytes, padded %d bytes\n", | 518 | debug_log("[cmd %x] transferred %d bytes, padded %d bytes, resid: %u\n", |
484 | rq->cmd[0], done, bcount); | 519 | rq->cmd[0], done, bcount, rq->resid_len); |
485 | 520 | ||
486 | /* And set the interrupt handler again */ | 521 | /* And set the interrupt handler again */ |
487 | ide_set_handler(drive, ide_pc_intr, timeout); | 522 | ide_set_handler(drive, ide_pc_intr, timeout); |
@@ -515,13 +550,13 @@ static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason) | |||
515 | 550 | ||
516 | while (retries-- && ((ireason & ATAPI_COD) == 0 || | 551 | while (retries-- && ((ireason & ATAPI_COD) == 0 || |
517 | (ireason & ATAPI_IO))) { | 552 | (ireason & ATAPI_IO))) { |
518 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " | 553 | printk(KERN_ERR PFX "%s: (IO,CoD != (0,1) while issuing " |
519 | "a packet command, retrying\n", drive->name); | 554 | "a packet command, retrying\n", drive->name); |
520 | udelay(100); | 555 | udelay(100); |
521 | ireason = ide_read_ireason(drive); | 556 | ireason = ide_read_ireason(drive); |
522 | if (retries == 0) { | 557 | if (retries == 0) { |
523 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " | 558 | printk(KERN_ERR PFX "%s: (IO,CoD != (0,1) while issuing" |
524 | "a packet command, ignoring\n", | 559 | " a packet command, ignoring\n", |
525 | drive->name); | 560 | drive->name); |
526 | ireason |= ATAPI_COD; | 561 | ireason |= ATAPI_COD; |
527 | ireason &= ~ATAPI_IO; | 562 | ireason &= ~ATAPI_IO; |
@@ -552,7 +587,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) | |||
552 | u8 ireason; | 587 | u8 ireason; |
553 | 588 | ||
554 | if (ide_wait_stat(&startstop, drive, ATA_DRQ, ATA_BUSY, WAIT_READY)) { | 589 | if (ide_wait_stat(&startstop, drive, ATA_DRQ, ATA_BUSY, WAIT_READY)) { |
555 | printk(KERN_ERR "%s: Strange, packet command initiated yet " | 590 | printk(KERN_ERR PFX "%s: Strange, packet command initiated yet " |
556 | "DRQ isn't asserted\n", drive->name); | 591 | "DRQ isn't asserted\n", drive->name); |
557 | return startstop; | 592 | return startstop; |
558 | } | 593 | } |
@@ -594,8 +629,8 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) | |||
594 | ireason = ide_wait_ireason(drive, ireason); | 629 | ireason = ide_wait_ireason(drive, ireason); |
595 | 630 | ||
596 | if ((ireason & ATAPI_COD) == 0 || (ireason & ATAPI_IO)) { | 631 | if ((ireason & ATAPI_COD) == 0 || (ireason & ATAPI_IO)) { |
597 | printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing " | 632 | printk(KERN_ERR PFX "%s: (IO,CoD) != (0,1) while " |
598 | "a packet command\n", drive->name); | 633 | "issuing a packet command\n", drive->name); |
599 | 634 | ||
600 | return ide_do_reset(drive); | 635 | return ide_do_reset(drive); |
601 | } | 636 | } |
@@ -633,7 +668,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd) | |||
633 | ide_hwif_t *hwif = drive->hwif; | 668 | ide_hwif_t *hwif = drive->hwif; |
634 | ide_expiry_t *expiry = NULL; | 669 | ide_expiry_t *expiry = NULL; |
635 | struct request *rq = hwif->rq; | 670 | struct request *rq = hwif->rq; |
636 | unsigned int timeout; | 671 | unsigned int timeout, bytes; |
637 | u16 bcount; | 672 | u16 bcount; |
638 | u8 valid_tf; | 673 | u8 valid_tf; |
639 | u8 drq_int = !!(drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT); | 674 | u8 drq_int = !!(drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT); |
@@ -649,13 +684,14 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_cmd *cmd) | |||
649 | } else { | 684 | } else { |
650 | pc = drive->pc; | 685 | pc = drive->pc; |
651 | 686 | ||
652 | /* We haven't transferred any data yet */ | ||
653 | pc->xferred = 0; | ||
654 | |||
655 | valid_tf = IDE_VALID_DEVICE; | 687 | valid_tf = IDE_VALID_DEVICE; |
656 | bcount = ((drive->media == ide_tape) ? | 688 | bytes = blk_rq_bytes(rq); |
657 | pc->req_xfer : | 689 | bcount = ((drive->media == ide_tape) ? bytes |
658 | min(pc->req_xfer, 63 * 1024)); | 690 | : min_t(unsigned int, |
691 | bytes, 63 * 1024)); | ||
692 | |||
693 | /* We haven't transferred any data yet */ | ||
694 | rq->resid_len = bcount; | ||
659 | 695 | ||
660 | if (pc->flags & PC_FLAG_DMA_ERROR) { | 696 | if (pc->flags & PC_FLAG_DMA_ERROR) { |
661 | pc->flags &= ~PC_FLAG_DMA_ERROR; | 697 | pc->flags &= ~PC_FLAG_DMA_ERROR; |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 424140c6c400..dcd72445b0cd 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -92,16 +92,16 @@ static void cdrom_saw_media_change(ide_drive_t *drive) | |||
92 | drive->atapi_flags &= ~IDE_AFLAG_TOC_VALID; | 92 | drive->atapi_flags &= ~IDE_AFLAG_TOC_VALID; |
93 | } | 93 | } |
94 | 94 | ||
95 | static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | 95 | static int cdrom_log_sense(ide_drive_t *drive, struct request *rq) |
96 | struct request_sense *sense) | ||
97 | { | 96 | { |
97 | struct request_sense *sense = &drive->sense_data; | ||
98 | int log = 0; | 98 | int log = 0; |
99 | 99 | ||
100 | ide_debug_log(IDE_DBG_SENSE, "sense_key: 0x%x", sense->sense_key); | ||
101 | |||
102 | if (!sense || !rq || (rq->cmd_flags & REQ_QUIET)) | 100 | if (!sense || !rq || (rq->cmd_flags & REQ_QUIET)) |
103 | return 0; | 101 | return 0; |
104 | 102 | ||
103 | ide_debug_log(IDE_DBG_SENSE, "sense_key: 0x%x", sense->sense_key); | ||
104 | |||
105 | switch (sense->sense_key) { | 105 | switch (sense->sense_key) { |
106 | case NO_SENSE: | 106 | case NO_SENSE: |
107 | case RECOVERED_ERROR: | 107 | case RECOVERED_ERROR: |
@@ -140,12 +140,12 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | |||
140 | } | 140 | } |
141 | 141 | ||
142 | static void cdrom_analyze_sense_data(ide_drive_t *drive, | 142 | static void cdrom_analyze_sense_data(ide_drive_t *drive, |
143 | struct request *failed_command, | 143 | struct request *failed_command) |
144 | struct request_sense *sense) | ||
145 | { | 144 | { |
145 | struct request_sense *sense = &drive->sense_data; | ||
146 | struct cdrom_info *info = drive->driver_data; | ||
146 | unsigned long sector; | 147 | unsigned long sector; |
147 | unsigned long bio_sectors; | 148 | unsigned long bio_sectors; |
148 | struct cdrom_info *info = drive->driver_data; | ||
149 | 149 | ||
150 | ide_debug_log(IDE_DBG_SENSE, "error_code: 0x%x, sense_key: 0x%x", | 150 | ide_debug_log(IDE_DBG_SENSE, "error_code: 0x%x, sense_key: 0x%x", |
151 | sense->error_code, sense->sense_key); | 151 | sense->error_code, sense->sense_key); |
@@ -154,7 +154,7 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive, | |||
154 | ide_debug_log(IDE_DBG_SENSE, "failed cmd: 0x%x", | 154 | ide_debug_log(IDE_DBG_SENSE, "failed cmd: 0x%x", |
155 | failed_command->cmd[0]); | 155 | failed_command->cmd[0]); |
156 | 156 | ||
157 | if (!cdrom_log_sense(drive, failed_command, sense)) | 157 | if (!cdrom_log_sense(drive, failed_command)) |
158 | return; | 158 | return; |
159 | 159 | ||
160 | /* | 160 | /* |
@@ -225,15 +225,14 @@ static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq) | |||
225 | * sense pointer set. | 225 | * sense pointer set. |
226 | */ | 226 | */ |
227 | memcpy(failed->sense, sense, 18); | 227 | memcpy(failed->sense, sense, 18); |
228 | sense = failed->sense; | ||
229 | failed->sense_len = rq->sense_len; | 228 | failed->sense_len = rq->sense_len; |
230 | } | 229 | } |
231 | cdrom_analyze_sense_data(drive, failed, sense); | 230 | cdrom_analyze_sense_data(drive, failed); |
232 | 231 | ||
233 | if (ide_end_rq(drive, failed, -EIO, blk_rq_bytes(failed))) | 232 | if (ide_end_rq(drive, failed, -EIO, blk_rq_bytes(failed))) |
234 | BUG(); | 233 | BUG(); |
235 | } else | 234 | } else |
236 | cdrom_analyze_sense_data(drive, NULL, sense); | 235 | cdrom_analyze_sense_data(drive, NULL); |
237 | } | 236 | } |
238 | 237 | ||
239 | 238 | ||
@@ -410,50 +409,6 @@ end_request: | |||
410 | return 2; | 409 | return 2; |
411 | } | 410 | } |
412 | 411 | ||
413 | /* | ||
414 | * Check the contents of the interrupt reason register from the cdrom | ||
415 | * and attempt to recover if there are problems. Returns 0 if everything's | ||
416 | * ok; nonzero if the request has been terminated. | ||
417 | */ | ||
418 | static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq, | ||
419 | int len, int ireason, int rw) | ||
420 | { | ||
421 | ide_hwif_t *hwif = drive->hwif; | ||
422 | |||
423 | ide_debug_log(IDE_DBG_FUNC, "ireason: 0x%x, rw: 0x%x", ireason, rw); | ||
424 | |||
425 | /* | ||
426 | * ireason == 0: the drive wants to receive data from us | ||
427 | * ireason == 2: the drive is expecting to transfer data to us | ||
428 | */ | ||
429 | if (ireason == (!rw << 1)) | ||
430 | return 0; | ||
431 | else if (ireason == (rw << 1)) { | ||
432 | |||
433 | /* whoops... */ | ||
434 | printk(KERN_ERR PFX "%s: %s: wrong transfer direction!\n", | ||
435 | drive->name, __func__); | ||
436 | |||
437 | ide_pad_transfer(drive, rw, len); | ||
438 | } else if (rw == 0 && ireason == 1) { | ||
439 | /* | ||
440 | * Some drives (ASUS) seem to tell us that status info is | ||
441 | * available. Just get it and ignore. | ||
442 | */ | ||
443 | (void)hwif->tp_ops->read_status(hwif); | ||
444 | return 0; | ||
445 | } else { | ||
446 | /* drive wants a command packet, or invalid ireason... */ | ||
447 | printk(KERN_ERR PFX "%s: %s: bad interrupt reason 0x%02x\n", | ||
448 | drive->name, __func__, ireason); | ||
449 | } | ||
450 | |||
451 | if (rq->cmd_type == REQ_TYPE_ATA_PC) | ||
452 | rq->cmd_flags |= REQ_FAILED; | ||
453 | |||
454 | return -1; | ||
455 | } | ||
456 | |||
457 | static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct ide_cmd *cmd) | 412 | static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct ide_cmd *cmd) |
458 | { | 413 | { |
459 | struct request *rq = cmd->rq; | 414 | struct request *rq = cmd->rq; |
@@ -645,8 +600,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
645 | goto out_end; | 600 | goto out_end; |
646 | } | 601 | } |
647 | 602 | ||
648 | /* check which way to transfer data */ | 603 | rc = ide_check_ireason(drive, rq, len, ireason, write); |
649 | rc = ide_cd_check_ireason(drive, rq, len, ireason, write); | ||
650 | if (rc) | 604 | if (rc) |
651 | goto out_end; | 605 | goto out_end; |
652 | 606 | ||
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 650981758f15..800c83a9db83 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -77,7 +77,8 @@ static int ide_floppy_callback(ide_drive_t *drive, int dsc) | |||
77 | (rq && blk_pc_request(rq))) | 77 | (rq && blk_pc_request(rq))) |
78 | uptodate = 1; /* FIXME */ | 78 | uptodate = 1; /* FIXME */ |
79 | else if (pc->c[0] == GPCMD_REQUEST_SENSE) { | 79 | else if (pc->c[0] == GPCMD_REQUEST_SENSE) { |
80 | u8 *buf = pc->buf; | 80 | |
81 | u8 *buf = bio_data(rq->bio); | ||
81 | 82 | ||
82 | if (!pc->error) { | 83 | if (!pc->error) { |
83 | floppy->sense_key = buf[2] & 0x0F; | 84 | floppy->sense_key = buf[2] & 0x0F; |
@@ -209,8 +210,7 @@ static void idefloppy_create_rw_cmd(ide_drive_t *drive, | |||
209 | pc->rq = rq; | 210 | pc->rq = rq; |
210 | if (rq->cmd_flags & REQ_RW) | 211 | if (rq->cmd_flags & REQ_RW) |
211 | pc->flags |= PC_FLAG_WRITING; | 212 | pc->flags |= PC_FLAG_WRITING; |
212 | pc->buf = NULL; | 213 | |
213 | pc->req_xfer = pc->buf_size = blocks * floppy->block_size; | ||
214 | pc->flags |= PC_FLAG_DMA_OK; | 214 | pc->flags |= PC_FLAG_DMA_OK; |
215 | } | 215 | } |
216 | 216 | ||
@@ -225,9 +225,6 @@ static void idefloppy_blockpc_cmd(struct ide_disk_obj *floppy, | |||
225 | if (rq_data_dir(rq) == WRITE) | 225 | if (rq_data_dir(rq) == WRITE) |
226 | pc->flags |= PC_FLAG_WRITING; | 226 | pc->flags |= PC_FLAG_WRITING; |
227 | } | 227 | } |
228 | /* pio will be performed by ide_pio_bytes() which handles sg fine */ | ||
229 | pc->buf = NULL; | ||
230 | pc->req_xfer = pc->buf_size = blk_rq_bytes(rq); | ||
231 | } | 228 | } |
232 | 229 | ||
233 | static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | 230 | static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, |
@@ -286,8 +283,8 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | |||
286 | 283 | ||
287 | cmd.rq = rq; | 284 | cmd.rq = rq; |
288 | 285 | ||
289 | if (blk_fs_request(rq) || pc->req_xfer) { | 286 | if (blk_fs_request(rq) || blk_rq_bytes(rq)) { |
290 | ide_init_sg_cmd(&cmd, pc->req_xfer); | 287 | ide_init_sg_cmd(&cmd, blk_rq_bytes(rq)); |
291 | ide_map_sg(drive, &cmd); | 288 | ide_map_sg(drive, &cmd); |
292 | } | 289 | } |
293 | 290 | ||
@@ -311,33 +308,33 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive, | |||
311 | { | 308 | { |
312 | struct ide_disk_obj *floppy = drive->driver_data; | 309 | struct ide_disk_obj *floppy = drive->driver_data; |
313 | struct gendisk *disk = floppy->disk; | 310 | struct gendisk *disk = floppy->disk; |
314 | u8 *page; | 311 | u8 *page, buf[40]; |
315 | int capacity, lba_capacity; | 312 | int capacity, lba_capacity; |
316 | u16 transfer_rate, sector_size, cyls, rpm; | 313 | u16 transfer_rate, sector_size, cyls, rpm; |
317 | u8 heads, sectors; | 314 | u8 heads, sectors; |
318 | 315 | ||
319 | ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE); | 316 | ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE); |
320 | 317 | ||
321 | if (ide_queue_pc_tail(drive, disk, pc)) { | 318 | if (ide_queue_pc_tail(drive, disk, pc, buf, pc->req_xfer)) { |
322 | printk(KERN_ERR PFX "Can't get flexible disk page params\n"); | 319 | printk(KERN_ERR PFX "Can't get flexible disk page params\n"); |
323 | return 1; | 320 | return 1; |
324 | } | 321 | } |
325 | 322 | ||
326 | if (pc->buf[3] & 0x80) | 323 | if (buf[3] & 0x80) |
327 | drive->dev_flags |= IDE_DFLAG_WP; | 324 | drive->dev_flags |= IDE_DFLAG_WP; |
328 | else | 325 | else |
329 | drive->dev_flags &= ~IDE_DFLAG_WP; | 326 | drive->dev_flags &= ~IDE_DFLAG_WP; |
330 | 327 | ||
331 | set_disk_ro(disk, !!(drive->dev_flags & IDE_DFLAG_WP)); | 328 | set_disk_ro(disk, !!(drive->dev_flags & IDE_DFLAG_WP)); |
332 | 329 | ||
333 | page = &pc->buf[8]; | 330 | page = &buf[8]; |
334 | 331 | ||
335 | transfer_rate = be16_to_cpup((__be16 *)&pc->buf[8 + 2]); | 332 | transfer_rate = be16_to_cpup((__be16 *)&buf[8 + 2]); |
336 | sector_size = be16_to_cpup((__be16 *)&pc->buf[8 + 6]); | 333 | sector_size = be16_to_cpup((__be16 *)&buf[8 + 6]); |
337 | cyls = be16_to_cpup((__be16 *)&pc->buf[8 + 8]); | 334 | cyls = be16_to_cpup((__be16 *)&buf[8 + 8]); |
338 | rpm = be16_to_cpup((__be16 *)&pc->buf[8 + 28]); | 335 | rpm = be16_to_cpup((__be16 *)&buf[8 + 28]); |
339 | heads = pc->buf[8 + 4]; | 336 | heads = buf[8 + 4]; |
340 | sectors = pc->buf[8 + 5]; | 337 | sectors = buf[8 + 5]; |
341 | 338 | ||
342 | capacity = cyls * heads * sectors * sector_size; | 339 | capacity = cyls * heads * sectors * sector_size; |
343 | 340 | ||
@@ -387,22 +384,19 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
387 | drive->capacity64 = 0; | 384 | drive->capacity64 = 0; |
388 | 385 | ||
389 | ide_floppy_create_read_capacity_cmd(&pc); | 386 | ide_floppy_create_read_capacity_cmd(&pc); |
390 | pc.buf = &pc_buf[0]; | 387 | if (ide_queue_pc_tail(drive, disk, &pc, pc_buf, pc.req_xfer)) { |
391 | pc.buf_size = sizeof(pc_buf); | ||
392 | |||
393 | if (ide_queue_pc_tail(drive, disk, &pc)) { | ||
394 | printk(KERN_ERR PFX "Can't get floppy parameters\n"); | 388 | printk(KERN_ERR PFX "Can't get floppy parameters\n"); |
395 | return 1; | 389 | return 1; |
396 | } | 390 | } |
397 | header_len = pc.buf[3]; | 391 | header_len = pc_buf[3]; |
398 | cap_desc = &pc.buf[4]; | 392 | cap_desc = &pc_buf[4]; |
399 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ | 393 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ |
400 | 394 | ||
401 | for (i = 0; i < desc_cnt; i++) { | 395 | for (i = 0; i < desc_cnt; i++) { |
402 | unsigned int desc_start = 4 + i*8; | 396 | unsigned int desc_start = 4 + i*8; |
403 | 397 | ||
404 | blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]); | 398 | blocks = be32_to_cpup((__be32 *)&pc_buf[desc_start]); |
405 | length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]); | 399 | length = be16_to_cpup((__be16 *)&pc_buf[desc_start + 6]); |
406 | 400 | ||
407 | ide_debug_log(IDE_DBG_PROBE, "Descriptor %d: %dkB, %d blocks, " | 401 | ide_debug_log(IDE_DBG_PROBE, "Descriptor %d: %dkB, %d blocks, " |
408 | "%d sector size", | 402 | "%d sector size", |
@@ -415,7 +409,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
415 | * the code below is valid only for the 1st descriptor, ie i=0 | 409 | * the code below is valid only for the 1st descriptor, ie i=0 |
416 | */ | 410 | */ |
417 | 411 | ||
418 | switch (pc.buf[desc_start + 4] & 0x03) { | 412 | switch (pc_buf[desc_start + 4] & 0x03) { |
419 | /* Clik! drive returns this instead of CAPACITY_CURRENT */ | 413 | /* Clik! drive returns this instead of CAPACITY_CURRENT */ |
420 | case CAPACITY_UNFORMATTED: | 414 | case CAPACITY_UNFORMATTED: |
421 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) | 415 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) |
@@ -464,7 +458,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
464 | break; | 458 | break; |
465 | } | 459 | } |
466 | ide_debug_log(IDE_DBG_PROBE, "Descriptor 0 Code: %d", | 460 | ide_debug_log(IDE_DBG_PROBE, "Descriptor 0 Code: %d", |
467 | pc.buf[desc_start + 4] & 0x03); | 461 | pc_buf[desc_start + 4] & 0x03); |
468 | } | 462 | } |
469 | 463 | ||
470 | /* Clik! disk does not support get_flexible_disk_page */ | 464 | /* Clik! disk does not support get_flexible_disk_page */ |
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c index cd8a42027ede..9c2288234dea 100644 --- a/drivers/ide/ide-floppy_ioctl.c +++ b/drivers/ide/ide-floppy_ioctl.c | |||
@@ -47,15 +47,13 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, | |||
47 | return -EINVAL; | 47 | return -EINVAL; |
48 | 48 | ||
49 | ide_floppy_create_read_capacity_cmd(pc); | 49 | ide_floppy_create_read_capacity_cmd(pc); |
50 | pc->buf = &pc_buf[0]; | ||
51 | pc->buf_size = sizeof(pc_buf); | ||
52 | 50 | ||
53 | if (ide_queue_pc_tail(drive, floppy->disk, pc)) { | 51 | if (ide_queue_pc_tail(drive, floppy->disk, pc, pc_buf, pc->req_xfer)) { |
54 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); | 52 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); |
55 | return -EIO; | 53 | return -EIO; |
56 | } | 54 | } |
57 | 55 | ||
58 | header_len = pc->buf[3]; | 56 | header_len = pc_buf[3]; |
59 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ | 57 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ |
60 | 58 | ||
61 | u_index = 0; | 59 | u_index = 0; |
@@ -72,8 +70,8 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, | |||
72 | if (u_index >= u_array_size) | 70 | if (u_index >= u_array_size) |
73 | break; /* User-supplied buffer too small */ | 71 | break; /* User-supplied buffer too small */ |
74 | 72 | ||
75 | blocks = be32_to_cpup((__be32 *)&pc->buf[desc_start]); | 73 | blocks = be32_to_cpup((__be32 *)&pc_buf[desc_start]); |
76 | length = be16_to_cpup((__be16 *)&pc->buf[desc_start + 6]); | 74 | length = be16_to_cpup((__be16 *)&pc_buf[desc_start + 6]); |
77 | 75 | ||
78 | if (put_user(blocks, argp)) | 76 | if (put_user(blocks, argp)) |
79 | return -EFAULT; | 77 | return -EFAULT; |
@@ -94,40 +92,42 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, | |||
94 | return 0; | 92 | return 0; |
95 | } | 93 | } |
96 | 94 | ||
97 | static void ide_floppy_create_format_unit_cmd(struct ide_atapi_pc *pc, int b, | 95 | static void ide_floppy_create_format_unit_cmd(struct ide_atapi_pc *pc, |
98 | int l, int flags) | 96 | u8 *buf, int b, int l, |
97 | int flags) | ||
99 | { | 98 | { |
100 | ide_init_pc(pc); | 99 | ide_init_pc(pc); |
101 | pc->c[0] = GPCMD_FORMAT_UNIT; | 100 | pc->c[0] = GPCMD_FORMAT_UNIT; |
102 | pc->c[1] = 0x17; | 101 | pc->c[1] = 0x17; |
103 | 102 | ||
104 | memset(pc->buf, 0, 12); | 103 | memset(buf, 0, 12); |
105 | pc->buf[1] = 0xA2; | 104 | buf[1] = 0xA2; |
106 | /* Default format list header, u8 1: FOV/DCRT/IMM bits set */ | 105 | /* Default format list header, u8 1: FOV/DCRT/IMM bits set */ |
107 | 106 | ||
108 | if (flags & 1) /* Verify bit on... */ | 107 | if (flags & 1) /* Verify bit on... */ |
109 | pc->buf[1] ^= 0x20; /* ... turn off DCRT bit */ | 108 | buf[1] ^= 0x20; /* ... turn off DCRT bit */ |
110 | pc->buf[3] = 8; | 109 | buf[3] = 8; |
111 | 110 | ||
112 | put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buf[4])); | 111 | put_unaligned(cpu_to_be32(b), (unsigned int *)(&buf[4])); |
113 | put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buf[8])); | 112 | put_unaligned(cpu_to_be32(l), (unsigned int *)(&buf[8])); |
114 | pc->buf_size = 12; | 113 | pc->req_xfer = 12; |
115 | pc->flags |= PC_FLAG_WRITING; | 114 | pc->flags |= PC_FLAG_WRITING; |
116 | } | 115 | } |
117 | 116 | ||
118 | static int ide_floppy_get_sfrp_bit(ide_drive_t *drive, struct ide_atapi_pc *pc) | 117 | static int ide_floppy_get_sfrp_bit(ide_drive_t *drive, struct ide_atapi_pc *pc) |
119 | { | 118 | { |
120 | struct ide_disk_obj *floppy = drive->driver_data; | 119 | struct ide_disk_obj *floppy = drive->driver_data; |
120 | u8 buf[20]; | ||
121 | 121 | ||
122 | drive->atapi_flags &= ~IDE_AFLAG_SRFP; | 122 | drive->atapi_flags &= ~IDE_AFLAG_SRFP; |
123 | 123 | ||
124 | ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_CAPABILITIES_PAGE); | 124 | ide_floppy_create_mode_sense_cmd(pc, IDEFLOPPY_CAPABILITIES_PAGE); |
125 | pc->flags |= PC_FLAG_SUPPRESS_ERROR; | 125 | pc->flags |= PC_FLAG_SUPPRESS_ERROR; |
126 | 126 | ||
127 | if (ide_queue_pc_tail(drive, floppy->disk, pc)) | 127 | if (ide_queue_pc_tail(drive, floppy->disk, pc, buf, pc->req_xfer)) |
128 | return 1; | 128 | return 1; |
129 | 129 | ||
130 | if (pc->buf[8 + 2] & 0x40) | 130 | if (buf[8 + 2] & 0x40) |
131 | drive->atapi_flags |= IDE_AFLAG_SRFP; | 131 | drive->atapi_flags |= IDE_AFLAG_SRFP; |
132 | 132 | ||
133 | return 0; | 133 | return 0; |
@@ -137,6 +137,7 @@ static int ide_floppy_format_unit(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
137 | int __user *arg) | 137 | int __user *arg) |
138 | { | 138 | { |
139 | struct ide_disk_obj *floppy = drive->driver_data; | 139 | struct ide_disk_obj *floppy = drive->driver_data; |
140 | u8 buf[12]; | ||
140 | int blocks, length, flags, err = 0; | 141 | int blocks, length, flags, err = 0; |
141 | 142 | ||
142 | if (floppy->openers > 1) { | 143 | if (floppy->openers > 1) { |
@@ -170,9 +171,9 @@ static int ide_floppy_format_unit(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
170 | } | 171 | } |
171 | 172 | ||
172 | ide_floppy_get_sfrp_bit(drive, pc); | 173 | ide_floppy_get_sfrp_bit(drive, pc); |
173 | ide_floppy_create_format_unit_cmd(pc, blocks, length, flags); | 174 | ide_floppy_create_format_unit_cmd(pc, buf, blocks, length, flags); |
174 | 175 | ||
175 | if (ide_queue_pc_tail(drive, floppy->disk, pc)) | 176 | if (ide_queue_pc_tail(drive, floppy->disk, pc, buf, pc->req_xfer)) |
176 | err = -EIO; | 177 | err = -EIO; |
177 | 178 | ||
178 | out: | 179 | out: |
@@ -196,11 +197,13 @@ static int ide_floppy_get_format_progress(ide_drive_t *drive, | |||
196 | int __user *arg) | 197 | int __user *arg) |
197 | { | 198 | { |
198 | struct ide_disk_obj *floppy = drive->driver_data; | 199 | struct ide_disk_obj *floppy = drive->driver_data; |
200 | u8 sense_buf[18]; | ||
199 | int progress_indication = 0x10000; | 201 | int progress_indication = 0x10000; |
200 | 202 | ||
201 | if (drive->atapi_flags & IDE_AFLAG_SRFP) { | 203 | if (drive->atapi_flags & IDE_AFLAG_SRFP) { |
202 | ide_create_request_sense_cmd(drive, pc); | 204 | ide_create_request_sense_cmd(drive, pc); |
203 | if (ide_queue_pc_tail(drive, floppy->disk, pc)) | 205 | if (ide_queue_pc_tail(drive, floppy->disk, pc, sense_buf, |
206 | pc->req_xfer)) | ||
204 | return -EIO; | 207 | return -EIO; |
205 | 208 | ||
206 | if (floppy->sense_key == 2 && | 209 | if (floppy->sense_key == 2 && |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 4b447a8a49d4..bb71e1e99dad 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -279,10 +279,12 @@ static void ide_tape_put(struct ide_tape_obj *tape) | |||
279 | * called on each failed packet command retry to analyze the request sense. We | 279 | * called on each failed packet command retry to analyze the request sense. We |
280 | * currently do not utilize this information. | 280 | * currently do not utilize this information. |
281 | */ | 281 | */ |
282 | static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | 282 | static void idetape_analyze_error(ide_drive_t *drive) |
283 | { | 283 | { |
284 | idetape_tape_t *tape = drive->driver_data; | 284 | idetape_tape_t *tape = drive->driver_data; |
285 | struct ide_atapi_pc *pc = drive->failed_pc; | 285 | struct ide_atapi_pc *pc = drive->failed_pc; |
286 | struct request *rq = drive->hwif->rq; | ||
287 | u8 *sense = bio_data(rq->bio); | ||
286 | 288 | ||
287 | tape->sense_key = sense[2] & 0xF; | 289 | tape->sense_key = sense[2] & 0xF; |
288 | tape->asc = sense[12]; | 290 | tape->asc = sense[12]; |
@@ -291,11 +293,9 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
291 | debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", | 293 | debug_log(DBG_ERR, "pc = %x, sense key = %x, asc = %x, ascq = %x\n", |
292 | pc->c[0], tape->sense_key, tape->asc, tape->ascq); | 294 | pc->c[0], tape->sense_key, tape->asc, tape->ascq); |
293 | 295 | ||
294 | /* Correct pc->xferred by asking the tape. */ | 296 | /* correct remaining bytes to transfer */ |
295 | if (pc->flags & PC_FLAG_DMA_ERROR) | 297 | if (pc->flags & PC_FLAG_DMA_ERROR) |
296 | pc->xferred = pc->req_xfer - | 298 | rq->resid_len = tape->blk_size * get_unaligned_be32(&sense[3]); |
297 | tape->blk_size * | ||
298 | get_unaligned_be32(&sense[3]); | ||
299 | 299 | ||
300 | /* | 300 | /* |
301 | * If error was the result of a zero-length read or write command, | 301 | * If error was the result of a zero-length read or write command, |
@@ -329,7 +329,7 @@ static void idetape_analyze_error(ide_drive_t *drive, u8 *sense) | |||
329 | pc->flags |= PC_FLAG_ABORT; | 329 | pc->flags |= PC_FLAG_ABORT; |
330 | } | 330 | } |
331 | if (!(pc->flags & PC_FLAG_ABORT) && | 331 | if (!(pc->flags & PC_FLAG_ABORT) && |
332 | pc->xferred) | 332 | (blk_rq_bytes(rq) - rq->resid_len)) |
333 | pc->retries = IDETAPE_MAX_PC_RETRIES + 1; | 333 | pc->retries = IDETAPE_MAX_PC_RETRIES + 1; |
334 | } | 334 | } |
335 | } | 335 | } |
@@ -354,12 +354,13 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
354 | 354 | ||
355 | if (pc->c[0] == REQUEST_SENSE) { | 355 | if (pc->c[0] == REQUEST_SENSE) { |
356 | if (uptodate) | 356 | if (uptodate) |
357 | idetape_analyze_error(drive, pc->buf); | 357 | idetape_analyze_error(drive); |
358 | else | 358 | else |
359 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " | 359 | printk(KERN_ERR "ide-tape: Error in REQUEST SENSE " |
360 | "itself - Aborting request!\n"); | 360 | "itself - Aborting request!\n"); |
361 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { | 361 | } else if (pc->c[0] == READ_6 || pc->c[0] == WRITE_6) { |
362 | int blocks = pc->xferred / tape->blk_size; | 362 | unsigned int blocks = |
363 | (blk_rq_bytes(rq) - rq->resid_len) / tape->blk_size; | ||
363 | 364 | ||
364 | tape->avg_size += blocks * tape->blk_size; | 365 | tape->avg_size += blocks * tape->blk_size; |
365 | 366 | ||
@@ -371,38 +372,12 @@ static int ide_tape_callback(ide_drive_t *drive, int dsc) | |||
371 | } | 372 | } |
372 | 373 | ||
373 | tape->first_frame += blocks; | 374 | tape->first_frame += blocks; |
374 | rq->resid_len -= blocks * tape->blk_size; | ||
375 | 375 | ||
376 | if (pc->error) { | 376 | if (pc->error) { |
377 | uptodate = 0; | 377 | uptodate = 0; |
378 | err = pc->error; | 378 | err = pc->error; |
379 | } | 379 | } |
380 | } else if (pc->c[0] == READ_POSITION && uptodate) { | ||
381 | u8 *readpos = pc->buf; | ||
382 | |||
383 | debug_log(DBG_SENSE, "BOP - %s\n", | ||
384 | (readpos[0] & 0x80) ? "Yes" : "No"); | ||
385 | debug_log(DBG_SENSE, "EOP - %s\n", | ||
386 | (readpos[0] & 0x40) ? "Yes" : "No"); | ||
387 | |||
388 | if (readpos[0] & 0x4) { | ||
389 | printk(KERN_INFO "ide-tape: Block location is unknown" | ||
390 | "to the tape\n"); | ||
391 | clear_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), | ||
392 | &drive->atapi_flags); | ||
393 | uptodate = 0; | ||
394 | err = IDE_DRV_ERROR_GENERAL; | ||
395 | } else { | ||
396 | debug_log(DBG_SENSE, "Block Location - %u\n", | ||
397 | be32_to_cpup((__be32 *)&readpos[4])); | ||
398 | |||
399 | tape->partition = readpos[1]; | ||
400 | tape->first_frame = be32_to_cpup((__be32 *)&readpos[4]); | ||
401 | set_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), | ||
402 | &drive->atapi_flags); | ||
403 | } | ||
404 | } | 380 | } |
405 | |||
406 | rq->errors = err; | 381 | rq->errors = err; |
407 | 382 | ||
408 | return uptodate; | 383 | return uptodate; |
@@ -477,6 +452,7 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, | |||
477 | struct ide_atapi_pc *pc) | 452 | struct ide_atapi_pc *pc) |
478 | { | 453 | { |
479 | idetape_tape_t *tape = drive->driver_data; | 454 | idetape_tape_t *tape = drive->driver_data; |
455 | struct request *rq = drive->hwif->rq; | ||
480 | 456 | ||
481 | if (drive->failed_pc == NULL && pc->c[0] != REQUEST_SENSE) | 457 | if (drive->failed_pc == NULL && pc->c[0] != REQUEST_SENSE) |
482 | drive->failed_pc = pc; | 458 | drive->failed_pc = pc; |
@@ -486,7 +462,6 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, | |||
486 | 462 | ||
487 | if (pc->retries > IDETAPE_MAX_PC_RETRIES || | 463 | if (pc->retries > IDETAPE_MAX_PC_RETRIES || |
488 | (pc->flags & PC_FLAG_ABORT)) { | 464 | (pc->flags & PC_FLAG_ABORT)) { |
489 | unsigned int done = blk_rq_bytes(drive->hwif->rq); | ||
490 | 465 | ||
491 | /* | 466 | /* |
492 | * We will "abort" retrying a packet command in case legitimate | 467 | * We will "abort" retrying a packet command in case legitimate |
@@ -510,7 +485,7 @@ static ide_startstop_t ide_tape_issue_pc(ide_drive_t *drive, | |||
510 | 485 | ||
511 | drive->failed_pc = NULL; | 486 | drive->failed_pc = NULL; |
512 | drive->pc_callback(drive, 0); | 487 | drive->pc_callback(drive, 0); |
513 | ide_complete_rq(drive, -EIO, done); | 488 | ide_complete_rq(drive, -EIO, blk_rq_bytes(rq)); |
514 | return ide_stopped; | 489 | return ide_stopped; |
515 | } | 490 | } |
516 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); | 491 | debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); |
@@ -579,15 +554,13 @@ static void ide_tape_create_rw_cmd(idetape_tape_t *tape, | |||
579 | struct ide_atapi_pc *pc, struct request *rq, | 554 | struct ide_atapi_pc *pc, struct request *rq, |
580 | u8 opcode) | 555 | u8 opcode) |
581 | { | 556 | { |
582 | unsigned int length = blk_rq_sectors(rq); | 557 | unsigned int length = blk_rq_sectors(rq) / (tape->blk_size >> 9); |
583 | 558 | ||
584 | ide_init_pc(pc); | 559 | ide_init_pc(pc); |
585 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); | 560 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
586 | pc->c[1] = 1; | 561 | pc->c[1] = 1; |
587 | pc->buf = NULL; | 562 | |
588 | pc->buf_size = length * tape->blk_size; | 563 | if (blk_rq_bytes(rq) == tape->buffer_size) |
589 | pc->req_xfer = pc->buf_size; | ||
590 | if (pc->req_xfer == tape->buffer_size) | ||
591 | pc->flags |= PC_FLAG_DMA_OK; | 564 | pc->flags |= PC_FLAG_DMA_OK; |
592 | 565 | ||
593 | if (opcode == READ_6) | 566 | if (opcode == READ_6) |
@@ -713,7 +686,7 @@ out: | |||
713 | 686 | ||
714 | cmd.rq = rq; | 687 | cmd.rq = rq; |
715 | 688 | ||
716 | ide_init_sg_cmd(&cmd, pc->req_xfer); | 689 | ide_init_sg_cmd(&cmd, blk_rq_bytes(rq)); |
717 | ide_map_sg(drive, &cmd); | 690 | ide_map_sg(drive, &cmd); |
718 | 691 | ||
719 | return ide_tape_issue_pc(drive, &cmd, pc); | 692 | return ide_tape_issue_pc(drive, &cmd, pc); |
@@ -767,33 +740,53 @@ static int idetape_flush_tape_buffers(ide_drive_t *drive) | |||
767 | int rc; | 740 | int rc; |
768 | 741 | ||
769 | idetape_create_write_filemark_cmd(drive, &pc, 0); | 742 | idetape_create_write_filemark_cmd(drive, &pc, 0); |
770 | rc = ide_queue_pc_tail(drive, tape->disk, &pc); | 743 | rc = ide_queue_pc_tail(drive, tape->disk, &pc, NULL, 0); |
771 | if (rc) | 744 | if (rc) |
772 | return rc; | 745 | return rc; |
773 | idetape_wait_ready(drive, 60 * 5 * HZ); | 746 | idetape_wait_ready(drive, 60 * 5 * HZ); |
774 | return 0; | 747 | return 0; |
775 | } | 748 | } |
776 | 749 | ||
777 | static void idetape_create_read_position_cmd(struct ide_atapi_pc *pc) | 750 | static int ide_tape_read_position(ide_drive_t *drive) |
778 | { | ||
779 | ide_init_pc(pc); | ||
780 | pc->c[0] = READ_POSITION; | ||
781 | pc->req_xfer = 20; | ||
782 | } | ||
783 | |||
784 | static int idetape_read_position(ide_drive_t *drive) | ||
785 | { | 751 | { |
786 | idetape_tape_t *tape = drive->driver_data; | 752 | idetape_tape_t *tape = drive->driver_data; |
787 | struct ide_atapi_pc pc; | 753 | struct ide_atapi_pc pc; |
788 | int position; | 754 | u8 buf[20]; |
789 | 755 | ||
790 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 756 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
791 | 757 | ||
792 | idetape_create_read_position_cmd(&pc); | 758 | /* prep cmd */ |
793 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) | 759 | ide_init_pc(&pc); |
760 | pc.c[0] = READ_POSITION; | ||
761 | pc.req_xfer = 20; | ||
762 | |||
763 | if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) | ||
794 | return -1; | 764 | return -1; |
795 | position = tape->first_frame; | 765 | |
796 | return position; | 766 | if (!pc.error) { |
767 | debug_log(DBG_SENSE, "BOP - %s\n", | ||
768 | (buf[0] & 0x80) ? "Yes" : "No"); | ||
769 | debug_log(DBG_SENSE, "EOP - %s\n", | ||
770 | (buf[0] & 0x40) ? "Yes" : "No"); | ||
771 | |||
772 | if (buf[0] & 0x4) { | ||
773 | printk(KERN_INFO "ide-tape: Block location is unknown" | ||
774 | "to the tape\n"); | ||
775 | clear_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), | ||
776 | &drive->atapi_flags); | ||
777 | return -1; | ||
778 | } else { | ||
779 | debug_log(DBG_SENSE, "Block Location - %u\n", | ||
780 | be32_to_cpup((__be32 *)&buf[4])); | ||
781 | |||
782 | tape->partition = buf[1]; | ||
783 | tape->first_frame = be32_to_cpup((__be32 *)&buf[4]); | ||
784 | set_bit(ilog2(IDE_AFLAG_ADDRESS_VALID), | ||
785 | &drive->atapi_flags); | ||
786 | } | ||
787 | } | ||
788 | |||
789 | return tape->first_frame; | ||
797 | } | 790 | } |
798 | 791 | ||
799 | static void idetape_create_locate_cmd(ide_drive_t *drive, | 792 | static void idetape_create_locate_cmd(ide_drive_t *drive, |
@@ -836,19 +829,21 @@ static int idetape_position_tape(ide_drive_t *drive, unsigned int block, | |||
836 | { | 829 | { |
837 | idetape_tape_t *tape = drive->driver_data; | 830 | idetape_tape_t *tape = drive->driver_data; |
838 | struct gendisk *disk = tape->disk; | 831 | struct gendisk *disk = tape->disk; |
839 | int retval; | 832 | int ret; |
840 | struct ide_atapi_pc pc; | 833 | struct ide_atapi_pc pc; |
841 | 834 | ||
842 | if (tape->chrdev_dir == IDETAPE_DIR_READ) | 835 | if (tape->chrdev_dir == IDETAPE_DIR_READ) |
843 | __ide_tape_discard_merge_buffer(drive); | 836 | __ide_tape_discard_merge_buffer(drive); |
844 | idetape_wait_ready(drive, 60 * 5 * HZ); | 837 | idetape_wait_ready(drive, 60 * 5 * HZ); |
845 | idetape_create_locate_cmd(drive, &pc, block, partition, skip); | 838 | idetape_create_locate_cmd(drive, &pc, block, partition, skip); |
846 | retval = ide_queue_pc_tail(drive, disk, &pc); | 839 | ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
847 | if (retval) | 840 | if (ret) |
848 | return (retval); | 841 | return ret; |
849 | 842 | ||
850 | idetape_create_read_position_cmd(&pc); | 843 | ret = ide_tape_read_position(drive); |
851 | return ide_queue_pc_tail(drive, disk, &pc); | 844 | if (ret < 0) |
845 | return ret; | ||
846 | return 0; | ||
852 | } | 847 | } |
853 | 848 | ||
854 | static void ide_tape_discard_merge_buffer(ide_drive_t *drive, | 849 | static void ide_tape_discard_merge_buffer(ide_drive_t *drive, |
@@ -859,7 +854,7 @@ static void ide_tape_discard_merge_buffer(ide_drive_t *drive, | |||
859 | 854 | ||
860 | __ide_tape_discard_merge_buffer(drive); | 855 | __ide_tape_discard_merge_buffer(drive); |
861 | if (restore_position) { | 856 | if (restore_position) { |
862 | position = idetape_read_position(drive); | 857 | position = ide_tape_read_position(drive); |
863 | seek = position > 0 ? position : 0; | 858 | seek = position > 0 ? position : 0; |
864 | if (idetape_position_tape(drive, seek, 0, 0)) { | 859 | if (idetape_position_tape(drive, seek, 0, 0)) { |
865 | printk(KERN_INFO "ide-tape: %s: position_tape failed in" | 860 | printk(KERN_INFO "ide-tape: %s: position_tape failed in" |
@@ -1039,20 +1034,19 @@ static int idetape_rewind_tape(ide_drive_t *drive) | |||
1039 | { | 1034 | { |
1040 | struct ide_tape_obj *tape = drive->driver_data; | 1035 | struct ide_tape_obj *tape = drive->driver_data; |
1041 | struct gendisk *disk = tape->disk; | 1036 | struct gendisk *disk = tape->disk; |
1042 | int retval; | ||
1043 | struct ide_atapi_pc pc; | 1037 | struct ide_atapi_pc pc; |
1038 | int ret; | ||
1044 | 1039 | ||
1045 | debug_log(DBG_SENSE, "Enter %s\n", __func__); | 1040 | debug_log(DBG_SENSE, "Enter %s\n", __func__); |
1046 | 1041 | ||
1047 | idetape_create_rewind_cmd(drive, &pc); | 1042 | idetape_create_rewind_cmd(drive, &pc); |
1048 | retval = ide_queue_pc_tail(drive, disk, &pc); | 1043 | ret = ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
1049 | if (retval) | 1044 | if (ret) |
1050 | return retval; | 1045 | return ret; |
1051 | 1046 | ||
1052 | idetape_create_read_position_cmd(&pc); | 1047 | ret = ide_tape_read_position(drive); |
1053 | retval = ide_queue_pc_tail(drive, disk, &pc); | 1048 | if (ret < 0) |
1054 | if (retval) | 1049 | return ret; |
1055 | return retval; | ||
1056 | return 0; | 1050 | return 0; |
1057 | } | 1051 | } |
1058 | 1052 | ||
@@ -1119,7 +1113,7 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, | |||
1119 | case MTBSF: | 1113 | case MTBSF: |
1120 | idetape_create_space_cmd(&pc, mt_count - count, | 1114 | idetape_create_space_cmd(&pc, mt_count - count, |
1121 | IDETAPE_SPACE_OVER_FILEMARK); | 1115 | IDETAPE_SPACE_OVER_FILEMARK); |
1122 | return ide_queue_pc_tail(drive, disk, &pc); | 1116 | return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
1123 | case MTFSFM: | 1117 | case MTFSFM: |
1124 | case MTBSFM: | 1118 | case MTBSFM: |
1125 | if (!sprev) | 1119 | if (!sprev) |
@@ -1259,7 +1253,7 @@ static int idetape_write_filemark(ide_drive_t *drive) | |||
1259 | 1253 | ||
1260 | /* Write a filemark */ | 1254 | /* Write a filemark */ |
1261 | idetape_create_write_filemark_cmd(drive, &pc, 1); | 1255 | idetape_create_write_filemark_cmd(drive, &pc, 1); |
1262 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) { | 1256 | if (ide_queue_pc_tail(drive, tape->disk, &pc, NULL, 0)) { |
1263 | printk(KERN_ERR "ide-tape: Couldn't write a filemark\n"); | 1257 | printk(KERN_ERR "ide-tape: Couldn't write a filemark\n"); |
1264 | return -EIO; | 1258 | return -EIO; |
1265 | } | 1259 | } |
@@ -1345,11 +1339,11 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
1345 | IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); | 1339 | IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); |
1346 | case MTEOM: | 1340 | case MTEOM: |
1347 | idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD); | 1341 | idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD); |
1348 | return ide_queue_pc_tail(drive, disk, &pc); | 1342 | return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
1349 | case MTERASE: | 1343 | case MTERASE: |
1350 | (void)idetape_rewind_tape(drive); | 1344 | (void)idetape_rewind_tape(drive); |
1351 | idetape_create_erase_cmd(&pc); | 1345 | idetape_create_erase_cmd(&pc); |
1352 | return ide_queue_pc_tail(drive, disk, &pc); | 1346 | return ide_queue_pc_tail(drive, disk, &pc, NULL, 0); |
1353 | case MTSETBLK: | 1347 | case MTSETBLK: |
1354 | if (mt_count) { | 1348 | if (mt_count) { |
1355 | if (mt_count < tape->blk_size || | 1349 | if (mt_count < tape->blk_size || |
@@ -1415,7 +1409,7 @@ static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, | |||
1415 | if (cmd == MTIOCGET || cmd == MTIOCPOS) { | 1409 | if (cmd == MTIOCGET || cmd == MTIOCPOS) { |
1416 | block_offset = tape->valid / | 1410 | block_offset = tape->valid / |
1417 | (tape->blk_size * tape->user_bs_factor); | 1411 | (tape->blk_size * tape->user_bs_factor); |
1418 | position = idetape_read_position(drive); | 1412 | position = ide_tape_read_position(drive); |
1419 | if (position < 0) | 1413 | if (position < 0) |
1420 | return -EIO; | 1414 | return -EIO; |
1421 | } | 1415 | } |
@@ -1458,9 +1452,10 @@ static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) | |||
1458 | { | 1452 | { |
1459 | idetape_tape_t *tape = drive->driver_data; | 1453 | idetape_tape_t *tape = drive->driver_data; |
1460 | struct ide_atapi_pc pc; | 1454 | struct ide_atapi_pc pc; |
1455 | u8 buf[12]; | ||
1461 | 1456 | ||
1462 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); | 1457 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); |
1463 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) { | 1458 | if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) { |
1464 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); | 1459 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); |
1465 | if (tape->blk_size == 0) { | 1460 | if (tape->blk_size == 0) { |
1466 | printk(KERN_WARNING "ide-tape: Cannot deal with zero " | 1461 | printk(KERN_WARNING "ide-tape: Cannot deal with zero " |
@@ -1469,10 +1464,10 @@ static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) | |||
1469 | } | 1464 | } |
1470 | return; | 1465 | return; |
1471 | } | 1466 | } |
1472 | tape->blk_size = (pc.buf[4 + 5] << 16) + | 1467 | tape->blk_size = (buf[4 + 5] << 16) + |
1473 | (pc.buf[4 + 6] << 8) + | 1468 | (buf[4 + 6] << 8) + |
1474 | pc.buf[4 + 7]; | 1469 | buf[4 + 7]; |
1475 | tape->drv_write_prot = (pc.buf[2] & 0x80) >> 7; | 1470 | tape->drv_write_prot = (buf[2] & 0x80) >> 7; |
1476 | } | 1471 | } |
1477 | 1472 | ||
1478 | static int idetape_chrdev_open(struct inode *inode, struct file *filp) | 1473 | static int idetape_chrdev_open(struct inode *inode, struct file *filp) |
@@ -1615,17 +1610,14 @@ static void idetape_get_inquiry_results(ide_drive_t *drive) | |||
1615 | char fw_rev[4], vendor_id[8], product_id[16]; | 1610 | char fw_rev[4], vendor_id[8], product_id[16]; |
1616 | 1611 | ||
1617 | idetape_create_inquiry_cmd(&pc); | 1612 | idetape_create_inquiry_cmd(&pc); |
1618 | pc.buf = &pc_buf[0]; | 1613 | if (ide_queue_pc_tail(drive, tape->disk, &pc, pc_buf, pc.req_xfer)) { |
1619 | pc.buf_size = sizeof(pc_buf); | ||
1620 | |||
1621 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) { | ||
1622 | printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", | 1614 | printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", |
1623 | tape->name); | 1615 | tape->name); |
1624 | return; | 1616 | return; |
1625 | } | 1617 | } |
1626 | memcpy(vendor_id, &pc.buf[8], 8); | 1618 | memcpy(vendor_id, &pc_buf[8], 8); |
1627 | memcpy(product_id, &pc.buf[16], 16); | 1619 | memcpy(product_id, &pc_buf[16], 16); |
1628 | memcpy(fw_rev, &pc.buf[32], 4); | 1620 | memcpy(fw_rev, &pc_buf[32], 4); |
1629 | 1621 | ||
1630 | ide_fixstring(vendor_id, 8, 0); | 1622 | ide_fixstring(vendor_id, 8, 0); |
1631 | ide_fixstring(product_id, 16, 0); | 1623 | ide_fixstring(product_id, 16, 0); |
@@ -1643,11 +1635,11 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive) | |||
1643 | { | 1635 | { |
1644 | idetape_tape_t *tape = drive->driver_data; | 1636 | idetape_tape_t *tape = drive->driver_data; |
1645 | struct ide_atapi_pc pc; | 1637 | struct ide_atapi_pc pc; |
1646 | u8 *caps; | 1638 | u8 buf[24], *caps; |
1647 | u8 speed, max_speed; | 1639 | u8 speed, max_speed; |
1648 | 1640 | ||
1649 | idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE); | 1641 | idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE); |
1650 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) { | 1642 | if (ide_queue_pc_tail(drive, tape->disk, &pc, buf, pc.req_xfer)) { |
1651 | printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" | 1643 | printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" |
1652 | " some default values\n"); | 1644 | " some default values\n"); |
1653 | tape->blk_size = 512; | 1645 | tape->blk_size = 512; |
@@ -1656,7 +1648,7 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive) | |||
1656 | put_unaligned(6*52, (u16 *)&tape->caps[16]); | 1648 | put_unaligned(6*52, (u16 *)&tape->caps[16]); |
1657 | return; | 1649 | return; |
1658 | } | 1650 | } |
1659 | caps = pc.buf + 4 + pc.buf[3]; | 1651 | caps = buf + 4 + buf[3]; |
1660 | 1652 | ||
1661 | /* convert to host order and save for later use */ | 1653 | /* convert to host order and save for later use */ |
1662 | speed = be16_to_cpup((__be16 *)&caps[14]); | 1654 | speed = be16_to_cpup((__be16 *)&caps[14]); |
diff --git a/include/linux/ide.h b/include/linux/ide.h index a6c6a2fad7c8..cdb29b6c195f 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
@@ -331,11 +331,6 @@ enum { | |||
331 | PC_FLAG_WRITING = (1 << 6), | 331 | PC_FLAG_WRITING = (1 << 6), |
332 | }; | 332 | }; |
333 | 333 | ||
334 | /* | ||
335 | * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes. | ||
336 | * This is used for several packet commands (not for READ/WRITE commands). | ||
337 | */ | ||
338 | #define IDE_PC_BUFFER_SIZE 64 | ||
339 | #define ATAPI_WAIT_PC (60 * HZ) | 334 | #define ATAPI_WAIT_PC (60 * HZ) |
340 | 335 | ||
341 | struct ide_atapi_pc { | 336 | struct ide_atapi_pc { |
@@ -347,12 +342,6 @@ struct ide_atapi_pc { | |||
347 | 342 | ||
348 | /* bytes to transfer */ | 343 | /* bytes to transfer */ |
349 | int req_xfer; | 344 | int req_xfer; |
350 | /* bytes actually transferred */ | ||
351 | int xferred; | ||
352 | |||
353 | /* data buffer */ | ||
354 | u8 *buf; | ||
355 | int buf_size; | ||
356 | 345 | ||
357 | /* the corresponding request */ | 346 | /* the corresponding request */ |
358 | struct request *rq; | 347 | struct request *rq; |
@@ -363,8 +352,6 @@ struct ide_atapi_pc { | |||
363 | * those are more or less driver-specific and some of them are subject | 352 | * those are more or less driver-specific and some of them are subject |
364 | * to change/removal later. | 353 | * to change/removal later. |
365 | */ | 354 | */ |
366 | u8 pc_buf[IDE_PC_BUFFER_SIZE]; | ||
367 | |||
368 | unsigned long timeout; | 355 | unsigned long timeout; |
369 | }; | 356 | }; |
370 | 357 | ||
@@ -1130,6 +1117,8 @@ void SELECT_MASK(ide_drive_t *, int); | |||
1130 | u8 ide_read_error(ide_drive_t *); | 1117 | u8 ide_read_error(ide_drive_t *); |
1131 | void ide_read_bcount_and_ireason(ide_drive_t *, u16 *, u8 *); | 1118 | void ide_read_bcount_and_ireason(ide_drive_t *, u16 *, u8 *); |
1132 | 1119 | ||
1120 | int ide_check_ireason(ide_drive_t *, struct request *, int, int, int); | ||
1121 | |||
1133 | int ide_check_atapi_device(ide_drive_t *, const char *); | 1122 | int ide_check_atapi_device(ide_drive_t *, const char *); |
1134 | 1123 | ||
1135 | void ide_init_pc(struct ide_atapi_pc *); | 1124 | void ide_init_pc(struct ide_atapi_pc *); |
@@ -1154,7 +1143,8 @@ enum { | |||
1154 | REQ_IDETAPE_WRITE = (1 << 3), | 1143 | REQ_IDETAPE_WRITE = (1 << 3), |
1155 | }; | 1144 | }; |
1156 | 1145 | ||
1157 | int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *); | 1146 | int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *, |
1147 | void *, unsigned int); | ||
1158 | 1148 | ||
1159 | int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *); | 1149 | int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *); |
1160 | int ide_do_start_stop(ide_drive_t *, struct gendisk *, int); | 1150 | int ide_do_start_stop(ide_drive_t *, struct gendisk *, int); |