aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-taskfile.c
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 /drivers/ide/ide-taskfile.c
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>
Diffstat (limited to 'drivers/ide/ide-taskfile.c')
-rw-r--r--drivers/ide/ide-taskfile.c32
1 files changed, 16 insertions, 16 deletions
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