Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f5a8e80 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

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: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 57292b58
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
	rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
	scsi_req_init(rq);
	rq->cmd_type = REQ_TYPE_DRV_PRIV;
	ide_req(rq)->type = ATA_PRIV_MISC;
	rq->special = (char *)pc;

	if (buf && bufflen) {
@@ -193,7 +194,7 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)

	BUG_ON(sense_len > sizeof(*sense));

	if (rq->cmd_type == REQ_TYPE_ATA_SENSE || drive->sense_rq_armed)
	if (ata_sense_request(rq) || drive->sense_rq_armed)
		return;

	memset(sense, 0, sizeof(*sense));
@@ -211,7 +212,8 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)
	}

	sense_rq->rq_disk = rq->rq_disk;
	sense_rq->cmd_type = REQ_TYPE_ATA_SENSE;
	sense_rq->cmd_type = REQ_TYPE_DRV_PRIV;
	ide_req(sense_rq)->type = ATA_PRIV_SENSE;
	sense_rq->rq_flags |= RQF_PREEMPT;

	req->cmd[0] = GPCMD_REQUEST_SENSE;
@@ -313,10 +315,14 @@ int ide_cd_get_xferlen(struct request *rq)
	switch (rq->cmd_type) {
	case REQ_TYPE_FS:
		return 32768;
	case REQ_TYPE_ATA_SENSE:
	case REQ_TYPE_BLOCK_PC:
	case REQ_TYPE_ATA_PC:
		return blk_rq_bytes(rq);
	case REQ_TYPE_DRV_PRIV:
		switch (ide_req(rq)->type) {
		case ATA_PRIV_PC:
		case ATA_PRIV_SENSE:
			return blk_rq_bytes(rq);
		}
	default:
		return 0;
	}
@@ -377,7 +383,7 @@ int ide_check_ireason(ide_drive_t *drive, struct request *rq, int len,
				drive->name, __func__, ireason);
	}

	if (dev_is_idecd(drive) && rq->cmd_type == REQ_TYPE_ATA_PC)
	if (dev_is_idecd(drive) && ata_pc_request(rq))
		rq->rq_flags |= RQF_FAILED;

	return 1;
@@ -480,7 +486,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
		if (uptodate == 0)
			drive->failed_pc = NULL;

		if (rq->cmd_type == REQ_TYPE_DRV_PRIV) {
		if (ata_misc_request(rq)) {
			rq->errors = 0;
			error = 0;
		} else {
+15 −10
Original line number Diff line number Diff line
@@ -210,7 +210,7 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
static void ide_cd_complete_failed_rq(ide_drive_t *drive, struct request *rq)
{
	/*
	 * For REQ_TYPE_ATA_SENSE, "rq->special" points to the original
	 * For ATA_PRIV_SENSE, "rq->special" points to the original
	 * failed request.  Also, the sense data should be read
	 * directly from rq which might be different from the original
	 * sense buffer if it got copied during mapping.
@@ -282,7 +282,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
				  "stat 0x%x",
				  rq->cmd[0], rq->cmd_type, err, stat);

	if (rq->cmd_type == REQ_TYPE_ATA_SENSE) {
	if (ata_sense_request(rq)) {
		/*
		 * We got an error trying to get sense info from the drive
		 * (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,
		rq = blk_get_request(drive->queue, write, __GFP_RECLAIM);
		scsi_req_init(rq);
		memcpy(scsi_req(rq)->cmd, cmd, BLK_MAX_CDB);
		rq->cmd_type = REQ_TYPE_ATA_PC;
		rq->cmd_type = REQ_TYPE_DRV_PRIV;
		ide_req(rq)->type = ATA_PRIV_PC;
		rq->rq_flags |= rq_flags;
		rq->timeout = timeout;
		if (buffer) {
@@ -520,7 +521,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
	ide_expiry_t *expiry = NULL;
	int dma_error = 0, dma, thislen, uptodate = 0;
	int write = (rq_data_dir(rq) == WRITE) ? 1 : 0, rc = 0;
	int sense = (rq->cmd_type == REQ_TYPE_ATA_SENSE);
	int sense = ata_sense_request(rq);
	unsigned int timeout;
	u16 len;
	u8 ireason, stat;
@@ -785,18 +786,22 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
		if (cdrom_start_rw(drive, rq) == ide_stopped)
			goto out_end;
		break;
	case REQ_TYPE_ATA_SENSE:
	case REQ_TYPE_BLOCK_PC:
	case REQ_TYPE_ATA_PC:
	handle_pc:
		if (!rq->timeout)
			rq->timeout = ATAPI_WAIT_PC;

		cdrom_do_block_pc(drive, rq);
		break;
	case REQ_TYPE_DRV_PRIV:
		switch (ide_req(rq)->type) {
		case ATA_PRIV_MISC:
			/* right now this can only be a reset... */
			uptodate = 1;
			goto out_end;
		case ATA_PRIV_SENSE:
		case ATA_PRIV_PC:
			goto handle_pc;
		}
	default:
		BUG();
	}
+1 −0
Original line number Diff line number Diff line
@@ -306,6 +306,7 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi)
	rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
	scsi_req_init(rq);
	rq->cmd_type = REQ_TYPE_DRV_PRIV;
	ide_req(rq)->type = ATA_PRIV_MISC;
	rq->rq_flags = RQF_QUIET;
	ret = blk_execute_rq(drive->queue, cd->disk, rq, 0);
	blk_put_request(rq);
+1 −0
Original line number Diff line number Diff line
@@ -168,6 +168,7 @@ int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting,
	rq = blk_get_request(q, READ, __GFP_RECLAIM);
	scsi_req_init(rq);
	rq->cmd_type = REQ_TYPE_DRV_PRIV;
	ide_req(rq)->type = ATA_PRIV_MISC;
	scsi_req(rq)->cmd_len = 5;
	scsi_req(rq)->cmd[0] = REQ_DEVSET_EXEC;
	*(int *)&scsi_req(rq)->cmd[1] = arg;
+4 −2
Original line number Diff line number Diff line
@@ -453,7 +453,8 @@ static int idedisk_prep_fn(struct request_queue *q, struct request *rq)
	cmd->tf_flags = IDE_TFLAG_DYN;
	cmd->protocol = ATA_PROT_NODATA;

	rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
	rq->cmd_type = REQ_TYPE_DRV_PRIV;
	ide_req(rq)->type = ATA_PRIV_TASKFILE;
	rq->special = cmd;
	cmd->rq = rq;

@@ -479,7 +480,8 @@ static int set_multcount(ide_drive_t *drive, int arg)

	rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
	scsi_req_init(rq);
	rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
	rq->cmd_type = REQ_TYPE_DRV_PRIV;
	ide_req(rq)->type = ATA_PRIV_TASKFILE;

	drive->mult_req = arg;
	drive->special_flags |= IDE_SFLAG_SET_MULTMODE;
Loading