aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-floppy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-floppy.c')
-rw-r--r--drivers/ide/ide-floppy.c346
1 files changed, 139 insertions, 207 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index faf22d716f80..5f133dfb541c 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -78,40 +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
81typedef 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. */
102enum {
103 /* 1 when we prefer to use DMA if possible */
104 PC_FLAG_DMA_RECOMMENDED = (1 << 0),
105 /* 1 while DMA in progress */
106 PC_FLAG_DMA_IN_PROGRESS = (1 << 1),
107 /* 1 when encountered problem during DMA */
108 PC_FLAG_DMA_ERROR = (1 << 2),
109 /* Data direction */
110 PC_FLAG_WRITING = (1 << 3),
111 /* Suppress error reporting */
112 PC_FLAG_SUPPRESS_ERROR = (1 << 4),
113};
114
115/* format capacities descriptor codes */ 81/* format capacities descriptor codes */
116#define CAPACITY_INVALID 0x00 82#define CAPACITY_INVALID 0x00
117#define CAPACITY_UNFORMATTED 0x01 83#define CAPACITY_UNFORMATTED 0x01
@@ -131,11 +97,11 @@ typedef struct ide_floppy_obj {
131 unsigned int openers; /* protected by BKL for now */ 97 unsigned int openers; /* protected by BKL for now */
132 98
133 /* Current packet command */ 99 /* Current packet command */
134 idefloppy_pc_t *pc; 100 struct ide_atapi_pc *pc;
135 /* Last failed packet command */ 101 /* Last failed packet command */
136 idefloppy_pc_t *failed_pc; 102 struct ide_atapi_pc *failed_pc;
137 /* Packet command stack */ 103 /* Packet command stack */
138 idefloppy_pc_t pc_stack[IDEFLOPPY_PC_STACK]; 104 struct ide_atapi_pc pc_stack[IDEFLOPPY_PC_STACK];
139 /* Next free packet command storage space */ 105 /* Next free packet command storage space */
140 int pc_stack_index; 106 int pc_stack_index;
141 struct request rq_stack[IDEFLOPPY_PC_STACK]; 107 struct request rq_stack[IDEFLOPPY_PC_STACK];
@@ -195,32 +161,6 @@ enum {
195#define IDEFLOPPY_ERROR_GENERAL 101 161#define IDEFLOPPY_ERROR_GENERAL 101
196 162
197/* 163/*
198 * The following is used to format the general configuration word of the
199 * ATAPI IDENTIFY DEVICE command.
200 */
201struct idefloppy_id_gcw {
202#if defined(__LITTLE_ENDIAN_BITFIELD)
203 unsigned packet_size :2; /* Packet Size */
204 unsigned reserved234 :3; /* Reserved */
205 unsigned drq_type :2; /* Command packet DRQ type */
206 unsigned removable :1; /* Removable media */
207 unsigned device_type :5; /* Device type */
208 unsigned reserved13 :1; /* Reserved */
209 unsigned protocol :2; /* Protocol type */
210#elif defined(__BIG_ENDIAN_BITFIELD)
211 unsigned protocol :2; /* Protocol type */
212 unsigned reserved13 :1; /* Reserved */
213 unsigned device_type :5; /* Device type */
214 unsigned removable :1; /* Removable media */
215 unsigned drq_type :2; /* Command packet DRQ type */
216 unsigned reserved234 :3; /* Reserved */
217 unsigned packet_size :2; /* Packet Size */
218#else
219#error "Bitfield endianness not defined! Check your byteorder.h"
220#endif
221};
222
223/*
224 * Pages of the SELECT SENSE / MODE SENSE packet commands. 164 * Pages of the SELECT SENSE / MODE SENSE packet commands.
225 * See SFF-8070i spec. 165 * See SFF-8070i spec.
226 */ 166 */
@@ -256,27 +196,10 @@ static void ide_floppy_put(struct ide_floppy_obj *floppy)
256} 196}
257 197
258/* 198/*
259 * Too bad. The drive wants to send us data which we are not ready to accept.
260 * Just throw it away.
261 */
262static void idefloppy_discard_data(ide_drive_t *drive, unsigned int bcount)
263{
264 while (bcount--)
265 (void) HWIF(drive)->INB(IDE_DATA_REG);
266}
267
268static void idefloppy_write_zeros(ide_drive_t *drive, unsigned int bcount)
269{
270 while (bcount--)
271 HWIF(drive)->OUTB(0, IDE_DATA_REG);
272}
273
274
275/*
276 * Used to finish servicing a request. For read/write requests, we will call 199 * Used to finish servicing a request. For read/write requests, we will call
277 * ide_end_request to pass to the next buffer. 200 * ide_end_request to pass to the next buffer.
278 */ 201 */
279static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) 202static int idefloppy_end_request(ide_drive_t *drive, int uptodate, int nsecs)
280{ 203{
281 idefloppy_floppy_t *floppy = drive->driver_data; 204 idefloppy_floppy_t *floppy = drive->driver_data;
282 struct request *rq = HWGROUP(drive)->rq; 205 struct request *rq = HWGROUP(drive)->rq;
@@ -305,7 +228,7 @@ static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs)
305 return 0; 228 return 0;
306} 229}
307 230
308static void ide_floppy_io_buffers(ide_drive_t *drive, idefloppy_pc_t *pc, 231static void ide_floppy_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
309 unsigned int bcount, int direction) 232 unsigned int bcount, int direction)
310{ 233{
311 struct request *rq = pc->rq; 234 struct request *rq = pc->rq;
@@ -333,26 +256,26 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, idefloppy_pc_t *pc,
333 done += count; 256 done += count;
334 } 257 }
335 258
336 idefloppy_do_end_request(drive, 1, done >> 9); 259 idefloppy_end_request(drive, 1, done >> 9);
337 260
338 if (bcount) { 261 if (bcount) {
339 printk(KERN_ERR "%s: leftover data in %s, bcount == %d\n", 262 printk(KERN_ERR "%s: leftover data in %s, bcount == %d\n",
340 drive->name, __func__, bcount); 263 drive->name, __func__, bcount);
341 if (direction) 264 if (direction)
342 idefloppy_write_zeros(drive, bcount); 265 ide_atapi_write_zeros(drive, bcount);
343 else 266 else
344 idefloppy_discard_data(drive, bcount); 267 ide_atapi_discard_data(drive, bcount);
345
346 } 268 }
347} 269}
348 270
349static void idefloppy_update_buffers(ide_drive_t *drive, idefloppy_pc_t *pc) 271static void idefloppy_update_buffers(ide_drive_t *drive,
272 struct ide_atapi_pc *pc)
350{ 273{
351 struct request *rq = pc->rq; 274 struct request *rq = pc->rq;
352 struct bio *bio = rq->bio; 275 struct bio *bio = rq->bio;
353 276
354 while ((bio = rq->bio) != NULL) 277 while ((bio = rq->bio) != NULL)
355 idefloppy_do_end_request(drive, 1, 0); 278 idefloppy_end_request(drive, 1, 0);
356} 279}
357 280
358/* 281/*
@@ -360,7 +283,7 @@ static void idefloppy_update_buffers(ide_drive_t *drive, idefloppy_pc_t *pc)
360 * the current request so that it will be processed immediately, on the next 283 * the current request so that it will be processed immediately, on the next
361 * pass through the driver. 284 * pass through the driver.
362 */ 285 */
363static void idefloppy_queue_pc_head(ide_drive_t *drive, idefloppy_pc_t *pc, 286static void idefloppy_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc,
364 struct request *rq) 287 struct request *rq)
365{ 288{
366 struct ide_floppy_obj *floppy = drive->driver_data; 289 struct ide_floppy_obj *floppy = drive->driver_data;
@@ -372,7 +295,7 @@ static void idefloppy_queue_pc_head(ide_drive_t *drive, idefloppy_pc_t *pc,
372 (void) ide_do_drive_cmd(drive, rq, ide_preempt); 295 (void) ide_do_drive_cmd(drive, rq, ide_preempt);
373} 296}
374 297
375static idefloppy_pc_t *idefloppy_next_pc_storage(ide_drive_t *drive) 298static struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive)
376{ 299{
377 idefloppy_floppy_t *floppy = drive->driver_data; 300 idefloppy_floppy_t *floppy = drive->driver_data;
378 301
@@ -393,7 +316,7 @@ static struct request *idefloppy_next_rq_storage(ide_drive_t *drive)
393static void idefloppy_request_sense_callback(ide_drive_t *drive) 316static void idefloppy_request_sense_callback(ide_drive_t *drive)
394{ 317{
395 idefloppy_floppy_t *floppy = drive->driver_data; 318 idefloppy_floppy_t *floppy = drive->driver_data;
396 u8 *buf = floppy->pc->buffer; 319 u8 *buf = floppy->pc->buf;
397 320
398 debug_log("Reached %s\n", __func__); 321 debug_log("Reached %s\n", __func__);
399 322
@@ -418,11 +341,11 @@ static void idefloppy_request_sense_callback(ide_drive_t *drive)
418 floppy->ascq); 341 floppy->ascq);
419 342
420 343
421 idefloppy_do_end_request(drive, 1, 0); 344 idefloppy_end_request(drive, 1, 0);
422 } else { 345 } else {
423 printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting" 346 printk(KERN_ERR "Error in REQUEST SENSE itself - Aborting"
424 " request!\n"); 347 " request!\n");
425 idefloppy_do_end_request(drive, 0, 0); 348 idefloppy_end_request(drive, 0, 0);
426 } 349 }
427} 350}
428 351
@@ -433,27 +356,27 @@ static void idefloppy_pc_callback(ide_drive_t *drive)
433 356
434 debug_log("Reached %s\n", __func__); 357 debug_log("Reached %s\n", __func__);
435 358
436 idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0); 359 idefloppy_end_request(drive, floppy->pc->error ? 0 : 1, 0);
437} 360}
438 361
439static void idefloppy_init_pc(idefloppy_pc_t *pc) 362static void idefloppy_init_pc(struct ide_atapi_pc *pc)
440{ 363{
441 memset(pc->c, 0, 12); 364 memset(pc->c, 0, 12);
442 pc->retries = 0; 365 pc->retries = 0;
443 pc->flags = 0; 366 pc->flags = 0;
444 pc->request_transfer = 0; 367 pc->req_xfer = 0;
445 pc->buffer = pc->pc_buffer; 368 pc->buf = pc->pc_buf;
446 pc->buffer_size = IDEFLOPPY_PC_BUFFER_SIZE; 369 pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE;
447 pc->callback = &idefloppy_pc_callback; 370 pc->idefloppy_callback = &idefloppy_pc_callback;
448} 371}
449 372
450static void idefloppy_create_request_sense_cmd(idefloppy_pc_t *pc) 373static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc)
451{ 374{
452 idefloppy_init_pc(pc); 375 idefloppy_init_pc(pc);
453 pc->c[0] = GPCMD_REQUEST_SENSE; 376 pc->c[0] = GPCMD_REQUEST_SENSE;
454 pc->c[4] = 255; 377 pc->c[4] = 255;
455 pc->request_transfer = 18; 378 pc->req_xfer = 18;
456 pc->callback = &idefloppy_request_sense_callback; 379 pc->idefloppy_callback = &idefloppy_request_sense_callback;
457} 380}
458 381
459/* 382/*
@@ -462,7 +385,7 @@ static void idefloppy_create_request_sense_cmd(idefloppy_pc_t *pc)
462 */ 385 */
463static void idefloppy_retry_pc(ide_drive_t *drive) 386static void idefloppy_retry_pc(ide_drive_t *drive)
464{ 387{
465 idefloppy_pc_t *pc; 388 struct ide_atapi_pc *pc;
466 struct request *rq; 389 struct request *rq;
467 390
468 (void)ide_read_error(drive); 391 (void)ide_read_error(drive);
@@ -477,7 +400,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
477{ 400{
478 idefloppy_floppy_t *floppy = drive->driver_data; 401 idefloppy_floppy_t *floppy = drive->driver_data;
479 ide_hwif_t *hwif = drive->hwif; 402 ide_hwif_t *hwif = drive->hwif;
480 idefloppy_pc_t *pc = floppy->pc; 403 struct ide_atapi_pc *pc = floppy->pc;
481 struct request *rq = pc->rq; 404 struct request *rq = pc->rq;
482 xfer_func_t *xferfunc; 405 xfer_func_t *xferfunc;
483 unsigned int temp; 406 unsigned int temp;
@@ -494,7 +417,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
494 rq_data_dir(rq) ? "write" : "read"); 417 rq_data_dir(rq) ? "write" : "read");
495 pc->flags |= PC_FLAG_DMA_ERROR; 418 pc->flags |= PC_FLAG_DMA_ERROR;
496 } else { 419 } else {
497 pc->actually_transferred = pc->request_transfer; 420 pc->xferred = pc->req_xfer;
498 idefloppy_update_buffers(drive, pc); 421 idefloppy_update_buffers(drive, pc);
499 } 422 }
500 debug_log("DMA finished\n"); 423 debug_log("DMA finished\n");
@@ -506,7 +429,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
506 /* No more interrupts */ 429 /* No more interrupts */
507 if ((stat & DRQ_STAT) == 0) { 430 if ((stat & DRQ_STAT) == 0) {
508 debug_log("Packet command completed, %d bytes transferred\n", 431 debug_log("Packet command completed, %d bytes transferred\n",
509 pc->actually_transferred); 432 pc->xferred);
510 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; 433 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
511 434
512 local_irq_enable_in_hardirq(); 435 local_irq_enable_in_hardirq();
@@ -529,7 +452,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
529 if (floppy->failed_pc == pc) 452 if (floppy->failed_pc == pc)
530 floppy->failed_pc = NULL; 453 floppy->failed_pc = NULL;
531 /* Command finished - Call the callback function */ 454 /* Command finished - Call the callback function */
532 pc->callback(drive); 455 pc->idefloppy_callback(drive);
533 return ide_stopped; 456 return ide_stopped;
534 } 457 }
535 458
@@ -542,10 +465,10 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
542 } 465 }
543 466
544 /* Get the number of bytes to transfer */ 467 /* Get the number of bytes to transfer */
545 bcount = (hwif->INB(IDE_BCOUNTH_REG) << 8) | 468 bcount = (hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]) << 8) |
546 hwif->INB(IDE_BCOUNTL_REG); 469 hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]);
547 /* on this interrupt */ 470 /* on this interrupt */
548 ireason = hwif->INB(IDE_IREASON_REG); 471 ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
549 472
550 if (ireason & CD) { 473 if (ireason & CD) {
551 printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__); 474 printk(KERN_ERR "ide-floppy: CoD != 0 in %s\n", __func__);
@@ -561,13 +484,13 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
561 } 484 }
562 if (!(pc->flags & PC_FLAG_WRITING)) { 485 if (!(pc->flags & PC_FLAG_WRITING)) {
563 /* Reading - Check that we have enough space */ 486 /* Reading - Check that we have enough space */
564 temp = pc->actually_transferred + bcount; 487 temp = pc->xferred + bcount;
565 if (temp > pc->request_transfer) { 488 if (temp > pc->req_xfer) {
566 if (temp > pc->buffer_size) { 489 if (temp > pc->buf_size) {
567 printk(KERN_ERR "ide-floppy: The floppy wants " 490 printk(KERN_ERR "ide-floppy: The floppy wants "
568 "to send us more data than expected " 491 "to send us more data than expected "
569 "- discarding data\n"); 492 "- discarding data\n");
570 idefloppy_discard_data(drive, bcount); 493 ide_atapi_discard_data(drive, bcount);
571 494
572 ide_set_handler(drive, 495 ide_set_handler(drive,
573 &idefloppy_pc_intr, 496 &idefloppy_pc_intr,
@@ -584,15 +507,15 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
584 else 507 else
585 xferfunc = hwif->atapi_input_bytes; 508 xferfunc = hwif->atapi_input_bytes;
586 509
587 if (pc->buffer) 510 if (pc->buf)
588 xferfunc(drive, pc->current_position, bcount); 511 xferfunc(drive, pc->cur_pos, bcount);
589 else 512 else
590 ide_floppy_io_buffers(drive, pc, bcount, 513 ide_floppy_io_buffers(drive, pc, bcount,
591 !!(pc->flags & PC_FLAG_WRITING)); 514 !!(pc->flags & PC_FLAG_WRITING));
592 515
593 /* Update the current position */ 516 /* Update the current position */
594 pc->actually_transferred += bcount; 517 pc->xferred += bcount;
595 pc->current_position += bcount; 518 pc->cur_pos += bcount;
596 519
597 /* And set the interrupt handler again */ 520 /* And set the interrupt handler again */
598 ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL); 521 ide_set_handler(drive, &idefloppy_pc_intr, IDEFLOPPY_WAIT_CMD, NULL);
@@ -606,6 +529,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive)
606 */ 529 */
607static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive) 530static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive)
608{ 531{
532 ide_hwif_t *hwif = drive->hwif;
609 ide_startstop_t startstop; 533 ide_startstop_t startstop;
610 idefloppy_floppy_t *floppy = drive->driver_data; 534 idefloppy_floppy_t *floppy = drive->driver_data;
611 u8 ireason; 535 u8 ireason;
@@ -615,7 +539,7 @@ static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive)
615 "initiated yet DRQ isn't asserted\n"); 539 "initiated yet DRQ isn't asserted\n");
616 return startstop; 540 return startstop;
617 } 541 }
618 ireason = drive->hwif->INB(IDE_IREASON_REG); 542 ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
619 if ((ireason & CD) == 0 || (ireason & IO)) { 543 if ((ireason & CD) == 0 || (ireason & IO)) {
620 printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while " 544 printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while "
621 "issuing a packet command\n"); 545 "issuing a packet command\n");
@@ -652,6 +576,7 @@ static int idefloppy_transfer_pc2(ide_drive_t *drive)
652 576
653static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) 577static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
654{ 578{
579 ide_hwif_t *hwif = drive->hwif;
655 idefloppy_floppy_t *floppy = drive->driver_data; 580 idefloppy_floppy_t *floppy = drive->driver_data;
656 ide_startstop_t startstop; 581 ide_startstop_t startstop;
657 u8 ireason; 582 u8 ireason;
@@ -661,7 +586,7 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
661 "initiated yet DRQ isn't asserted\n"); 586 "initiated yet DRQ isn't asserted\n");
662 return startstop; 587 return startstop;
663 } 588 }
664 ireason = drive->hwif->INB(IDE_IREASON_REG); 589 ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]);
665 if ((ireason & CD) == 0 || (ireason & IO)) { 590 if ((ireason & CD) == 0 || (ireason & IO)) {
666 printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) " 591 printk(KERN_ERR "ide-floppy: (IO,CoD) != (0,1) "
667 "while issuing a packet command\n"); 592 "while issuing a packet command\n");
@@ -682,7 +607,7 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)
682} 607}
683 608
684static void ide_floppy_report_error(idefloppy_floppy_t *floppy, 609static void ide_floppy_report_error(idefloppy_floppy_t *floppy,
685 idefloppy_pc_t *pc) 610 struct ide_atapi_pc *pc)
686{ 611{
687 /* supress error messages resulting from Medium not present */ 612 /* supress error messages resulting from Medium not present */
688 if (floppy->sense_key == 0x02 && 613 if (floppy->sense_key == 0x02 &&
@@ -698,7 +623,7 @@ static void ide_floppy_report_error(idefloppy_floppy_t *floppy,
698} 623}
699 624
700static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, 625static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
701 idefloppy_pc_t *pc) 626 struct ide_atapi_pc *pc)
702{ 627{
703 idefloppy_floppy_t *floppy = drive->driver_data; 628 idefloppy_floppy_t *floppy = drive->driver_data;
704 ide_hwif_t *hwif = drive->hwif; 629 ide_hwif_t *hwif = drive->hwif;
@@ -719,7 +644,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
719 pc->error = IDEFLOPPY_ERROR_GENERAL; 644 pc->error = IDEFLOPPY_ERROR_GENERAL;
720 645
721 floppy->failed_pc = NULL; 646 floppy->failed_pc = NULL;
722 pc->callback(drive); 647 pc->idefloppy_callback(drive);
723 return ide_stopped; 648 return ide_stopped;
724 } 649 }
725 650
@@ -727,9 +652,9 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
727 652
728 pc->retries++; 653 pc->retries++;
729 /* We haven't transferred any data yet */ 654 /* We haven't transferred any data yet */
730 pc->actually_transferred = 0; 655 pc->xferred = 0;
731 pc->current_position = pc->buffer; 656 pc->cur_pos = pc->buf;
732 bcount = min(pc->request_transfer, 63 * 1024); 657 bcount = min(pc->req_xfer, 63 * 1024);
733 658
734 if (pc->flags & PC_FLAG_DMA_ERROR) { 659 if (pc->flags & PC_FLAG_DMA_ERROR) {
735 pc->flags &= ~PC_FLAG_DMA_ERROR; 660 pc->flags &= ~PC_FLAG_DMA_ERROR;
@@ -757,7 +682,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
757 /* immediate */ 682 /* immediate */
758 pkt_xfer_routine = &idefloppy_transfer_pc; 683 pkt_xfer_routine = &idefloppy_transfer_pc;
759 } 684 }
760 685
761 if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) { 686 if (floppy->flags & IDEFLOPPY_FLAG_DRQ_INTERRUPT) {
762 /* Issue the packet command */ 687 /* Issue the packet command */
763 ide_execute_command(drive, WIN_PACKETCMD, 688 ide_execute_command(drive, WIN_PACKETCMD,
@@ -767,7 +692,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
767 return ide_started; 692 return ide_started;
768 } else { 693 } else {
769 /* Issue the packet command */ 694 /* Issue the packet command */
770 HWIF(drive)->OUTB(WIN_PACKETCMD, IDE_COMMAND_REG); 695 hwif->OUTB(WIN_PACKETCMD, hwif->io_ports[IDE_COMMAND_OFFSET]);
771 return (*pkt_xfer_routine) (drive); 696 return (*pkt_xfer_routine) (drive);
772 } 697 }
773} 698}
@@ -776,11 +701,11 @@ static void idefloppy_rw_callback(ide_drive_t *drive)
776{ 701{
777 debug_log("Reached %s\n", __func__); 702 debug_log("Reached %s\n", __func__);
778 703
779 idefloppy_do_end_request(drive, 1, 0); 704 idefloppy_end_request(drive, 1, 0);
780 return; 705 return;
781} 706}
782 707
783static void idefloppy_create_prevent_cmd(idefloppy_pc_t *pc, int prevent) 708static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent)
784{ 709{
785 debug_log("creating prevent removal command, prevent = %d\n", prevent); 710 debug_log("creating prevent removal command, prevent = %d\n", prevent);
786 711
@@ -789,39 +714,39 @@ static void idefloppy_create_prevent_cmd(idefloppy_pc_t *pc, int prevent)
789 pc->c[4] = prevent; 714 pc->c[4] = prevent;
790} 715}
791 716
792static void idefloppy_create_read_capacity_cmd(idefloppy_pc_t *pc) 717static void idefloppy_create_read_capacity_cmd(struct ide_atapi_pc *pc)
793{ 718{
794 idefloppy_init_pc(pc); 719 idefloppy_init_pc(pc);
795 pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES; 720 pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES;
796 pc->c[7] = 255; 721 pc->c[7] = 255;
797 pc->c[8] = 255; 722 pc->c[8] = 255;
798 pc->request_transfer = 255; 723 pc->req_xfer = 255;
799} 724}
800 725
801static void idefloppy_create_format_unit_cmd(idefloppy_pc_t *pc, int b, int l, 726static void idefloppy_create_format_unit_cmd(struct ide_atapi_pc *pc, int b,
802 int flags) 727 int l, int flags)
803{ 728{
804 idefloppy_init_pc(pc); 729 idefloppy_init_pc(pc);
805 pc->c[0] = GPCMD_FORMAT_UNIT; 730 pc->c[0] = GPCMD_FORMAT_UNIT;
806 pc->c[1] = 0x17; 731 pc->c[1] = 0x17;
807 732
808 memset(pc->buffer, 0, 12); 733 memset(pc->buf, 0, 12);
809 pc->buffer[1] = 0xA2; 734 pc->buf[1] = 0xA2;
810 /* Default format list header, u8 1: FOV/DCRT/IMM bits set */ 735 /* Default format list header, u8 1: FOV/DCRT/IMM bits set */
811 736
812 if (flags & 1) /* Verify bit on... */ 737 if (flags & 1) /* Verify bit on... */
813 pc->buffer[1] ^= 0x20; /* ... turn off DCRT bit */ 738 pc->buf[1] ^= 0x20; /* ... turn off DCRT bit */
814 pc->buffer[3] = 8; 739 pc->buf[3] = 8;
815 740
816 put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4])); 741 put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buf[4]));
817 put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8])); 742 put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buf[8]));
818 pc->buffer_size = 12; 743 pc->buf_size = 12;
819 pc->flags |= PC_FLAG_WRITING; 744 pc->flags |= PC_FLAG_WRITING;
820} 745}
821 746
822/* A mode sense command is used to "sense" floppy parameters. */ 747/* A mode sense command is used to "sense" floppy parameters. */
823static void idefloppy_create_mode_sense_cmd(idefloppy_pc_t *pc, u8 page_code, 748static void idefloppy_create_mode_sense_cmd(struct ide_atapi_pc *pc,
824 u8 type) 749 u8 page_code, u8 type)
825{ 750{
826 u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */ 751 u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */
827 752
@@ -842,24 +767,24 @@ static void idefloppy_create_mode_sense_cmd(idefloppy_pc_t *pc, u8 page_code,
842 "in create_mode_sense_cmd\n"); 767 "in create_mode_sense_cmd\n");
843 } 768 }
844 put_unaligned(cpu_to_be16(length), (u16 *) &pc->c[7]); 769 put_unaligned(cpu_to_be16(length), (u16 *) &pc->c[7]);
845 pc->request_transfer = length; 770 pc->req_xfer = length;
846} 771}
847 772
848static void idefloppy_create_start_stop_cmd(idefloppy_pc_t *pc, int start) 773static void idefloppy_create_start_stop_cmd(struct ide_atapi_pc *pc, int start)
849{ 774{
850 idefloppy_init_pc(pc); 775 idefloppy_init_pc(pc);
851 pc->c[0] = GPCMD_START_STOP_UNIT; 776 pc->c[0] = GPCMD_START_STOP_UNIT;
852 pc->c[4] = start; 777 pc->c[4] = start;
853} 778}
854 779
855static void idefloppy_create_test_unit_ready_cmd(idefloppy_pc_t *pc) 780static void idefloppy_create_test_unit_ready_cmd(struct ide_atapi_pc *pc)
856{ 781{
857 idefloppy_init_pc(pc); 782 idefloppy_init_pc(pc);
858 pc->c[0] = GPCMD_TEST_UNIT_READY; 783 pc->c[0] = GPCMD_TEST_UNIT_READY;
859} 784}
860 785
861static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, 786static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy,
862 idefloppy_pc_t *pc, struct request *rq, 787 struct ide_atapi_pc *pc, struct request *rq,
863 unsigned long sector) 788 unsigned long sector)
864{ 789{
865 int block = sector / floppy->bs_factor; 790 int block = sector / floppy->bs_factor;
@@ -874,41 +799,41 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy,
874 put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); 799 put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]);
875 put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); 800 put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]);
876 801
877 pc->callback = &idefloppy_rw_callback; 802 pc->idefloppy_callback = &idefloppy_rw_callback;
878 pc->rq = rq; 803 pc->rq = rq;
879 pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; 804 pc->b_count = cmd == READ ? 0 : rq->bio->bi_size;
880 if (rq->cmd_flags & REQ_RW) 805 if (rq->cmd_flags & REQ_RW)
881 pc->flags |= PC_FLAG_WRITING; 806 pc->flags |= PC_FLAG_WRITING;
882 pc->buffer = NULL; 807 pc->buf = NULL;
883 pc->request_transfer = pc->buffer_size = blocks * floppy->block_size; 808 pc->req_xfer = pc->buf_size = blocks * floppy->block_size;
884 pc->flags |= PC_FLAG_DMA_RECOMMENDED; 809 pc->flags |= PC_FLAG_DMA_RECOMMENDED;
885} 810}
886 811
887static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, 812static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy,
888 idefloppy_pc_t *pc, struct request *rq) 813 struct ide_atapi_pc *pc, struct request *rq)
889{ 814{
890 idefloppy_init_pc(pc); 815 idefloppy_init_pc(pc);
891 pc->callback = &idefloppy_rw_callback; 816 pc->idefloppy_callback = &idefloppy_rw_callback;
892 memcpy(pc->c, rq->cmd, sizeof(pc->c)); 817 memcpy(pc->c, rq->cmd, sizeof(pc->c));
893 pc->rq = rq; 818 pc->rq = rq;
894 pc->b_count = rq->data_len; 819 pc->b_count = rq->data_len;
895 if (rq->data_len && rq_data_dir(rq) == WRITE) 820 if (rq->data_len && rq_data_dir(rq) == WRITE)
896 pc->flags |= PC_FLAG_WRITING; 821 pc->flags |= PC_FLAG_WRITING;
897 pc->buffer = rq->data; 822 pc->buf = rq->data;
898 if (rq->bio) 823 if (rq->bio)
899 pc->flags |= PC_FLAG_DMA_RECOMMENDED; 824 pc->flags |= PC_FLAG_DMA_RECOMMENDED;
900 /* 825 /*
901 * possibly problematic, doesn't look like ide-floppy correctly 826 * possibly problematic, doesn't look like ide-floppy correctly
902 * handled scattered requests if dma fails... 827 * handled scattered requests if dma fails...
903 */ 828 */
904 pc->request_transfer = pc->buffer_size = rq->data_len; 829 pc->req_xfer = pc->buf_size = rq->data_len;
905} 830}
906 831
907static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, 832static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
908 struct request *rq, sector_t block_s) 833 struct request *rq, sector_t block_s)
909{ 834{
910 idefloppy_floppy_t *floppy = drive->driver_data; 835 idefloppy_floppy_t *floppy = drive->driver_data;
911 idefloppy_pc_t *pc; 836 struct ide_atapi_pc *pc;
912 unsigned long block = (unsigned long)block_s; 837 unsigned long block = (unsigned long)block_s;
913 838
914 debug_log("dev: %s, cmd_type: %x, errors: %d\n", 839 debug_log("dev: %s, cmd_type: %x, errors: %d\n",
@@ -924,7 +849,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
924 else 849 else
925 printk(KERN_ERR "ide-floppy: %s: I/O error\n", 850 printk(KERN_ERR "ide-floppy: %s: I/O error\n",
926 drive->name); 851 drive->name);
927 idefloppy_do_end_request(drive, 0, 0); 852 idefloppy_end_request(drive, 0, 0);
928 return ide_stopped; 853 return ide_stopped;
929 } 854 }
930 if (blk_fs_request(rq)) { 855 if (blk_fs_request(rq)) {
@@ -932,20 +857,20 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
932 (rq->nr_sectors % floppy->bs_factor)) { 857 (rq->nr_sectors % floppy->bs_factor)) {
933 printk(KERN_ERR "%s: unsupported r/w request size\n", 858 printk(KERN_ERR "%s: unsupported r/w request size\n",
934 drive->name); 859 drive->name);
935 idefloppy_do_end_request(drive, 0, 0); 860 idefloppy_end_request(drive, 0, 0);
936 return ide_stopped; 861 return ide_stopped;
937 } 862 }
938 pc = idefloppy_next_pc_storage(drive); 863 pc = idefloppy_next_pc_storage(drive);
939 idefloppy_create_rw_cmd(floppy, pc, rq, block); 864 idefloppy_create_rw_cmd(floppy, pc, rq, block);
940 } else if (blk_special_request(rq)) { 865 } else if (blk_special_request(rq)) {
941 pc = (idefloppy_pc_t *) rq->buffer; 866 pc = (struct ide_atapi_pc *) rq->buffer;
942 } else if (blk_pc_request(rq)) { 867 } else if (blk_pc_request(rq)) {
943 pc = idefloppy_next_pc_storage(drive); 868 pc = idefloppy_next_pc_storage(drive);
944 idefloppy_blockpc_cmd(floppy, pc, rq); 869 idefloppy_blockpc_cmd(floppy, pc, rq);
945 } else { 870 } else {
946 blk_dump_rq_flags(rq, 871 blk_dump_rq_flags(rq,
947 "ide-floppy: unsupported command in queue"); 872 "ide-floppy: unsupported command in queue");
948 idefloppy_do_end_request(drive, 0, 0); 873 idefloppy_end_request(drive, 0, 0);
949 return ide_stopped; 874 return ide_stopped;
950 } 875 }
951 876
@@ -957,7 +882,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
957 * Add a special packet command request to the tail of the request queue, 882 * Add a special packet command request to the tail of the request queue,
958 * and wait for it to be serviced. 883 * and wait for it to be serviced.
959 */ 884 */
960static int idefloppy_queue_pc_tail(ide_drive_t *drive, idefloppy_pc_t *pc) 885static int idefloppy_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc)
961{ 886{
962 struct ide_floppy_obj *floppy = drive->driver_data; 887 struct ide_floppy_obj *floppy = drive->driver_data;
963 struct request rq; 888 struct request rq;
@@ -977,7 +902,7 @@ static int idefloppy_queue_pc_tail(ide_drive_t *drive, idefloppy_pc_t *pc)
977static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) 902static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
978{ 903{
979 idefloppy_floppy_t *floppy = drive->driver_data; 904 idefloppy_floppy_t *floppy = drive->driver_data;
980 idefloppy_pc_t pc; 905 struct ide_atapi_pc pc;
981 u8 *page; 906 u8 *page;
982 int capacity, lba_capacity; 907 int capacity, lba_capacity;
983 u16 transfer_rate, sector_size, cyls, rpm; 908 u16 transfer_rate, sector_size, cyls, rpm;
@@ -991,16 +916,16 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
991 " parameters\n"); 916 " parameters\n");
992 return 1; 917 return 1;
993 } 918 }
994 floppy->wp = !!(pc.buffer[3] & 0x80); 919 floppy->wp = !!(pc.buf[3] & 0x80);
995 set_disk_ro(floppy->disk, floppy->wp); 920 set_disk_ro(floppy->disk, floppy->wp);
996 page = &pc.buffer[8]; 921 page = &pc.buf[8];
997 922
998 transfer_rate = be16_to_cpu(*(u16 *)&pc.buffer[8 + 2]); 923 transfer_rate = be16_to_cpu(*(u16 *)&pc.buf[8 + 2]);
999 sector_size = be16_to_cpu(*(u16 *)&pc.buffer[8 + 6]); 924 sector_size = be16_to_cpu(*(u16 *)&pc.buf[8 + 6]);
1000 cyls = be16_to_cpu(*(u16 *)&pc.buffer[8 + 8]); 925 cyls = be16_to_cpu(*(u16 *)&pc.buf[8 + 8]);
1001 rpm = be16_to_cpu(*(u16 *)&pc.buffer[8 + 28]); 926 rpm = be16_to_cpu(*(u16 *)&pc.buf[8 + 28]);
1002 heads = pc.buffer[8 + 4]; 927 heads = pc.buf[8 + 4];
1003 sectors = pc.buffer[8 + 5]; 928 sectors = pc.buf[8 + 5];
1004 929
1005 capacity = cyls * heads * sectors * sector_size; 930 capacity = cyls * heads * sectors * sector_size;
1006 931
@@ -1029,7 +954,7 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
1029static int idefloppy_get_sfrp_bit(ide_drive_t *drive) 954static int idefloppy_get_sfrp_bit(ide_drive_t *drive)
1030{ 955{
1031 idefloppy_floppy_t *floppy = drive->driver_data; 956 idefloppy_floppy_t *floppy = drive->driver_data;
1032 idefloppy_pc_t pc; 957 struct ide_atapi_pc pc;
1033 958
1034 floppy->srfp = 0; 959 floppy->srfp = 0;
1035 idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE, 960 idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE,
@@ -1039,7 +964,7 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive)
1039 if (idefloppy_queue_pc_tail(drive, &pc)) 964 if (idefloppy_queue_pc_tail(drive, &pc))
1040 return 1; 965 return 1;
1041 966
1042 floppy->srfp = pc.buffer[8 + 2] & 0x40; 967 floppy->srfp = pc.buf[8 + 2] & 0x40;
1043 return (0); 968 return (0);
1044} 969}
1045 970
@@ -1050,7 +975,7 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive)
1050static int ide_floppy_get_capacity(ide_drive_t *drive) 975static int ide_floppy_get_capacity(ide_drive_t *drive)
1051{ 976{
1052 idefloppy_floppy_t *floppy = drive->driver_data; 977 idefloppy_floppy_t *floppy = drive->driver_data;
1053 idefloppy_pc_t pc; 978 struct ide_atapi_pc pc;
1054 u8 *cap_desc; 979 u8 *cap_desc;
1055 u8 header_len, desc_cnt; 980 u8 header_len, desc_cnt;
1056 int i, rc = 1, blocks, length; 981 int i, rc = 1, blocks, length;
@@ -1066,15 +991,15 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
1066 printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); 991 printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n");
1067 return 1; 992 return 1;
1068 } 993 }
1069 header_len = pc.buffer[3]; 994 header_len = pc.buf[3];
1070 cap_desc = &pc.buffer[4]; 995 cap_desc = &pc.buf[4];
1071 desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ 996 desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */
1072 997
1073 for (i = 0; i < desc_cnt; i++) { 998 for (i = 0; i < desc_cnt; i++) {
1074 unsigned int desc_start = 4 + i*8; 999 unsigned int desc_start = 4 + i*8;
1075 1000
1076 blocks = be32_to_cpu(*(u32 *)&pc.buffer[desc_start]); 1001 blocks = be32_to_cpu(*(u32 *)&pc.buf[desc_start]);
1077 length = be16_to_cpu(*(u16 *)&pc.buffer[desc_start + 6]); 1002 length = be16_to_cpu(*(u16 *)&pc.buf[desc_start + 6]);
1078 1003
1079 debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n", 1004 debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n",
1080 i, blocks * length / 1024, blocks, length); 1005 i, blocks * length / 1024, blocks, length);
@@ -1085,7 +1010,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
1085 * the code below is valid only for the 1st descriptor, ie i=0 1010 * the code below is valid only for the 1st descriptor, ie i=0
1086 */ 1011 */
1087 1012
1088 switch (pc.buffer[desc_start + 4] & 0x03) { 1013 switch (pc.buf[desc_start + 4] & 0x03) {
1089 /* Clik! drive returns this instead of CAPACITY_CURRENT */ 1014 /* Clik! drive returns this instead of CAPACITY_CURRENT */
1090 case CAPACITY_UNFORMATTED: 1015 case CAPACITY_UNFORMATTED:
1091 if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) 1016 if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE))
@@ -1130,7 +1055,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
1130 break; 1055 break;
1131 } 1056 }
1132 debug_log("Descriptor 0 Code: %d\n", 1057 debug_log("Descriptor 0 Code: %d\n",
1133 pc.buffer[desc_start + 4] & 0x03); 1058 pc.buf[desc_start + 4] & 0x03);
1134 } 1059 }
1135 1060
1136 /* Clik! disk does not support get_flexible_disk_page */ 1061 /* Clik! disk does not support get_flexible_disk_page */
@@ -1162,7 +1087,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
1162 1087
1163static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) 1088static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
1164{ 1089{
1165 idefloppy_pc_t pc; 1090 struct ide_atapi_pc pc;
1166 u8 header_len, desc_cnt; 1091 u8 header_len, desc_cnt;
1167 int i, blocks, length, u_array_size, u_index; 1092 int i, blocks, length, u_array_size, u_index;
1168 int __user *argp; 1093 int __user *argp;
@@ -1178,7 +1103,7 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
1178 printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); 1103 printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n");
1179 return (-EIO); 1104 return (-EIO);
1180 } 1105 }
1181 header_len = pc.buffer[3]; 1106 header_len = pc.buf[3];
1182 desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ 1107 desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */
1183 1108
1184 u_index = 0; 1109 u_index = 0;
@@ -1195,8 +1120,8 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
1195 if (u_index >= u_array_size) 1120 if (u_index >= u_array_size)
1196 break; /* User-supplied buffer too small */ 1121 break; /* User-supplied buffer too small */
1197 1122
1198 blocks = be32_to_cpu(*(u32 *)&pc.buffer[desc_start]); 1123 blocks = be32_to_cpu(*(u32 *)&pc.buf[desc_start]);
1199 length = be16_to_cpu(*(u16 *)&pc.buffer[desc_start + 6]); 1124 length = be16_to_cpu(*(u16 *)&pc.buf[desc_start + 6]);
1200 1125
1201 if (put_user(blocks, argp)) 1126 if (put_user(blocks, argp))
1202 return(-EFAULT); 1127 return(-EFAULT);
@@ -1227,7 +1152,7 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
1227static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) 1152static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg)
1228{ 1153{
1229 idefloppy_floppy_t *floppy = drive->driver_data; 1154 idefloppy_floppy_t *floppy = drive->driver_data;
1230 idefloppy_pc_t pc; 1155 struct ide_atapi_pc pc;
1231 int progress_indication = 0x10000; 1156 int progress_indication = 0x10000;
1232 1157
1233 if (floppy->srfp) { 1158 if (floppy->srfp) {
@@ -1271,33 +1196,39 @@ static sector_t idefloppy_capacity(ide_drive_t *drive)
1271 */ 1196 */
1272static int idefloppy_identify_device(ide_drive_t *drive, struct hd_driveid *id) 1197static int idefloppy_identify_device(ide_drive_t *drive, struct hd_driveid *id)
1273{ 1198{
1274 struct idefloppy_id_gcw gcw; 1199 u8 gcw[2];
1200 u8 device_type, protocol, removable, drq_type, packet_size;
1275 1201
1276 *((u16 *) &gcw) = id->config; 1202 *((u16 *) &gcw) = id->config;
1277 1203
1204 device_type = gcw[1] & 0x1F;
1205 removable = (gcw[0] & 0x80) >> 7;
1206 protocol = (gcw[1] & 0xC0) >> 6;
1207 drq_type = (gcw[0] & 0x60) >> 5;
1208 packet_size = gcw[0] & 0x03;
1209
1278#ifdef CONFIG_PPC 1210#ifdef CONFIG_PPC
1279 /* kludge for Apple PowerBook internal zip */ 1211 /* kludge for Apple PowerBook internal zip */
1280 if ((gcw.device_type == 5) && 1212 if (device_type == 5 &&
1281 !strstr(id->model, "CD-ROM") && 1213 !strstr(id->model, "CD-ROM") && strstr(id->model, "ZIP"))
1282 strstr(id->model, "ZIP")) 1214 device_type = 0;
1283 gcw.device_type = 0;
1284#endif 1215#endif
1285 1216
1286 if (gcw.protocol != 2) 1217 if (protocol != 2)
1287 printk(KERN_ERR "ide-floppy: Protocol (0x%02x) is not ATAPI\n", 1218 printk(KERN_ERR "ide-floppy: Protocol (0x%02x) is not ATAPI\n",
1288 gcw.protocol); 1219 protocol);
1289 else if (gcw.device_type != 0) 1220 else if (device_type != 0)
1290 printk(KERN_ERR "ide-floppy: Device type (0x%02x) is not set " 1221 printk(KERN_ERR "ide-floppy: Device type (0x%02x) is not set "
1291 "to floppy\n", gcw.device_type); 1222 "to floppy\n", device_type);
1292 else if (!gcw.removable) 1223 else if (!removable)
1293 printk(KERN_ERR "ide-floppy: The removable flag is not set\n"); 1224 printk(KERN_ERR "ide-floppy: The removable flag is not set\n");
1294 else if (gcw.drq_type == 3) { 1225 else if (drq_type == 3)
1295 printk(KERN_ERR "ide-floppy: Sorry, DRQ type (0x%02x) not " 1226 printk(KERN_ERR "ide-floppy: Sorry, DRQ type (0x%02x) not "
1296 "supported\n", gcw.drq_type); 1227 "supported\n", drq_type);
1297 } else if (gcw.packet_size != 0) { 1228 else if (packet_size != 0)
1298 printk(KERN_ERR "ide-floppy: Packet size (0x%02x) is not 12 " 1229 printk(KERN_ERR "ide-floppy: Packet size (0x%02x) is not 12 "
1299 "bytes long\n", gcw.packet_size); 1230 "bytes\n", packet_size);
1300 } else 1231 else
1301 return 1; 1232 return 1;
1302 return 0; 1233 return 0;
1303} 1234}
@@ -1322,11 +1253,12 @@ static inline void idefloppy_add_settings(ide_drive_t *drive) { ; }
1322 1253
1323static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy) 1254static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
1324{ 1255{
1325 struct idefloppy_id_gcw gcw; 1256 u8 gcw[2];
1326 1257
1327 *((u16 *) &gcw) = drive->id->config; 1258 *((u16 *) &gcw) = drive->id->config;
1328 floppy->pc = floppy->pc_stack; 1259 floppy->pc = floppy->pc_stack;
1329 if (gcw.drq_type == 1) 1260
1261 if (((gcw[0] & 0x60) >> 5) == 1)
1330 floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT; 1262 floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT;
1331 /* 1263 /*
1332 * We used to check revisions here. At this point however I'm giving up. 1264 * We used to check revisions here. At this point however I'm giving up.
@@ -1413,7 +1345,7 @@ static ide_driver_t idefloppy_driver = {
1413 .media = ide_floppy, 1345 .media = ide_floppy,
1414 .supports_dsc_overlap = 0, 1346 .supports_dsc_overlap = 0,
1415 .do_request = idefloppy_do_request, 1347 .do_request = idefloppy_do_request,
1416 .end_request = idefloppy_do_end_request, 1348 .end_request = idefloppy_end_request,
1417 .error = __ide_error, 1349 .error = __ide_error,
1418 .abort = __ide_abort, 1350 .abort = __ide_abort,
1419#ifdef CONFIG_IDE_PROC_FS 1351#ifdef CONFIG_IDE_PROC_FS
@@ -1426,7 +1358,7 @@ static int idefloppy_open(struct inode *inode, struct file *filp)
1426 struct gendisk *disk = inode->i_bdev->bd_disk; 1358 struct gendisk *disk = inode->i_bdev->bd_disk;
1427 struct ide_floppy_obj *floppy; 1359 struct ide_floppy_obj *floppy;
1428 ide_drive_t *drive; 1360 ide_drive_t *drive;
1429 idefloppy_pc_t pc; 1361 struct ide_atapi_pc pc;
1430 int ret = 0; 1362 int ret = 0;
1431 1363
1432 debug_log("Reached %s\n", __func__); 1364 debug_log("Reached %s\n", __func__);
@@ -1489,7 +1421,7 @@ static int idefloppy_release(struct inode *inode, struct file *filp)
1489 struct gendisk *disk = inode->i_bdev->bd_disk; 1421 struct gendisk *disk = inode->i_bdev->bd_disk;
1490 struct ide_floppy_obj *floppy = ide_floppy_g(disk); 1422 struct ide_floppy_obj *floppy = ide_floppy_g(disk);
1491 ide_drive_t *drive = floppy->drive; 1423 ide_drive_t *drive = floppy->drive;
1492 idefloppy_pc_t pc; 1424 struct ide_atapi_pc pc;
1493 1425
1494 debug_log("Reached %s\n", __func__); 1426 debug_log("Reached %s\n", __func__);
1495 1427
@@ -1521,8 +1453,8 @@ static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1521 return 0; 1453 return 0;
1522} 1454}
1523 1455
1524static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, 1456static int ide_floppy_lockdoor(idefloppy_floppy_t *floppy,
1525 unsigned long arg, unsigned int cmd) 1457 struct ide_atapi_pc *pc, unsigned long arg, unsigned int cmd)
1526{ 1458{
1527 if (floppy->openers > 1) 1459 if (floppy->openers > 1)
1528 return -EBUSY; 1460 return -EBUSY;
@@ -1551,7 +1483,7 @@ static int ide_floppy_format_unit(idefloppy_floppy_t *floppy,
1551 int __user *arg) 1483 int __user *arg)
1552{ 1484{
1553 int blocks, length, flags, err = 0; 1485 int blocks, length, flags, err = 0;
1554 idefloppy_pc_t pc; 1486 struct ide_atapi_pc pc;
1555 1487
1556 if (floppy->openers > 1) { 1488 if (floppy->openers > 1) {
1557 /* Don't format if someone is using the disk */ 1489 /* Don't format if someone is using the disk */
@@ -1602,7 +1534,7 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file,
1602 struct block_device *bdev = inode->i_bdev; 1534 struct block_device *bdev = inode->i_bdev;
1603 struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk); 1535 struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk);
1604 ide_drive_t *drive = floppy->drive; 1536 ide_drive_t *drive = floppy->drive;
1605 idefloppy_pc_t pc; 1537 struct ide_atapi_pc pc;
1606 void __user *argp = (void __user *)arg; 1538 void __user *argp = (void __user *)arg;
1607 int err; 1539 int err;
1608 1540