From patchwork Fri May 19 13:37:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9737273 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 52ECF6041F for ; Fri, 19 May 2017 13:37:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30C6B28815 for ; Fri, 19 May 2017 13:37:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 255AD288FA; Fri, 19 May 2017 13:37:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBFCB28922 for ; Fri, 19 May 2017 13:37:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754853AbdESNhy (ORCPT ); Fri, 19 May 2017 09:37:54 -0400 Received: from mail-lf0-f48.google.com ([209.85.215.48]:35471 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754825AbdESNhw (ORCPT ); Fri, 19 May 2017 09:37:52 -0400 Received: by mail-lf0-f48.google.com with SMTP id y126so1149059lfc.2 for ; Fri, 19 May 2017 06:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NTJPXbvanHXXpyCKjRIa+kiTutlDZ9dTTt5vB9grCU0=; b=Q6IqN/oAasiZvDuHSS+njr62PSpDrYSO+kCbkUd9fiHcup+0G16XTZjw6Q6Tcre4Au +l8b7a6iy0ZtgUm6ZTOAZGpvM/6LIZva6OgmJ7MUzhMh5tRVT4+9xOL5E+20aEKoRvb2 Y7HETFJUA5TjzjNmMPrhf3TSpbC1eTAKFRgkw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NTJPXbvanHXXpyCKjRIa+kiTutlDZ9dTTt5vB9grCU0=; b=Tfz5yorOMmB0fsX5/wCFnQKAWxXlCmY97Uu5hlmY5mlTQsapY4kjrRIqdjTojZ/Y53 1JaaFrWU/XY4+D5B6ZN3x8Di2tRApqfOECcWNkr/5YMvsDnJXNlce53I0wvhsRimowxc hQIik6IU+3kubg9piKYBhhs8Q77gLxQgXynABcG7nF2ugkZl5ydZ6b3E6l8g3IaofZgy K9fkDScOb5M04cJaALXGPc8nyhthEyVwIgjK0anUbT6dfytKWtASoOnAfs/Ka+fAaIRm 7Vh/o3nRRHQBk8BNAAJujfLKj5s7AmH+IfwLBdAGH9WV+fu7U9Ha24siVr5AgjR/6Cro fhjQ== X-Gm-Message-State: AODbwcCd2ZummNTYk3qyKFxmQm3pFtlamiyh5NRrG/+q7yEn4dO/6GuR WqsMqxK/RewK7LqY X-Received: by 10.25.38.15 with SMTP id m15mr2393633lfm.32.1495201071059; Fri, 19 May 2017 06:37:51 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 19sm1514130ljf.32.2017.05.19.06.37.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 May 2017 06:37:49 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter Cc: linux-block@vger.kernel.org, Jens Axboe , Christoph Hellwig , Arnd Bergmann , Bartlomiej Zolnierkiewicz , Paolo Valente , Avri Altman , Linus Walleij Subject: [PATCH 2/6] mmc: block: Tag DRV_OPs with a driver operation type Date: Fri, 19 May 2017 15:37:28 +0200 Message-Id: <20170519133732.27470-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170519133732.27470-1-linus.walleij@linaro.org> References: <20170519133732.27470-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/mmc/core/block.c | 37 ++++++++++++++++++++++++------------- drivers/mmc/core/queue.h | 9 +++++++++ 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 553ab4d1db94..b24e7f5171c9 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -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, __GFP_RECLAIM); 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)->ioc_count = 1; blk_execute_rq(mq->queue, NULL, req, 0); @@ -618,11 +619,11 @@ static int mmc_blk_ioctl_cmd(struct block_device *bdev, } /* - * 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 * 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_card *card = mq->card; @@ -631,18 +632,27 @@ static void mmc_blk_ioctl_cmd_issue(struct mmc_queue *mq, struct request *req) int i; 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]); - 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)); + switch (mq_rq->drv_op) { + case MMC_DRV_OP_IOCTL: + 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); + blk_end_request_all(req, ioc_err); + break; + default: + /* Unknown operation */ + break; + } } 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, idata[0]->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, __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)->ioc_count = num_of_cmds; 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) mmc_blk_issue_rw_rq(mq, NULL); - mmc_blk_ioctl_cmd_issue(mq, req); + mmc_blk_issue_drv_op(mq, req); break; case REQ_OP_DISCARD: /* diff --git a/drivers/mmc/core/queue.h b/drivers/mmc/core/queue.h index 2793020a3c8c..1e6062eb3e07 100644 --- a/drivers/mmc/core/queue.h +++ b/drivers/mmc/core/queue.h @@ -32,6 +32,14 @@ struct mmc_blk_request { 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_blk_request brq; struct scatterlist *sg; @@ -39,6 +47,7 @@ struct mmc_queue_req { struct scatterlist *bounce_sg; unsigned int bounce_sg_len; struct mmc_async_req areq; + enum mmc_drv_op drv_op; int ioc_result; struct mmc_blk_ioc_data **idata; unsigned int ioc_count;