From patchwork Thu Jun 8 13:27:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 103391 Delivered-To: patches@linaro.org Received: by 10.140.91.77 with SMTP id y71csp2439545qgd; Thu, 8 Jun 2017 06:28:00 -0700 (PDT) X-Received: by 10.25.15.157 with SMTP id 29mr8725536lfp.10.1496928479973; Thu, 08 Jun 2017 06:27:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496928479; cv=none; d=google.com; s=arc-20160816; b=Q6ItS+YvAfj+SltpTNbJRazbZFJNIntpv/hZ0Jgk11l1wupvVEDLVH6LhrpsRSyoH0 1RK6+PqhcyC0WdhBWxZa+KhK1kBD1TCSXn70yurvjxgXTe7EBdVvPg7ev9RaJ+UQ//lc qV8d+84M5sOMZ4idWoK7nKrdlDy/rHk6U3+XAFOWBZRIA2wE2ri+YOUc3b31BFNELsqy BOI5eAcXPUwG97e3TYi4evuguw694YK0ayTwdLgmKA/ttVibnSI+xfwWjlsaEbemc/li ZqtEvA2qqAE22LFaCdiAyXDCc6TfmKEH8gQmvie+7Ahkq+Juo/ceP4ayRYYsTW1CUDTD 4r3w== 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=YrZyqzdOqLiOchSGsGsAgBc1j+YuZWec945LHFHiZsE=; b=isw6XRTmT9xD07sAYUEflL44uTxqzhkFwElk+dmGrDA7XEVe+vRv7xF5q/IWebFjmr 3FncN5TmENYM1g9RhI6BlrFnuceAF6F1RIoGeiZ9AZMLeVNYWOBqPps0pkp9D1X+9u5m ajkQtt8oNDXmcvHpRO6S+ZC6FIhWIUL6K5UB2ZldnL44IgHt+fvNnuFEsPMGVfVu92Dq Qcg0v3DCHEku85GOeg4rMo1B7WJHf8Pzky/uoBQ37i5lLFTXVotno4KLSAAYj4NJjpaq l9wTyEVDbWVEUNMtd5s269Ky3AeNd5qvQjjTtcYw/TPBBR/hZ41dzKH8r/SZWjpamHpc 9x0A== 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::22a 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-x22a.google.com (mail-lf0-x22a.google.com. [2a00:1450:4010:c07::22a]) by mx.google.com with ESMTPS id c82si2515787lfc.169.2017.06.08.06.27.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Jun 2017 06:27:59 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::22a as permitted sender) client-ip=2a00:1450:4010:c07::22a; 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::22a 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-x22a.google.com with SMTP id v20so18057205lfa.1 for ; Thu, 08 Jun 2017 06:27:59 -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=YrZyqzdOqLiOchSGsGsAgBc1j+YuZWec945LHFHiZsE=; b=Gy9AMSc6Bb9Uq1fQ2rLSwJYuRZYmKzpASQyoN0YjYZyodwHlLI3r8STDMw75wkx89z icA6I80pgxbL7GY7n2Jzt5et/6KKnfFLngnhwfzrBTGxbVGZFEiEcXlFJU2pDIMAD6as JyoGeDuz7ILeIux2Bdv04sd39wsgXBGwHSNKY= 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=YrZyqzdOqLiOchSGsGsAgBc1j+YuZWec945LHFHiZsE=; b=FLUkgK6zES0Mvlpu92F0pF6s2bAPPI0iB6HlaSqJrbjRjJHhSJ8KdIffABIPgZYaPV RmgQQeSRGEhrm1AcMx+NN2FPO9kBNaTUOQOYkObLTtPrn/Xz5y/3/RWrpNcGYEtKh5zI 0mSh9MNecwcR+T7uNIaTsH2Q3ifPPBBkNpZrIpLv4rtWnUCMx7P3Q37u0HLP+gTwxAlF 1Rbe+YuP7rwFudSbj/FiWkGpMRYzzkJMn0MC+iHJion3kk16r8w5VUnt2SnLRUGMOdkL pnUBUHrnERjgv6eQOJNSSIEPGh4QbxE31F/cpsbliBCbaE+zgyjVJX4yhDwli622SFaX HV9A== X-Gm-Message-State: AODbwcD1xNcFn8c+Dr2Dgdi6tXTdLuTkEARaEk7YoxM3rEAcHC6/7OB+ JLO6IuEGlCXXF2CfX4kzBjgY X-Received: by 10.46.84.14 with SMTP id i14mr4792126ljb.100.1496928479621; Thu, 08 Jun 2017 06:27:59 -0700 (PDT) Return-Path: Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id i8sm1025178ljb.55.2017.06.08.06.27.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Jun 2017 06:27:59 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Jaehoon Chung , Adrian Hunter , Linus Walleij Subject: [PATCH 7/9] mmc: core: Re-factor code for sending CID Date: Thu, 8 Jun 2017 15:27:43 +0200 Message-Id: <1496928465-25004-8-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496928465-25004-1-git-send-email-ulf.hansson@linaro.org> References: <1496928465-25004-1-git-send-email-ulf.hansson@linaro.org> Instead of having the caller to check for SPI mode, let's leave that to internals of mmc_send_cid(). In this way the code gets cleaner and it becomes clear what is specific to SPI and non-SPI mode. Signed-off-by: Ulf Hansson --- drivers/mmc/core/mmc.c | 5 +---- drivers/mmc/core/mmc_ops.c | 12 ++++++++++-- drivers/mmc/core/mmc_ops.h | 1 - drivers/mmc/core/sd.c | 6 +----- 4 files changed, 12 insertions(+), 12 deletions(-) -- 2.7.4 Reviewed-by: Linus Walleij diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index ff6cdc3..e504b66 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1556,10 +1556,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, /* * Fetch CID from card. */ - if (mmc_host_is_spi(host)) - err = mmc_send_cid(host, cid); - else - err = mmc_all_send_cid(host, cid); + err = mmc_send_cid(host, cid); if (err) goto err; diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 9994840..50571a6 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -207,7 +207,7 @@ int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) return err; } -int mmc_all_send_cid(struct mmc_host *host, u32 *cid) +static int mmc_all_send_cid(struct mmc_host *host, u32 *cid) { int err; struct mmc_command cmd = {}; @@ -334,7 +334,7 @@ int mmc_send_csd(struct mmc_card *card, u32 *csd) return ret; } -int mmc_send_cid(struct mmc_host *host, u32 *cid) +static int mmc_spi_send_cid(struct mmc_host *host, u32 *cid) { int ret, i; __be32 *cid_tmp; @@ -355,6 +355,14 @@ int mmc_send_cid(struct mmc_host *host, u32 *cid) return ret; } +int mmc_send_cid(struct mmc_host *host, u32 *cid) +{ + if (mmc_host_is_spi(host)) + return mmc_spi_send_cid(host, cid); + + return mmc_all_send_cid(host, cid); +} + int mmc_get_ext_csd(struct mmc_card *card, u8 **new_ext_csd) { int err; diff --git a/drivers/mmc/core/mmc_ops.h b/drivers/mmc/core/mmc_ops.h index 9d6b15b..d3d5d68 100644 --- a/drivers/mmc/core/mmc_ops.h +++ b/drivers/mmc/core/mmc_ops.h @@ -22,7 +22,6 @@ int mmc_deselect_cards(struct mmc_host *host); int mmc_set_dsr(struct mmc_host *host); int mmc_go_idle(struct mmc_host *host); 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); diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 1d7542d..a1b0aa1 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -788,11 +788,7 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr) } } - if (mmc_host_is_spi(host)) - err = mmc_send_cid(host, cid); - else - err = mmc_all_send_cid(host, cid); - + err = mmc_send_cid(host, cid); return err; }