diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-03-27 07:46:34 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-03-27 07:46:34 -0400 |
commit | 313afea7f25cc6d420179e0b316499c164e3e372 (patch) | |
tree | 573be1b3912d970951ba30c718332c6174ac8144 /drivers/ide/ide-floppy.c | |
parent | c152cc1a90f9680cefa74d9ff9ce36038081ba72 (diff) |
ide-{floppy,tape}: cleanup ide*_end_request()
* ide*_end_request() is only called with uptodate == 0 or uptodate == 1
so cleanup it accordingly.
* Inline ide*_end_request() content at call sites so the only user left
is ->end_request method.
* ->end_request is now used only for private driver requests so remove
handling of other requests from ide*_end_request().
There should be no functional changes caused by this patch.
Acked-by: Borislav Petkov <petkovbb@gmail.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-floppy.c')
-rw-r--r-- | drivers/ide/ide-floppy.c | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index fb235641da33..bdd8f8e2df6d 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
@@ -62,40 +62,21 @@ | |||
62 | #define IDEFLOPPY_PC_DELAY (HZ/20) /* default delay for ZIP 100 (50ms) */ | 62 | #define IDEFLOPPY_PC_DELAY (HZ/20) /* default delay for ZIP 100 (50ms) */ |
63 | 63 | ||
64 | /* | 64 | /* |
65 | * Used to finish servicing a request. For read/write requests, we will call | 65 | * Used to finish servicing a private request. |
66 | * ide_end_request to pass to the next buffer. | ||
67 | */ | 66 | */ |
68 | static int ide_floppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) | 67 | static int ide_floppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) |
69 | { | 68 | { |
70 | struct request *rq = drive->hwif->rq; | 69 | struct request *rq = drive->hwif->rq; |
71 | int error; | ||
72 | 70 | ||
73 | ide_debug_log(IDE_DBG_FUNC, "enter"); | 71 | ide_debug_log(IDE_DBG_FUNC, "enter"); |
74 | 72 | ||
75 | switch (uptodate) { | 73 | if (uptodate == 0) |
76 | case 0: | ||
77 | error = IDE_DRV_ERROR_GENERAL; | ||
78 | break; | ||
79 | |||
80 | case 1: | ||
81 | error = 0; | ||
82 | break; | ||
83 | |||
84 | default: | ||
85 | error = uptodate; | ||
86 | } | ||
87 | |||
88 | if (error) | ||
89 | drive->failed_pc = NULL; | 74 | drive->failed_pc = NULL; |
90 | 75 | ||
91 | if (!blk_special_request(rq)) { | 76 | rq->errors = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; |
92 | /* our real local end request function */ | 77 | |
93 | ide_end_request(drive, uptodate, nsecs); | ||
94 | return 0; | ||
95 | } | ||
96 | rq->errors = error; | ||
97 | /* fixme: need to move this local also */ | ||
98 | ide_complete_rq(drive, 0); | 78 | ide_complete_rq(drive, 0); |
79 | |||
99 | return 0; | 80 | return 0; |
100 | } | 81 | } |
101 | 82 | ||
@@ -106,13 +87,14 @@ static void idefloppy_update_buffers(ide_drive_t *drive, | |||
106 | struct bio *bio = rq->bio; | 87 | struct bio *bio = rq->bio; |
107 | 88 | ||
108 | while ((bio = rq->bio) != NULL) | 89 | while ((bio = rq->bio) != NULL) |
109 | ide_floppy_end_request(drive, 1, 0); | 90 | ide_end_request(drive, 1, 0); |
110 | } | 91 | } |
111 | 92 | ||
112 | static void ide_floppy_callback(ide_drive_t *drive, int dsc) | 93 | static void ide_floppy_callback(ide_drive_t *drive, int dsc) |
113 | { | 94 | { |
114 | struct ide_disk_obj *floppy = drive->driver_data; | 95 | struct ide_disk_obj *floppy = drive->driver_data; |
115 | struct ide_atapi_pc *pc = drive->pc; | 96 | struct ide_atapi_pc *pc = drive->pc; |
97 | struct request *rq = pc->rq; | ||
116 | int uptodate = pc->error ? 0 : 1; | 98 | int uptodate = pc->error ? 0 : 1; |
117 | 99 | ||
118 | ide_debug_log(IDE_DBG_FUNC, "enter"); | 100 | ide_debug_log(IDE_DBG_FUNC, "enter"); |
@@ -121,7 +103,7 @@ static void ide_floppy_callback(ide_drive_t *drive, int dsc) | |||
121 | drive->failed_pc = NULL; | 103 | drive->failed_pc = NULL; |
122 | 104 | ||
123 | if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 || | 105 | if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 || |
124 | (pc->rq && blk_pc_request(pc->rq))) | 106 | (rq && blk_pc_request(rq))) |
125 | uptodate = 1; /* FIXME */ | 107 | uptodate = 1; /* FIXME */ |
126 | else if (pc->c[0] == GPCMD_REQUEST_SENSE) { | 108 | else if (pc->c[0] == GPCMD_REQUEST_SENSE) { |
127 | u8 *buf = pc->buf; | 109 | u8 *buf = pc->buf; |
@@ -145,7 +127,14 @@ static void ide_floppy_callback(ide_drive_t *drive, int dsc) | |||
145 | "Aborting request!\n"); | 127 | "Aborting request!\n"); |
146 | } | 128 | } |
147 | 129 | ||
148 | ide_floppy_end_request(drive, uptodate, 0); | 130 | if (uptodate == 0) |
131 | drive->failed_pc = NULL; | ||
132 | |||
133 | if (blk_special_request(rq)) { | ||
134 | rq->errors = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; | ||
135 | ide_complete_rq(drive, 0); | ||
136 | } else | ||
137 | ide_end_request(drive, uptodate, 0); | ||
149 | } | 138 | } |
150 | 139 | ||
151 | static void ide_floppy_report_error(struct ide_disk_obj *floppy, | 140 | static void ide_floppy_report_error(struct ide_disk_obj *floppy, |
@@ -286,21 +275,25 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | |||
286 | : "dev?")); | 275 | : "dev?")); |
287 | 276 | ||
288 | if (rq->errors >= ERROR_MAX) { | 277 | if (rq->errors >= ERROR_MAX) { |
289 | if (drive->failed_pc) | 278 | if (drive->failed_pc) { |
290 | ide_floppy_report_error(floppy, drive->failed_pc); | 279 | ide_floppy_report_error(floppy, drive->failed_pc); |
291 | else | 280 | drive->failed_pc = NULL; |
281 | } else | ||
292 | printk(KERN_ERR PFX "%s: I/O error\n", drive->name); | 282 | printk(KERN_ERR PFX "%s: I/O error\n", drive->name); |
293 | 283 | ||
294 | ide_floppy_end_request(drive, 0, 0); | 284 | if (blk_special_request(rq)) { |
295 | return ide_stopped; | 285 | rq->errors = IDE_DRV_ERROR_GENERAL; |
286 | ide_complete_rq(drive, 0); | ||
287 | return ide_stopped; | ||
288 | } else | ||
289 | goto out_end; | ||
296 | } | 290 | } |
297 | if (blk_fs_request(rq)) { | 291 | if (blk_fs_request(rq)) { |
298 | if (((long)rq->sector % floppy->bs_factor) || | 292 | if (((long)rq->sector % floppy->bs_factor) || |
299 | (rq->nr_sectors % floppy->bs_factor)) { | 293 | (rq->nr_sectors % floppy->bs_factor)) { |
300 | printk(KERN_ERR PFX "%s: unsupported r/w rq size\n", | 294 | printk(KERN_ERR PFX "%s: unsupported r/w rq size\n", |
301 | drive->name); | 295 | drive->name); |
302 | ide_floppy_end_request(drive, 0, 0); | 296 | goto out_end; |
303 | return ide_stopped; | ||
304 | } | 297 | } |
305 | pc = &floppy->queued_pc; | 298 | pc = &floppy->queued_pc; |
306 | idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block); | 299 | idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block); |
@@ -311,8 +304,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | |||
311 | idefloppy_blockpc_cmd(floppy, pc, rq); | 304 | idefloppy_blockpc_cmd(floppy, pc, rq); |
312 | } else { | 305 | } else { |
313 | blk_dump_rq_flags(rq, PFX "unsupported command in queue"); | 306 | blk_dump_rq_flags(rq, PFX "unsupported command in queue"); |
314 | ide_floppy_end_request(drive, 0, 0); | 307 | goto out_end; |
315 | return ide_stopped; | ||
316 | } | 308 | } |
317 | 309 | ||
318 | if (blk_fs_request(rq) || pc->req_xfer) { | 310 | if (blk_fs_request(rq) || pc->req_xfer) { |
@@ -326,6 +318,10 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive, | |||
326 | pc->rq = rq; | 318 | pc->rq = rq; |
327 | 319 | ||
328 | return idefloppy_issue_pc(drive, pc); | 320 | return idefloppy_issue_pc(drive, pc); |
321 | out_end: | ||
322 | drive->failed_pc = NULL; | ||
323 | ide_end_request(drive, 0, 0); | ||
324 | return ide_stopped; | ||
329 | } | 325 | } |
330 | 326 | ||
331 | /* | 327 | /* |