aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:45 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:45 -0400
commit130e886708d6e11f3d54e5d27c266578de56f343 (patch)
treeaf6c09224bd1aa21119c052cd3664719916ec795
parentba7d479c36dde12821c01ad0696d678635b8fb92 (diff)
ide: remove ide_end_request()
* Add ide_rq_bytes() helper. * Add blk_noretry_request() quirk to ide_complete_rq() (currently only fs requests can be marked as "noretry" so there is no change in behavior). * Switch current ide_end_request() users to use ide_complete_rq(). [ No need to check for rq->nr_sectors == 0 in {ide_dma,task_pio}_intr(), nsectors == 0 in cdrom_end_request() and err == 0 in ide_do_devset(). ] * Remove no longer needed ide_end_request(). There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r--drivers/ide/ide-atapi.c6
-rw-r--r--drivers/ide/ide-cd.c7
-rw-r--r--drivers/ide/ide-devsets.c4
-rw-r--r--drivers/ide/ide-disk.c2
-rw-r--r--drivers/ide/ide-dma.c3
-rw-r--r--drivers/ide/ide-eh.c2
-rw-r--r--drivers/ide/ide-floppy.c4
-rw-r--r--drivers/ide/ide-io.c61
-rw-r--r--drivers/ide/ide-tape.c2
-rw-r--r--drivers/ide/ide-taskfile.c4
-rw-r--r--include/linux/ide.h2
11 files changed, 37 insertions, 60 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 30156aa61016..c3fd528a1b4d 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -410,7 +410,8 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
410 if (rq->errors == 0) 410 if (rq->errors == 0)
411 rq->errors = -EIO; 411 rq->errors = -EIO;
412 } 412 }
413 ide_end_request(drive, uptodate, 0); 413 ide_complete_rq(drive, uptodate ? 0 : -EIO,
414 ide_rq_bytes(rq));
414 } 415 }
415 416
416 return ide_stopped; 417 return ide_stopped;
@@ -469,7 +470,8 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
469 470
470 /* FIXME: don't do partial completions */ 471 /* FIXME: don't do partial completions */
471 if (drive->media == ide_floppy) 472 if (drive->media == ide_floppy)
472 ide_end_request(drive, 1, done >> 9); 473 ide_complete_rq(drive, 0,
474 done ? done : ide_rq_bytes(rq));
473 } else 475 } else
474 xferfunc(drive, NULL, pc->cur_pos, bcount); 476 xferfunc(drive, NULL, pc->cur_pos, bcount);
475 477
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index e4fa807fdcfa..2f698c6e913f 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -298,7 +298,7 @@ static void cdrom_end_request(ide_drive_t *drive, int uptodate)
298 if (blk_fs_request(rq) == 0 && uptodate <= 0 && rq->errors == 0) 298 if (blk_fs_request(rq) == 0 && uptodate <= 0 && rq->errors == 0)
299 rq->errors = -EIO; 299 rq->errors = -EIO;
300 300
301 ide_end_request(drive, uptodate, nsectors); 301 ide_complete_rq(drive, uptodate ? 0 : -EIO, nsectors << 9);
302} 302}
303 303
304static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st) 304static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st)
@@ -793,10 +793,11 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
793 if (dma_error) 793 if (dma_error)
794 return ide_error(drive, "dma error", stat); 794 return ide_error(drive, "dma error", stat);
795 if (blk_fs_request(rq)) { 795 if (blk_fs_request(rq)) {
796 ide_end_request(drive, 1, rq->nr_sectors); 796 ide_complete_rq(drive, 0, rq->nr_sectors
797 ? (rq->nr_sectors << 9) : ide_rq_bytes(rq));
797 return ide_stopped; 798 return ide_stopped;
798 } else if (rq->cmd_type == REQ_TYPE_ATA_PC && !rq->bio) { 799 } else if (rq->cmd_type == REQ_TYPE_ATA_PC && !rq->bio) {
799 ide_end_request(drive, 1, 1); 800 ide_complete_rq(drive, 0, 512);
800 return ide_stopped; 801 return ide_stopped;
801 } 802 }
802 goto end_request; 803 goto end_request;
diff --git a/drivers/ide/ide-devsets.c b/drivers/ide/ide-devsets.c
index 7c3953414d47..5bf958e5b1d5 100644
--- a/drivers/ide/ide-devsets.c
+++ b/drivers/ide/ide-devsets.c
@@ -183,8 +183,6 @@ ide_startstop_t ide_do_devset(ide_drive_t *drive, struct request *rq)
183 err = setfunc(drive, *(int *)&rq->cmd[1]); 183 err = setfunc(drive, *(int *)&rq->cmd[1]);
184 if (err) 184 if (err)
185 rq->errors = err; 185 rq->errors = err;
186 else 186 ide_complete_rq(drive, err, ide_rq_bytes(rq));
187 err = 1;
188 ide_end_request(drive, err, 0);
189 return ide_stopped; 187 return ide_stopped;
190} 188}
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index ad9a3f54d21d..d8caa65ca7a5 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -186,7 +186,7 @@ static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
186 blk_dump_rq_flags(rq, "ide_do_rw_disk - bad command"); 186 blk_dump_rq_flags(rq, "ide_do_rw_disk - bad command");
187 if (rq->errors == 0) 187 if (rq->errors == 0)
188 rq->errors = -EIO; 188 rq->errors = -EIO;
189 ide_end_request(drive, 0, 0); 189 ide_complete_rq(drive, -EIO, ide_rq_bytes(rq));
190 return ide_stopped; 190 return ide_stopped;
191 } 191 }
192 192
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 820e5104ba47..8f5e32e692f0 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -101,7 +101,8 @@ ide_startstop_t ide_dma_intr(ide_drive_t *drive)
101 if ((cmd->tf_flags & IDE_TFLAG_FS) == 0) 101 if ((cmd->tf_flags & IDE_TFLAG_FS) == 0)
102 ide_finish_cmd(drive, cmd, stat); 102 ide_finish_cmd(drive, cmd, stat);
103 else 103 else
104 ide_end_request(drive, 1, cmd->rq->nr_sectors); 104 ide_complete_rq(drive, 0,
105 cmd->rq->nr_sectors << 9);
105 return ide_stopped; 106 return ide_stopped;
106 } 107 }
107 printk(KERN_ERR "%s: %s: bad DMA status (0x%02x)\n", 108 printk(KERN_ERR "%s: %s: bad DMA status (0x%02x)\n",
diff --git a/drivers/ide/ide-eh.c b/drivers/ide/ide-eh.c
index ccfd06ef5bb9..aff1a9b04559 100644
--- a/drivers/ide/ide-eh.c
+++ b/drivers/ide/ide-eh.c
@@ -149,7 +149,7 @@ static inline void ide_complete_drive_reset(ide_drive_t *drive, int err)
149 if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET) { 149 if (rq && blk_special_request(rq) && rq->cmd[0] == REQ_DRIVE_RESET) {
150 if (err <= 0 && rq->errors == 0) 150 if (err <= 0 && rq->errors == 0)
151 rq->errors = -EIO; 151 rq->errors = -EIO;
152 ide_end_request(drive, err ? err : 1, 0); 152 ide_complete_rq(drive, err ? err : 0, ide_rq_bytes(rq));
153 } 153 }
154} 154}
155 155
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 7ef2b90e530a..8c518c6a6477 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -68,7 +68,7 @@ static void idefloppy_update_buffers(ide_drive_t *drive,
68 struct bio *bio = rq->bio; 68 struct bio *bio = rq->bio;
69 69
70 while ((bio = rq->bio) != NULL) 70 while ((bio = rq->bio) != NULL)
71 ide_end_request(drive, 1, 0); 71 ide_complete_rq(drive, 0, ide_rq_bytes(rq));
72} 72}
73 73
74static int ide_floppy_callback(ide_drive_t *drive, int dsc) 74static int ide_floppy_callback(ide_drive_t *drive, int dsc)
@@ -300,7 +300,7 @@ out_end:
300 drive->failed_pc = NULL; 300 drive->failed_pc = NULL;
301 if (blk_fs_request(rq) == 0 && rq->errors == 0) 301 if (blk_fs_request(rq) == 0 && rq->errors == 0)
302 rq->errors = -EIO; 302 rq->errors = -EIO;
303 ide_end_request(drive, 0, 0); 303 ide_complete_rq(drive, -EIO, ide_rq_bytes(rq));
304 return ide_stopped; 304 return ide_stopped;
305} 305}
306 306
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 8e2868617a46..f59c709052d2 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -71,48 +71,6 @@ int ide_end_rq(ide_drive_t *drive, struct request *rq, int error,
71} 71}
72EXPORT_SYMBOL_GPL(ide_end_rq); 72EXPORT_SYMBOL_GPL(ide_end_rq);
73 73
74/**
75 * ide_end_request - complete an IDE I/O
76 * @drive: IDE device for the I/O
77 * @uptodate:
78 * @nr_sectors: number of sectors completed
79 *
80 * This is our end_request wrapper function. We complete the I/O
81 * update random number input and dequeue the request, which if
82 * it was tagged may be out of order.
83 */
84
85int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors)
86{
87 unsigned int nr_bytes = nr_sectors << 9;
88 struct request *rq = drive->hwif->rq;
89 int rc, error = 0;
90
91 if (!nr_bytes) {
92 if (blk_pc_request(rq))
93 nr_bytes = rq->data_len;
94 else
95 nr_bytes = rq->hard_cur_sectors << 9;
96 }
97
98 /*
99 * if failfast is set on a request, override number of sectors
100 * and complete the whole request right now
101 */
102 if (blk_noretry_request(rq) && uptodate <= 0)
103 nr_bytes = rq->hard_nr_sectors << 9;
104
105 if (uptodate <= 0)
106 error = uptodate ? uptodate : -EIO;
107
108 rc = ide_end_rq(drive, rq, error, nr_bytes);
109 if (rc == 0)
110 drive->hwif->rq = NULL;
111
112 return rc;
113}
114EXPORT_SYMBOL(ide_end_request);
115
116void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err) 74void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
117{ 75{
118 struct ide_taskfile *tf = &cmd->tf; 76 struct ide_taskfile *tf = &cmd->tf;
@@ -141,12 +99,29 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
141 kfree(cmd); 99 kfree(cmd);
142} 100}
143 101
102/* obsolete, blk_rq_bytes() should be used instead */
103unsigned int ide_rq_bytes(struct request *rq)
104{
105 if (blk_pc_request(rq))
106 return rq->data_len;
107 else
108 return rq->hard_cur_sectors << 9;
109}
110EXPORT_SYMBOL_GPL(ide_rq_bytes);
111
144int ide_complete_rq(ide_drive_t *drive, int error, unsigned int nr_bytes) 112int ide_complete_rq(ide_drive_t *drive, int error, unsigned int nr_bytes)
145{ 113{
146 ide_hwif_t *hwif = drive->hwif; 114 ide_hwif_t *hwif = drive->hwif;
147 struct request *rq = hwif->rq; 115 struct request *rq = hwif->rq;
148 int rc; 116 int rc;
149 117
118 /*
119 * if failfast is set on a request, override number of sectors
120 * and complete the whole request right now
121 */
122 if (blk_noretry_request(rq) && error <= 0)
123 nr_bytes = rq->hard_nr_sectors << 9;
124
150 rc = ide_end_rq(drive, rq, error, nr_bytes); 125 rc = ide_end_rq(drive, rq, error, nr_bytes);
151 if (rc == 0) 126 if (rc == 0)
152 hwif->rq = NULL; 127 hwif->rq = NULL;
@@ -170,7 +145,7 @@ void ide_kill_rq(ide_drive_t *drive, struct request *rq)
170 rq->errors = IDE_DRV_ERROR_GENERAL; 145 rq->errors = IDE_DRV_ERROR_GENERAL;
171 else if (blk_fs_request(rq) == 0 && rq->errors == 0) 146 else if (blk_fs_request(rq) == 0 && rq->errors == 0)
172 rq->errors = -EIO; 147 rq->errors = -EIO;
173 ide_end_request(drive, 0, 0); 148 ide_complete_rq(drive, -EIO, ide_rq_bytes(rq));
174 } 149 }
175} 150}
176 151
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 2df708927687..853d047aa78f 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -762,7 +762,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
762 "request queue (%d)\n", drive->name, rq->cmd_type); 762 "request queue (%d)\n", drive->name, rq->cmd_type);
763 if (blk_fs_request(rq) == 0 && rq->errors == 0) 763 if (blk_fs_request(rq) == 0 && rq->errors == 0)
764 rq->errors = -EIO; 764 rq->errors = -EIO;
765 ide_end_request(drive, 0, 0); 765 ide_complete_rq(drive, -EIO, ide_rq_bytes(rq));
766 return ide_stopped; 766 return ide_stopped;
767 } 767 }
768 768
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index b9d7ba2c8a00..db6d7821e45b 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -283,7 +283,7 @@ static void ide_error_cmd(ide_drive_t *drive, struct ide_cmd *cmd)
283 } 283 }
284 284
285 if (sectors > 0) 285 if (sectors > 0)
286 ide_end_request(drive, 1, sectors); 286 ide_complete_rq(drive, 0, sectors << 9);
287 } 287 }
288} 288}
289 289
@@ -352,7 +352,7 @@ out_end:
352 if ((cmd->tf_flags & IDE_TFLAG_FS) == 0) 352 if ((cmd->tf_flags & IDE_TFLAG_FS) == 0)
353 ide_finish_cmd(drive, cmd, stat); 353 ide_finish_cmd(drive, cmd, stat);
354 else 354 else
355 ide_end_request(drive, 1, cmd->rq->nr_sectors); 355 ide_complete_rq(drive, 0, cmd->rq->nr_sectors << 9);
356 return ide_stopped; 356 return ide_stopped;
357out_err: 357out_err:
358 ide_error_cmd(drive, cmd); 358 ide_error_cmd(drive, cmd);
diff --git a/include/linux/ide.h b/include/linux/ide.h
index cbfb64fdeda7..b6142171baf0 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1131,8 +1131,8 @@ int generic_ide_ioctl(ide_drive_t *, struct block_device *, unsigned, unsigned l
1131extern int ide_vlb_clk; 1131extern int ide_vlb_clk;
1132extern int ide_pci_clk; 1132extern int ide_pci_clk;
1133 1133
1134unsigned int ide_rq_bytes(struct request *);
1134int ide_end_rq(ide_drive_t *, struct request *, int, unsigned int); 1135int ide_end_rq(ide_drive_t *, struct request *, int, unsigned int);
1135int ide_end_request(ide_drive_t *, int, int);
1136void ide_kill_rq(ide_drive_t *, struct request *); 1136void ide_kill_rq(ide_drive_t *, struct request *);
1137 1137
1138void __ide_set_handler(ide_drive_t *, ide_handler_t *, unsigned int, 1138void __ide_set_handler(ide_drive_t *, ide_handler_t *, unsigned int,