summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-01-31 10:57:30 -0500
committerJens Axboe <axboe@fb.com>2017-01-31 16:00:39 -0500
commit2f5a8e80f79dc82e00f4cca557dc9ceaf064b450 (patch)
treebc64c6e6f7e24d792742a3547018066568948fba
parent57292b58ddb58689e8c3b4c6eadbef10d9ca44dd (diff)
ide: don't abuse cmd_type
Currently the legacy ide driver defines several request types of it's own, which is in the way of removing that field entirely. Instead add a type field to struct ide_request and use that to distinguish the different types of IDE-internal requests. It's a bit of a mess, but so is the surrounding code.. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--drivers/ide/ide-atapi.c18
-rw-r--r--drivers/ide/ide-cd.c25
-rw-r--r--drivers/ide/ide-cd_ioctl.c1
-rw-r--r--drivers/ide/ide-devsets.c1
-rw-r--r--drivers/ide/ide-disk.c6
-rw-r--r--drivers/ide/ide-eh.c4
-rw-r--r--drivers/ide/ide-floppy.c18
-rw-r--r--drivers/ide/ide-io.c8
-rw-r--r--drivers/ide/ide-ioctls.c4
-rw-r--r--drivers/ide/ide-park.c2
-rw-r--r--drivers/ide/ide-pm.c16
-rw-r--r--drivers/ide/ide-tape.c6
-rw-r--r--drivers/ide/ide-taskfile.c3
-rw-r--r--include/linux/ide.h56
14 files changed, 117 insertions, 51 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 7c826ecbd276..a8c650e8c92e 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -95,6 +95,7 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
95 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); 95 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
96 scsi_req_init(rq); 96 scsi_req_init(rq);
97 rq->cmd_type = REQ_TYPE_DRV_PRIV; 97 rq->cmd_type = REQ_TYPE_DRV_PRIV;
98 ide_req(rq)->type = ATA_PRIV_MISC;
98 rq->special = (char *)pc; 99 rq->special = (char *)pc;
99 100
100 if (buf && bufflen) { 101 if (buf && bufflen) {
@@ -193,7 +194,7 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)
193 194
194 BUG_ON(sense_len > sizeof(*sense)); 195 BUG_ON(sense_len > sizeof(*sense));
195 196
196 if (rq->cmd_type == REQ_TYPE_ATA_SENSE || drive->sense_rq_armed) 197 if (ata_sense_request(rq) || drive->sense_rq_armed)
197 return; 198 return;
198 199
199 memset(sense, 0, sizeof(*sense)); 200 memset(sense, 0, sizeof(*sense));
@@ -211,7 +212,8 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)
211 } 212 }
212 213
213 sense_rq->rq_disk = rq->rq_disk; 214 sense_rq->rq_disk = rq->rq_disk;
214 sense_rq->cmd_type = REQ_TYPE_ATA_SENSE; 215 sense_rq->cmd_type = REQ_TYPE_DRV_PRIV;
216 ide_req(sense_rq)->type = ATA_PRIV_SENSE;
215 sense_rq->rq_flags |= RQF_PREEMPT; 217 sense_rq->rq_flags |= RQF_PREEMPT;
216 218
217 req->cmd[0] = GPCMD_REQUEST_SENSE; 219 req->cmd[0] = GPCMD_REQUEST_SENSE;
@@ -313,10 +315,14 @@ int ide_cd_get_xferlen(struct request *rq)
313 switch (rq->cmd_type) { 315 switch (rq->cmd_type) {
314 case REQ_TYPE_FS: 316 case REQ_TYPE_FS:
315 return 32768; 317 return 32768;
316 case REQ_TYPE_ATA_SENSE:
317 case REQ_TYPE_BLOCK_PC: 318 case REQ_TYPE_BLOCK_PC:
318 case REQ_TYPE_ATA_PC:
319 return blk_rq_bytes(rq); 319 return blk_rq_bytes(rq);
320 case REQ_TYPE_DRV_PRIV:
321 switch (ide_req(rq)->type) {
322 case ATA_PRIV_PC:
323 case ATA_PRIV_SENSE:
324 return blk_rq_bytes(rq);
325 }
320 default: 326 default:
321 return 0; 327 return 0;
322 } 328 }
@@ -377,7 +383,7 @@ int ide_check_ireason(ide_drive_t *drive, struct request *rq, int len,
377 drive->name, __func__, ireason); 383 drive->name, __func__, ireason);
378 } 384 }
379 385
380 if (dev_is_idecd(drive) && rq->cmd_type == REQ_TYPE_ATA_PC) 386 if (dev_is_idecd(drive) && ata_pc_request(rq))
381 rq->rq_flags |= RQF_FAILED; 387 rq->rq_flags |= RQF_FAILED;
382 388
383 return 1; 389 return 1;
@@ -480,7 +486,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
480 if (uptodate == 0) 486 if (uptodate == 0)
481 drive->failed_pc = NULL; 487 drive->failed_pc = NULL;
482 488
483 if (rq->cmd_type == REQ_TYPE_DRV_PRIV) { 489 if (ata_misc_request(rq)) {
484 rq->errors = 0; 490 rq->errors = 0;
485 error = 0; 491 error = 0;
486 } else { 492 } else {
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 6eb98725e194..207af7816544 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -210,7 +210,7 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
210static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq) 210static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq)
211{ 211{
212 /* 212 /*
213 * For REQ_TYPE_ATA_SENSE, "rq->special" points to the original 213 * For ATA_PRIV_SENSE, "rq->special" points to the original
214 * failed request. Also, the sense data should be read 214 * failed request. Also, the sense data should be read
215 * directly from rq which might be different from the original 215 * directly from rq which might be different from the original
216 * sense buffer if it got copied during mapping. 216 * sense buffer if it got copied during mapping.
@@ -282,7 +282,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
282 "stat 0x%x", 282 "stat 0x%x",
283 rq->cmd[0], rq->cmd_type, err, stat); 283 rq->cmd[0], rq->cmd_type, err, stat);
284 284
285 if (rq->cmd_type == REQ_TYPE_ATA_SENSE) { 285 if (ata_sense_request(rq)) {
286 /* 286 /*
287 * We got an error trying to get sense info from the drive 287 * We got an error trying to get sense info from the drive
288 * (probably while trying to recover from a former error). 288 * (probably while trying to recover from a former error).
@@ -438,7 +438,8 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
438 rq = blk_get_request(drive->queue, write, __GFP_RECLAIM); 438 rq = blk_get_request(drive->queue, write, __GFP_RECLAIM);
439 scsi_req_init(rq); 439 scsi_req_init(rq);
440 memcpy(scsi_req(rq)->cmd, cmd, BLK_MAX_CDB); 440 memcpy(scsi_req(rq)->cmd, cmd, BLK_MAX_CDB);
441 rq->cmd_type = REQ_TYPE_ATA_PC; 441 rq->cmd_type = REQ_TYPE_DRV_PRIV;
442 ide_req(rq)->type = ATA_PRIV_PC;
442 rq->rq_flags |= rq_flags; 443 rq->rq_flags |= rq_flags;
443 rq->timeout = timeout; 444 rq->timeout = timeout;
444 if (buffer) { 445 if (buffer) {
@@ -520,7 +521,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
520 ide_expiry_t *expiry = NULL; 521 ide_expiry_t *expiry = NULL;
521 int dma_error = 0, dma, thislen, uptodate = 0; 522 int dma_error = 0, dma, thislen, uptodate = 0;
522 int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0; 523 int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0;
523 int sense = (rq->cmd_type == REQ_TYPE_ATA_SENSE); 524 int sense = ata_sense_request(rq);
524 unsigned int timeout; 525 unsigned int timeout;
525 u16 len; 526 u16 len;
526 u8 ireason, stat; 527 u8 ireason, stat;
@@ -785,18 +786,22 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
785 if (cdrom_start_rw(drive, rq) == ide_stopped) 786 if (cdrom_start_rw(drive, rq) == ide_stopped)
786 goto out_end; 787 goto out_end;
787 break; 788 break;
788 case REQ_TYPE_ATA_SENSE:
789 case REQ_TYPE_BLOCK_PC: 789 case REQ_TYPE_BLOCK_PC:
790 case REQ_TYPE_ATA_PC: 790 handle_pc:
791 if (!rq->timeout) 791 if (!rq->timeout)
792 rq->timeout = ATAPI_WAIT_PC; 792 rq->timeout = ATAPI_WAIT_PC;
793
794 cdrom_do_block_pc(drive, rq); 793 cdrom_do_block_pc(drive, rq);
795 break; 794 break;
796 case REQ_TYPE_DRV_PRIV: 795 case REQ_TYPE_DRV_PRIV:
797 /* right now this can only be a reset... */ 796 switch (ide_req(rq)->type) {
798 uptodate = 1; 797 case ATA_PRIV_MISC:
799 goto out_end; 798 /* right now this can only be a reset... */
799 uptodate = 1;
800 goto out_end;
801 case ATA_PRIV_SENSE:
802 case ATA_PRIV_PC:
803 goto handle_pc;
804 }
800 default: 805 default:
801 BUG(); 806 BUG();
802 } 807 }
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c
index da0aa0153fb1..3f03eed0ff78 100644
--- a/drivers/ide/ide-cd_ioctl.c
+++ b/drivers/ide/ide-cd_ioctl.c
@@ -306,6 +306,7 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi)
306 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); 306 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
307 scsi_req_init(rq); 307 scsi_req_init(rq);
308 rq->cmd_type = REQ_TYPE_DRV_PRIV; 308 rq->cmd_type = REQ_TYPE_DRV_PRIV;
309 ide_req(rq)->type = ATA_PRIV_MISC;
309 rq->rq_flags = RQF_QUIET; 310 rq->rq_flags = RQF_QUIET;
310 ret = blk_execute_rq(drive->queue, cd->disk, rq, 0); 311 ret = blk_execute_rq(drive->queue, cd->disk, rq, 0);
311 blk_put_request(rq); 312 blk_put_request(rq);
diff --git a/drivers/ide/ide-devsets.c b/drivers/ide/ide-devsets.c
index fd56c9dd9bc7..c040b9de2b4e 100644
--- a/drivers/ide/ide-devsets.c
+++ b/drivers/ide/ide-devsets.c
@@ -168,6 +168,7 @@ int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting,
168 rq = blk_get_request(q, READ, __GFP_RECLAIM); 168 rq = blk_get_request(q, READ, __GFP_RECLAIM);
169 scsi_req_init(rq); 169 scsi_req_init(rq);
170 rq->cmd_type = REQ_TYPE_DRV_PRIV; 170 rq->cmd_type = REQ_TYPE_DRV_PRIV;
171 ide_req(rq)->type = ATA_PRIV_MISC;
171 scsi_req(rq)->cmd_len = 5; 172 scsi_req(rq)->cmd_len = 5;
172 scsi_req(rq)->cmd[0] = REQ_DEVSET_EXEC; 173 scsi_req(rq)->cmd[0] = REQ_DEVSET_EXEC;
173 *(int *)&scsi_req(rq)->cmd[1] = arg; 174 *(int *)&scsi_req(rq)->cmd[1] = arg;
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 3437c5b28599..69cf71729841 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -453,7 +453,8 @@ static int idedisk_prep_fn(struct request_queue *q, struct request *rq)
453 cmd->tf_flags = IDE_TFLAG_DYN; 453 cmd->tf_flags = IDE_TFLAG_DYN;
454 cmd->protocol = ATA_PROT_NODATA; 454 cmd->protocol = ATA_PROT_NODATA;
455 455
456 rq->cmd_type = REQ_TYPE_ATA_TASKFILE; 456 rq->cmd_type = REQ_TYPE_DRV_PRIV;
457 ide_req(rq)->type = ATA_PRIV_TASKFILE;
457 rq->special = cmd; 458 rq->special = cmd;
458 cmd->rq = rq; 459 cmd->rq = rq;
459 460
@@ -479,7 +480,8 @@ static int set_multcount(ide_drive_t *drive, int arg)
479 480
480 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); 481 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
481 scsi_req_init(rq); 482 scsi_req_init(rq);
482 rq->cmd_type = REQ_TYPE_ATA_TASKFILE; 483 rq->cmd_type = REQ_TYPE_DRV_PRIV;
484 ide_req(rq)->type = ATA_PRIV_TASKFILE;
483 485
484 drive->mult_req = arg; 486 drive->mult_req = arg;
485 drive->special_flags |= IDE_SFLAG_SET_MULTMODE; 487 drive->special_flags |= IDE_SFLAG_SET_MULTMODE;
diff --git a/drivers/ide/ide-eh.c b/drivers/ide/ide-eh.c
index 35e5b892f9d7..1e4b1476e559 100644
--- a/drivers/ide/ide-eh.c
+++ b/drivers/ide/ide-eh.c
@@ -124,7 +124,7 @@ ide_startstop_t ide_error(ide_drive_t *drive, const char *msg, u8 stat)
124 124
125 /* retry only "normal" I/O: */ 125 /* retry only "normal" I/O: */
126 if (rq->cmd_type != REQ_TYPE_FS) { 126 if (rq->cmd_type != REQ_TYPE_FS) {
127 if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { 127 if (ata_taskfile_request(rq)) {
128 struct ide_cmd *cmd = rq->special; 128 struct ide_cmd *cmd = rq->special;
129 129
130 if (cmd) 130 if (cmd)
@@ -147,7 +147,7 @@ static inline void ide_complete_drive_reset(ide_drive_t *drive, int err)
147{ 147{
148 struct request *rq = drive->hwif->rq; 148 struct request *rq = drive->hwif->rq;
149 149
150 if (rq && rq->cmd_type == REQ_TYPE_DRV_PRIV && 150 if (rq && ata_misc_request(rq) &&
151 scsi_req(rq)->cmd[0] == REQ_DRIVE_RESET) { 151 scsi_req(rq)->cmd[0] == REQ_DRIVE_RESET) {
152 if (err <= 0 && rq->errors == 0) 152 if (err <= 0 && rq->errors == 0)
153 rq->errors = -EIO; 153 rq->errors = -EIO;
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 3bd678ad3519..24c6d363b3a4 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -97,7 +97,7 @@ static int ide_floppy_callback(ide_drive_t *drive, int dsc)
97 "Aborting request!\n"); 97 "Aborting request!\n");
98 } 98 }
99 99
100 if (rq->cmd_type == REQ_TYPE_DRV_PRIV) 100 if (ata_misc_request(rq))
101 rq->errors = uptodate ? 0 : IDE_DRV_ERROR_GENERAL; 101 rq->errors = uptodate ? 0 : IDE_DRV_ERROR_GENERAL;
102 102
103 return uptodate; 103 return uptodate;
@@ -246,7 +246,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
246 } else 246 } else
247 printk(KERN_ERR PFX "%s: I/O error\n", drive->name); 247 printk(KERN_ERR PFX "%s: I/O error\n", drive->name);
248 248
249 if (rq->cmd_type == REQ_TYPE_DRV_PRIV) { 249 if (ata_misc_request(rq)) {
250 rq->errors = 0; 250 rq->errors = 0;
251 ide_complete_rq(drive, 0, blk_rq_bytes(rq)); 251 ide_complete_rq(drive, 0, blk_rq_bytes(rq));
252 return ide_stopped; 252 return ide_stopped;
@@ -265,14 +265,20 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
265 pc = &floppy->queued_pc; 265 pc = &floppy->queued_pc;
266 idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block); 266 idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block);
267 break; 267 break;
268 case REQ_TYPE_DRV_PRIV:
269 case REQ_TYPE_ATA_SENSE:
270 pc = (struct ide_atapi_pc *)rq->special;
271 break;
272 case REQ_TYPE_BLOCK_PC: 268 case REQ_TYPE_BLOCK_PC:
273 pc = &floppy->queued_pc; 269 pc = &floppy->queued_pc;
274 idefloppy_blockpc_cmd(floppy, pc, rq); 270 idefloppy_blockpc_cmd(floppy, pc, rq);
275 break; 271 break;
272 case REQ_TYPE_DRV_PRIV:
273 switch (ide_req(rq)->type) {
274 case ATA_PRIV_MISC:
275 case ATA_PRIV_SENSE:
276 pc = (struct ide_atapi_pc *)rq->special;
277 break;
278 default:
279 BUG();
280 }
281 break;
276 default: 282 default:
277 BUG(); 283 BUG();
278 } 284 }
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 3378503afed4..6735c92b8da7 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -102,7 +102,7 @@ void ide_complete_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 stat, u8 err)
102 drive->dev_flags |= IDE_DFLAG_PARKED; 102 drive->dev_flags |= IDE_DFLAG_PARKED;
103 } 103 }
104 104
105 if (rq && rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { 105 if (rq && ata_taskfile_request(rq)) {
106 struct ide_cmd *orig_cmd = rq->special; 106 struct ide_cmd *orig_cmd = rq->special;
107 107
108 if (cmd->tf_flags & IDE_TFLAG_DYN) 108 if (cmd->tf_flags & IDE_TFLAG_DYN)
@@ -135,7 +135,7 @@ EXPORT_SYMBOL(ide_complete_rq);
135 135
136void ide_kill_rq(ide_drive_t *drive, struct request *rq) 136void ide_kill_rq(ide_drive_t *drive, struct request *rq)
137{ 137{
138 u8 drv_req = (rq->cmd_type == REQ_TYPE_DRV_PRIV) && rq->rq_disk; 138 u8 drv_req = ata_misc_request(rq) && rq->rq_disk;
139 u8 media = drive->media; 139 u8 media = drive->media;
140 140
141 drive->failed_pc = NULL; 141 drive->failed_pc = NULL;
@@ -340,7 +340,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
340 if (drive->current_speed == 0xff) 340 if (drive->current_speed == 0xff)
341 ide_config_drive_speed(drive, drive->desired_speed); 341 ide_config_drive_speed(drive, drive->desired_speed);
342 342
343 if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) 343 if (ata_taskfile_request(rq))
344 return execute_drive_cmd(drive, rq); 344 return execute_drive_cmd(drive, rq);
345 else if (ata_pm_request(rq)) { 345 else if (ata_pm_request(rq)) {
346 struct ide_pm_state *pm = rq->special; 346 struct ide_pm_state *pm = rq->special;
@@ -353,7 +353,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
353 pm->pm_step == IDE_PM_COMPLETED) 353 pm->pm_step == IDE_PM_COMPLETED)
354 ide_complete_pm_rq(drive, rq); 354 ide_complete_pm_rq(drive, rq);
355 return startstop; 355 return startstop;
356 } else if (!rq->rq_disk && rq->cmd_type == REQ_TYPE_DRV_PRIV) 356 } else if (!rq->rq_disk && ata_misc_request(rq))
357 /* 357 /*
358 * TODO: Once all ULDs have been modified to 358 * TODO: Once all ULDs have been modified to
359 * check for specific op codes rather than 359 * check for specific op codes rather than
diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c
index a5d22c6e956a..fc19e842deef 100644
--- a/drivers/ide/ide-ioctls.c
+++ b/drivers/ide/ide-ioctls.c
@@ -127,7 +127,8 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)
127 127
128 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); 128 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
129 scsi_req_init(rq); 129 scsi_req_init(rq);
130 rq->cmd_type = REQ_TYPE_ATA_TASKFILE; 130 rq->cmd_type = REQ_TYPE_DRV_PRIV;
131 ide_req(rq)->type = ATA_PRIV_TASKFILE;
131 err = blk_execute_rq(drive->queue, NULL, rq, 0); 132 err = blk_execute_rq(drive->queue, NULL, rq, 0);
132 blk_put_request(rq); 133 blk_put_request(rq);
133 134
@@ -225,6 +226,7 @@ static int generic_drive_reset(ide_drive_t *drive)
225 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); 226 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
226 scsi_req_init(rq); 227 scsi_req_init(rq);
227 rq->cmd_type = REQ_TYPE_DRV_PRIV; 228 rq->cmd_type = REQ_TYPE_DRV_PRIV;
229 ide_req(rq)->type = ATA_PRIV_MISC;
228 scsi_req(rq)->cmd_len = 1; 230 scsi_req(rq)->cmd_len = 1;
229 scsi_req(rq)->cmd[0] = REQ_DRIVE_RESET; 231 scsi_req(rq)->cmd[0] = REQ_DRIVE_RESET;
230 if (blk_execute_rq(drive->queue, NULL, rq, 1)) 232 if (blk_execute_rq(drive->queue, NULL, rq, 1))
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c
index c37604a75097..fc3c944ca4be 100644
--- a/drivers/ide/ide-park.c
+++ b/drivers/ide/ide-park.c
@@ -36,6 +36,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
36 scsi_req(rq)->cmd[0] = REQ_PARK_HEADS; 36 scsi_req(rq)->cmd[0] = REQ_PARK_HEADS;
37 scsi_req(rq)->cmd_len = 1; 37 scsi_req(rq)->cmd_len = 1;
38 rq->cmd_type = REQ_TYPE_DRV_PRIV; 38 rq->cmd_type = REQ_TYPE_DRV_PRIV;
39 ide_req(rq)->type = ATA_PRIV_MISC;
39 rq->special = &timeout; 40 rq->special = &timeout;
40 rc = blk_execute_rq(q, NULL, rq, 1); 41 rc = blk_execute_rq(q, NULL, rq, 1);
41 blk_put_request(rq); 42 blk_put_request(rq);
@@ -54,6 +55,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
54 scsi_req(rq)->cmd[0] = REQ_UNPARK_HEADS; 55 scsi_req(rq)->cmd[0] = REQ_UNPARK_HEADS;
55 scsi_req(rq)->cmd_len = 1; 56 scsi_req(rq)->cmd_len = 1;
56 rq->cmd_type = REQ_TYPE_DRV_PRIV; 57 rq->cmd_type = REQ_TYPE_DRV_PRIV;
58 ide_req(rq)->type = ATA_PRIV_MISC;
57 elv_add_request(q, rq, ELEVATOR_INSERT_FRONT); 59 elv_add_request(q, rq, ELEVATOR_INSERT_FRONT);
58 60
59out: 61out:
diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c
index f6767aba7cfb..0c1296815dfa 100644
--- a/drivers/ide/ide-pm.c
+++ b/drivers/ide/ide-pm.c
@@ -20,7 +20,8 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
20 memset(&rqpm, 0, sizeof(rqpm)); 20 memset(&rqpm, 0, sizeof(rqpm));
21 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); 21 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
22 scsi_req_init(rq); 22 scsi_req_init(rq);
23 rq->cmd_type = REQ_TYPE_ATA_PM_SUSPEND; 23 rq->cmd_type = REQ_TYPE_DRV_PRIV;
24 ide_req(rq)->type = ATA_PRIV_PM_SUSPEND;
24 rq->special = &rqpm; 25 rq->special = &rqpm;
25 rqpm.pm_step = IDE_PM_START_SUSPEND; 26 rqpm.pm_step = IDE_PM_START_SUSPEND;
26 if (mesg.event == PM_EVENT_PRETHAW) 27 if (mesg.event == PM_EVENT_PRETHAW)
@@ -91,7 +92,8 @@ int generic_ide_resume(struct device *dev)
91 memset(&rqpm, 0, sizeof(rqpm)); 92 memset(&rqpm, 0, sizeof(rqpm));
92 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); 93 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
93 scsi_req_init(rq); 94 scsi_req_init(rq);
94 rq->cmd_type = REQ_TYPE_ATA_PM_RESUME; 95 rq->cmd_type = REQ_TYPE_DRV_PRIV;
96 ide_req(rq)->type = ATA_PRIV_PM_RESUME;
95 rq->rq_flags |= RQF_PREEMPT; 97 rq->rq_flags |= RQF_PREEMPT;
96 rq->special = &rqpm; 98 rq->special = &rqpm;
97 rqpm.pm_step = IDE_PM_START_RESUME; 99 rqpm.pm_step = IDE_PM_START_RESUME;
@@ -223,10 +225,10 @@ void ide_complete_pm_rq(ide_drive_t *drive, struct request *rq)
223 225
224#ifdef DEBUG_PM 226#ifdef DEBUG_PM
225 printk("%s: completing PM request, %s\n", drive->name, 227 printk("%s: completing PM request, %s\n", drive->name,
226 (rq->cmd_type == REQ_TYPE_ATA_PM_SUSPEND) ? "suspend" : "resume"); 228 (ide_req(rq)->type == ATA_PRIV_PM_SUSPEND) ? "suspend" : "resume");
227#endif 229#endif
228 spin_lock_irqsave(q->queue_lock, flags); 230 spin_lock_irqsave(q->queue_lock, flags);
229 if (rq->cmd_type == REQ_TYPE_ATA_PM_SUSPEND) 231 if (ide_req(rq)->type == ATA_PRIV_PM_SUSPEND)
230 blk_stop_queue(q); 232 blk_stop_queue(q);
231 else 233 else
232 drive->dev_flags &= ~IDE_DFLAG_BLOCKED; 234 drive->dev_flags &= ~IDE_DFLAG_BLOCKED;
@@ -242,11 +244,13 @@ void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
242{ 244{
243 struct ide_pm_state *pm = rq->special; 245 struct ide_pm_state *pm = rq->special;
244 246
245 if (rq->cmd_type == REQ_TYPE_ATA_PM_SUSPEND && 247 if (rq->cmd_type == REQ_TYPE_DRV_PRIV &&
248 ide_req(rq)->type == ATA_PRIV_PM_SUSPEND &&
246 pm->pm_step == IDE_PM_START_SUSPEND) 249 pm->pm_step == IDE_PM_START_SUSPEND)
247 /* Mark drive blocked when starting the suspend sequence. */ 250 /* Mark drive blocked when starting the suspend sequence. */
248 drive->dev_flags |= IDE_DFLAG_BLOCKED; 251 drive->dev_flags |= IDE_DFLAG_BLOCKED;
249 else if (rq->cmd_type == REQ_TYPE_ATA_PM_RESUME && 252 else if (rq->cmd_type == REQ_TYPE_DRV_PRIV &&
253 ide_req(rq)->type == ATA_PRIV_PM_RESUME &&
250 pm->pm_step == IDE_PM_START_RESUME) { 254 pm->pm_step == IDE_PM_START_RESUME) {
251 /* 255 /*
252 * The first thing we do on wakeup is to wait for BSY bit to 256 * The first thing we do on wakeup is to wait for BSY bit to
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index f6bc1e2bb035..37c7beabaacc 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -577,8 +577,9 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
577 req->cmd[0], (unsigned long long)blk_rq_pos(rq), 577 req->cmd[0], (unsigned long long)blk_rq_pos(rq),
578 blk_rq_sectors(rq)); 578 blk_rq_sectors(rq));
579 579
580 BUG_ON(!(rq->cmd_type == REQ_TYPE_DRV_PRIV || 580 BUG_ON(rq->cmd_type != REQ_TYPE_DRV_PRIV);
581 rq->cmd_type == REQ_TYPE_ATA_SENSE)); 581 BUG_ON(ide_req(rq)->type != ATA_PRIV_MISC &&
582 ide_req(rq)->type != ATA_PRIV_SENSE);
582 583
583 /* Retry a failed packet command */ 584 /* Retry a failed packet command */
584 if (drive->failed_pc && drive->pc->c[0] == REQUEST_SENSE) { 585 if (drive->failed_pc && drive->pc->c[0] == REQUEST_SENSE) {
@@ -856,6 +857,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)
856 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM); 857 rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
857 scsi_req_init(rq); 858 scsi_req_init(rq);
858 rq->cmd_type = REQ_TYPE_DRV_PRIV; 859 rq->cmd_type = REQ_TYPE_DRV_PRIV;
860 ide_req(rq)->type = ATA_PRIV_MISC;
859 scsi_req(rq)->cmd[13] = cmd; 861 scsi_req(rq)->cmd[13] = cmd;
860 rq->rq_disk = tape->disk; 862 rq->rq_disk = tape->disk;
861 rq->__sector = tape->first_frame; 863 rq->__sector = tape->first_frame;
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index a393e13b8007..9ccc1d573393 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -432,7 +432,8 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf,
432 432
433 rq = blk_get_request(drive->queue, rw, __GFP_RECLAIM); 433 rq = blk_get_request(drive->queue, rw, __GFP_RECLAIM);
434 scsi_req_init(rq); 434 scsi_req_init(rq);
435 rq->cmd_type = REQ_TYPE_ATA_TASKFILE; 435 rq->cmd_type = REQ_TYPE_DRV_PRIV;
436 ide_req(rq)->type = ATA_PRIV_TASKFILE;
436 437
437 /* 438 /*
438 * (ks) We transfer currently only whole sectors. 439 * (ks) We transfer currently only whole sectors.
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 086fbe172817..5cc6caa94cac 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -40,24 +40,58 @@
40 40
41struct device; 41struct device;
42 42
43/* IDE-specific values for req->cmd_type */ 43/* values for ide_request.type */
44enum ata_cmd_type_bits { 44enum ata_priv_type {
45 REQ_TYPE_ATA_TASKFILE = REQ_TYPE_DRV_PRIV + 1, 45 ATA_PRIV_MISC,
46 REQ_TYPE_ATA_PC, 46 ATA_PRIV_TASKFILE,
47 REQ_TYPE_ATA_SENSE, /* sense request */ 47 ATA_PRIV_PC,
48 REQ_TYPE_ATA_PM_SUSPEND,/* suspend request */ 48 ATA_PRIV_SENSE, /* sense request */
49 REQ_TYPE_ATA_PM_RESUME, /* resume request */ 49 ATA_PRIV_PM_SUSPEND, /* suspend request */
50 ATA_PRIV_PM_RESUME, /* resume request */
50}; 51};
51 52
52#define ata_pm_request(rq) \
53 ((rq)->cmd_type == REQ_TYPE_ATA_PM_SUSPEND || \
54 (rq)->cmd_type == REQ_TYPE_ATA_PM_RESUME)
55
56struct ide_request { 53struct ide_request {
57 struct scsi_request sreq; 54 struct scsi_request sreq;
58 u8 sense[SCSI_SENSE_BUFFERSIZE]; 55 u8 sense[SCSI_SENSE_BUFFERSIZE];
56 u8 type;
59}; 57};
60 58
59static inline struct ide_request *ide_req(struct request *rq)
60{
61 return blk_mq_rq_to_pdu(rq);
62}
63
64static inline bool ata_misc_request(struct request *rq)
65{
66 return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
67 ide_req(rq)->type == ATA_PRIV_MISC;
68}
69
70static inline bool ata_taskfile_request(struct request *rq)
71{
72 return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
73 ide_req(rq)->type == ATA_PRIV_TASKFILE;
74}
75
76static inline bool ata_pc_request(struct request *rq)
77{
78 return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
79 ide_req(rq)->type == ATA_PRIV_PC;
80}
81
82static inline bool ata_sense_request(struct request *rq)
83{
84 return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
85 ide_req(rq)->type == ATA_PRIV_SENSE;
86}
87
88static inline bool ata_pm_request(struct request *rq)
89{
90 return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
91 (ide_req(rq)->type == ATA_PRIV_PM_SUSPEND ||
92 ide_req(rq)->type == ATA_PRIV_PM_RESUME);
93}
94
61/* Error codes returned in rq->errors to the higher part of the driver. */ 95/* Error codes returned in rq->errors to the higher part of the driver. */
62enum { 96enum {
63 IDE_DRV_ERROR_GENERAL = 101, 97 IDE_DRV_ERROR_GENERAL = 101,