diff options
author | Borislav Petkov <petkovbb@googlemail.com> | 2008-04-17 18:46:27 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-04-17 18:46:27 -0400 |
commit | 8e555123911cc912427bd25b52ebfb7b6c08e39a (patch) | |
tree | 900c3816816c6826666b2b48359b38282cea3be7 | |
parent | d236d74c0d91c7eeaef26560d3690430189e171f (diff) |
ide-floppy: convert driver to using generic ide_atapi_pc
Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r-- | drivers/ide/ide-floppy.c | 205 |
1 files changed, 93 insertions, 112 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 4ce67bdb5d5e..7e62dfc186f6 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -78,26 +78,6 @@ | |||
78 | */ | 78 | */ |
79 | #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES) | 79 | #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES) |
80 | 80 | ||
81 | typedef struct idefloppy_packet_command_s { | ||
82 | u8 c[12]; /* Actual packet bytes */ | ||
83 | int retries; /* On each retry, we increment | ||
84 | retries */ | ||
85 | int error; /* Error code */ | ||
86 | int request_transfer; /* Bytes to transfer */ | ||
87 | int actually_transferred; /* Bytes actually transferred */ | ||
88 | int buffer_size; /* Size of our data buffer */ | ||
89 | int b_count; /* Missing/Available data on | ||
90 | the current buffer */ | ||
91 | struct request *rq; /* The corresponding request */ | ||
92 | u8 *buffer; /* Data buffer */ | ||
93 | u8 *current_position; /* Pointer into above buffer */ | ||
94 | void (*callback) (ide_drive_t *); /* Called when this packet | ||
95 | command is completed */ | ||
96 | u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE]; /* Temporary buffer */ | ||
97 | unsigned long flags; /* Status/Action bit flags: long | ||
98 | for set_bit */ | ||
99 | } idefloppy_pc_t; | ||
100 | |||
101 | /* Packet command flag bits. */ | 81 | /* Packet command flag bits. */ |
102 | enum { | 82 | enum { |
103 | /* 1 when we prefer to use DMA if possible */ | 83 | /* 1 when we prefer to use DMA if possible */ |
@@ -131,11 +111,11 @@ typedef struct ide_floppy_obj { | |||
131 | unsigned int openers; /* protected by BKL for now */ | 111 | unsigned int openers; /* protected by BKL for now */ |
132 | 112 | ||
133 | /* Current packet command */ | 113 | /* Current packet command */ |
134 | idefloppy_pc_t *pc; | 114 | struct ide_atapi_pc *pc; |
135 | /* Last failed packet command */ | 115 | /* Last failed packet command */ |
136 | idefloppy_pc_t *failed_pc; | 116 | struct ide_atapi_pc *failed_pc; |
137 | /* Packet command stack */ | 117 | /* Packet command stack */ |
138 | idefloppy_pc_t pc_stack[IDEFLOPPY_PC_STACK]; | 118 | struct ide_atapi_pc pc_stack[IDEFLOPPY_PC_STACK]; |
139 | /* Next free packet command storage space */ | 119 | /* Next free packet command storage space */ |
140 | int pc_stack_index; | 120 | int pc_stack_index; |
141 | struct request rq_stack[IDEFLOPPY_PC_STACK]; | 121 | struct request rq_stack[IDEFLOPPY_PC_STACK]; |
@@ -262,7 +242,7 @@ static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) | |||
262 | return 0; | 242 | return 0; |
263 | } | 243 | } |
264 | 244 | ||
265 | static void ide_floppy_io_buffers(ide_drive_t *drive, idefloppy_pc_t *pc, | 245 | static void ide_floppy_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, |
266 | unsigned int bcount, int direction) | 246 | unsigned int bcount, int direction) |
267 | { | 247 | { |
268 | struct request *rq = pc->rq; | 248 | struct request *rq = pc->rq; |
@@ -302,7 +282,8 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, idefloppy_pc_t *pc, | |||
302 | } | 282 | } |
303 | } | 283 | } |
304 | 284 | ||
305 | static void idefloppy_update_buffers(ide_drive_t *drive, idefloppy_pc_t *pc) | 285 | static void idefloppy_update_buffers(ide_drive_t *drive, |
286 | struct ide_atapi_pc *pc) | ||
306 | { | 287 | { |
307 | struct request *rq = pc->rq; | 288 | struct request *rq = pc->rq; |
308 | struct bio *bio = rq->bio; | 289 | struct bio *bio = rq->bio; |
@@ -316,7 +297,7 @@ static void idefloppy_update_buffers(ide_drive_t *drive, idefloppy_pc_t *pc) | |||
316 | * the current request so that it will be processed immediately, on the next | 297 | * the current request so that it will be processed immediately, on the next |
317 | * pass through the driver. | 298 | * pass through the driver. |
318 | */ | 299 | */ |
319 | static void idefloppy_queue_pc_head(ide_drive_t *drive, idefloppy_pc_t *pc, | 300 | static void idefloppy_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, |
320 | struct request *rq) | 301 | struct request *rq) |
321 | { | 302 | { |
322 | struct ide_floppy_obj *floppy = drive->driver_data; | 303 | struct ide_floppy_obj *floppy = drive->driver_data; |
@@ -328,7 +309,7 @@ static void idefloppy_queue_pc_head(ide_drive_t *drive, idefloppy_pc_t *pc, | |||
328 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); | 309 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); |
329 | } | 310 | } |
330 | 311 | ||
331 | static idefloppy_pc_t *idefloppy_next_pc_storage(ide_drive_t *drive) | 312 | static struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive) |
332 | { | 313 | { |
333 | idefloppy_floppy_t *floppy = drive->driver_data; | 314 | idefloppy_floppy_t *floppy = drive->driver_data; |
334 | 315 | ||
@@ -349,7 +330,7 @@ static struct request *idefloppy_next_rq_storage(ide_drive_t *drive) | |||
349 | static void idefloppy_request_sense_callback(ide_drive_t *drive) | 330 | static void idefloppy_request_sense_callback(ide_drive_t *drive) |
350 | { | 331 | { |
351 | idefloppy_floppy_t *floppy = drive->driver_data; | 332 | idefloppy_floppy_t *floppy = drive->driver_data; |
352 | u8 *buf = floppy->pc->buffer; | 333 | u8 *buf = floppy->pc->buf; |
353 | 334 | ||
354 | debug_log("Reached %s\n", __func__); | 335 | debug_log("Reached %s\n", __func__); |
355 | 336 | ||
@@ -392,24 +373,24 @@ static void idefloppy_pc_callback(ide_drive_t *drive) | |||
392 | idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0); | 373 | idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0); |
393 | } | 374 | } |
394 | 375 | ||
395 | static void idefloppy_init_pc(idefloppy_pc_t *pc) | 376 | static void idefloppy_init_pc(struct ide_atapi_pc *pc) |
396 | { | 377 | { |
397 | memset(pc->c, 0, 12); | 378 | memset(pc->c, 0, 12); |
398 | pc->retries = 0; | 379 | pc->retries = 0; |
399 | pc->flags = 0; | 380 | pc->flags = 0; |
400 | pc->request_transfer = 0; | 381 | pc->req_xfer = 0; |
401 | pc->buffer = pc->pc_buffer; | 382 | pc->buf = pc->pc_buf; |
402 | pc->buffer_size = IDEFLOPPY_PC_BUFFER_SIZE; | 383 | pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE; |
403 | pc->callback = &idefloppy_pc_callback; | 384 | pc->idefloppy_callback = &idefloppy_pc_callback; |
404 | } | 385 | } |
405 | 386 | ||
406 | static void idefloppy_create_request_sense_cmd(idefloppy_pc_t *pc) | 387 | static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) |
407 | { | 388 | { |
408 | idefloppy_init_pc(pc); | 389 | idefloppy_init_pc(pc); |
409 | pc->c[0] = GPCMD_REQUEST_SENSE; | 390 | pc->c[0] = GPCMD_REQUEST_SENSE; |
410 | pc->c[4] = 255; | 391 | pc->c[4] = 255; |
411 | pc->request_transfer = 18; | 392 | pc->req_xfer = 18; |
412 | pc->callback = &idefloppy_request_sense_callback; | 393 | pc->idefloppy_callback = &idefloppy_request_sense_callback; |
413 | } | 394 | } |
414 | 395 | ||
415 | /* | 396 | /* |
@@ -418,7 +399,7 @@ static void idefloppy_create_request_sense_cmd(idefloppy_pc_t *pc) | |||
418 | */ | 399 | */ |
419 | static void idefloppy_retry_pc(ide_drive_t *drive) | 400 | static void idefloppy_retry_pc(ide_drive_t *drive) |
420 | { | 401 | { |
421 | idefloppy_pc_t *pc; | 402 | struct ide_atapi_pc *pc; |
422 | struct request *rq; | 403 | struct request *rq; |
423 | 404 | ||
424 | (void)ide_read_error(drive); | 405 | (void)ide_read_error(drive); |
@@ -433,7 +414,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
433 | { | 414 | { |
434 | idefloppy_floppy_t *floppy = drive->driver_data; | 415 | idefloppy_floppy_t *floppy = drive->driver_data; |
435 | ide_hwif_t *hwif = drive->hwif; | 416 | ide_hwif_t *hwif = drive->hwif; |
436 | idefloppy_pc_t *pc = floppy->pc; | 417 | struct ide_atapi_pc *pc = floppy->pc; |
437 | struct request *rq = pc->rq; | 418 | struct request *rq = pc->rq; |
438 | xfer_func_t *xferfunc; | 419 | xfer_func_t *xferfunc; |
439 | unsigned int temp; | 420 | unsigned int temp; |
@@ -450,7 +431,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
450 | rq_data_dir(rq) ? "write" : "read"); | 431 | rq_data_dir(rq) ? "write" : "read"); |
451 | pc->flags |= PC_FLAG_DMA_ERROR; | 432 | pc->flags |= PC_FLAG_DMA_ERROR; |
452 | } else { | 433 | } else { |
453 | pc->actually_transferred = pc->request_transfer; | 434 | pc->xferred = pc->req_xfer; |
454 | idefloppy_update_buffers(drive, pc); | 435 | idefloppy_update_buffers(drive, pc); |
455 | } | 436 | } |
456 | debug_log("DMA finished\n"); | 437 | debug_log("DMA finished\n"); |
@@ -462,7 +443,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
462 | /* No more interrupts */ | 443 | /* No more interrupts */ |
463 | if ((stat & DRQ_STAT) == 0) { | 444 | if ((stat & DRQ_STAT) == 0) { |
464 | debug_log("Packet command completed, %d bytes transferred\n", | 445 | debug_log("Packet command completed, %d bytes transferred\n", |
465 | pc->actually_transferred); | 446 | pc->xferred); |
466 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | 447 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; |
467 | 448 | ||
468 | local_irq_enable_in_hardirq(); | 449 | local_irq_enable_in_hardirq(); |
@@ -485,7 +466,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
485 | if (floppy->failed_pc == pc) | 466 | if (floppy->failed_pc == pc) |
486 | floppy->failed_pc = NULL; | 467 | floppy->failed_pc = NULL; |
487 | /* Command finished - Call the callback function */ | 468 | /* Command finished - Call the callback function */ |
488 | pc->callback(drive); | 469 | pc->idefloppy_callback(drive); |
489 | return ide_stopped; | 470 | return ide_stopped; |
490 | } | 471 | } |
491 | 472 | ||
@@ -517,9 +498,9 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
517 | } | 498 | } |
518 | if (!(pc->flags & PC_FLAG_WRITING)) { | 499 | if (!(pc->flags & PC_FLAG_WRITING)) { |
519 | /* Reading - Check that we have enough space */ | 500 | /* Reading - Check that we have enough space */ |
520 | temp = pc->actually_transferred + bcount; | 501 | temp = pc->xferred + bcount; |
521 | if (temp > pc->request_transfer) { | 502 | if (temp > pc->req_xfer) { |
522 | if (temp > pc->buffer_size) { | 503 | if (temp > pc->buf_size) { |
523 | printk(KERN_ERR "ide-floppy: The floppy wants " | 504 | printk(KERN_ERR "ide-floppy: The floppy wants " |
524 | "to send us more data than expected " | 505 | "to send us more data than expected " |
525 | "- discarding data\n"); | 506 | "- discarding data\n"); |
@@ -540,15 +521,15 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
540 | else | 521 | else |
541 | xferfunc = hwif->atapi_input_bytes; | 522 | xferfunc = hwif->atapi_input_bytes; |
542 | 523 | ||
543 | if (pc->buffer) | 524 | if (pc->buf) |
544 | xferfunc(drive, pc->current_position, bcount); | 525 | xferfunc(drive, pc->cur_pos, bcount); |
545 | else | 526 | else |
546 | ide_floppy_io_buffers(drive, pc, bcount, | 527 | ide_floppy_io_buffers(drive, pc, bcount, |
547 | !!(pc->flags & PC_FLAG_WRITING)); | 528 | !!(pc->flags & PC_FLAG_WRITING)); |
548 | 529 | ||
549 | /* Update the current position */ | 530 | /* Update the current position */ |
550 | pc->actually_transferred += bcount; | 531 | pc->xferred += bcount; |
551 | pc->current_position += bcount; | 532 | pc->cur_pos += bcount; |
552 | 533 | ||
553 | /* And set the interrupt handler again */ | 534 | /* And set the interrupt handler again */ |
554 | ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); | 535 | ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); |
@@ -640,7 +621,7 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) | |||
640 | } | 621 | } |
641 | 622 | ||
642 | static void ide_floppy_report_error(idefloppy_floppy_t *floppy, | 623 | static void ide_floppy_report_error(idefloppy_floppy_t *floppy, |
643 | idefloppy_pc_t *pc) | 624 | struct ide_atapi_pc *pc) |
644 | { | 625 | { |
645 | /* supress error messages resulting from Medium not present */ | 626 | /* supress error messages resulting from Medium not present */ |
646 | if (floppy->sense_key == 0x02 && | 627 | if (floppy->sense_key == 0x02 && |
@@ -656,7 +637,7 @@ static void ide_floppy_report_error(idefloppy_floppy_t *floppy, | |||
656 | } | 637 | } |
657 | 638 | ||
658 | static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | 639 | static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, |
659 | idefloppy_pc_t *pc) | 640 | struct ide_atapi_pc *pc) |
660 | { | 641 | { |
661 | idefloppy_floppy_t *floppy = drive->driver_data; | 642 | idefloppy_floppy_t *floppy = drive->driver_data; |
662 | ide_hwif_t *hwif = drive->hwif; | 643 | ide_hwif_t *hwif = drive->hwif; |
@@ -677,7 +658,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
677 | pc->error = IDEFLOPPY_ERROR_GENERAL; | 658 | pc->error = IDEFLOPPY_ERROR_GENERAL; |
678 | 659 | ||
679 | floppy->failed_pc = NULL; | 660 | floppy->failed_pc = NULL; |
680 | pc->callback(drive); | 661 | pc->idefloppy_callback(drive); |
681 | return ide_stopped; | 662 | return ide_stopped; |
682 | } | 663 | } |
683 | 664 | ||
@@ -685,9 +666,9 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
685 | 666 | ||
686 | pc->retries++; | 667 | pc->retries++; |
687 | /* We haven't transferred any data yet */ | 668 | /* We haven't transferred any data yet */ |
688 | pc->actually_transferred = 0; | 669 | pc->xferred = 0; |
689 | pc->current_position = pc->buffer; | 670 | pc->cur_pos = pc->buf; |
690 | bcount = min(pc->request_transfer, 63 * 1024); | 671 | bcount = min(pc->req_xfer, 63 * 1024); |
691 | 672 | ||
692 | if (pc->flags & PC_FLAG_DMA_ERROR) { | 673 | if (pc->flags & PC_FLAG_DMA_ERROR) { |
693 | pc->flags &= ~PC_FLAG_DMA_ERROR; | 674 | pc->flags &= ~PC_FLAG_DMA_ERROR; |
@@ -715,7 +696,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
715 | /* immediate */ | 696 | /* immediate */ |
716 | pkt_xfer_routine = &idefloppy_transfer_pc; | 697 | pkt_xfer_routine = &idefloppy_transfer_pc; |
717 | } | 698 | } |
718 | 699 | ||
719 | if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) { | 700 | if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) { |
720 | /* Issue the packet command */ | 701 | /* Issue the packet command */ |
721 | ide_execute_command(drive, WIN_PACKETCMD, | 702 | ide_execute_command(drive, WIN_PACKETCMD, |
@@ -738,7 +719,7 @@ static void idefloppy_rw_callback(ide_drive_t *drive) | |||
738 | return; | 719 | return; |
739 | } | 720 | } |
740 | 721 | ||
741 | static void idefloppy_create_prevent_cmd(idefloppy_pc_t *pc, int prevent) | 722 | static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent) |
742 | { | 723 | { |
743 | debug_log("creating prevent removal command, prevent = %d\n", prevent); | 724 | debug_log("creating prevent removal command, prevent = %d\n", prevent); |
744 | 725 | ||
@@ -747,39 +728,39 @@ static void idefloppy_create_prevent_cmd(idefloppy_pc_t *pc, int prevent) | |||
747 | pc->c[4] = prevent; | 728 | pc->c[4] = prevent; |
748 | } | 729 | } |
749 | 730 | ||
750 | static void idefloppy_create_read_capacity_cmd(idefloppy_pc_t *pc) | 731 | static void idefloppy_create_read_capacity_cmd(struct ide_atapi_pc *pc) |
751 | { | 732 | { |
752 | idefloppy_init_pc(pc); | 733 | idefloppy_init_pc(pc); |
753 | pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES; | 734 | pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES; |
754 | pc->c[7] = 255; | 735 | pc->c[7] = 255; |
755 | pc->c[8] = 255; | 736 | pc->c[8] = 255; |
756 | pc->request_transfer = 255; | 737 | pc->req_xfer = 255; |
757 | } | 738 | } |
758 | 739 | ||
759 | static void idefloppy_create_format_unit_cmd(idefloppy_pc_t *pc, int b, int l, | 740 | static void idefloppy_create_format_unit_cmd(struct ide_atapi_pc *pc, int b, |
760 | int flags) | 741 | int l, int flags) |
761 | { | 742 | { |
762 | idefloppy_init_pc(pc); | 743 | idefloppy_init_pc(pc); |
763 | pc->c[0] = GPCMD_FORMAT_UNIT; | 744 | pc->c[0] = GPCMD_FORMAT_UNIT; |
764 | pc->c[1] = 0x17; | 745 | pc->c[1] = 0x17; |
765 | 746 | ||
766 | memset(pc->buffer, 0, 12); | 747 | memset(pc->buf, 0, 12); |
767 | pc->buffer[1] = 0xA2; | 748 | pc->buf[1] = 0xA2; |
768 | /* Default format list header, u8 1: FOV/DCRT/IMM bits set */ | 749 | /* Default format list header, u8 1: FOV/DCRT/IMM bits set */ |
769 | 750 | ||
770 | if (flags & 1) /* Verify bit on... */ | 751 | if (flags & 1) /* Verify bit on... */ |
771 | pc->buffer[1] ^= 0x20; /* ... turn off DCRT bit */ | 752 | pc->buf[1] ^= 0x20; /* ... turn off DCRT bit */ |
772 | pc->buffer[3] = 8; | 753 | pc->buf[3] = 8; |
773 | 754 | ||
774 | put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4])); | 755 | put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buf[4])); |
775 | put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8])); | 756 | put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buf[8])); |
776 | pc->buffer_size = 12; | 757 | pc->buf_size = 12; |
777 | pc->flags |= PC_FLAG_WRITING; | 758 | pc->flags |= PC_FLAG_WRITING; |
778 | } | 759 | } |
779 | 760 | ||
780 | /* A mode sense command is used to "sense" floppy parameters. */ | 761 | /* A mode sense command is used to "sense" floppy parameters. */ |
781 | static void idefloppy_create_mode_sense_cmd(idefloppy_pc_t *pc, u8 page_code, | 762 | static void idefloppy_create_mode_sense_cmd(struct ide_atapi_pc *pc, |
782 | u8 type) | 763 | u8 page_code, u8 type) |
783 | { | 764 | { |
784 | u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */ | 765 | u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */ |
785 | 766 | ||
@@ -800,24 +781,24 @@ static void idefloppy_create_mode_sense_cmd(idefloppy_pc_t *pc, u8 page_code, | |||
800 | "in create_mode_sense_cmd\n"); | 781 | "in create_mode_sense_cmd\n"); |
801 | } | 782 | } |
802 | put_unaligned(cpu_to_be16(length), (u16 *) &pc->c[7]); | 783 | put_unaligned(cpu_to_be16(length), (u16 *) &pc->c[7]); |
803 | pc->request_transfer = length; | 784 | pc->req_xfer = length; |
804 | } | 785 | } |
805 | 786 | ||
806 | static void idefloppy_create_start_stop_cmd(idefloppy_pc_t *pc, int start) | 787 | static void idefloppy_create_start_stop_cmd(struct ide_atapi_pc *pc, int start) |
807 | { | 788 | { |
808 | idefloppy_init_pc(pc); | 789 | idefloppy_init_pc(pc); |
809 | pc->c[0] = GPCMD_START_STOP_UNIT; | 790 | pc->c[0] = GPCMD_START_STOP_UNIT; |
810 | pc->c[4] = start; | 791 | pc->c[4] = start; |
811 | } | 792 | } |
812 | 793 | ||
813 | static void idefloppy_create_test_unit_ready_cmd(idefloppy_pc_t *pc) | 794 | static void idefloppy_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) |
814 | { | 795 | { |
815 | idefloppy_init_pc(pc); | 796 | idefloppy_init_pc(pc); |
816 | pc->c[0] = GPCMD_TEST_UNIT_READY; | 797 | pc->c[0] = GPCMD_TEST_UNIT_READY; |
817 | } | 798 | } |
818 | 799 | ||
819 | static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, | 800 | static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, |
820 | idefloppy_pc_t *pc, struct request *rq, | 801 | struct ide_atapi_pc *pc, struct request *rq, |
821 | unsigned long sector) | 802 | unsigned long sector) |
822 | { | 803 | { |
823 | int block = sector / floppy->bs_factor; | 804 | int block = sector / floppy->bs_factor; |
@@ -832,41 +813,41 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, | |||
832 | put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); | 813 | put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); |
833 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); | 814 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); |
834 | 815 | ||
835 | pc->callback = &idefloppy_rw_callback; | 816 | pc->idefloppy_callback = &idefloppy_rw_callback; |
836 | pc->rq = rq; | 817 | pc->rq = rq; |
837 | pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; | 818 | pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; |
838 | if (rq->cmd_flags & REQ_RW) | 819 | if (rq->cmd_flags & REQ_RW) |
839 | pc->flags |= PC_FLAG_WRITING; | 820 | pc->flags |= PC_FLAG_WRITING; |
840 | pc->buffer = NULL; | 821 | pc->buf = NULL; |
841 | pc->request_transfer = pc->buffer_size = blocks * floppy->block_size; | 822 | pc->req_xfer = pc->buf_size = blocks * floppy->block_size; |
842 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; | 823 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; |
843 | } | 824 | } |
844 | 825 | ||
845 | static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, | 826 | static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, |
846 | idefloppy_pc_t *pc, struct request *rq) | 827 | struct ide_atapi_pc *pc, struct request *rq) |
847 | { | 828 | { |
848 | idefloppy_init_pc(pc); | 829 | idefloppy_init_pc(pc); |
849 | pc->callback = &idefloppy_rw_callback; | 830 | pc->idefloppy_callback = &idefloppy_rw_callback; |
850 | memcpy(pc->c, rq->cmd, sizeof(pc->c)); | 831 | memcpy(pc->c, rq->cmd, sizeof(pc->c)); |
851 | pc->rq = rq; | 832 | pc->rq = rq; |
852 | pc->b_count = rq->data_len; | 833 | pc->b_count = rq->data_len; |
853 | if (rq->data_len && rq_data_dir(rq) == WRITE) | 834 | if (rq->data_len && rq_data_dir(rq) == WRITE) |
854 | pc->flags |= PC_FLAG_WRITING; | 835 | pc->flags |= PC_FLAG_WRITING; |
855 | pc->buffer = rq->data; | 836 | pc->buf = rq->data; |
856 | if (rq->bio) | 837 | if (rq->bio) |
857 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; | 838 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; |
858 | /* | 839 | /* |
859 | * possibly problematic, doesn't look like ide-floppy correctly | 840 | * possibly problematic, doesn't look like ide-floppy correctly |
860 | * handled scattered requests if dma fails... | 841 | * handled scattered requests if dma fails... |
861 | */ | 842 | */ |
862 | pc->request_transfer = pc->buffer_size = rq->data_len; | 843 | pc->req_xfer = pc->buf_size = rq->data_len; |
863 | } | 844 | } |
864 | 845 | ||
865 | static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, | 846 | static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, |
866 | struct request *rq, sector_t block_s) | 847 | struct request *rq, sector_t block_s) |
867 | { | 848 | { |
868 | idefloppy_floppy_t *floppy = drive->driver_data; | 849 | idefloppy_floppy_t *floppy = drive->driver_data; |
869 | idefloppy_pc_t *pc; | 850 | struct ide_atapi_pc *pc; |
870 | unsigned long block = (unsigned long)block_s; | 851 | unsigned long block = (unsigned long)block_s; |
871 | 852 | ||
872 | debug_log("dev: %s, cmd_type: %x, errors: %d\n", | 853 | debug_log("dev: %s, cmd_type: %x, errors: %d\n", |
@@ -896,7 +877,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, | |||
896 | pc = idefloppy_next_pc_storage(drive); | 877 | pc = idefloppy_next_pc_storage(drive); |
897 | idefloppy_create_rw_cmd(floppy, pc, rq, block); | 878 | idefloppy_create_rw_cmd(floppy, pc, rq, block); |
898 | } else if (blk_special_request(rq)) { | 879 | } else if (blk_special_request(rq)) { |
899 | pc = (idefloppy_pc_t *) rq->buffer; | 880 | pc = (struct ide_atapi_pc *) rq->buffer; |
900 | } else if (blk_pc_request(rq)) { | 881 | } else if (blk_pc_request(rq)) { |
901 | pc = idefloppy_next_pc_storage(drive); | 882 | pc = idefloppy_next_pc_storage(drive); |
902 | idefloppy_blockpc_cmd(floppy, pc, rq); | 883 | idefloppy_blockpc_cmd(floppy, pc, rq); |
@@ -915,7 +896,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, | |||
915 | * Add a special packet command request to the tail of the request queue, | 896 | * Add a special packet command request to the tail of the request queue, |
916 | * and wait for it to be serviced. | 897 | * and wait for it to be serviced. |
917 | */ | 898 | */ |
918 | static int idefloppy_queue_pc_tail(ide_drive_t *drive, idefloppy_pc_t *pc) | 899 | static int idefloppy_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) |
919 | { | 900 | { |
920 | struct ide_floppy_obj *floppy = drive->driver_data; | 901 | struct ide_floppy_obj *floppy = drive->driver_data; |
921 | struct request rq; | 902 | struct request rq; |
@@ -935,7 +916,7 @@ static int idefloppy_queue_pc_tail(ide_drive_t *drive, idefloppy_pc_t *pc) | |||
935 | static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) | 916 | static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) |
936 | { | 917 | { |
937 | idefloppy_floppy_t *floppy = drive->driver_data; | 918 | idefloppy_floppy_t *floppy = drive->driver_data; |
938 | idefloppy_pc_t pc; | 919 | struct ide_atapi_pc pc; |
939 | u8 *page; | 920 | u8 *page; |
940 | int capacity, lba_capacity; | 921 | int capacity, lba_capacity; |
941 | u16 transfer_rate, sector_size, cyls, rpm; | 922 | u16 transfer_rate, sector_size, cyls, rpm; |
@@ -949,16 +930,16 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) | |||
949 | " parameters\n"); | 930 | " parameters\n"); |
950 | return 1; | 931 | return 1; |
951 | } | 932 | } |
952 | floppy->wp = !!(pc.buffer[3] & 0x80); | 933 | floppy->wp = !!(pc.buf[3] & 0x80); |
953 | set_disk_ro(floppy->disk, floppy->wp); | 934 | set_disk_ro(floppy->disk, floppy->wp); |
954 | page = &pc.buffer[8]; | 935 | page = &pc.buf[8]; |
955 | 936 | ||
956 | transfer_rate = be16_to_cpu(*(u16 *)&pc.buffer[8 + 2]); | 937 | transfer_rate = be16_to_cpu(*(u16 *)&pc.buf[8 + 2]); |
957 | sector_size = be16_to_cpu(*(u16 *)&pc.buffer[8 + 6]); | 938 | sector_size = be16_to_cpu(*(u16 *)&pc.buf[8 + 6]); |
958 | cyls = be16_to_cpu(*(u16 *)&pc.buffer[8 + 8]); | 939 | cyls = be16_to_cpu(*(u16 *)&pc.buf[8 + 8]); |
959 | rpm = be16_to_cpu(*(u16 *)&pc.buffer[8 + 28]); | 940 | rpm = be16_to_cpu(*(u16 *)&pc.buf[8 + 28]); |
960 | heads = pc.buffer[8 + 4]; | 941 | heads = pc.buf[8 + 4]; |
961 | sectors = pc.buffer[8 + 5]; | 942 | sectors = pc.buf[8 + 5]; |
962 | 943 | ||
963 | capacity = cyls * heads * sectors * sector_size; | 944 | capacity = cyls * heads * sectors * sector_size; |
964 | 945 | ||
@@ -987,7 +968,7 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) | |||
987 | static int idefloppy_get_sfrp_bit(ide_drive_t *drive) | 968 | static int idefloppy_get_sfrp_bit(ide_drive_t *drive) |
988 | { | 969 | { |
989 | idefloppy_floppy_t *floppy = drive->driver_data; | 970 | idefloppy_floppy_t *floppy = drive->driver_data; |
990 | idefloppy_pc_t pc; | 971 | struct ide_atapi_pc pc; |
991 | 972 | ||
992 | floppy->srfp = 0; | 973 | floppy->srfp = 0; |
993 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE, | 974 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE, |
@@ -997,7 +978,7 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive) | |||
997 | if (idefloppy_queue_pc_tail(drive, &pc)) | 978 | if (idefloppy_queue_pc_tail(drive, &pc)) |
998 | return 1; | 979 | return 1; |
999 | 980 | ||
1000 | floppy->srfp = pc.buffer[8 + 2] & 0x40; | 981 | floppy->srfp = pc.buf[8 + 2] & 0x40; |
1001 | return (0); | 982 | return (0); |
1002 | } | 983 | } |
1003 | 984 | ||
@@ -1008,7 +989,7 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive) | |||
1008 | static int ide_floppy_get_capacity(ide_drive_t *drive) | 989 | static int ide_floppy_get_capacity(ide_drive_t *drive) |
1009 | { | 990 | { |
1010 | idefloppy_floppy_t *floppy = drive->driver_data; | 991 | idefloppy_floppy_t *floppy = drive->driver_data; |
1011 | idefloppy_pc_t pc; | 992 | struct ide_atapi_pc pc; |
1012 | u8 *cap_desc; | 993 | u8 *cap_desc; |
1013 | u8 header_len, desc_cnt; | 994 | u8 header_len, desc_cnt; |
1014 | int i, rc = 1, blocks, length; | 995 | int i, rc = 1, blocks, length; |
@@ -1024,15 +1005,15 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
1024 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); | 1005 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); |
1025 | return 1; | 1006 | return 1; |
1026 | } | 1007 | } |
1027 | header_len = pc.buffer[3]; | 1008 | header_len = pc.buf[3]; |
1028 | cap_desc = &pc.buffer[4]; | 1009 | cap_desc = &pc.buf[4]; |
1029 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ | 1010 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ |
1030 | 1011 | ||
1031 | for (i = 0; i < desc_cnt; i++) { | 1012 | for (i = 0; i < desc_cnt; i++) { |
1032 | unsigned int desc_start = 4 + i*8; | 1013 | unsigned int desc_start = 4 + i*8; |
1033 | 1014 | ||
1034 | blocks = be32_to_cpu(*(u32 *)&pc.buffer[desc_start]); | 1015 | blocks = be32_to_cpu(*(u32 *)&pc.buf[desc_start]); |
1035 | length = be16_to_cpu(*(u16 *)&pc.buffer[desc_start + 6]); | 1016 | length = be16_to_cpu(*(u16 *)&pc.buf[desc_start + 6]); |
1036 | 1017 | ||
1037 | debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n", | 1018 | debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n", |
1038 | i, blocks * length / 1024, blocks, length); | 1019 | i, blocks * length / 1024, blocks, length); |
@@ -1043,7 +1024,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
1043 | * the code below is valid only for the 1st descriptor, ie i=0 | 1024 | * the code below is valid only for the 1st descriptor, ie i=0 |
1044 | */ | 1025 | */ |
1045 | 1026 | ||
1046 | switch (pc.buffer[desc_start + 4] & 0x03) { | 1027 | switch (pc.buf[desc_start + 4] & 0x03) { |
1047 | /* Clik! drive returns this instead of CAPACITY_CURRENT */ | 1028 | /* Clik! drive returns this instead of CAPACITY_CURRENT */ |
1048 | case CAPACITY_UNFORMATTED: | 1029 | case CAPACITY_UNFORMATTED: |
1049 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) | 1030 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) |
@@ -1088,7 +1069,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
1088 | break; | 1069 | break; |
1089 | } | 1070 | } |
1090 | debug_log("Descriptor 0 Code: %d\n", | 1071 | debug_log("Descriptor 0 Code: %d\n", |
1091 | pc.buffer[desc_start + 4] & 0x03); | 1072 | pc.buf[desc_start + 4] & 0x03); |
1092 | } | 1073 | } |
1093 | 1074 | ||
1094 | /* Clik! disk does not support get_flexible_disk_page */ | 1075 | /* Clik! disk does not support get_flexible_disk_page */ |
@@ -1120,7 +1101,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
1120 | 1101 | ||
1121 | static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | 1102 | static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) |
1122 | { | 1103 | { |
1123 | idefloppy_pc_t pc; | 1104 | struct ide_atapi_pc pc; |
1124 | u8 header_len, desc_cnt; | 1105 | u8 header_len, desc_cnt; |
1125 | int i, blocks, length, u_array_size, u_index; | 1106 | int i, blocks, length, u_array_size, u_index; |
1126 | int __user *argp; | 1107 | int __user *argp; |
@@ -1136,7 +1117,7 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | |||
1136 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); | 1117 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); |
1137 | return (-EIO); | 1118 | return (-EIO); |
1138 | } | 1119 | } |
1139 | header_len = pc.buffer[3]; | 1120 | header_len = pc.buf[3]; |
1140 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ | 1121 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ |
1141 | 1122 | ||
1142 | u_index = 0; | 1123 | u_index = 0; |
@@ -1153,8 +1134,8 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | |||
1153 | if (u_index >= u_array_size) | 1134 | if (u_index >= u_array_size) |
1154 | break; /* User-supplied buffer too small */ | 1135 | break; /* User-supplied buffer too small */ |
1155 | 1136 | ||
1156 | blocks = be32_to_cpu(*(u32 *)&pc.buffer[desc_start]); | 1137 | blocks = be32_to_cpu(*(u32 *)&pc.buf[desc_start]); |
1157 | length = be16_to_cpu(*(u16 *)&pc.buffer[desc_start + 6]); | 1138 | length = be16_to_cpu(*(u16 *)&pc.buf[desc_start + 6]); |
1158 | 1139 | ||
1159 | if (put_user(blocks, argp)) | 1140 | if (put_user(blocks, argp)) |
1160 | return(-EFAULT); | 1141 | return(-EFAULT); |
@@ -1185,7 +1166,7 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | |||
1185 | static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) | 1166 | static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) |
1186 | { | 1167 | { |
1187 | idefloppy_floppy_t *floppy = drive->driver_data; | 1168 | idefloppy_floppy_t *floppy = drive->driver_data; |
1188 | idefloppy_pc_t pc; | 1169 | struct ide_atapi_pc pc; |
1189 | int progress_indication = 0x10000; | 1170 | int progress_indication = 0x10000; |
1190 | 1171 | ||
1191 | if (floppy->srfp) { | 1172 | if (floppy->srfp) { |
@@ -1391,7 +1372,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
1391 | struct gendisk *disk = inode->i_bdev->bd_disk; | 1372 | struct gendisk *disk = inode->i_bdev->bd_disk; |
1392 | struct ide_floppy_obj *floppy; | 1373 | struct ide_floppy_obj *floppy; |
1393 | ide_drive_t *drive; | 1374 | ide_drive_t *drive; |
1394 | idefloppy_pc_t pc; | 1375 | struct ide_atapi_pc pc; |
1395 | int ret = 0; | 1376 | int ret = 0; |
1396 | 1377 | ||
1397 | debug_log("Reached %s\n", __func__); | 1378 | debug_log("Reached %s\n", __func__); |
@@ -1454,7 +1435,7 @@ static int idefloppy_release(struct inode *inode, struct file *filp) | |||
1454 | struct gendisk *disk = inode->i_bdev->bd_disk; | 1435 | struct gendisk *disk = inode->i_bdev->bd_disk; |
1455 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); | 1436 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); |
1456 | ide_drive_t *drive = floppy->drive; | 1437 | ide_drive_t *drive = floppy->drive; |
1457 | idefloppy_pc_t pc; | 1438 | struct ide_atapi_pc pc; |
1458 | 1439 | ||
1459 | debug_log("Reached %s\n", __func__); | 1440 | debug_log("Reached %s\n", __func__); |
1460 | 1441 | ||
@@ -1486,8 +1467,8 @@ static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo) | |||
1486 | return 0; | 1467 | return 0; |
1487 | } | 1468 | } |
1488 | 1469 | ||
1489 | static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, | 1470 | static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, |
1490 | unsigned long arg, unsigned int cmd) | 1471 | struct ide_atapi_pc *pc, unsigned long arg, unsigned int cmd) |
1491 | { | 1472 | { |
1492 | if (floppy->openers > 1) | 1473 | if (floppy->openers > 1) |
1493 | return -EBUSY; | 1474 | return -EBUSY; |
@@ -1516,7 +1497,7 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, | |||
1516 | int __user *arg) | 1497 | int __user *arg) |
1517 | { | 1498 | { |
1518 | int blocks, length, flags, err = 0; | 1499 | int blocks, length, flags, err = 0; |
1519 | idefloppy_pc_t pc; | 1500 | struct ide_atapi_pc pc; |
1520 | 1501 | ||
1521 | if (floppy->openers > 1) { | 1502 | if (floppy->openers > 1) { |
1522 | /* Don't format if someone is using the disk */ | 1503 | /* Don't format if someone is using the disk */ |
@@ -1567,7 +1548,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file, | |||
1567 | struct block_device *bdev = inode->i_bdev; | 1548 | struct block_device *bdev = inode->i_bdev; |
1568 | struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk); | 1549 | struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk); |
1569 | ide_drive_t *drive = floppy->drive; | 1550 | ide_drive_t *drive = floppy->drive; |
1570 | idefloppy_pc_t pc; | 1551 | struct ide_atapi_pc pc; |
1571 | void __user *argp = (void __user *)arg; | 1552 | void __user *argp = (void __user *)arg; |
1572 | int err; | 1553 | int err; |
1573 | 1554 | ||