Skip to content

Commit adb1af9

Browse files
committed
ide: pass command instead of request to ide_pio_datablock()
* Add IDE_TFLAG_FS taskfile flag and set it for REQ_TYPE_FS requests. * Convert ->{in,out}put_data methods to take command instead of request as an argument. Then convert pre_task_out_intr(), task_end_request(), task_error(), task_in_unexpected(), ide_pio_sector(), ide_pio_multi() and ide_pio_datablock() in similar way. * Rename task_end_request() to ide_finish_cmd(). There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent 22aa4b3 commit adb1af9

12 files changed

Lines changed: 76 additions & 75 deletions

File tree

‎drivers/ide/at91_ide.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static void apply_timings(const u8 chipselect, const u8 pio,
143143
set_smc_timings(chipselect, cycle, setup, pulse, data_float, use_iordy);
144144
}
145145

146-
static void at91_ide_input_data(ide_drive_t *drive, struct request *rq,
146+
static void at91_ide_input_data(ide_drive_t *drive, struct ide_cmd *cmd,
147147
void *buf, unsigned int len)
148148
{
149149
ide_hwif_t *hwif = drive->hwif;
@@ -160,7 +160,7 @@ static void at91_ide_input_data(ide_drive_t *drive, struct request *rq,
160160
leave_16bit(chipselect, mode);
161161
}
162162

163-
static void at91_ide_output_data(ide_drive_t *drive, struct request *rq,
163+
static void at91_ide_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
164164
void *buf, unsigned int len)
165165
{
166166
ide_hwif_t *hwif = drive->hwif;

‎drivers/ide/au1xxx-ide.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ void auide_outsw(unsigned long port, void *addr, u32 count)
8686
ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
8787
}
8888

89-
static void au1xxx_input_data(ide_drive_t *drive, struct request *rq,
89+
static void au1xxx_input_data(ide_drive_t *drive, struct ide_cmd *cmd,
9090
void *buf, unsigned int len)
9191
{
9292
auide_insw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);
9393
}
9494

95-
static void au1xxx_output_data(ide_drive_t *drive, struct request *rq,
95+
static void au1xxx_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
9696
void *buf, unsigned int len)
9797
{
9898
auide_outsw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);

‎drivers/ide/falconide.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,23 @@ static void falconide_get_lock(irq_handler_t handler, void *data)
6262
}
6363
}
6464

65-
static void falconide_input_data(ide_drive_t *drive, struct request *rq,
65+
static void falconide_input_data(ide_drive_t *drive, struct ide_cmd *cmd,
6666
void *buf, unsigned int len)
6767
{
6868
unsigned long data_addr = drive->hwif->io_ports.data_addr;
6969

70-
if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS)
70+
if (drive->media == ide_disk && cmd && (cmd->tf_flags & IDE_TFLAG_FS))
7171
return insw(data_addr, buf, (len + 1) / 2);
7272

7373
raw_insw_swapw((u16 *)data_addr, buf, (len + 1) / 2);
7474
}
7575

76-
static void falconide_output_data(ide_drive_t *drive, struct request *rq,
76+
static void falconide_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
7777
void *buf, unsigned int len)
7878
{
7979
unsigned long data_addr = drive->hwif->io_ports.data_addr;
8080

81-
if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS)
81+
if (drive->media == ide_disk && cmd && (cmd->tf_flags & IDE_TFLAG_FS))
8282
return outsw(data_addr, buf, (len + 1) / 2);
8383

8484
raw_outsw_swapw((u16 *)data_addr, buf, (len + 1) / 2);

‎drivers/ide/ide-disk.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ static ide_startstop_t __ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
156156
tf->device = head;
157157
}
158158

159+
cmd.tf_flags |= IDE_TFLAG_FS;
160+
159161
if (rq_data_dir(rq))
160162
cmd.tf_flags |= IDE_TFLAG_WRITE;
161163

‎drivers/ide/ide-dma.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ ide_startstop_t ide_dma_intr(ide_drive_t *drive)
9696

