From patchwork Mon May 22 08:23:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 100266 Delivered-To: patches@linaro.org Received: by 10.140.96.100 with SMTP id j91csp140432qge; Mon, 22 May 2017 01:24:01 -0700 (PDT) X-Received: by 10.25.235.135 with SMTP id f7mr3841169lfk.61.1495441441877; Mon, 22 May 2017 01:24:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495441441; cv=none; d=google.com; s=arc-20160816; b=me8xy8qM137mHuRS8YSWUn8RZvqdsLrL0muz/2tCnDWD/DWEYnT0/BaEXCIEMo+Pt6 4GUJCHLUPw3bHlrrHhkGjcK4/roNp4MIjzqv58ERNbgORu6cimK1U5ixOEFmXkul3WeH XRzDf4frNaOm1aqjoHrSKoDfTvuaTiSnZEqmrd2bebzybTS6BMze3s9w60StE5PB/Zbf qMAXVehObswjGMyxQ7e8gAYGIjYo9Z9y2AVL9c8Yj3o0l+alcvws3yBjxLffNvb174lC YTUR05XfY6MB1pgxnySeCyvUAexR0wVsK34Sb6JXrHGLIz4SHivyM/ItDJOamaHqvPcY /2+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=WYbHjWPH4AYw6MWIUSf8eX3XSi8jUoNSwFnLl0z7eZk=; b=i4qAqFl9b69XRzARZlbURpubzpje71vhPtaGW43Aiz9mUHvb01DzEUKqnuz41NY7Xe OgGOX7bxSixf3SnKJYlvDjFMkx+hysRVbZh9G6Ef1UfT3dvSSqlhbbk43vlrBUmz745K e7KirKxCHF3v/P2xKj7gFNNcK7sV9HraGISn4QkLhYHa7X20bvd5TMheYY/EvfJg8LV0 aY6q5m1oG/kvOXBWnZnQyQrmUbXUnkIKRTE+hjuVyYLFMdUGeA18K9nXe7iv5CdmNanm LmbBlWo77zVe9bQjqiM9fWhgnj9ieLZYssPTAZ/PP9qM+t26xQyWkWv/3L2UGCdHpi2f J2nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-lf0-x22b.google.com (mail-lf0-x22b.google.com. [2a00:1450:4010:c07::22b]) by mx.google.com with ESMTPS id z139si7935082lfd.408.2017.05.22.01.24.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 May 2017 01:24:01 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) client-ip=2a00:1450:4010:c07::22b; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22b as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x22b.google.com with SMTP id m18so26583004lfj.0 for ; Mon, 22 May 2017 01:24:01 -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; bh=WYbHjWPH4AYw6MWIUSf8eX3XSi8jUoNSwFnLl0z7eZk=; b=XgMRZeAa6WZIGoI1OLvK7IS4++hqQbJd8wobMkGRz1me7k2hvTJPHWUpAesAdON8vv XKQRzh/sTH+OQAI6POU26nUzZHCh1l2yZyFu2q/Xr99s1Tw89M/SSi7RakoNpPExL7ad nZYRseVVG/CsjsERD7lk7064vZtvac7FR6Agc= 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; bh=WYbHjWPH4AYw6MWIUSf8eX3XSi8jUoNSwFnLl0z7eZk=; b=bAnejfafKU9KeTICm2Cs/temKA6eUe4FhW+ZAqOgrlhjF5uWFaVl6mIuCYcqV9n3qY P9684n+L4nJjD/vn3fdUtTK+hZWA7HMA1OZw8rRObkWO4pIxs6B4CjBar7MbLmLQ6b2Z ym2ewrh5D5SskQqdGo/cdyN5htTA0f9/j2Far5rGwjNe3VjgI0LXzbVJStfJ7DU4sz55 9Vt+RKuxDV9wUu1xbssZmlwwFJQ0DeAryCnWsR0BWqaWkh/WNgbe85RgB9GsyVix1sDh /SxlqjaHaDEtotWOxO9dk+0qtg6LtYPliVTi82iATlBwxdElGEs5XKvga0Nisx22KA9R FVqQ== X-Gm-Message-State: AODbwcC/7HKHIOpWHIbhT3JV1/9xn3/LNz5W4IFc+KIteh+S/xMEWbWj BVD+Z4isUH7ITdRI0kI= X-Received: by 10.46.13.1 with SMTP id 1mr6007673ljn.134.1495441441349; Mon, 22 May 2017 01:24:01 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-221-67.na.cust.bahnhof.se. [155.4.221.67]) by smtp.gmail.com with ESMTPSA id 34sm2481947lfp.1.2017.05.22.01.24.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 May 2017 01:24:00 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Linus Walleij Subject: [PATCH V2] mmc: block: Use __mmc_send_status() and drop get_card_status() Date: Mon, 22 May 2017 10:23:58 +0200 Message-Id: <1495441438-5129-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 The only reason to why the mmc block device driver needs to implements its own version of how to get the status of the card, is that it needs to specify a different amount of retries. Therefore add a new exported function which allows the caller to specify the number of retries and convert everybody to use it, as this simplifies the code. Signed-off-by: Ulf Hansson --- Changes in v2: - Allow callers to specify retries. --- drivers/mmc/core/block.c | 22 +++------------------- drivers/mmc/core/mmc_ops.c | 10 ++++++++-- drivers/mmc/core/mmc_ops.h | 1 + 3 files changed, 12 insertions(+), 21 deletions(-) -- 2.7.4 Reviewed-by: Linus Walleij diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index e973798..8263859 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -127,7 +127,6 @@ 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); -static int get_card_status(struct mmc_card *card, u32 *status, int retries); static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk) { @@ -385,7 +384,7 @@ static int ioctl_rpmb_card_status_poll(struct mmc_card *card, u32 *status, return -EINVAL; do { - err = get_card_status(card, status, 5); + err = __mmc_send_status(card, status, 5); if (err) break; @@ -885,21 +884,6 @@ static int mmc_sd_num_wr_blocks(struct mmc_card *card, u32 *written_blocks) return 0; } -static int get_card_status(struct mmc_card *card, u32 *status, int retries) -{ - struct mmc_command cmd = {}; - int err; - - cmd.opcode = MMC_SEND_STATUS; - if (!mmc_host_is_spi(card->host)) - cmd.arg = card->rca << 16; - cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC; - err = mmc_wait_for_cmd(card->host, &cmd, retries); - if (err == 0) - *status = cmd.resp[0]; - return err; -} - static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms, bool hw_busy_detect, struct request *req, bool *gen_err) { @@ -908,7 +892,7 @@ static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms, u32 status; do { - err = get_card_status(card, &status, 5); + err = __mmc_send_status(card, &status, 5); if (err) { pr_err("%s: error %d requesting status\n", req->rq_disk->disk_name, err); @@ -1076,7 +1060,7 @@ static int mmc_blk_cmd_recovery(struct mmc_card *card, struct request *req, * we can't be sure the returned status is for the r/w command. */ for (retry = 2; retry >= 0; retry--) { - err = get_card_status(card, &status, 0); + err = __mmc_send_status(card, &status, 0); if (!err) break; diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 78f75f0..ae1fc48 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -54,7 +54,7 @@ static const u8 tuning_blk_pattern_8bit[] = { 0xff, 0x77, 0x77, 0xff, 0x77, 0xbb, 0xdd, 0xee, }; -int mmc_send_status(struct mmc_card *card, u32 *status) +int __mmc_send_status(struct mmc_card *card, u32 *status, unsigned int retries) { int err; struct mmc_command cmd = {}; @@ -64,7 +64,7 @@ int mmc_send_status(struct mmc_card *card, u32 *status) cmd.arg = card->rca << 16; cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC; - err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); + err = mmc_wait_for_cmd(card->host, &cmd, retries); if (err) return err; @@ -76,6 +76,12 @@ int mmc_send_status(struct mmc_card *card, u32 *status) return 0; } +EXPORT_SYMBOL_GPL(__mmc_send_status); + +int mmc_send_status(struct mmc_card *card, u32 *status) +{ + return __mmc_send_status(card, status, MMC_CMD_RETRIES); +} static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card) { diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h index 978bd2e..b8d0552 100644 --- a/drivers/mmc/core/mmc_ops.h +++ b/drivers/mmc/core/mmc_ops.h @@ -25,6 +25,7 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr); int mmc_all_send_cid(struct mmc_host *host, u32 *cid); int mmc_set_relative_addr(struct mmc_card *card); int mmc_send_csd(struct mmc_card *card, u32 *csd); +int __mmc_send_status(struct mmc_card *card, u32 *status, unsigned int retries); int mmc_send_status(struct mmc_card *card, u32 *status); int mmc_send_cid(struct mmc_host *host, u32 *cid); int mmc_spi_read_ocr(struct mmc_host *host, int highcap, u32 *ocrp);