From patchwork Thu Oct 30 06:36:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Branden X-Patchwork-Id: 5194001 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C7CDC9F349 for ; Thu, 30 Oct 2014 06:38:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3394A20179 for ; Thu, 30 Oct 2014 06:38:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7BAC92024C for ; Thu, 30 Oct 2014 06:38:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758245AbaJ3Gic (ORCPT ); Thu, 30 Oct 2014 02:38:32 -0400 Received: from mail-gw2-out.broadcom.com ([216.31.210.63]:15186 "EHLO mail-gw2-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758108AbaJ3GhF (ORCPT ); Thu, 30 Oct 2014 02:37:05 -0400 X-IronPort-AV: E=Sophos;i="5.07,284,1413270000"; d="scan'208";a="49476488" Received: from irvexchcas07.broadcom.com (HELO IRVEXCHCAS07.corp.ad.broadcom.com) ([10.9.208.55]) by mail-gw2-out.broadcom.com with ESMTP; 30 Oct 2014 00:00:57 -0700 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS07.corp.ad.broadcom.com (10.9.208.55) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 29 Oct 2014 23:37:04 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.3.174.1; Wed, 29 Oct 2014 23:37:04 -0700 Received: from mail.broadcom.com (lbrmn-lnxub113.ric.broadcom.com [10.136.13.65]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 4855B40FE6; Wed, 29 Oct 2014 23:36:46 -0700 (PDT) From: Scott Branden To: Ulf Hansson , Russell King , Peter Griffin , Stephen Warren , Chris Ball , Piotr Krol CC: , , Joe Perches , , Ray Jui , , Scott Branden Subject: [PATCHv2 2/5] mmc: sdhci-bcm2835: make shift calculations consistent Date: Wed, 29 Oct 2014 23:36:54 -0700 Message-ID: <1414651017-3545-3-git-send-email-sbranden@broadcom.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1414651017-3545-1-git-send-email-sbranden@broadcom.com> References: <1414651017-3545-1-git-send-email-sbranden@broadcom.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make the shift calculations consistent rather than having different implementations to calculate the same thing. Signed-off-by: Scott Branden --- drivers/mmc/host/sdhci-bcm2835.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/mmc/host/sdhci-bcm2835.c b/drivers/mmc/host/sdhci-bcm2835.c index c8ee02c..b6cb365 100644 --- a/drivers/mmc/host/sdhci-bcm2835.c +++ b/drivers/mmc/host/sdhci-bcm2835.c @@ -54,6 +54,8 @@ struct bcm2835_sdhci { u32 shadow; }; +#define REG_OFFSET_IN_BITS(reg) ((reg) << 3 & 0x18) + static inline u32 bcm2835_sdhci_readl(struct sdhci_host *host, int reg) { u32 val = readl(host->ioaddr + reg); @@ -67,20 +69,14 @@ static inline u32 bcm2835_sdhci_readl(struct sdhci_host *host, int reg) static u16 bcm2835_sdhci_readw(struct sdhci_host *host, int reg) { u32 val = bcm2835_sdhci_readl(host, (reg & ~3)); - u32 word_num = (reg >> 1) & 1; - u32 word_shift = word_num * 16; - u32 word = (val >> word_shift) & 0xffff; - + u16 word = val >> REG_OFFSET_IN_BITS(reg) & 0xffff; return word; } static u8 bcm2835_sdhci_readb(struct sdhci_host *host, int reg) { u32 val = bcm2835_sdhci_readl(host, (reg & ~3)); - u32 byte_num = reg & 3; - u32 byte_shift = byte_num * 8; - u32 byte = (val >> byte_shift) & 0xff; - + u8 byte = val >> REG_OFFSET_IN_BITS(reg) & 0xff; return byte; } @@ -98,8 +94,7 @@ static void bcm2835_sdhci_writew(struct sdhci_host *host, u16 val, int reg) struct bcm2835_sdhci *bcm2835_host = pltfm_host->priv; u32 oldval = (reg == SDHCI_COMMAND) ? bcm2835_host->shadow : bcm2835_sdhci_readl(host, reg & ~3); - u32 word_num = (reg >> 1) & 1; - u32 word_shift = word_num * 16; + u32 word_shift = REG_OFFSET_IN_BITS(reg); u32 mask = 0xffff << word_shift; u32 newval = (oldval & ~mask) | (val << word_shift); @@ -112,8 +107,7 @@ static void bcm2835_sdhci_writew(struct sdhci_host *host, u16 val, int reg) static void bcm2835_sdhci_writeb(struct sdhci_host *host, u8 val, int reg) { u32 oldval = bcm2835_sdhci_readl(host, reg & ~3); - u32 byte_num = reg & 3; - u32 byte_shift = byte_num * 8; + u32 byte_shift = REG_OFFSET_IN_BITS(reg); u32 mask = 0xff << byte_shift; u32 newval = (oldval & ~mask) | (val << byte_shift);