From patchwork Sun Aug 20 21:39:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 110488 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp521483qge; Sun, 20 Aug 2017 14:39:33 -0700 (PDT) X-Received: by 10.84.215.15 with SMTP id k15mr16679076pli.92.1503265173086; Sun, 20 Aug 2017 14:39:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503265173; cv=none; d=google.com; s=arc-20160816; b=FvAAnIa6YvdGOmVOZuPImvACOl6Etc/dZKP2ximFGSI1EYsuPlLGkGKyB9KNtafVuo uManbOfcQ/soqZe06rAQaBrB5jKWGOuIsDNBTSA5LRoaLE9cS4klUsTnvwWneZbKLKuU oElRElVIqmG/0UR4KBsKYrvTf1PrVlf+58bEKdu3T9UOKYLcLCx0msCz2qyLYEbkJ8L4 Rg/TyaIYtxskxFu1syzEZqdcJBxrKpkYENYb25jqjSsEib8Xvl6rH4EDjtewiVrMLE0D bdGOJegKyDXT3E5AKdTzF+CJ80WmqvFdM+/jYECdV/0jg6MzHQ25p+cQYQtnYGtwbbUx ffig== 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=RtY/AGQOhtu5Utm/U8qql/3sB9LFx24BKFARwIFEGME=; b=RTjS7B+gJ8Wu/7KALqWEOfUnvQ2kFMQh2khsxcw7ov/U6XQ+cxV9R2YqLwf7PIdaTt 8DPjb7dKRPuN9amLYrYzH/IwwiF4APp4GBxWzvUkFye9uwGTMWsbV7iPhoLTr/WsVOWb w+64NuMD0+L2q5XZjjzA8jWKChKwwpiJzLG/mE6+YmCd+bNqe7KGDGpynH2eyI1La5sD oEZpOdLgO13vSsMCJ1rHDQ045WZJAshpNcgoVAFs7UIlAmzI/REkdEnzzeYn1NKdD0MV 1wH+xH+kldrt/rNfKwXo2p80dB4Cx35zrGLPXeN4CjC3bSUIPrSy3fipoyYfOx6rJDwt vOrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ieJb1urY; 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 z1si3544613pgn.611.2017.08.20.14.39.32; Sun, 20 Aug 2017 14:39:33 -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 header.s=google header.b=ieJb1urY; 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 S1753371AbdHTVjc (ORCPT + 6 others); Sun, 20 Aug 2017 17:39:32 -0400 Received: from mail-lf0-f49.google.com ([209.85.215.49]:37283 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753351AbdHTVjb (ORCPT ); Sun, 20 Aug 2017 17:39:31 -0400 Received: by mail-lf0-f49.google.com with SMTP id f7so39963031lfg.4 for ; Sun, 20 Aug 2017 14:39:30 -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=CTe8GnjC9E3IjzzM2OtJxq461JWpK6rwJ2/d5zB2ATw=; b=ieJb1urYluB9H9zNBa2NQBiD5YlysuUfwnC/Gd2sne+HBMmFyJGPg4xrHe/wFsIPb0 72or8iZodN7uvLQhS6M0Fq8Zhsnvrpo6mLOZ2QHMSTjg5LTBDuiNjuHPwlfqWScI7D0h ZLXbIQK6YHEOunMtjhEvzM9df8cnjsL6oIgvI= 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=CTe8GnjC9E3IjzzM2OtJxq461JWpK6rwJ2/d5zB2ATw=; b=E/6DxbOzgD0H6YALZOoWOnIlzAyFYRHyFIf0TLXzr4V6JSe8yPBaDopDUAjpbZVdfP AVwDFfoQvf/cFjL4Ks8zcx2re2jPrBVjMDegJ+jcy4xMoBM3cdCnJIMlXpEtw8YTnr5l LaA16ec8vBekPMTbJcp6PJNGdHfMWP7ysmQBA9dYXcGT8Numjicj3QFneiOAjZ+3HEc7 EXLnpFSOQjxbgNi9mQzOZef8QeLWew04oVrCGfkMjvAoBuwzxBeIk+I9vBzP3vIwg0yd qRY95JucPA4tB3ifuhXucCm16Hz9XuEVqHmHElT0I7txKMdKMii5hz6JqejQQrb+P0nI 3VaA== X-Gm-Message-State: AHYfb5ghTaiJNl4202oh/FjB478P5mwHWsU/PggJ6xZGPVDyVAaMgPbe m7gcfWBEDEJZRsim0EC5Sg== X-Received: by 10.25.198.19 with SMTP id w19mr187045lff.211.1503265169828; Sun, 20 Aug 2017 14:39:29 -0700 (PDT) Received: from genomnajs.bredbandsbolaget.se (c-097b71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.123.9]) by smtp.gmail.com with ESMTPSA id f136sm2381830lff.34.2017.08.20.14.39.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Aug 2017 14:39:29 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij Subject: [PATCH 5/8 v5] mmc: block: Refactor mmc_blk_part_switch() Date: Sun, 20 Aug 2017 23:39:10 +0200 Message-Id: <20170820213913.9737-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170820213913.9737-1-linus.walleij@linaro.org> References: <20170820213913.9737-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Instead of passing a struct mmc_blk_data * to mmc_blk_part_switch() let's pass the actual partition type we want to switch to. This is necessary in order not to have a block device with a backing mmc_blk_data and request queue and all for every hardware partition, such as RPMB. Signed-off-by: Linus Walleij --- ChangeLog v1->v5: - Rebase. - Renumber v5 to keep together with the rest of the series. --- drivers/mmc/core/block.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) -- 2.13.5 -- 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 b0585f7971f1..3abdbab401ad 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -127,7 +127,7 @@ module_param(perdev_minors, int, 0444); MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device"); static inline int mmc_blk_part_switch(struct mmc_card *card, - struct mmc_blk_data *md); + unsigned int part_type); static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk) { @@ -488,7 +488,7 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md, mrq.cmd = &cmd; - err = mmc_blk_part_switch(card, md); + err = mmc_blk_part_switch(card, md->part_type); if (err) return err; @@ -768,29 +768,29 @@ static int mmc_blk_part_switch_post(struct mmc_card *card, } static inline int mmc_blk_part_switch(struct mmc_card *card, - struct mmc_blk_data *md) + unsigned int part_type) { int ret = 0; struct mmc_blk_data *main_md = dev_get_drvdata(&card->dev); - if (main_md->part_curr == md->part_type) + if (main_md->part_curr == part_type) return 0; if (mmc_card_mmc(card)) { u8 part_config = card->ext_csd.part_config; - ret = mmc_blk_part_switch_pre(card, md->part_type); + ret = mmc_blk_part_switch_pre(card, part_type); if (ret) return ret; part_config &= ~EXT_CSD_PART_CONFIG_ACC_MASK; - part_config |= md->part_type; + part_config |= part_type; ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONFIG, part_config, card->ext_csd.part_time); if (ret) { - mmc_blk_part_switch_post(card, md->part_type); + mmc_blk_part_switch_post(card, part_type); return ret; } @@ -799,7 +799,7 @@ static inline int mmc_blk_part_switch(struct mmc_card *card, ret = mmc_blk_part_switch_post(card, main_md->part_curr); } - main_md->part_curr = md->part_type; + main_md->part_curr = part_type; return ret; } @@ -1142,7 +1142,7 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host, int part_err; main_md->part_curr = main_md->part_type; - part_err = mmc_blk_part_switch(host->card, md); + part_err = mmc_blk_part_switch(host->card, md->part_type); if (part_err) { /* * We have failed to get back into the correct @@ -1181,6 +1181,7 @@ 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; struct mmc_blk_data *md = mq->blkdata; + struct mmc_blk_data *main_md = dev_get_drvdata(&card->dev); struct mmc_blk_ioc_data **idata; u8 **ext_csd; u32 status; @@ -1199,7 +1200,7 @@ static void mmc_blk_issue_drv_op(struct mmc_queue *mq, struct request *req) } /* 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)); + mmc_blk_part_switch(card, main_md->part_type); break; case MMC_DRV_OP_BOOT_WP: ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP, @@ -1922,7 +1923,7 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) /* claim host only for the first request */ mmc_get_card(card); - ret = mmc_blk_part_switch(card, md); + ret = mmc_blk_part_switch(card, md->part_type); if (ret) { if (req) { blk_end_request_all(req, BLK_STS_IOERR); @@ -2456,7 +2457,7 @@ static void mmc_blk_remove(struct mmc_card *card) mmc_blk_remove_parts(card, md); pm_runtime_get_sync(&card->dev); mmc_claim_host(card->host); - mmc_blk_part_switch(card, md); + mmc_blk_part_switch(card, md->part_type); mmc_release_host(card->host); if (card->type != MMC_TYPE_SD_COMBO) pm_runtime_disable(&card->dev);