diff options
author | Borislav Petkov <bbpetkov@yahoo.de> | 2008-02-02 13:56:38 -0500 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-02-02 13:56:38 -0500 |
commit | 0571c7a4f58fc6070fb9d556e4896de864c2a593 (patch) | |
tree | 46fd538dbed793663fe12570fc174650b48bc32d /drivers/ide/ide-floppy.c | |
parent | 6e5fa7b88c376b9d33228888f2ccd71fc79b2a17 (diff) |
ide-floppy: fix most of the remaining checkpatch.pl issues
such as
ERROR: switch and case should be at the same indent
ERROR: need spaces around that '=' (ctx:VxV)
ERROR: trailing statements should be on next line
WARNING: no space between function name and open parenthesis '('
WARNING: printk() should include KERN_ facility level
ERROR: That open brace { should be on the previous line
ERROR: use tabs not spaces
ERROR: do not use assignment in if condition
WARNING: braces {} are not necessary for single statement blocks
ERROR: need space after that ',' (ctx:VxV)
WARNING: line over 80 characters
ERROR: do not use assignment in if condition
...
and so on.
Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-floppy.c')
-rw-r--r-- | drivers/ide/ide-floppy.c | 355 |
1 files changed, 160 insertions, 195 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index ac66622a3570..864ccd1caba4 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -4,9 +4,7 @@ | |||
4 | * Copyright (C) 1996-1999 Gadi Oxman <gadio@netvision.net.il> | 4 | * Copyright (C) 1996-1999 Gadi Oxman <gadio@netvision.net.il> |
5 | * Copyright (C) 2000-2002 Paul Bristow <paul@paulbristow.net> | 5 | * Copyright (C) 2000-2002 Paul Bristow <paul@paulbristow.net> |
6 | * Copyright (C) 2005 Bartlomiej Zolnierkiewicz | 6 | * Copyright (C) 2005 Bartlomiej Zolnierkiewicz |
7 | */ | 7 | * |
8 | |||
9 | /* | ||
10 | * The driver currently doesn't have any fancy features, just the bare | 8 | * The driver currently doesn't have any fancy features, just the bare |
11 | * minimum read/write support. | 9 | * minimum read/write support. |
12 | * | 10 | * |
@@ -51,57 +49,56 @@ | |||
51 | #define IDEFLOPPY_DEBUG_LOG 0 | 49 | #define IDEFLOPPY_DEBUG_LOG 0 |
52 | 50 | ||
53 | /* #define IDEFLOPPY_DEBUG(fmt, args...) printk(KERN_INFO fmt, ## args) */ | 51 | /* #define IDEFLOPPY_DEBUG(fmt, args...) printk(KERN_INFO fmt, ## args) */ |
54 | #define IDEFLOPPY_DEBUG( fmt, args... ) | 52 | #define IDEFLOPPY_DEBUG(fmt, args...) |
55 | 53 | ||
56 | #if IDEFLOPPY_DEBUG_LOG | 54 | #if IDEFLOPPY_DEBUG_LOG |
57 | #define debug_log(fmt, args...) \ | 55 | #define debug_log(fmt, args...) \ |
58 | printk(KERN_INFO "ide-floppy: " fmt, ## args) | 56 | printk(KERN_INFO "ide-floppy: " fmt, ## args) |
59 | #else | 57 | #else |
60 | #define debug_log(fmt, args... ) do {} while(0) | 58 | #define debug_log(fmt, args...) do {} while (0) |
61 | #endif | 59 | #endif |
62 | 60 | ||
63 | 61 | ||
64 | /* | 62 | /* Some drives require a longer irq timeout. */ |
65 | * Some drives require a longer irq timeout. | ||
66 | */ | ||
67 | #define IDEFLOPPY_WAIT_CMD (5 * WAIT_CMD) | 63 | #define IDEFLOPPY_WAIT_CMD (5 * WAIT_CMD) |
68 | 64 | ||
69 | /* | 65 | /* |
70 | * After each failed packet command we issue a request sense command | 66 | * After each failed packet command we issue a request sense command and retry |
71 | * and retry the packet command IDEFLOPPY_MAX_PC_RETRIES times. | 67 | * the packet command IDEFLOPPY_MAX_PC_RETRIES times. |
72 | */ | 68 | */ |
73 | #define IDEFLOPPY_MAX_PC_RETRIES 3 | 69 | #define IDEFLOPPY_MAX_PC_RETRIES 3 |
74 | 70 | ||
75 | /* | 71 | /* |
76 | * With each packet command, we allocate a buffer of | 72 | * With each packet command, we allocate a buffer of IDEFLOPPY_PC_BUFFER_SIZE |
77 | * IDEFLOPPY_PC_BUFFER_SIZE bytes. | 73 | * bytes. |
78 | */ | 74 | */ |
79 | #define IDEFLOPPY_PC_BUFFER_SIZE 256 | 75 | #define IDEFLOPPY_PC_BUFFER_SIZE 256 |
80 | 76 | ||
81 | /* | 77 | /* |
82 | * In various places in the driver, we need to allocate storage | 78 | * In various places in the driver, we need to allocate storage for packet |
83 | * for packet commands and requests, which will remain valid while | 79 | * commands and requests, which will remain valid while we leave the driver to |
84 | * we leave the driver to wait for an interrupt or a timeout event. | 80 | * wait for an interrupt or a timeout event. |
85 | */ | 81 | */ |
86 | #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES) | 82 | #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES) |
87 | 83 | ||
88 | /* | ||
89 | * Our view of a packet command. | ||
90 | */ | ||
91 | typedef struct idefloppy_packet_command_s { | 84 | typedef struct idefloppy_packet_command_s { |
92 | u8 c[12]; /* Actual packet bytes */ | 85 | u8 c[12]; /* Actual packet bytes */ |
93 | int retries; /* On each retry, we increment retries */ | 86 | int retries; /* On each retry, we increment |
87 | retries */ | ||
94 | int error; /* Error code */ | 88 | int error; /* Error code */ |
95 | int request_transfer; /* Bytes to transfer */ | 89 | int request_transfer; /* Bytes to transfer */ |
96 | int actually_transferred; /* Bytes actually transferred */ | 90 | int actually_transferred; /* Bytes actually transferred */ |
97 | int buffer_size; /* Size of our data buffer */ | 91 | int buffer_size; /* Size of our data buffer */ |
98 | int b_count; /* Missing/Available data on the current buffer */ | 92 | int b_count; /* Missing/Available data on |
93 | the current buffer */ | ||
99 | struct request *rq; /* The corresponding request */ | 94 | struct request *rq; /* The corresponding request */ |
100 | u8 *buffer; /* Data buffer */ | 95 | u8 *buffer; /* Data buffer */ |
101 | u8 *current_position; /* Pointer into the above buffer */ | 96 | u8 *current_position; /* Pointer into above buffer */ |
102 | void (*callback) (ide_drive_t *); /* Called when this packet command is completed */ | 97 | void (*callback) (ide_drive_t *); /* Called when this packet |
98 | command is completed */ | ||
103 | u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE]; /* Temporary buffer */ | 99 | u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE]; /* Temporary buffer */ |
104 | unsigned long flags; /* Status/Action bit flags: long for set_bit */ | 100 | unsigned long flags; /* Status/Action bit flags: long |
101 | for set_bit */ | ||
105 | } idefloppy_pc_t; | 102 | } idefloppy_pc_t; |
106 | 103 | ||
107 | /* Packet command flag bits. */ | 104 | /* Packet command flag bits. */ |
@@ -125,9 +122,9 @@ enum { | |||
125 | #define CAPACITY_NO_CARTRIDGE 0x03 | 122 | #define CAPACITY_NO_CARTRIDGE 0x03 |
126 | 123 | ||
127 | /* | 124 | /* |
128 | * Most of our global data which we need to save even as we leave the | 125 | * Most of our global data which we need to save even as we leave the driver |
129 | * driver due to an interrupt or a timer event is stored in a variable | 126 | * due to an interrupt or a timer event is stored in a variable of type |
130 | * of type idefloppy_floppy_t, defined below. | 127 | * idefloppy_floppy_t, defined below. |
131 | */ | 128 | */ |
132 | typedef struct ide_floppy_obj { | 129 | typedef struct ide_floppy_obj { |
133 | ide_drive_t *drive; | 130 | ide_drive_t *drive; |
@@ -148,17 +145,13 @@ typedef struct ide_floppy_obj { | |||
148 | /* We implement a circular array */ | 145 | /* We implement a circular array */ |
149 | int rq_stack_index; | 146 | int rq_stack_index; |
150 | 147 | ||
151 | /* | 148 | /* Last error information */ |
152 | * Last error information | ||
153 | */ | ||
154 | u8 sense_key, asc, ascq; | 149 | u8 sense_key, asc, ascq; |
155 | /* delay this long before sending packet command */ | 150 | /* delay this long before sending packet command */ |
156 | u8 ticks; | 151 | u8 ticks; |
157 | int progress_indication; | 152 | int progress_indication; |
158 | 153 | ||
159 | /* | 154 | /* Device information */ |
160 | * Device information | ||
161 | */ | ||
162 | /* Current format */ | 155 | /* Current format */ |
163 | int blocks, block_size, bs_factor; | 156 | int blocks, block_size, bs_factor; |
164 | /* Last format capacity descriptor */ | 157 | /* Last format capacity descriptor */ |
@@ -189,34 +182,26 @@ enum { | |||
189 | IDEFLOPPY_FLAG_ZIP_DRIVE = (1 << 4), | 182 | IDEFLOPPY_FLAG_ZIP_DRIVE = (1 << 4), |
190 | }; | 183 | }; |
191 | 184 | ||
192 | /* | 185 | /* Defines for the MODE SENSE command */ |
193 | * Defines for the mode sense command | ||
194 | */ | ||
195 | #define MODE_SENSE_CURRENT 0x00 | 186 | #define MODE_SENSE_CURRENT 0x00 |
196 | #define MODE_SENSE_CHANGEABLE 0x01 | 187 | #define MODE_SENSE_CHANGEABLE 0x01 |
197 | #define MODE_SENSE_DEFAULT 0x02 | 188 | #define MODE_SENSE_DEFAULT 0x02 |
198 | #define MODE_SENSE_SAVED 0x03 | 189 | #define MODE_SENSE_SAVED 0x03 |
199 | 190 | ||
200 | /* | 191 | /* IOCTLs used in low-level formatting. */ |
201 | * IOCTLs used in low-level formatting. | ||
202 | */ | ||
203 | |||
204 | #define IDEFLOPPY_IOCTL_FORMAT_SUPPORTED 0x4600 | 192 | #define IDEFLOPPY_IOCTL_FORMAT_SUPPORTED 0x4600 |
205 | #define IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY 0x4601 | 193 | #define IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY 0x4601 |
206 | #define IDEFLOPPY_IOCTL_FORMAT_START 0x4602 | 194 | #define IDEFLOPPY_IOCTL_FORMAT_START 0x4602 |
207 | #define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 | 195 | #define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 |
208 | 196 | ||
209 | /* | 197 | /* Error code returned in rq->errors to the higher part of the driver. */ |
210 | * Error codes which are returned in rq->errors to the higher part | ||
211 | * of the driver. | ||
212 | */ | ||
213 | #define IDEFLOPPY_ERROR_GENERAL 101 | 198 | #define IDEFLOPPY_ERROR_GENERAL 101 |
214 | 199 | ||
215 | /* | 200 | /* |
216 | * The following is used to format the general configuration word of | 201 | * The following is used to format the general configuration word of the |
217 | * the ATAPI IDENTIFY DEVICE command. | 202 | * ATAPI IDENTIFY DEVICE command. |
218 | */ | 203 | */ |
219 | struct idefloppy_id_gcw { | 204 | struct idefloppy_id_gcw { |
220 | #if defined(__LITTLE_ENDIAN_BITFIELD) | 205 | #if defined(__LITTLE_ENDIAN_BITFIELD) |
221 | unsigned packet_size :2; /* Packet Size */ | 206 | unsigned packet_size :2; /* Packet Size */ |
222 | unsigned reserved234 :3; /* Reserved */ | 207 | unsigned reserved234 :3; /* Reserved */ |
@@ -274,10 +259,10 @@ static void ide_floppy_put(struct ide_floppy_obj *floppy) | |||
274 | } | 259 | } |
275 | 260 | ||
276 | /* | 261 | /* |
277 | * Too bad. The drive wants to send us data which we are not ready to accept. | 262 | * Too bad. The drive wants to send us data which we are not ready to accept. |
278 | * Just throw it away. | 263 | * Just throw it away. |
279 | */ | 264 | */ |
280 | static void idefloppy_discard_data (ide_drive_t *drive, unsigned int bcount) | 265 | static void idefloppy_discard_data(ide_drive_t *drive, unsigned int bcount) |
281 | { | 266 | { |
282 | while (bcount--) | 267 | while (bcount--) |
283 | (void) HWIF(drive)->INB(IDE_DATA_REG); | 268 | (void) HWIF(drive)->INB(IDE_DATA_REG); |
@@ -291,10 +276,8 @@ static void idefloppy_write_zeros(ide_drive_t *drive, unsigned int bcount) | |||
291 | 276 | ||
292 | 277 | ||
293 | /* | 278 | /* |
294 | * idefloppy_do_end_request is used to finish servicing a request. | 279 | * Used to finish servicing a request. For read/write requests, we will call |
295 | * | 280 | * ide_end_request to pass to the next buffer. |
296 | * For read/write requests, we will call ide_end_request to pass to the | ||
297 | * next buffer. | ||
298 | */ | 281 | */ |
299 | static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) | 282 | static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) |
300 | { | 283 | { |
@@ -305,9 +288,9 @@ static int idefloppy_do_end_request(ide_drive_t *drive, int uptodate, int nsecs) | |||
305 | debug_log("Reached %s\n", __func__); | 288 | debug_log("Reached %s\n", __func__); |
306 | 289 | ||
307 | switch (uptodate) { | 290 | switch (uptodate) { |
308 | case 0: error = IDEFLOPPY_ERROR_GENERAL; break; | 291 | case 0: error = IDEFLOPPY_ERROR_GENERAL; break; |
309 | case 1: error = 0; break; | 292 | case 1: error = 0; break; |
310 | default: error = uptodate; | 293 | default: error = uptodate; |
311 | } | 294 | } |
312 | if (error) | 295 | if (error) |
313 | floppy->failed_pc = NULL; | 296 | floppy->failed_pc = NULL; |
@@ -366,7 +349,7 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, idefloppy_pc_t *pc, | |||
366 | } | 349 | } |
367 | } | 350 | } |
368 | 351 | ||
369 | static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc) | 352 | static void idefloppy_update_buffers(ide_drive_t *drive, idefloppy_pc_t *pc) |
370 | { | 353 | { |
371 | struct request *rq = pc->rq; | 354 | struct request *rq = pc->rq; |
372 | struct bio *bio = rq->bio; | 355 | struct bio *bio = rq->bio; |
@@ -376,11 +359,12 @@ static void idefloppy_update_buffers (ide_drive_t *drive, idefloppy_pc_t *pc) | |||
376 | } | 359 | } |
377 | 360 | ||
378 | /* | 361 | /* |
379 | * idefloppy_queue_pc_head generates a new packet command request in front | 362 | * Generate a new packet command request in front of the request queue, before |
380 | * of the request queue, before the current request, so that it will be | 363 | * the current request so that it will be processed immediately, on the next |
381 | * processed immediately, on the next pass through the driver. | 364 | * pass through the driver. |
382 | */ | 365 | */ |
383 | static void idefloppy_queue_pc_head (ide_drive_t *drive,idefloppy_pc_t *pc,struct request *rq) | 366 | static void idefloppy_queue_pc_head(ide_drive_t *drive, idefloppy_pc_t *pc, |
367 | struct request *rq) | ||
384 | { | 368 | { |
385 | struct ide_floppy_obj *floppy = drive->driver_data; | 369 | struct ide_floppy_obj *floppy = drive->driver_data; |
386 | 370 | ||
@@ -391,16 +375,16 @@ static void idefloppy_queue_pc_head (ide_drive_t *drive,idefloppy_pc_t *pc,struc | |||
391 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); | 375 | (void) ide_do_drive_cmd(drive, rq, ide_preempt); |
392 | } | 376 | } |
393 | 377 | ||
394 | static idefloppy_pc_t *idefloppy_next_pc_storage (ide_drive_t *drive) | 378 | static idefloppy_pc_t *idefloppy_next_pc_storage(ide_drive_t *drive) |
395 | { | 379 | { |
396 | idefloppy_floppy_t *floppy = drive->driver_data; | 380 | idefloppy_floppy_t *floppy = drive->driver_data; |
397 | 381 | ||
398 | if (floppy->pc_stack_index == IDEFLOPPY_PC_STACK) | 382 | if (floppy->pc_stack_index == IDEFLOPPY_PC_STACK) |
399 | floppy->pc_stack_index=0; | 383 | floppy->pc_stack_index = 0; |
400 | return (&floppy->pc_stack[floppy->pc_stack_index++]); | 384 | return (&floppy->pc_stack[floppy->pc_stack_index++]); |
401 | } | 385 | } |
402 | 386 | ||
403 | static struct request *idefloppy_next_rq_storage (ide_drive_t *drive) | 387 | static struct request *idefloppy_next_rq_storage(ide_drive_t *drive) |
404 | { | 388 | { |
405 | idefloppy_floppy_t *floppy = drive->driver_data; | 389 | idefloppy_floppy_t *floppy = drive->driver_data; |
406 | 390 | ||
@@ -445,10 +429,8 @@ static void idefloppy_request_sense_callback(ide_drive_t *drive) | |||
445 | } | 429 | } |
446 | } | 430 | } |
447 | 431 | ||
448 | /* | 432 | /* General packet command callback function. */ |
449 | * General packet command callback function. | 433 | static void idefloppy_pc_callback(ide_drive_t *drive) |
450 | */ | ||
451 | static void idefloppy_pc_callback (ide_drive_t *drive) | ||
452 | { | 434 | { |
453 | idefloppy_floppy_t *floppy = drive->driver_data; | 435 | idefloppy_floppy_t *floppy = drive->driver_data; |
454 | 436 | ||
@@ -457,10 +439,7 @@ static void idefloppy_pc_callback (ide_drive_t *drive) | |||
457 | idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0); | 439 | idefloppy_do_end_request(drive, floppy->pc->error ? 0 : 1, 0); |
458 | } | 440 | } |
459 | 441 | ||
460 | /* | 442 | static void idefloppy_init_pc(idefloppy_pc_t *pc) |
461 | * idefloppy_init_pc initializes a packet command. | ||
462 | */ | ||
463 | static void idefloppy_init_pc (idefloppy_pc_t *pc) | ||
464 | { | 443 | { |
465 | memset(pc->c, 0, 12); | 444 | memset(pc->c, 0, 12); |
466 | pc->retries = 0; | 445 | pc->retries = 0; |
@@ -471,7 +450,7 @@ static void idefloppy_init_pc (idefloppy_pc_t *pc) | |||
471 | pc->callback = &idefloppy_pc_callback; | 450 | pc->callback = &idefloppy_pc_callback; |
472 | } | 451 | } |
473 | 452 | ||
474 | static void idefloppy_create_request_sense_cmd (idefloppy_pc_t *pc) | 453 | static void idefloppy_create_request_sense_cmd(idefloppy_pc_t *pc) |
475 | { | 454 | { |
476 | idefloppy_init_pc(pc); | 455 | idefloppy_init_pc(pc); |
477 | pc->c[0] = GPCMD_REQUEST_SENSE; | 456 | pc->c[0] = GPCMD_REQUEST_SENSE; |
@@ -481,11 +460,10 @@ static void idefloppy_create_request_sense_cmd (idefloppy_pc_t *pc) | |||
481 | } | 460 | } |
482 | 461 | ||
483 | /* | 462 | /* |
484 | * idefloppy_retry_pc is called when an error was detected during the | 463 | * Called when an error was detected during the last packet command. We queue a |
485 | * last packet command. We queue a request sense packet command in | 464 | * request sense packet command in the head of the request list. |
486 | * the head of the request list. | ||
487 | */ | 465 | */ |
488 | static void idefloppy_retry_pc (ide_drive_t *drive) | 466 | static void idefloppy_retry_pc(ide_drive_t *drive) |
489 | { | 467 | { |
490 | idefloppy_pc_t *pc; | 468 | idefloppy_pc_t *pc; |
491 | struct request *rq; | 469 | struct request *rq; |
@@ -528,7 +506,8 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
528 | /* Clear the interrupt */ | 506 | /* Clear the interrupt */ |
529 | stat = drive->hwif->INB(IDE_STATUS_REG); | 507 | stat = drive->hwif->INB(IDE_STATUS_REG); |
530 | 508 | ||
531 | if ((stat & DRQ_STAT) == 0) { /* No more interrupts */ | 509 | /* No more interrupts */ |
510 | if ((stat & DRQ_STAT) == 0) { | ||
532 | debug_log("Packet command completed, %d bytes transferred\n", | 511 | debug_log("Packet command completed, %d bytes transferred\n", |
533 | pc->actually_transferred); | 512 | pc->actually_transferred); |
534 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; | 513 | pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS; |
@@ -628,7 +607,7 @@ static ide_startstop_t idefloppy_pc_intr (ide_drive_t *drive) | |||
628 | * It fails at high speeds on the Iomega ZIP drive, so there's a slower version | 607 | * It fails at high speeds on the Iomega ZIP drive, so there's a slower version |
629 | * for that drive below. The algorithm is chosen based on drive type | 608 | * for that drive below. The algorithm is chosen based on drive type |
630 | */ | 609 | */ |
631 | static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive) | 610 | static ide_startstop_t idefloppy_transfer_pc(ide_drive_t *drive) |
632 | { | 611 | { |
633 | ide_startstop_t startstop; | 612 | ide_startstop_t startstop; |
634 | idefloppy_floppy_t *floppy = drive->driver_data; | 613 | idefloppy_floppy_t *floppy = drive->driver_data; |
@@ -655,18 +634,16 @@ static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive) | |||
655 | 634 | ||
656 | 635 | ||
657 | /* | 636 | /* |
658 | * What we have here is a classic case of a top half / bottom half | 637 | * What we have here is a classic case of a top half / bottom half interrupt |
659 | * interrupt service routine. In interrupt mode, the device sends | 638 | * service routine. In interrupt mode, the device sends an interrupt to signal |
660 | * an interrupt to signal it's ready to receive a packet. However, | 639 | * that it is ready to receive a packet. However, we need to delay about 2-3 |
661 | * we need to delay about 2-3 ticks before issuing the packet or we | 640 | * ticks before issuing the packet or we gets in trouble. |
662 | * gets in trouble. | ||
663 | * | 641 | * |
664 | * So, follow carefully. transfer_pc1 is called as an interrupt (or | 642 | * So, follow carefully. transfer_pc1 is called as an interrupt (or directly). |
665 | * directly). In either case, when the device says it's ready for a | 643 | * In either case, when the device says it's ready for a packet, we schedule |
666 | * packet, we schedule the packet transfer to occur about 2-3 ticks | 644 | * the packet transfer to occur about 2-3 ticks later in transfer_pc2. |
667 | * later in transfer_pc2. | ||
668 | */ | 645 | */ |
669 | static int idefloppy_transfer_pc2 (ide_drive_t *drive) | 646 | static int idefloppy_transfer_pc2(ide_drive_t *drive) |
670 | { | 647 | { |
671 | idefloppy_floppy_t *floppy = drive->driver_data; | 648 | idefloppy_floppy_t *floppy = drive->driver_data; |
672 | 649 | ||
@@ -676,7 +653,7 @@ static int idefloppy_transfer_pc2 (ide_drive_t *drive) | |||
676 | return IDEFLOPPY_WAIT_CMD; | 653 | return IDEFLOPPY_WAIT_CMD; |
677 | } | 654 | } |
678 | 655 | ||
679 | static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) | 656 | static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive) |
680 | { | 657 | { |
681 | idefloppy_floppy_t *floppy = drive->driver_data; | 658 | idefloppy_floppy_t *floppy = drive->driver_data; |
682 | ide_startstop_t startstop; | 659 | ide_startstop_t startstop; |
@@ -693,7 +670,7 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) | |||
693 | "while issuing a packet command\n"); | 670 | "while issuing a packet command\n"); |
694 | return ide_do_reset(drive); | 671 | return ide_do_reset(drive); |
695 | } | 672 | } |
696 | /* | 673 | /* |
697 | * The following delay solves a problem with ATAPI Zip 100 drives | 674 | * The following delay solves a problem with ATAPI Zip 100 drives |
698 | * where the Busy flag was apparently being deasserted before the | 675 | * where the Busy flag was apparently being deasserted before the |
699 | * unit was ready to receive data. This was happening on a | 676 | * unit was ready to receive data. This was happening on a |
@@ -702,10 +679,8 @@ static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) | |||
702 | * used until after the packet is moved in about 50 msec. | 679 | * used until after the packet is moved in about 50 msec. |
703 | */ | 680 | */ |
704 | 681 | ||
705 | ide_set_handler(drive, | 682 | ide_set_handler(drive, &idefloppy_pc_intr, floppy->ticks, |
706 | &idefloppy_pc_intr, /* service routine for packet command */ | 683 | &idefloppy_transfer_pc2); |
707 | floppy->ticks, /* wait this long before "failing" */ | ||
708 | &idefloppy_transfer_pc2); /* fail == transfer_pc2 */ | ||
709 | return ide_started; | 684 | return ide_started; |
710 | } | 685 | } |
711 | 686 | ||
@@ -725,10 +700,8 @@ static void ide_floppy_report_error(idefloppy_floppy_t *floppy, | |||
725 | 700 | ||
726 | } | 701 | } |
727 | 702 | ||
728 | /* | 703 | static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, |
729 | * Issue a packet command | 704 | idefloppy_pc_t *pc) |
730 | */ | ||
731 | static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *pc) | ||
732 | { | 705 | { |
733 | idefloppy_floppy_t *floppy = drive->driver_data; | 706 | idefloppy_floppy_t *floppy = drive->driver_data; |
734 | ide_hwif_t *hwif = drive->hwif; | 707 | ide_hwif_t *hwif = drive->hwif; |
@@ -773,7 +746,8 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p | |||
773 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | | 746 | ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | |
774 | IDE_TFLAG_OUT_DEVICE, bcount, dma); | 747 | IDE_TFLAG_OUT_DEVICE, bcount, dma); |
775 | 748 | ||
776 | if (dma) { /* Begin DMA, if necessary */ | 749 | if (dma) { |
750 | /* Begin DMA, if necessary */ | ||
777 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; | 751 | pc->flags |= PC_FLAG_DMA_IN_PROGRESS; |
778 | hwif->dma_start(drive); | 752 | hwif->dma_start(drive); |
779 | } | 753 | } |
@@ -801,7 +775,7 @@ static ide_startstop_t idefloppy_issue_pc (ide_drive_t *drive, idefloppy_pc_t *p | |||
801 | } | 775 | } |
802 | } | 776 | } |
803 | 777 | ||
804 | static void idefloppy_rw_callback (ide_drive_t *drive) | 778 | static void idefloppy_rw_callback(ide_drive_t *drive) |
805 | { | 779 | { |
806 | debug_log("Reached %s\n", __func__); | 780 | debug_log("Reached %s\n", __func__); |
807 | 781 | ||
@@ -809,7 +783,7 @@ static void idefloppy_rw_callback (ide_drive_t *drive) | |||
809 | return; | 783 | return; |
810 | } | 784 | } |
811 | 785 | ||
812 | static void idefloppy_create_prevent_cmd (idefloppy_pc_t *pc, int prevent) | 786 | static void idefloppy_create_prevent_cmd(idefloppy_pc_t *pc, int prevent) |
813 | { | 787 | { |
814 | debug_log("creating prevent removal command, prevent = %d\n", prevent); | 788 | debug_log("creating prevent removal command, prevent = %d\n", prevent); |
815 | 789 | ||
@@ -818,7 +792,7 @@ static void idefloppy_create_prevent_cmd (idefloppy_pc_t *pc, int prevent) | |||
818 | pc->c[4] = prevent; | 792 | pc->c[4] = prevent; |
819 | } | 793 | } |
820 | 794 | ||
821 | static void idefloppy_create_read_capacity_cmd (idefloppy_pc_t *pc) | 795 | static void idefloppy_create_read_capacity_cmd(idefloppy_pc_t *pc) |
822 | { | 796 | { |
823 | idefloppy_init_pc(pc); | 797 | idefloppy_init_pc(pc); |
824 | pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES; | 798 | pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES; |
@@ -827,7 +801,7 @@ static void idefloppy_create_read_capacity_cmd (idefloppy_pc_t *pc) | |||
827 | pc->request_transfer = 255; | 801 | pc->request_transfer = 255; |
828 | } | 802 | } |
829 | 803 | ||
830 | static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l, | 804 | static void idefloppy_create_format_unit_cmd(idefloppy_pc_t *pc, int b, int l, |
831 | int flags) | 805 | int flags) |
832 | { | 806 | { |
833 | idefloppy_init_pc(pc); | 807 | idefloppy_init_pc(pc); |
@@ -844,38 +818,37 @@ static void idefloppy_create_format_unit_cmd (idefloppy_pc_t *pc, int b, int l, | |||
844 | 818 | ||
845 | put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4])); | 819 | put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buffer[4])); |
846 | put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8])); | 820 | put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buffer[8])); |
847 | pc->buffer_size=12; | 821 | pc->buffer_size = 12; |
848 | pc->flags |= PC_FLAG_WRITING; | 822 | pc->flags |= PC_FLAG_WRITING; |
849 | } | 823 | } |
850 | 824 | ||
851 | /* | 825 | /* A mode sense command is used to "sense" floppy parameters. */ |
852 | * A mode sense command is used to "sense" floppy parameters. | 826 | static void idefloppy_create_mode_sense_cmd(idefloppy_pc_t *pc, u8 page_code, |
853 | */ | 827 | u8 type) |
854 | static void idefloppy_create_mode_sense_cmd (idefloppy_pc_t *pc, u8 page_code, u8 type) | ||
855 | { | 828 | { |
856 | u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */ | 829 | u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */ |
857 | 830 | ||
858 | idefloppy_init_pc(pc); | 831 | idefloppy_init_pc(pc); |
859 | pc->c[0] = GPCMD_MODE_SENSE_10; | 832 | pc->c[0] = GPCMD_MODE_SENSE_10; |
860 | pc->c[1] = 0; | 833 | pc->c[1] = 0; |
861 | pc->c[2] = page_code + (type << 6); | 834 | pc->c[2] = page_code + (type << 6); |
862 | 835 | ||
863 | switch (page_code) { | 836 | switch (page_code) { |
864 | case IDEFLOPPY_CAPABILITIES_PAGE: | 837 | case IDEFLOPPY_CAPABILITIES_PAGE: |
865 | length += 12; | 838 | length += 12; |
866 | break; | 839 | break; |
867 | case IDEFLOPPY_FLEXIBLE_DISK_PAGE: | 840 | case IDEFLOPPY_FLEXIBLE_DISK_PAGE: |
868 | length += 32; | 841 | length += 32; |
869 | break; | 842 | break; |
870 | default: | 843 | default: |
871 | printk(KERN_ERR "ide-floppy: unsupported page code " | 844 | printk(KERN_ERR "ide-floppy: unsupported page code " |
872 | "in create_mode_sense_cmd\n"); | 845 | "in create_mode_sense_cmd\n"); |
873 | } | 846 | } |
874 | put_unaligned(cpu_to_be16(length), (u16 *) &pc->c[7]); | 847 | put_unaligned(cpu_to_be16(length), (u16 *) &pc->c[7]); |
875 | pc->request_transfer = length; | 848 | pc->request_transfer = length; |
876 | } | 849 | } |
877 | 850 | ||
878 | static void idefloppy_create_start_stop_cmd (idefloppy_pc_t *pc, int start) | 851 | static void idefloppy_create_start_stop_cmd(idefloppy_pc_t *pc, int start) |
879 | { | 852 | { |
880 | idefloppy_init_pc(pc); | 853 | idefloppy_init_pc(pc); |
881 | pc->c[0] = GPCMD_START_STOP_UNIT; | 854 | pc->c[0] = GPCMD_START_STOP_UNIT; |
@@ -914,8 +887,8 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, | |||
914 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; | 887 | pc->flags |= PC_FLAG_DMA_RECOMMENDED; |
915 | } | 888 | } |
916 | 889 | ||
917 | static void | 890 | static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, |
918 | idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct request *rq) | 891 | idefloppy_pc_t *pc, struct request *rq) |
919 | { | 892 | { |
920 | idefloppy_init_pc(pc); | 893 | idefloppy_init_pc(pc); |
921 | pc->callback = &idefloppy_rw_callback; | 894 | pc->callback = &idefloppy_rw_callback; |
@@ -934,10 +907,8 @@ idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, idefloppy_pc_t *pc, struct req | |||
934 | pc->request_transfer = pc->buffer_size = rq->data_len; | 907 | pc->request_transfer = pc->buffer_size = rq->data_len; |
935 | } | 908 | } |
936 | 909 | ||
937 | /* | 910 | static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, |
938 | * idefloppy_do_request is our request handling function. | 911 | struct request *rq, sector_t block_s) |
939 | */ | ||
940 | static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request *rq, sector_t block_s) | ||
941 | { | 912 | { |
942 | idefloppy_floppy_t *floppy = drive->driver_data; | 913 | idefloppy_floppy_t *floppy = drive->driver_data; |
943 | idefloppy_pc_t *pc; | 914 | idefloppy_pc_t *pc; |
@@ -962,8 +933,8 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request | |||
962 | if (blk_fs_request(rq)) { | 933 | if (blk_fs_request(rq)) { |
963 | if (((long)rq->sector % floppy->bs_factor) || | 934 | if (((long)rq->sector % floppy->bs_factor) || |
964 | (rq->nr_sectors % floppy->bs_factor)) { | 935 | (rq->nr_sectors % floppy->bs_factor)) { |
965 | printk("%s: unsupported r/w request size\n", | 936 | printk(KERN_ERR "%s: unsupported r/w request size\n", |
966 | drive->name); | 937 | drive->name); |
967 | idefloppy_do_end_request(drive, 0, 0); | 938 | idefloppy_do_end_request(drive, 0, 0); |
968 | return ide_stopped; | 939 | return ide_stopped; |
969 | } | 940 | } |
@@ -986,15 +957,15 @@ static ide_startstop_t idefloppy_do_request (ide_drive_t *drive, struct request | |||
986 | } | 957 | } |
987 | 958 | ||
988 | /* | 959 | /* |
989 | * idefloppy_queue_pc_tail adds a special packet command request to the | 960 | * Add a special packet command request to the tail of the request queue, |
990 | * tail of the request queue, and waits for it to be serviced. | 961 | * and wait for it to be serviced. |
991 | */ | 962 | */ |
992 | static int idefloppy_queue_pc_tail (ide_drive_t *drive,idefloppy_pc_t *pc) | 963 | static int idefloppy_queue_pc_tail(ide_drive_t *drive, idefloppy_pc_t *pc) |
993 | { | 964 | { |
994 | struct ide_floppy_obj *floppy = drive->driver_data; | 965 | struct ide_floppy_obj *floppy = drive->driver_data; |
995 | struct request rq; | 966 | struct request rq; |
996 | 967 | ||
997 | ide_init_drive_cmd (&rq); | 968 | ide_init_drive_cmd(&rq); |
998 | rq.buffer = (char *) pc; | 969 | rq.buffer = (char *) pc; |
999 | rq.cmd_type = REQ_TYPE_SPECIAL; | 970 | rq.cmd_type = REQ_TYPE_SPECIAL; |
1000 | rq.rq_disk = floppy->disk; | 971 | rq.rq_disk = floppy->disk; |
@@ -1121,7 +1092,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
1121 | /* Clik! drive returns this instead of CAPACITY_CURRENT */ | 1092 | /* Clik! drive returns this instead of CAPACITY_CURRENT */ |
1122 | case CAPACITY_UNFORMATTED: | 1093 | case CAPACITY_UNFORMATTED: |
1123 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) | 1094 | if (!(floppy->flags & IDEFLOPPY_FLAG_CLIK_DRIVE)) |
1124 | /* | 1095 | /* |
1125 | * If it is not a clik drive, break out | 1096 | * If it is not a clik drive, break out |
1126 | * (maintains previous driver behaviour) | 1097 | * (maintains previous driver behaviour) |
1127 | */ | 1098 | */ |
@@ -1247,14 +1218,14 @@ static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | |||
1247 | } | 1218 | } |
1248 | 1219 | ||
1249 | /* | 1220 | /* |
1250 | ** Get ATAPI_FORMAT_UNIT progress indication. | 1221 | * Get ATAPI_FORMAT_UNIT progress indication. |
1251 | ** | 1222 | * |
1252 | ** Userland gives a pointer to an int. The int is set to a progress | 1223 | * Userland gives a pointer to an int. The int is set to a progress |
1253 | ** indicator 0-65536, with 65536=100%. | 1224 | * indicator 0-65536, with 65536=100%. |
1254 | ** | 1225 | * |
1255 | ** If the drive does not support format progress indication, we just check | 1226 | * If the drive does not support format progress indication, we just check |
1256 | ** the dsc bit, and return either 0 or 65536. | 1227 | * the dsc bit, and return either 0 or 65536. |
1257 | */ | 1228 | */ |
1258 | 1229 | ||
1259 | static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) | 1230 | static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) |
1260 | { | 1231 | { |
@@ -1264,17 +1235,15 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) | |||
1264 | 1235 | ||
1265 | if (floppy->srfp) { | 1236 | if (floppy->srfp) { |
1266 | idefloppy_create_request_sense_cmd(&pc); | 1237 | idefloppy_create_request_sense_cmd(&pc); |
1267 | if (idefloppy_queue_pc_tail(drive, &pc)) { | 1238 | if (idefloppy_queue_pc_tail(drive, &pc)) |
1268 | return (-EIO); | 1239 | return (-EIO); |
1269 | } | ||
1270 | 1240 | ||
1271 | if (floppy->sense_key == 2 && | 1241 | if (floppy->sense_key == 2 && |
1272 | floppy->asc == 4 && | 1242 | floppy->asc == 4 && |
1273 | floppy->ascq == 4) { | 1243 | floppy->ascq == 4) |
1274 | progress_indication = floppy->progress_indication; | 1244 | progress_indication = floppy->progress_indication; |
1275 | } | 1245 | |
1276 | /* Else assume format_unit has finished, and we're | 1246 | /* Else assume format_unit has finished, and we're at 0x10000 */ |
1277 | ** at 0x10000 */ | ||
1278 | } else { | 1247 | } else { |
1279 | unsigned long flags; | 1248 | unsigned long flags; |
1280 | u8 stat; | 1249 | u8 stat; |
@@ -1291,10 +1260,7 @@ static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) | |||
1291 | return (0); | 1260 | return (0); |
1292 | } | 1261 | } |
1293 | 1262 | ||
1294 | /* | 1263 | static sector_t idefloppy_capacity(ide_drive_t *drive) |
1295 | * Return the current floppy capacity. | ||
1296 | */ | ||
1297 | static sector_t idefloppy_capacity (ide_drive_t *drive) | ||
1298 | { | 1264 | { |
1299 | idefloppy_floppy_t *floppy = drive->driver_data; | 1265 | idefloppy_floppy_t *floppy = drive->driver_data; |
1300 | unsigned long capacity = floppy->blocks * floppy->bs_factor; | 1266 | unsigned long capacity = floppy->blocks * floppy->bs_factor; |
@@ -1344,22 +1310,20 @@ static void idefloppy_add_settings(ide_drive_t *drive) | |||
1344 | { | 1310 | { |
1345 | idefloppy_floppy_t *floppy = drive->driver_data; | 1311 | idefloppy_floppy_t *floppy = drive->driver_data; |
1346 | 1312 | ||
1347 | /* | 1313 | ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 1023, 1, 1, |
1348 | * drive setting name read/write data type min max mul_factor div_factor data pointer set function | 1314 | &drive->bios_cyl, NULL); |
1349 | */ | 1315 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, |
1350 | ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 1023, 1, 1, &drive->bios_cyl, NULL); | 1316 | &drive->bios_head, NULL); |
1351 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &drive->bios_head, NULL); | 1317 | ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, |
1352 | ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL); | 1318 | &drive->bios_sect, NULL); |
1353 | ide_add_setting(drive, "ticks", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &floppy->ticks, NULL); | 1319 | ide_add_setting(drive, "ticks", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, |
1320 | &floppy->ticks, NULL); | ||
1354 | } | 1321 | } |
1355 | #else | 1322 | #else |
1356 | static inline void idefloppy_add_settings(ide_drive_t *drive) { ; } | 1323 | static inline void idefloppy_add_settings(ide_drive_t *drive) { ; } |
1357 | #endif | 1324 | #endif |
1358 | 1325 | ||
1359 | /* | 1326 | static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy) |
1360 | * Driver initialization. | ||
1361 | */ | ||
1362 | static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) | ||
1363 | { | 1327 | { |
1364 | struct idefloppy_id_gcw gcw; | 1328 | struct idefloppy_id_gcw gcw; |
1365 | 1329 | ||
@@ -1368,16 +1332,14 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) | |||
1368 | if (gcw.drq_type == 1) | 1332 | if (gcw.drq_type == 1) |
1369 | floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT; | 1333 | floppy->flags |= IDEFLOPPY_FLAG_DRQ_INTERRUPT; |
1370 | /* | 1334 | /* |
1371 | * We used to check revisions here. At this point however | 1335 | * We used to check revisions here. At this point however I'm giving up. |
1372 | * I'm giving up. Just assume they are all broken, its easier. | 1336 | * Just assume they are all broken, its easier. |
1373 | * | 1337 | * |
1374 | * The actual reason for the workarounds was likely | 1338 | * The actual reason for the workarounds was likely a driver bug after |
1375 | * a driver bug after all rather than a firmware bug, | 1339 | * all rather than a firmware bug, and the workaround below used to hide |
1376 | * and the workaround below used to hide it. It should | 1340 | * it. It should be fixed as of version 1.9, but to be on the safe side |
1377 | * be fixed as of version 1.9, but to be on the safe side | 1341 | * we'll leave the limitation below for the 2.2.x tree. |
1378 | * we'll leave the limitation below for the 2.2.x tree. | ||
1379 | */ | 1342 | */ |
1380 | |||
1381 | if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { | 1343 | if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { |
1382 | floppy->flags |= IDEFLOPPY_FLAG_ZIP_DRIVE; | 1344 | floppy->flags |= IDEFLOPPY_FLAG_ZIP_DRIVE; |
1383 | /* This value will be visible in the /proc/ide/hdx/settings */ | 1345 | /* This value will be visible in the /proc/ide/hdx/settings */ |
@@ -1386,16 +1348,14 @@ static void idefloppy_setup (ide_drive_t *drive, idefloppy_floppy_t *floppy) | |||
1386 | } | 1348 | } |
1387 | 1349 | ||
1388 | /* | 1350 | /* |
1389 | * Guess what? The IOMEGA Clik! drive also needs the | 1351 | * Guess what? The IOMEGA Clik! drive also needs the above fix. It makes |
1390 | * above fix. It makes nasty clicking noises without | 1352 | * nasty clicking noises without it, so please don't remove this. |
1391 | * it, so please don't remove this. | 1353 | */ |
1392 | */ | ||
1393 | if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { | 1354 | if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { |
1394 | blk_queue_max_sectors(drive->queue, 64); | 1355 | blk_queue_max_sectors(drive->queue, 64); |
1395 | floppy->flags |= IDEFLOPPY_FLAG_CLIK_DRIVE; | 1356 | floppy->flags |= IDEFLOPPY_FLAG_CLIK_DRIVE; |
1396 | } | 1357 | } |
1397 | 1358 | ||
1398 | |||
1399 | (void) ide_floppy_get_capacity(drive); | 1359 | (void) ide_floppy_get_capacity(drive); |
1400 | idefloppy_add_settings(drive); | 1360 | idefloppy_add_settings(drive); |
1401 | } | 1361 | } |
@@ -1425,19 +1385,19 @@ static void idefloppy_cleanup_obj(struct kref *kref) | |||
1425 | } | 1385 | } |
1426 | 1386 | ||
1427 | #ifdef CONFIG_IDE_PROC_FS | 1387 | #ifdef CONFIG_IDE_PROC_FS |
1428 | static int proc_idefloppy_read_capacity | 1388 | static int proc_idefloppy_read_capacity(char *page, char **start, off_t off, |
1429 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 1389 | int count, int *eof, void *data) |
1430 | { | 1390 | { |
1431 | ide_drive_t*drive = (ide_drive_t *)data; | 1391 | ide_drive_t*drive = (ide_drive_t *)data; |
1432 | int len; | 1392 | int len; |
1433 | 1393 | ||
1434 | len = sprintf(page,"%llu\n", (long long)idefloppy_capacity(drive)); | 1394 | len = sprintf(page, "%llu\n", (long long)idefloppy_capacity(drive)); |
1435 | PROC_IDE_READ_RETURN(page,start,off,count,eof,len); | 1395 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); |
1436 | } | 1396 | } |
1437 | 1397 | ||
1438 | static ide_proc_entry_t idefloppy_proc[] = { | 1398 | static ide_proc_entry_t idefloppy_proc[] = { |
1439 | { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL }, | 1399 | { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL }, |
1440 | { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, | 1400 | { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, |
1441 | { NULL, 0, NULL, NULL } | 1401 | { NULL, 0, NULL, NULL } |
1442 | }; | 1402 | }; |
1443 | #endif /* CONFIG_IDE_PROC_FS */ | 1403 | #endif /* CONFIG_IDE_PROC_FS */ |
@@ -1474,7 +1434,8 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
1474 | 1434 | ||
1475 | debug_log("Reached %s\n", __func__); | 1435 | debug_log("Reached %s\n", __func__); |
1476 | 1436 | ||
1477 | if (!(floppy = ide_floppy_get(disk))) | 1437 | floppy = ide_floppy_get(disk); |
1438 | if (!floppy) | ||
1478 | return -ENXIO; | 1439 | return -ENXIO; |
1479 | 1440 | ||
1480 | drive = floppy->drive; | 1441 | drive = floppy->drive; |
@@ -1494,10 +1455,10 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
1494 | if (ide_floppy_get_capacity(drive) | 1455 | if (ide_floppy_get_capacity(drive) |
1495 | && (filp->f_flags & O_NDELAY) == 0 | 1456 | && (filp->f_flags & O_NDELAY) == 0 |
1496 | /* | 1457 | /* |
1497 | ** Allow O_NDELAY to open a drive without a disk, or with | 1458 | * Allow O_NDELAY to open a drive without a disk, or with an |
1498 | ** an unreadable disk, so that we can get the format | 1459 | * unreadable disk, so that we can get the format capacity |
1499 | ** capacity of the drive or begin the format - Sam | 1460 | * of the drive or begin the format - Sam |
1500 | */ | 1461 | */ |
1501 | ) { | 1462 | ) { |
1502 | ret = -EIO; | 1463 | ret = -EIO; |
1503 | goto out_put_floppy; | 1464 | goto out_put_floppy; |
@@ -1726,16 +1687,20 @@ static int ide_floppy_probe(ide_drive_t *drive) | |||
1726 | goto failed; | 1687 | goto failed; |
1727 | if (drive->media != ide_floppy) | 1688 | if (drive->media != ide_floppy) |
1728 | goto failed; | 1689 | goto failed; |
1729 | if (!idefloppy_identify_device (drive, drive->id)) { | 1690 | if (!idefloppy_identify_device(drive, drive->id)) { |
1730 | printk (KERN_ERR "ide-floppy: %s: not supported by this version of ide-floppy\n", drive->name); | 1691 | printk(KERN_ERR "ide-floppy: %s: not supported by this version" |
1692 | " of ide-floppy\n", drive->name); | ||
1731 | goto failed; | 1693 | goto failed; |
1732 | } | 1694 | } |
1733 | if (drive->scsi) { | 1695 | if (drive->scsi) { |
1734 | printk("ide-floppy: passing drive %s to ide-scsi emulation.\n", drive->name); | 1696 | printk(KERN_INFO "ide-floppy: passing drive %s to ide-scsi" |
1697 | " emulation.\n", drive->name); | ||
1735 | goto failed; | 1698 | goto failed; |
1736 | } | 1699 | } |
1737 | if ((floppy = kzalloc(sizeof (idefloppy_floppy_t), GFP_KERNEL)) == NULL) { | 1700 | floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL); |
1738 | printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name); | 1701 | if (!floppy) { |
1702 | printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy" | ||
1703 | " structure\n", drive->name); | ||
1739 | goto failed; | 1704 | goto failed; |
1740 | } | 1705 | } |
1741 | 1706 | ||
@@ -1757,7 +1722,7 @@ static int ide_floppy_probe(ide_drive_t *drive) | |||
1757 | 1722 | ||
1758 | drive->driver_data = floppy; | 1723 | drive->driver_data = floppy; |
1759 | 1724 | ||
1760 | idefloppy_setup (drive, floppy); | 1725 | idefloppy_setup(drive, floppy); |
1761 | 1726 | ||
1762 | g->minors = 1 << PARTN_BITS; | 1727 | g->minors = 1 << PARTN_BITS; |
1763 | g->driverfs_dev = &drive->gendev; | 1728 | g->driverfs_dev = &drive->gendev; |
@@ -1773,9 +1738,7 @@ failed: | |||
1773 | return -ENODEV; | 1738 | return -ENODEV; |
1774 | } | 1739 | } |
1775 | 1740 | ||
1776 | MODULE_DESCRIPTION("ATAPI FLOPPY Driver"); | 1741 | static void __exit idefloppy_exit(void) |
1777 | |||
1778 | static void __exit idefloppy_exit (void) | ||
1779 | { | 1742 | { |
1780 | driver_unregister(&idefloppy_driver.gen_driver); | 1743 | driver_unregister(&idefloppy_driver.gen_driver); |
1781 | } | 1744 | } |
@@ -1790,3 +1753,5 @@ MODULE_ALIAS("ide:*m-floppy*"); | |||
1790 | module_init(idefloppy_init); | 1753 | module_init(idefloppy_init); |
1791 | module_exit(idefloppy_exit); | 1754 | module_exit(idefloppy_exit); |
1792 | MODULE_LICENSE("GPL"); | 1755 | MODULE_LICENSE("GPL"); |
1756 | MODULE_DESCRIPTION("ATAPI FLOPPY Driver"); | ||
1757 | |||