aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:47 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:47 -0400
commitbf717c0a2e18dbe82eeb28e57b0abede3cdf45d6 (patch)
tree98d209372f0fed08fca6c4936677ee09cf435209
parent35b5d0be3d8de9a5ac51471c12029fb115200cdc (diff)
ide: keep track of number of bytes instead of sectors in struct ide_cmd
* Pass number of bytes instead of sectors to ide_init_sg_cmd(). * Pass number of bytes to process to ide_pio_sector() and rename it to ide_pio_bytes(). * Rename ->nsect field to ->nbytes in struct ide_cmd and use ->nbytes, ->nleft and ->cursg_ofs to keep track of number of bytes instead of sectors. 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>
-rw-r--r--drivers/ide/ide-disk.c4
-rw-r--r--drivers/ide/ide-floppy.c2
-rw-r--r--drivers/ide/ide-io.c6
-rw-r--r--drivers/ide/ide-taskfile.c32
-rw-r--r--include/linux/ide.h4
5 files changed, 24 insertions, 24 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 4b32c4eb7b82..ca934c8a1289 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -152,7 +152,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
152 cmd.rq = rq; 152 cmd.rq = rq;
153 153
154 if (dma == 0) { 154 if (dma == 0) {
155 ide_init_sg_cmd(&cmd, nsectors); 155 ide_init_sg_cmd(&cmd, nsectors << 9);
156 ide_map_sg(drive, &cmd); 156 ide_map_sg(drive, &cmd);
157 } 157 }
158 158
@@ -162,7 +162,7 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
162 /* fallback to PIO */ 162 /* fallback to PIO */
163 cmd.tf_flags |= IDE_TFLAG_DMA_PIO_FALLBACK; 163 cmd.tf_flags |= IDE_TFLAG_DMA_PIO_FALLBACK;
164 ide_tf_set_cmd(drive, &cmd, 0); 164 ide_tf_set_cmd(drive, &cmd, 0);
165 ide_init_sg_cmd(&cmd, nsectors); 165 ide_init_sg_cmd(&cmd, nsectors << 9);
166 rc = do_rw_taskfile(drive, &cmd); 166 rc = do_rw_taskfile(drive, &cmd);
167 } 167 }
168 168
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index f3ed5de3141b..7ae662334835 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -294,7 +294,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
294 cmd.rq = rq; 294 cmd.rq = rq;
295 295
296 if (blk_fs_request(rq) || pc->req_xfer) { 296 if (blk_fs_request(rq) || pc->req_xfer) {
297 ide_init_sg_cmd(&cmd, rq->nr_sectors); 297 ide_init_sg_cmd(&cmd, rq->nr_sectors << 9);
298 ide_map_sg(drive, &cmd); 298 ide_map_sg(drive, &cmd);
299 } 299 }
300 300
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index b4901b690c9a..1adc5e2e7fb3 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -245,9 +245,9 @@ void ide_map_sg(ide_drive_t *drive, struct ide_cmd *cmd)
245} 245}
246EXPORT_SYMBOL_GPL(ide_map_sg); 246EXPORT_SYMBOL_GPL(ide_map_sg);
247 247
248void ide_init_sg_cmd(struct ide_cmd *cmd, int nsect) 248void ide_init_sg_cmd(struct ide_cmd *cmd, unsigned int nr_bytes)
249{ 249{
250 cmd->nsect = cmd->nleft = nsect; 250 cmd->nbytes = cmd->nleft = nr_bytes;
251 cmd->cursg_ofs = 0; 251 cmd->cursg_ofs = 0;
252 cmd->cursg = NULL; 252 cmd->cursg = NULL;
253} 253}
@@ -272,7 +272,7 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive,
272 272
273 if (cmd) { 273 if (cmd) {
274 if (cmd->protocol == ATA_PROT_PIO) { 274 if (cmd->protocol == ATA_PROT_PIO) {
275 ide_init_sg_cmd(cmd, rq->nr_sectors); 275 ide_init_sg_cmd(cmd, rq->nr_sectors << 9);
276 ide_map_sg(drive, cmd); 276 ide_map_sg(drive, cmd);
277 } 277 }
278 278
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 329fd6f13f79..84532be97c00 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -188,8 +188,8 @@ static u8 wait_drive_not_busy(ide_drive_t *drive)
188 return stat; 188 return stat;
189} 189}
190 190
191static void ide_pio_sector(ide_drive_t *drive, struct ide_cmd *cmd, 191static void ide_pio_bytes(ide_drive_t *drive, struct ide_cmd *cmd,
192 unsigned int write) 192 unsigned int write, unsigned int nr_bytes)
193{ 193{
194 ide_hwif_t *hwif = drive->hwif; 194 ide_hwif_t *hwif = drive->hwif;
195 struct scatterlist *sg = hwif->sg_table; 195 struct scatterlist *sg = hwif->sg_table;
@@ -208,7 +208,7 @@ static void ide_pio_sector(ide_drive_t *drive, struct ide_cmd *cmd,
208 } 208 }
209 209
210 page = sg_page(cursg); 210 page = sg_page(cursg);
211 offset = cursg->offset + cmd->cursg_ofs * SECTOR_SIZE; 211 offset = cursg->offset + cmd->cursg_ofs;
212 212
213 /* get the current page and offset */ 213 /* get the current page and offset */
214 page = nth_page(page, (offset >> PAGE_SHIFT)); 214 page = nth_page(page, (offset >> PAGE_SHIFT));
@@ -219,19 +219,19 @@ static void ide_pio_sector(ide_drive_t *drive, struct ide_cmd *cmd,
219#endif 219#endif
220 buf = kmap_atomic(page, KM_BIO_SRC_IRQ) + offset; 220 buf = kmap_atomic(page, KM_BIO_SRC_IRQ) + offset;
221 221
222 cmd->nleft--; 222 cmd->nleft -= nr_bytes;
223 cmd->cursg_ofs++; 223 cmd->cursg_ofs += nr_bytes;
224 224
225 if ((cmd->cursg_ofs * SECTOR_SIZE) == cursg->length) { 225 if (cmd->cursg_ofs == cursg->length) {
226 cmd->cursg = sg_next(cmd->cursg); 226 cmd->cursg = sg_next(cmd->cursg);
227 cmd->cursg_ofs = 0; 227 cmd->cursg_ofs = 0;
228 } 228 }
229 229
230 /* do the actual data transfer */ 230 /* do the actual data transfer */
231 if (write) 231 if (write)
232 hwif->tp_ops->output_data(drive, cmd, buf, SECTOR_SIZE); 232 hwif->tp_ops->output_data(drive, cmd, buf, nr_bytes);
233 else 233 else
234 hwif->tp_ops->input_data(drive, cmd, buf, SECTOR_SIZE); 234 hwif->tp_ops->input_data(drive, cmd, buf, nr_bytes);
235 235
236 kunmap_atomic(buf, KM_BIO_SRC_IRQ); 236 kunmap_atomic(buf, KM_BIO_SRC_IRQ);
237#ifdef CONFIG_HIGHMEM 237#ifdef CONFIG_HIGHMEM
@@ -244,9 +244,9 @@ static void ide_pio_multi(ide_drive_t *drive, struct ide_cmd *cmd,
244{ 244{
245 unsigned int nsect; 245 unsigned int nsect;
246 246
247 nsect = min_t(unsigned int, cmd->nleft, drive->mult_count); 247 nsect = min_t(unsigned int, cmd->nleft >> 9, drive->mult_count);
248 while (nsect--) 248 while (nsect--)
249 ide_pio_sector(drive, cmd, write); 249 ide_pio_bytes(drive, cmd, write, SECTOR_SIZE);
250} 250}
251 251
252static void ide_pio_datablock(ide_drive_t *drive, struct ide_cmd *cmd, 252static void ide_pio_datablock(ide_drive_t *drive, struct ide_cmd *cmd,
@@ -265,7 +265,7 @@ static void ide_pio_datablock(ide_drive_t *drive, struct ide_cmd *cmd,
265 if (cmd->tf_flags & IDE_TFLAG_MULTI_PIO) 265 if (cmd->tf_flags & IDE_TFLAG_MULTI_PIO)
266 ide_pio_multi(drive, cmd, write); 266 ide_pio_multi(drive, cmd, write);
267 else 267 else
268 ide_pio_sector(drive, cmd, write); 268 ide_pio_bytes(drive, cmd, write, SECTOR_SIZE);
269 269
270 drive->io_32bit = saved_io_32bit; 270 drive->io_32bit = saved_io_32bit;
271} 271}
@@ -273,18 +273,18 @@ static void ide_pio_datablock(ide_drive_t *drive, struct ide_cmd *cmd,
273static void ide_error_cmd(ide_drive_t *drive, struct ide_cmd *cmd) 273static void ide_error_cmd(ide_drive_t *drive, struct ide_cmd *cmd)
274{ 274{
275 if (cmd->tf_flags & IDE_TFLAG_FS) { 275 if (cmd->tf_flags & IDE_TFLAG_FS) {
276 int sectors = cmd->nsect - cmd->nleft; 276 int nr_bytes = cmd->nbytes - cmd->nleft;
277 277
278 if (cmd->protocol == ATA_PROT_PIO && 278 if (cmd->protocol == ATA_PROT_PIO &&
279 ((cmd->tf_flags & IDE_TFLAG_WRITE) || cmd->nleft == 0)) { 279 ((cmd->tf_flags & IDE_TFLAG_WRITE) || cmd->nleft == 0)) {
280 if (cmd->tf_flags & IDE_TFLAG_MULTI_PIO) 280 if (cmd->tf_flags & IDE_TFLAG_MULTI_PIO)
281 sectors -= drive->mult_count; 281 nr_bytes -= drive->mult_count << 9;
282 else 282 else
283 sectors--; 283 nr_bytes -= SECTOR_SIZE;
284 } 284 }
285 285
286 if (sectors > 0) 286 if (nr_bytes > 0)
287 ide_complete_rq(drive, 0, sectors << 9); 287 ide_complete_rq(drive, 0, nr_bytes);
288 } 288 }
289} 289}
290 290
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 2d0c7afd5e58..d5d832271f44 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -350,7 +350,7 @@ struct ide_cmd {
350 int orig_sg_nents; 350 int orig_sg_nents;
351 int sg_dma_direction; /* DMA transfer direction */ 351 int sg_dma_direction; /* DMA transfer direction */
352 352
353 unsigned int nsect; 353 unsigned int nbytes;
354 unsigned int nleft; 354 unsigned int nleft;
355 struct scatterlist *cursg; 355 struct scatterlist *cursg;
356 unsigned int cursg_ofs; 356 unsigned int cursg_ofs;
@@ -1409,7 +1409,7 @@ int ide_pci_resume(struct pci_dev *);
1409#endif 1409#endif
1410 1410
1411void ide_map_sg(ide_drive_t *, struct ide_cmd *); 1411void ide_map_sg(ide_drive_t *, struct ide_cmd *);
1412void ide_init_sg_cmd(struct ide_cmd *, int); 1412void ide_init_sg_cmd(struct ide_cmd *, unsigned int);
1413 1413
1414#define BAD_DMA_DRIVE 0 1414#define BAD_DMA_DRIVE 0
1415#define GOOD_DMA_DRIVE 1 1415#define GOOD_DMA_DRIVE 1