mmc: block: Tag DRV_OPs with a driver operation type
We will expand the DRV_OP usage, so we need to know which operation we're performing. Tag the operations with an enum:ed type and rename the function so it is clear that it deals with any command and put a switch statement in it. Currently only ioctls are supported. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
67e69d5220
commit
02166a01f8
|
@ -602,6 +602,7 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev,
|
||||||
idata->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN,
|
idata->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN,
|
||||||
__GFP_RECLAIM);
|
__GFP_RECLAIM);
|
||||||
idatas[0] = idata;
|
idatas[0] = idata;
|
||||||
|
req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_IOCTL;
|
||||||
req_to_mmc_queue_req(req)->idata = idatas;
|
req_to_mmc_queue_req(req)->idata = idatas;
|
||||||
req_to_mmc_queue_req(req)->ioc_count = 1;
|
req_to_mmc_queue_req(req)->ioc_count = 1;
|
||||||
blk_execute_rq(mq->queue, NULL, req, 0);
|
blk_execute_rq(mq->queue, NULL, req, 0);
|
||||||
|
@ -618,11 +619,11 @@ cmd_err:
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The ioctl commands come back from the block layer after it queued it and
|
* The non-block commands come back from the block layer after it queued it and
|
||||||
* processed it with all other requests and then they get issued in this
|
* processed it with all other requests and then they get issued in this
|
||||||
* function.
|
* function.
|
||||||
*/
|
*/
|
||||||
static void mmc_blk_ioctl_cmd_issue(struct mmc_queue *mq, struct request *req)
|
static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req)
|
||||||
{
|
{
|
||||||
struct mmc_queue_req *mq_rq;
|
struct mmc_queue_req *mq_rq;
|
||||||
struct mmc_card *card = mq->card;
|
struct mmc_card *card = mq->card;
|
||||||
|
@ -631,18 +632,27 @@ static void mmc_blk_ioctl_cmd_issue(struct mmc_queue *mq, struct request *req)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mq_rq = req_to_mmc_queue_req(req);
|
mq_rq = req_to_mmc_queue_req(req);
|
||||||
for (i = 0; i < mq_rq->ioc_count; i++) {
|
|
||||||
ioc_err = __mmc_blk_ioctl_cmd(card, md, mq_rq->idata[i]);
|
switch (mq_rq->drv_op) {
|
||||||
if (ioc_err)
|
case MMC_DRV_OP_IOCTL:
|
||||||
break;
|
for (i = 0; i < mq_rq->ioc_count; i++) {
|
||||||
|
ioc_err =
|
||||||
|
__mmc_blk_ioctl_cmd(card, md, mq_rq->idata[i]);
|
||||||
|
if (ioc_err)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mq_rq->ioc_result = ioc_err;
|
||||||
|
|
||||||
|
/* Always switch back to main area after RPMB access */
|
||||||
|
if (md->area_type & MMC_BLK_DATA_AREA_RPMB)
|
||||||
|
mmc_blk_part_switch(card, dev_get_drvdata(&card->dev));
|
||||||
|
|
||||||
|
blk_end_request_all(req, ioc_err);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* Unknown operation */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
mq_rq->ioc_result = ioc_err;
|
|
||||||
|
|
||||||
/* Always switch back to main area after RPMB access */
|
|
||||||
if (md->area_type & MMC_BLK_DATA_AREA_RPMB)
|
|
||||||
mmc_blk_part_switch(card, dev_get_drvdata(&card->dev));
|
|
||||||
|
|
||||||
blk_end_request_all(req, ioc_err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev,
|
static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev,
|
||||||
|
@ -705,6 +715,7 @@ static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev,
|
||||||
req = blk_get_request(mq->queue,
|
req = blk_get_request(mq->queue,
|
||||||
idata[0]->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN,
|
idata[0]->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN,
|
||||||
__GFP_RECLAIM);
|
__GFP_RECLAIM);
|
||||||
|
req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_IOCTL;
|
||||||
req_to_mmc_queue_req(req)->idata = idata;
|
req_to_mmc_queue_req(req)->idata = idata;
|
||||||
req_to_mmc_queue_req(req)->ioc_count = num_of_cmds;
|
req_to_mmc_queue_req(req)->ioc_count = num_of_cmds;
|
||||||
blk_execute_rq(mq->queue, NULL, req, 0);
|
blk_execute_rq(mq->queue, NULL, req, 0);
|
||||||
|
@ -1904,7 +1915,7 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
|
||||||
*/
|
*/
|
||||||
if (mq->qcnt)
|
if (mq->qcnt)
|
||||||
mmc_blk_issue_rw_rq(mq, NULL);
|
mmc_blk_issue_rw_rq(mq, NULL);
|
||||||
mmc_blk_ioctl_cmd_issue(mq, req);
|
mmc_blk_issue_drv_op(mq, req);
|
||||||
break;
|
break;
|
||||||
case REQ_OP_DISCARD:
|
case REQ_OP_DISCARD:
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -32,6 +32,14 @@ struct mmc_blk_request {
|
||||||
int retune_retry_done;
|
int retune_retry_done;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* enum mmc_drv_op - enumerates the operations in the mmc_queue_req
|
||||||
|
* @MMC_DRV_OP_IOCTL: ioctl operation
|
||||||
|
*/
|
||||||
|
enum mmc_drv_op {
|
||||||
|
MMC_DRV_OP_IOCTL,
|
||||||
|
};
|
||||||
|
|
||||||
struct mmc_queue_req {
|
struct mmc_queue_req {
|
||||||
struct mmc_blk_request brq;
|
struct mmc_blk_request brq;
|
||||||
struct scatterlist *sg;
|
struct scatterlist *sg;
|
||||||
|
@ -39,6 +47,7 @@ struct mmc_queue_req {
|
||||||
struct scatterlist *bounce_sg;
|
struct scatterlist *bounce_sg;
|
||||||
unsigned int bounce_sg_len;
|
unsigned int bounce_sg_len;
|
||||||
struct mmc_async_req areq;
|
struct mmc_async_req areq;
|
||||||
|
enum mmc_drv_op drv_op;
|
||||||
int ioc_result;
|
int ioc_result;
|
||||||
struct mmc_blk_ioc_data **idata;
|
struct mmc_blk_ioc_data **idata;
|
||||||
unsigned int ioc_count;
|
unsigned int ioc_count;
|
||||||
|
|
Loading…
Reference in a new issue