From patchwork Thu Apr 5 20:19:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 132887 Delivered-To: patches@linaro.org Received: by 10.46.84.29 with SMTP id i29csp6712537ljb; Thu, 5 Apr 2018 13:20:11 -0700 (PDT) X-Received: by 2002:a19:e418:: with SMTP id b24-v6mr14151973lfh.61.1522959611204; Thu, 05 Apr 2018 13:20:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522959611; cv=none; d=google.com; s=arc-20160816; b=Azs25e7IcrXoadH3btQ1MOWhDHRbO0nhNKAFWKkLiiN81avAUyUbUhyHRCXwu8XOmq Nnfo0zhffMrIUGnVRDhK+oXR4/MDCbuAYyuNLlYYDr2y9zSq2Yn11BYAMx09Qz+f6bPe R2NGxA0ntYnNdIPrDGRYNTfqbLwaeSqZzpEEjKeu4NGcU+13Tsae7GkQx/iQXeAN+a3O SRnw4KwnmO+As1FXv2+bJ2Iv7Hy7nenteSET1tgnXh+3mM3lyIpo99pwR7j3D6Wc/3e1 gPnPldn7EIlAa4BOIwD4C7C0EKXv2+e+MU1L9ReMpysZkjJ7OZUkP+H24n2Oa1hTHvbR 0ogg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=P+n6KYJ/751SQqDpKzbVQJs59emJ3Z8ZwiYRMTp5UjU=; b=I7Q1BMQQUDPVfFI5C7xatKaGz8zKdWU/PthTQXR09rk5nHoK0OseM7jdYJCyAn70GL wPEDnY3ILa9uGCRzHWdS1gS91A+ibOntPOsmSdcgUYa+fkj3Ko0Kebz3JID5tN8/3out 3ATdGmNL8PSHDs4WT/rWbBBUYhYs82QaWjjzhVUmRmLjud8okNsGPVuURw7Cz8bIGR4A bIS5Wd/2PcBX0sVGE6A6Y+G04pjH/Bna8au2DqKFm8bzDlBGpqCcpvkHWXQXSBvxBLFx j20JkULizJL8XistV9kyMhP6Kcs/xZ10I2eJnO/jKAvrDZ22BlyR6iUv7qCfLbn5mZ86 5r/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ktsNhdIk; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 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-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id h78-v6sor2075507lfb.67.2018.04.05.13.20.11 for (Google Transport Security); Thu, 05 Apr 2018 13:20:11 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ktsNhdIk; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=P+n6KYJ/751SQqDpKzbVQJs59emJ3Z8ZwiYRMTp5UjU=; b=ktsNhdIkWBKJqAtIkr70l8eFzMvv9Jfc5QYLXBC5P1o+FC6YvhT0PME/NoXPUNrxep 8nxms4lmxWvDtVK+mNK+RceZzn7D5urN5jhnkwz4ZdAR+HG4BUiwsEsPe2T8hlkYqm/+ s5V5eqtSZ+lKbb6kbidB4rNo2XRdnfn7Qqr/I= 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=P+n6KYJ/751SQqDpKzbVQJs59emJ3Z8ZwiYRMTp5UjU=; b=ChkCm/mYSpA/Rl59aqwI2Yabmm9TupNLu5vb6dlNg0GLw6x+QV6fwhtRH56cRrYCVv A0AUarfovWG7L0Q+DwoEGj/LfqyL0AbPKJi/zwvEwPdws44j8tG0ngvUdm+U3aR6i0Hf 3KoR5+PD1iyqmIUta5fdz0A1+Dt+GcW9w2a0t9qC9Wd9U4EfnFC9ceBM+eYbfPGsZWkb 0rxhV+1dbtipzYaGYVXokuCvh/57ck1DaNjfucTBRFiApk5plVUaKLSrl0CgVW5Nc9EJ H54A2vvQ9WH/zvR2PpZcRf+/Qq/knHBrQsbNPbEhDqG0xeHU75UfE7rB69kDUEYok+Bb KtdA== X-Gm-Message-State: ALQs6tChflvIUIK2oBC8LP1bBcYcjihG7eWk1DJu8reeunCi9YOCISgK /MS/wDDTrnzo2a60XLGwTP8quxpp X-Google-Smtp-Source: AIpwx4+v351sTqTrHKpterceRdrijxHJfOcHr4GS5rmCie/IvC2Ugx5SusSFE1nn5vRUl9+wBZ4zyQ== X-Received: by 2002:a19:d403:: with SMTP id l3-v6mr9262478lfg.51.1522959610950; Thu, 05 Apr 2018 13:20:10 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id h66-v6sm1687533lfi.89.2018.04.05.13.20.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Apr 2018 13:20:10 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Adrian Hunter , Brian Norris , Shawn Lin , Doug Anderson , Hans de Goede , Quentin Schulz Subject: [PATCH 1/5] mmc: core: Re-factor some code for SDIO re-initialization Date: Thu, 5 Apr 2018 22:19:50 +0200 Message-Id: <1522959594-3411-2-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1522959594-3411-1-git-send-email-ulf.hansson@linaro.org> References: <1522959594-3411-1-git-send-email-ulf.hansson@linaro.org> The mmc_sdio_init_card() function has a couple of callers. In the re-initialization cases, some additional reset commands are issued before mmc_sdio_init_card() is called. As these additional reset commands are the same, let's move these into a new static function, mmc_sdio_reinit_card() and call mmc_sdio_init_card() from there. In this way we avoid the open coding. Signed-off-by: Ulf Hansson --- drivers/mmc/core/sdio.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) -- 2.7.4 diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index c599a62..c20168a 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -801,6 +801,22 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, return err; } +static int mmc_sdio_reinit_card(struct mmc_host *host, bool powered_resume) +{ + int ret; + + sdio_reset(host); + mmc_go_idle(host); + mmc_send_if_cond(host, host->card->ocr); + + ret = mmc_send_io_op_cond(host, 0, NULL); + if (ret) + return ret; + + return mmc_sdio_init_card(host, host->card->ocr, host->card, + powered_resume); +} + /* * Host is being removed. Free up the current card. */ @@ -948,14 +964,7 @@ static int mmc_sdio_resume(struct mmc_host *host) /* No need to reinitialize powered-resumed nonremovable cards */ if (mmc_card_is_removable(host) || !mmc_card_keep_power(host)) { - sdio_reset(host); - mmc_go_idle(host); - mmc_send_if_cond(host, host->card->ocr); - err = mmc_send_io_op_cond(host, 0, NULL); - if (!err) - err = mmc_sdio_init_card(host, host->card->ocr, - host->card, - mmc_card_keep_power(host)); + err = mmc_sdio_reinit_card(host, mmc_card_keep_power(host)); } else if (mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host)) { /* We may have switched to 1-bit mode during suspend */ err = sdio_enable_4bit_bus(host->card); @@ -978,8 +987,6 @@ static int mmc_sdio_power_restore(struct mmc_host *host) { int ret; - mmc_claim_host(host); - /* * Reset the card by performing the same steps that are taken by * mmc_rescan_try_freq() and mmc_attach_sdio() during a "normal" probe. @@ -997,20 +1004,12 @@ static int mmc_sdio_power_restore(struct mmc_host *host) * */ - sdio_reset(host); - mmc_go_idle(host); - mmc_send_if_cond(host, host->card->ocr); - - ret = mmc_send_io_op_cond(host, 0, NULL); - if (ret) - goto out; + mmc_claim_host(host); - ret = mmc_sdio_init_card(host, host->card->ocr, host->card, - mmc_card_keep_power(host)); + ret = mmc_sdio_reinit_card(host, mmc_card_keep_power(host)); if (!ret && host->sdio_irqs) mmc_signal_sdio_irq(host); -out: mmc_release_host(host); return ret;