diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:35 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:35 -0400 |
commit | 394a4c2101f43bfb5fea7b5d1f5789a14ac018d7 (patch) | |
tree | 3ad1006008b2d1ff2eb4ce8b1433d921fa6b6a2c | |
parent | 20df429dd6671804999493baf2952f82582869fa (diff) |
ide-{floppy,tape}: remove request stack
* Add 'struct request request_sense_rq' to struct ide_{floppy,tape}_obj
and switch ide*_retry_pc() to use it (there can be only one REQUEST SENSE
request active for a given device).
* Remove no longer needed ide*_next_rq_storage(), rq_stack[]
and rq_stack_index.
* DBG_PCRQ_STACK -> DBG_PC_STACK
* Update comments for IDE*_PC_STACK and idetape_queue_pc_{head,tail}().
There should be no functional changes caused by this patch.
Cc: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r-- | drivers/ide/ide-floppy.c | 22 | ||||
-rw-r--r-- | drivers/ide/ide-tape.c | 68 |
2 files changed, 18 insertions, 72 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index 06db5edf9cee..41bb61037da2 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -77,8 +77,8 @@ | |||
77 | 77 | ||
78 | /* | 78 | /* |
79 | * In various places in the driver, we need to allocate storage for packet | 79 | * In various places in the driver, we need to allocate storage for packet |
80 | * commands and requests, which will remain valid while we leave the driver to | 80 | * commands, which will remain valid while we leave the driver to wait for |
81 | * wait for an interrupt or a timeout event. | 81 | * an interrupt or a timeout event. |
82 | */ | 82 | */ |
83 | #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES) | 83 | #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES) |
84 | 84 | ||
@@ -108,9 +108,8 @@ typedef struct ide_floppy_obj { | |||
108 | struct ide_atapi_pc pc_stack[IDEFLOPPY_PC_STACK]; | 108 | struct ide_atapi_pc pc_stack[IDEFLOPPY_PC_STACK]; |
109 | /* Next free packet command storage space */ | 109 | /* Next free packet command storage space */ |
110 | int pc_stack_index; | 110 | int pc_stack_index; |
111 | struct request rq_stack[IDEFLOPPY_PC_STACK]; | 111 | |
112 | /* We implement a circular array */ | 112 | struct request request_sense_rq; |
113 | int rq_stack_index; | ||
114 | 113 | ||
115 | /* Last error information */ | 114 | /* Last error information */ |
116 | u8 sense_key, asc, ascq; | 115 | u8 sense_key, asc, ascq; |
@@ -306,15 +305,6 @@ static struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive) | |||
306 | return (&floppy->pc_stack[floppy->pc_stack_index++]); | 305 | return (&floppy->pc_stack[floppy->pc_stack_index++]); |
307 | } | 306 | } |
308 | 307 | ||
309 | static struct request *idefloppy_next_rq_storage(ide_drive_t *drive) | ||
310 | { | ||
311 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
312 | |||
313 | if (floppy->rq_stack_index == IDEFLOPPY_PC_STACK) | ||
314 | floppy->rq_stack_index = 0; | ||
315 | return (&floppy->rq_stack[floppy->rq_stack_index++]); | ||
316 | } | ||
317 | |||
318 | static void ide_floppy_callback(ide_drive_t *drive) | 308 | static void ide_floppy_callback(ide_drive_t *drive) |
319 | { | 309 | { |
320 | idefloppy_floppy_t *floppy = drive->driver_data; | 310 | idefloppy_floppy_t *floppy = drive->driver_data; |
@@ -373,12 +363,12 @@ static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) | |||
373 | */ | 363 | */ |
374 | static void idefloppy_retry_pc(ide_drive_t *drive) | 364 | static void idefloppy_retry_pc(ide_drive_t *drive) |
375 | { | 365 | { |
366 | struct ide_floppy_obj *floppy = drive->driver_data; | ||
367 | struct request *rq = &floppy->request_sense_rq; | ||
376 | struct ide_atapi_pc *pc; | 368 | struct ide_atapi_pc *pc; |
377 | struct request *rq; | ||
378 | 369 | ||
379 | (void)ide_read_error(drive); | 370 | (void)ide_read_error(drive); |
380 | pc = idefloppy_next_pc_storage(drive); | 371 | pc = idefloppy_next_pc_storage(drive); |
381 | rq = idefloppy_next_rq_storage(drive); | ||
382 | idefloppy_create_request_sense_cmd(pc); | 372 | idefloppy_create_request_sense_cmd(pc); |
383 | idefloppy_queue_pc_head(drive, pc, rq); | 373 | idefloppy_queue_pc_head(drive, pc, rq); |
384 | } | 374 | } |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 83014abf330f..dd3533505e3b 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -56,8 +56,8 @@ enum { | |||
56 | DBG_CHRDEV = (1 << 2), | 56 | DBG_CHRDEV = (1 << 2), |
57 | /* all remaining procedures */ | 57 | /* all remaining procedures */ |
58 | DBG_PROCS = (1 << 3), | 58 | DBG_PROCS = (1 << 3), |
59 | /* buffer alloc info (pc_stack & rq_stack) */ | 59 | /* buffer alloc info (pc_stack) */ |
60 | DBG_PCRQ_STACK = (1 << 4), | 60 | DBG_PC_STACK = (1 << 4), |
61 | }; | 61 | }; |
62 | 62 | ||
63 | /* define to see debug info */ | 63 | /* define to see debug info */ |
@@ -89,9 +89,9 @@ enum { | |||
89 | #define IDETAPE_PC_BUFFER_SIZE 256 | 89 | #define IDETAPE_PC_BUFFER_SIZE 256 |
90 | 90 | ||
91 | /* | 91 | /* |
92 | * In various places in the driver, we need to allocate storage | 92 | * In various places in the driver, we need to allocate storage for packet |
93 | * for packet commands and requests, which will remain valid while | 93 | * commands, which will remain valid while we leave the driver to wait for |
94 | * we leave the driver to wait for an interrupt or a timeout event. | 94 | * an interrupt or a timeout event. |
95 | */ | 95 | */ |
96 | #define IDETAPE_PC_STACK (10 + IDETAPE_MAX_PC_RETRIES) | 96 | #define IDETAPE_PC_STACK (10 + IDETAPE_MAX_PC_RETRIES) |
97 | 97 | ||
@@ -230,9 +230,8 @@ typedef struct ide_tape_obj { | |||
230 | struct ide_atapi_pc pc_stack[IDETAPE_PC_STACK]; | 230 | struct ide_atapi_pc pc_stack[IDETAPE_PC_STACK]; |
231 | /* Next free packet command storage space */ | 231 | /* Next free packet command storage space */ |
232 | int pc_stack_index; | 232 | int pc_stack_index; |
233 | struct request rq_stack[IDETAPE_PC_STACK]; | 233 | |
234 | /* We implement a circular array */ | 234 | struct request request_sense_rq; |
235 | int rq_stack_index; | ||
236 | 235 | ||
237 | /* | 236 | /* |
238 | * DSC polling variables. | 237 | * DSC polling variables. |
@@ -462,7 +461,7 @@ static struct ide_atapi_pc *idetape_next_pc_storage(ide_drive_t *drive) | |||
462 | { | 461 | { |
463 | idetape_tape_t *tape = drive->driver_data; | 462 | idetape_tape_t *tape = drive->driver_data; |
464 | 463 | ||
465 | debug_log(DBG_PCRQ_STACK, "pc_stack_index=%d\n", tape->pc_stack_index); | 464 | debug_log(DBG_PC_STACK, "pc_stack_index=%d\n", tape->pc_stack_index); |
466 | 465 | ||
467 | if (tape->pc_stack_index == IDETAPE_PC_STACK) | 466 | if (tape->pc_stack_index == IDETAPE_PC_STACK) |
468 | tape->pc_stack_index = 0; | 467 | tape->pc_stack_index = 0; |
@@ -470,30 +469,6 @@ static struct ide_atapi_pc *idetape_next_pc_storage(ide_drive_t *drive) | |||
470 | } | 469 | } |
471 | 470 | ||
472 | /* | 471 | /* |
473 | * idetape_next_rq_storage is used along with idetape_next_pc_storage. | ||
474 | * Since we queue packet commands in the request queue, we need to | ||
475 | * allocate a request, along with the allocation of a packet command. | ||
476 | */ | ||
477 | |||
478 | /************************************************************** | ||
479 | * * | ||
480 | * This should get fixed to use kmalloc(.., GFP_ATOMIC) * | ||
481 | * followed later on by kfree(). -ml * | ||
482 | * * | ||
483 | **************************************************************/ | ||
484 | |||
485 | static struct request *idetape_next_rq_storage(ide_drive_t *drive) | ||
486 | { | ||
487 | idetape_tape_t *tape = drive->driver_data; | ||
488 | |||
489 | debug_log(DBG_PCRQ_STACK, "rq_stack_index=%d\n", tape->rq_stack_index); | ||
490 | |||
491 | if (tape->rq_stack_index == IDETAPE_PC_STACK) | ||
492 | tape->rq_stack_index = 0; | ||
493 | return (&tape->rq_stack[tape->rq_stack_index++]); | ||
494 | } | ||
495 | |||
496 | /* | ||
497 | * called on each failed packet command retry to analyze the request sense. We | 472 | * called on each failed packet command retry to analyze the request sense. We |
498 | * currently do not utilize this information. | 473 | * currently do not utilize this information. |
499 | */ | 474 | */ |
@@ -692,17 +667,7 @@ static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) | |||
692 | /* | 667 | /* |
693 | * Generate a new packet command request in front of the request queue, before | 668 | * Generate a new packet command request in front of the request queue, before |
694 | * the current request, so that it will be processed immediately, on the next | 669 | * the current request, so that it will be processed immediately, on the next |
695 | * pass through the driver. The function below is called from the request | 670 | * pass through the driver. |
696 | * handling part of the driver (the "bottom" part). Safe storage for the request | ||
697 | * should be allocated with ide_tape_next_{pc,rq}_storage() prior to that. | ||
698 | * | ||
699 | * Memory for those requests is pre-allocated at initialization time, and is | ||
700 | * limited to IDETAPE_PC_STACK requests. We assume that we have enough space for | ||
701 | * the maximum possible number of inter-dependent packet commands. | ||
702 | * | ||
703 | * The higher level of the driver - The ioctl handler and the character device | ||
704 | * handling functions should queue request to the lower level part and wait for | ||
705 | * their completion using idetape_queue_pc_tail or idetape_queue_rw_tail. | ||
706 | */ | 671 | */ |
707 | static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | 672 | static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, |
708 | struct request *rq) | 673 | struct request *rq) |
@@ -726,12 +691,12 @@ static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
726 | */ | 691 | */ |
727 | static void idetape_retry_pc(ide_drive_t *drive) | 692 | static void idetape_retry_pc(ide_drive_t *drive) |
728 | { | 693 | { |
694 | struct ide_tape_obj *tape = drive->driver_data; | ||
695 | struct request *rq = &tape->request_sense_rq; | ||
729 | struct ide_atapi_pc *pc; | 696 | struct ide_atapi_pc *pc; |
730 | struct request *rq; | ||
731 | 697 | ||
732 | (void)ide_read_error(drive); | 698 | (void)ide_read_error(drive); |
733 | pc = idetape_next_pc_storage(drive); | 699 | pc = idetape_next_pc_storage(drive); |
734 | rq = idetape_next_rq_storage(drive); | ||
735 | idetape_create_request_sense_cmd(pc); | 700 | idetape_create_request_sense_cmd(pc); |
736 | set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); | 701 | set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); |
737 | idetape_queue_pc_head(drive, pc, rq); | 702 | idetape_queue_pc_head(drive, pc, rq); |
@@ -1247,16 +1212,7 @@ static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) | |||
1247 | 1212 | ||
1248 | /* | 1213 | /* |
1249 | * We add a special packet command request to the tail of the request queue, and | 1214 | * We add a special packet command request to the tail of the request queue, and |
1250 | * wait for it to be serviced. This is not to be called from within the request | 1215 | * wait for it to be serviced. |
1251 | * handling part of the driver! We allocate here data on the stack and it is | ||
1252 | * valid until the request is finished. This is not the case for the bottom part | ||
1253 | * of the driver, where we are always leaving the functions to wait for an | ||
1254 | * interrupt or a timer event. | ||
1255 | * | ||
1256 | * From the bottom part of the driver, we should allocate safe memory using | ||
1257 | * idetape_next_pc_storage() and ide_tape_next_rq_storage(), and add the request | ||
1258 | * to the request list without waiting for it to be serviced! In that case, we | ||
1259 | * usually use idetape_queue_pc_head(). | ||
1260 | */ | 1216 | */ |
1261 | static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) | 1217 | static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) |
1262 | { | 1218 | { |