9797
if (OK_STAT(stat, DRIVE_READY, drive->bad_wstat | ATA_DRQ)) {
9898
if (!dma_stat) {
99-
struct request *rq = hwif->rq;
99+
struct ide_cmd *cmd = &hwif->cmd;
100100

101-
task_end_request(drive, rq, stat);
101+
ide_finish_cmd(drive, cmd, stat);
102102
return ide_stopped;
103103
}
104104
printk(KERN_ERR "%s: %s: bad DMA status (0x%02x)\n",

‎drivers/ide/ide-h8300.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ static void mm_insw(unsigned long addr, void *buf, u32 len)
143143
*bp = bswap(*(volatile u16 *)addr);
144144
}
145145

146-
static void h8300_input_data(ide_drive_t *drive, struct request *rq,
146+
static void h8300_input_data(ide_drive_t *drive, struct ide_cmd *cmd,
147147
void *buf, unsigned int len)
148148
{
149149
mm_insw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);
150150
}
151151

152-
static void h8300_output_data(ide_drive_t *drive, struct request *rq,
152+
static void h8300_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
153153
void *buf, unsigned int len)
154154
{
155155
mm_outsw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2);

‎drivers/ide/ide-io-std.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static void ata_vlb_sync(unsigned long port)
219219
* so if an odd len is specified, be sure that there's at least one
220220
* extra byte allocated for the buffer.
221221
*/
222-
void ide_input_data(ide_drive_t *drive, struct request *rq, void *buf,
222+
void ide_input_data(ide_drive_t *drive, struct ide_cmd *cmd, void *buf,
223223
unsigned int len)
224224
{
225225
ide_hwif_t *hwif = drive->hwif;
@@ -265,7 +265,7 @@ EXPORT_SYMBOL_GPL(ide_input_data);
265265
/*
266266
* This is used for most PIO data transfers *to* the IDE interface
267267
*/
268-
void ide_output_data(ide_drive_t *drive, struct request *rq, void *buf,
268+
void ide_output_data(ide_drive_t *drive, struct ide_cmd *cmd, void *buf,
269269
unsigned int len)
270270
{
271271
ide_hwif_t *hwif = drive->hwif;

‎drivers/ide/ide-taskfile.c‎

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,31 @@ int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf)
5454
}
5555

5656
static ide_startstop_t task_no_data_intr(ide_drive_t *);
57-
static ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *);
57+
static ide_startstop_t pre_task_out_intr(ide_drive_t *, struct ide_cmd *);
5858
static ide_startstop_t task_in_intr(ide_drive_t *);
5959

60-
ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd)
60+
ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *orig_cmd)
6161
{
6262
ide_hwif_t *hwif = drive->hwif;
63+
struct ide_cmd *cmd = &hwif->cmd;
6364
struct ide_taskfile *tf = &cmd->tf;
6465
ide_handler_t *handler = NULL;
6566
const struct ide_tp_ops *tp_ops = hwif->tp_ops;
6667
const struct ide_dma_ops *dma_ops = hwif->dma_ops;
6768

68-
if (cmd->data_phase == TASKFILE_MULTI_IN ||
69-
cmd->data_phase == TASKFILE_MULTI_OUT) {
69+
if (orig_cmd->data_phase == TASKFILE_MULTI_IN ||
70+
orig_cmd->data_phase == TASKFILE_MULTI_OUT) {
7071
if (!drive->mult_count) {
7172
printk(KERN_ERR "%s: multimode not set!\n",
7273
drive->name);
7374
return ide_stopped;
7475
}
7576
}
7677

77-
if (cmd->ftf_flags & IDE_FTFLAG_FLAGGED)
78-
cmd->ftf_flags |= IDE_FTFLAG_SET_IN_FLAGS;
78+
if (orig_cmd->ftf_flags & IDE_FTFLAG_FLAGGED)
79+
orig_cmd->ftf_flags |= IDE_FTFLAG_SET_IN_FLAGS;
7980

80-
memcpy(&hwif->cmd, cmd, sizeof(*cmd));
81+
memcpy(cmd, orig_cmd, sizeof(*cmd));
8182

8283
if ((cmd->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) {
8384
ide_tf_dump(drive->name, tf);
@@ -91,7 +92,7 @@ ide_startstop_t do_rw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd)
9192
case TASKFILE_OUT:
9293
tp_ops->exec_command(hwif, tf->command);
9394
ndelay(400); /* FIXME */
94-
return pre_task_out_intr(drive, cmd->rq);
95+
return pre_task_out_intr(drive, cmd);
9596
case TASKFILE_MULTI_IN:
9697
case TASKFILE_IN:
9798
handler = task_in_intr;
@@ -203,7 +204,7 @@ static u8 wait_drive_not_busy(ide_drive_t *drive)
203204
return stat;
204205
}
205206

206-
static void ide_pio_sector(ide_drive_t *drive, struct request *rq,
207+
static void ide_pio_sector(ide_drive_t *drive, struct ide_cmd *cmd,
207208
unsigned int write)
208209
{
209210
ide_hwif_t *hwif = drive->hwif;
@@ -244,34 +245,33 @@ static void ide_pio_sector(ide_drive_t *drive, struct request *rq,
244245

245246
/* do the actual data transfer */
246247
if (write)
247-
hwif->tp_ops->output_data(drive, rq, buf, SECTOR_SIZE);
248+
hwif->tp_ops->output_data(drive, cmd, buf, SECTOR_SIZE);
248249
else
249-
hwif->tp_ops->input_data(drive, rq, buf, SECTOR_SIZE);
250+
hwif->tp_ops->input_data(drive, cmd, buf, SECTOR_SIZE);
250251

251252
kunmap_atomic(buf, KM_BIO_SRC_IRQ);
252253
#ifdef CONFIG_HIGHMEM
253254
local_irq_restore(flags);
254255
#endif
255256
}
256257

257-
static void ide_pio_multi(ide_drive_t *drive, struct request *rq,
258+
static void ide_pio_multi(ide_drive_t *drive, struct ide_cmd *cmd,
258259
unsigned int write)
259260
{
260261
unsigned int nsect;
261262

262263
nsect = min_t(unsigned int, drive->hwif->nleft, drive->mult_count);
263264
while (nsect--)
264-
ide_pio_sector(drive, rq, write);
265+
ide_pio_sector(drive, cmd, write);
265266
}
266267

267-
static void ide_pio_datablock(ide_drive_t *drive, struct request *rq,
268-
unsigned int write)
268+
static void ide_pio_datablock(ide_drive_t *drive, struct ide_cmd *cmd,
269+
unsigned int write)
269270
{
270-
struct ide_cmd *cmd = &drive->hwif->cmd;
271271
u8 saved_io_32bit = drive->io_32bit;
272272

273-
if (blk_fs_request(rq))
274-
rq->errors = 0;
273+
if (cmd->tf_flags & IDE_TFLAG_FS)
274+
cmd->rq->errors = 0;
275275

276276
if (cmd->tf_flags & IDE_TFLAG_IO_16BIT)
277277
drive->io_32bit = 0;
@@ -281,22 +281,21 @@ static void ide_pio_datablock(ide_drive_t *drive, struct request *rq,
281281
switch (cmd->data_phase) {
282282
case TASKFILE_MULTI_IN:
283283
case TASKFILE_MULTI_OUT:
284-
ide_pio_multi(drive, rq, write);
284+
ide_pio_multi(drive, cmd, write);
285285
break;
286286
default:
287-
ide_pio_sector(drive, rq, write);
287+
ide_pio_sector(drive, cmd, write);
288288
break;
289289
}
290290

291291
drive->io_32bit = saved_io_32bit;
292292
}
293293

294-
static ide_startstop_t task_error(ide_drive_t *drive, struct request *rq,
294+
static ide_startstop_t task_error(ide_drive_t *drive, struct ide_cmd *cmd,
295295
const char *s, u8 stat)
296296
{
297-
if (blk_fs_request(rq)) {
297+
if (cmd->tf_flags & IDE_TFLAG_FS) {
298298
ide_hwif_t *hwif = drive->hwif;
299-
struct ide_cmd *cmd = &hwif->cmd;
300299
int sectors = hwif->nsect - hwif->nleft;
301300

302301
switch (cmd->data_phase) {
@@ -323,19 +322,17 @@ static ide_startstop_t task_error(ide_drive_t *drive, struct request *rq,
323322
return ide_error(drive, s, stat);
324323
}
325324

326-
void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat)
325+
void ide_finish_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat)
327326
{
328-
if (blk_fs_request(rq) == 0) {
329-
struct ide_cmd *cmd = rq->special;
327+
if ((cmd->tf_flags & IDE_TFLAG_FS) == 0) {
330328
u8 err = ide_read_error(drive);
331329

332-
if (cmd)
333-
ide_complete_cmd(drive, cmd, stat, err);
330+
ide_complete_cmd(drive, cmd, stat, err);
334331
ide_complete_rq(drive, err);
335332
return;
336333
}
337334

338-
ide_end_request(drive, 1, rq->nr_sectors);
335+
ide_end_request(drive, 1, cmd->rq->nr_sectors);
339336
}
340337

341338
/*
@@ -344,11 +341,12 @@ void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat)
344341
* It might be a spurious irq (shared irq), but it might be a
345342
* command that had no output.
346343
*/
347-
static ide_startstop_t task_in_unexpected(ide_drive_t *drive, struct request *rq, u8 stat)
344+
static ide_startstop_t task_in_unexpected(ide_drive_t *drive,
345+
struct ide_cmd *cmd, u8 stat)
348346
{
349347
/* Command all done? */
350348
if (OK_STAT(stat, ATA_DRDY, ATA_BUSY)) {
351-
task_end_request(drive, rq, stat);
349+
ide_finish_cmd(drive, cmd, stat);
352350
return ide_stopped;
353351
}
354352

@@ -363,25 +361,25 @@ static ide_startstop_t task_in_unexpected(ide_drive_t *drive, struct request *rq
363361
static ide_startstop_t task_in_intr(ide_drive_t *drive)
364362
{
365363
ide_hwif_t *hwif = drive->hwif;
366-
struct request *rq = hwif->rq;
364+
struct ide_cmd *cmd = &drive->hwif->cmd;
367365
u8 stat = hwif->tp_ops->read_status(hwif);
368366

369367
/* Error? */
370368
if (stat & ATA_ERR)
371-
return task_error(drive, rq, __func__, stat);
369+
return task_error(drive, cmd, __func__, stat);
372370

373371
/* Didn't want any data? Odd. */
374372
if ((stat & ATA_DRQ) == 0)
375-
return task_in_unexpected(drive, rq, stat);
373+
return task_in_unexpected(drive, cmd, stat);
376374

377-
ide_pio_datablock(drive, rq, 0);
375+
ide_pio_datablock(drive, cmd, 0);
378376

379377
/* Are we done? Check status and finish transfer. */
380378
if (!hwif->nleft) {
381379
stat = wait_drive_not_busy(drive);
382380
if (!OK_STAT(stat, 0, BAD_STAT))
383-
return task_error(drive, rq, __func__, stat);
384-
task_end_request(drive, rq, stat);
381+
return task_error(drive, cmd, __func__, stat);
382+
ide_finish_cmd(drive, cmd, stat);
385383
return ide_stopped;
386384
}
387385

@@ -397,31 +395,31 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive)
397395
static ide_startstop_t task_out_intr (ide_drive_t *drive)
398396
{
399397
ide_hwif_t *hwif = drive->hwif;
400-
struct request *rq = hwif->rq;
398+
struct ide_cmd *cmd = &drive->hwif->cmd;
401399
u8 stat = hwif->tp_ops->read_status(hwif);
402400

403401
if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat))
404-
return task_error(drive, rq, __func__, stat);
402+
return task_error(drive, cmd, __func__, stat);
405403

406404
/* Deal with unexpected ATA data phase. */
407405
if (((stat & ATA_DRQ) == 0) ^ !hwif->nleft)
408-
return task_error(drive, rq, __func__, stat);
406+
return task_error(drive, cmd, __func__, stat);
409407

410408
if (!hwif->nleft) {
411-
task_end_request(drive, rq, stat);
409+
ide_finish_cmd(drive, cmd, stat);
412410
return ide_stopped;
413411
}
414412

415413
/* Still data left to transfer. */
416-
ide_pio_datablock(drive, rq, 1);
414+
ide_pio_datablock(drive, cmd, 1);
417415
ide_set_handler(drive, &task_out_intr, WAIT_WORSTCASE, NULL);
418416

419417
return ide_started;
420418
}
421419

422-
static ide_startstop_t pre_task_out_intr(ide_drive_t *drive, struct request *rq)
420+
static ide_startstop_t pre_task_out_intr(ide_drive_t *drive,
421+
struct ide_cmd *cmd)
423422
{
424-
struct ide_cmd *cmd = &drive->hwif->cmd;
425423
ide_startstop_t startstop;
426424

427425
if (ide_wait_stat(&startstop, drive, ATA_DRQ,
@@ -437,7 +435,7 @@ static ide_startstop_t pre_task_out_intr(ide_drive_t *drive, struct request *rq)
437435
local_irq_disable();
438436

439437
ide_set_handler(drive, &task_out_intr, WAIT_WORSTCASE, NULL);
440-
ide_pio_datablock(drive, rq, 1);
438+
ide_pio_datablock(drive, cmd, 1);
441439

442440
return ide_started;
443441
}

‎drivers/ide/q40ide.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,23 @@ static void q40_ide_setup_ports(hw_regs_t *hw, unsigned long base,
7272
hw->chipset = ide_generic;
7373
}
7474

75-
static void q40ide_input_data(ide_drive_t *drive, struct request *rq,
75+
static void q40ide_input_data(ide_drive_t *drive, struct ide_cmd *cmd,
7676
void *buf, unsigned int len)
7777
{
7878
unsigned long data_addr = drive->hwif->io_ports.data_addr;
7979

80-
if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS)
80+
if (drive->media == ide_disk && cmd && (cmd->tf_flags & IDE_TFLAG_FS))
8181
return insw(data_addr, buf, (len + 1) / 2);
8282

8383
raw_insw_swapw((u16 *)data_addr, buf, (len + 1) / 2);
8484
}
8585

86-
static void q40ide_output_data(ide_drive_t *drive, struct request *rq,
86+
static void q40ide_output_data(ide_drive_t *drive, struct ide_cmd *cmd,
8787
void *buf, unsigned int len)
8888
{
8989
unsigned long data_addr = drive->hwif->io_ports.data_addr;
9090

91-
if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS)
91+
if (drive->media == ide_disk && cmd && (cmd->tf_flags & IDE_TFLAG_FS))
9292
return outsw(data_addr, buf, (len + 1) / 2);
9393

9494
raw_outsw_swapw((u16 *)data_addr, buf, (len + 1) / 2);

0 commit comments

Comments
 (0)