From patchwork Mon Aug 21 07:41:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 110496 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp940848qge; Mon, 21 Aug 2017 00:42:32 -0700 (PDT) X-Received: by 10.99.157.72 with SMTP id i69mr8705418pgd.255.1503301352151; Mon, 21 Aug 2017 00:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503301352; cv=none; d=google.com; s=arc-20160816; b=euyS1vOcxFY5vdg1Bh6VyUZFHhTR9sQb8eYfXX/5p30mtXHPEzaKL2uYQlJtKHIcLd fmvdC9TFZ0mucCmUatj42PZOVafSsGSPI+zMGBbDx7O5hLNKOu9NLbp6iYoUDihJGpyo qz0XVXtzSU4Y2ADfvXr+kioatNB/Dhi5H9qsIO0ei4lrPwrtVVyZ5PETDD9SkCS8qJL0 ii6QKE+os3n+kMN1IaM76ILxRPHVremqt6JTCynNTRFTfLQHjBFXmm/fHJ1uetXDI4Zy ZannR/RY9/+mJmXnVKrNiplcuvLP1n4BE0cShZmDU9/jGsyUg2hIiMK3ufhTs5gx/ouz PF4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=6g4BuS9TGLFxV3dVFP4VDuZzueJIrBFcNYqCHNA0Z20=; b=wcH41k96eMuGEfUkEBYP2SFKDpPqcenzTX+JldeYX0qy0mzewc/OlaaX3f6z3iPRUz ieaUAkWhKPa8JOMwxYKS9eXLjcI1M/q4cq3sAnyFYhpMPwcEr2kE6iGUXr+UhkspsWv8 3QkUwBs8Qd5IYbgJg75bS4CuWfn3iHH+qNLKqI2flb8egIMK9R5MCWgVNkra5KNKbHJQ NGj8RfGxAuGGEALGUFxMYrxFiZS+Jt491YqkSNAZGaKZSv0MAUkukBthlTKmehtQ320K NTLB9PnWUCp1OxIVsk5oMSpaEb6ngQhgvTCWp6E+gDAZms6EQs49u5daemdYW9Vy9266 BkLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=dRphKLst; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a14si6817861pgd.77.2017.08.21.00.42.31; Mon, 21 Aug 2017 00:42:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=dRphKLst; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752235AbdHUHm2 (ORCPT + 26 others); Mon, 21 Aug 2017 03:42:28 -0400 Received: from fllnx210.ext.ti.com ([198.47.19.17]:41265 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751067AbdHUHmY (ORCPT ); Mon, 21 Aug 2017 03:42:24 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v7L7flSF000940; Mon, 21 Aug 2017 02:41:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1503301307; bh=6m1DXPJ34UHm+eVvY36i+POZTHljpI1rjLH3X7X3TkQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=dRphKLstIj7zKkU4Biomf4l39WZ7qiZt+KWYHmjfRybIzzHfftZ9ChZ55OQ0eXxR5 YSFwhM4dZsspFOjR351qTrYZ1K6QI4MLTRY6ZtJW6MAF1QsVTyC0TOGrUJ9L9Oklej AuvmShWyc8zzLAzS2oFseaUmiIyaYfpyNzgNUu4k= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v7L7fl4c027391; Mon, 21 Aug 2017 02:41:47 -0500 Received: from DFLE115.ent.ti.com (10.64.6.36) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Mon, 21 Aug 2017 02:41:47 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Mon, 21 Aug 2017 02:41:46 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v7L7fdNP030136; Mon, 21 Aug 2017 02:41:43 -0500 From: Kishon Vijay Abraham I To: Ulf Hansson , Adrian Hunter CC: Rob Herring , Tony Lindgren , Sekhar Nori , Russell King , Ravikumar Kattekola , , , , , , Kishon Vijay Abraham I Subject: [PATCH 1/5] mmc: sdhci: Tidy reading 136-bit responses Date: Mon, 21 Aug 2017 13:11:28 +0530 Message-ID: <20170821074132.4622-2-kishon@ti.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170821074132.4622-1-kishon@ti.com> References: <20170821074132.4622-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Adrian Hunter Read each register only once and move the code to a separate function so that it is not jammed against the 80 column margin. Signed-off-by: Adrian Hunter Signed-off-by: Kishon Vijay Abraham I --- drivers/mmc/host/sdhci.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) -- 2.11.0 diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index a1ad2ddadca1..ba639b7851cb 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1173,24 +1173,32 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) } EXPORT_SYMBOL_GPL(sdhci_send_command); +static void sdhci_read_rsp_136(struct sdhci_host *host, struct mmc_command *cmd) +{ + int i, reg; + + for (i = 0; i < 4; i++) { + reg = SDHCI_RESPONSE + (3 - i) * 4; + cmd->resp[i] = sdhci_readl(host, reg); + } + + /* CRC is stripped so we need to do some shifting */ + for (i = 0; i < 4; i++) { + cmd->resp[i] <<= 8; + if (i != 3) + cmd->resp[i] |= cmd->resp[i + 1] >> 24; + } +} + static void sdhci_finish_command(struct sdhci_host *host) { struct mmc_command *cmd = host->cmd; - int i; host->cmd = NULL; if (cmd->flags & MMC_RSP_PRESENT) { if (cmd->flags & MMC_RSP_136) { - /* CRC is stripped so we need to do some shifting. */ - for (i = 0;i < 4;i++) { - cmd->resp[i] = sdhci_readl(host, - SDHCI_RESPONSE + (3-i)*4) << 8; - if (i != 3) - cmd->resp[i] |= - sdhci_readb(host, - SDHCI_RESPONSE + (3-i)*4-1); - } + sdhci_read_rsp_136(host, cmd); } else { cmd->resp[0] = sdhci_readl(host, SDHCI_RESPONSE); }