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: 100192 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp319194qge; Fri, 19 May 2017 06:37:55 -0700 (PDT) X-Received: by 10.84.138.193 with SMTP id 59mr11734458plp.184.1495201075318; Fri, 19 May 2017 06:37:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495201075; cv=none; d=google.com; s=arc-20160816; b=K7ASGSCSY3F8Oty+CXt3inDU/b3nksktM5r0U3bLbUOWSYzFDB+UrnH/uAmRuJLp8s bH6RzD3UOV3YpqAzDNl/Zvbcpx6Cp08ce2QsGXhBr0V6l/hdKcpY4H/JuzZ7Dg9ONlVa mO9gOOcLB2pny+Vu4WqDhTHFxP9oAawLJoJTglbJXNu8vMN4Pn3dQKDcsQZffIwdlWgi JYg7f20XwXGp6DCM8+5Z8s0uuX/vX/L4cOmFE/UTGNGLSdy9XWfjAlF4z/dPbpJP8PYd D1akx3cvvsdwR5xeXD/TYoqR6/GWLIji4aFRKvMi/gjUodyCzAOUiqy43k0bxAi0iBnv toyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=L1XhwrAydLK+XeQREjGL6+uYAnF20xxBD2mRWxXy+VQ=; b=GQyRrwSkFeaZHRtU223EN91eA63FVSGgXoDxMvHGQ2pWzwVkrcNfnO7aWe28facnoS SAEkvK/uL6Zlcm77KisDsUBvOETZRVY4Vn0+CKUgtj70Orl5JwzQAEWzEcvimDRkg5v7 wT0gZ3plZL4coHLiParQJ/LxVn0+3ncawhL8AxBsRzQvKXb6MpIy9s54f7f3Ax6XOvVD tDtTtT+rNhS0h/rmrUw1bh8a1T8MYczi2q6g7AdVDTR/Fj5JpzriS3xE4uMKAQr7pZdT 0WxDhHzlagcTtt5KXQakp/gBm5yyWRCEImeBPpfruXVemXAdCK6e2Uk3NftYU+GFHR8a hhyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si8689720plb.270.2017.05.19.06.37.55; Fri, 19 May 2017 06:37:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754853AbdESNhy (ORCPT + 6 others); 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 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(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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;