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: 39810 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D0651202FE for ; Thu, 30 Oct 2014 06:38:41 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id r20sf2761712wiv.2 for ; Wed, 29 Oct 2014 23:38:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=aV9O4I/Wfgk7uLO4dZ2nxpr3p/2RiAHc7r9lGZZtuOg=; b=ESgUur+XvNNrc+e50irjsjrJV1IeiFBrz8r8oMzh3ECZ06Q3xi14hk9qB89plIPvDr qcIn5MYmFyje7C94CZ/HBemjVolgttcu+Hq6MFhJzQwWZpKe2coPzPnlbjo3g0pJbd21 Ump0qb3RCx9YkkUKyzn97aFTmd7arYT6Z3s5PxeocT1iZVH6SiWkW7JY2dVTY5avVJEP W+PbIz+fw5j2Cfh8MU6eBjXlCPsZii1cMPmAnVg+UOmVI1zjuP7nSgQJEau0ePGCdiQ0 sMsLFMlaRuGfMkDpoIGfkfFm23vvf9nLxMTWWaGUNU+uXvKyTOADgw+k0lql67kbDrYq zklA== X-Gm-Message-State: ALoCoQlIVm6CUuKmGSOw+ne/H454X1FzheJLuQJwA/YkXsfCDZWSohhyxvZeoLYTf+D2iNZ9TGsQ X-Received: by 10.194.86.66 with SMTP id n2mr4762wjz.7.1414651121086; Wed, 29 Oct 2014 23:38:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.170 with SMTP id d10ls274015lad.75.gmail; Wed, 29 Oct 2014 23:38:40 -0700 (PDT) X-Received: by 10.152.22.135 with SMTP id d7mr16434842laf.46.1414651120906; Wed, 29 Oct 2014 23:38:40 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id ci5si10502694lad.58.2014.10.29.23.38.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Oct 2014 23:38:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id z12so3805214lbi.11 for ; Wed, 29 Oct 2014 23:38:40 -0700 (PDT) X-Received: by 10.152.6.228 with SMTP id e4mr16441775laa.71.1414651120562; Wed, 29 Oct 2014 23:38:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp783846lbz; Wed, 29 Oct 2014 23:38:39 -0700 (PDT) X-Received: by 10.66.220.3 with SMTP id ps3mr15597157pac.8.1414651118592; Wed, 29 Oct 2014 23:38:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cm6si5848343pad.83.2014.10.29.23.38.36 for ; Wed, 29 Oct 2014 23:38:38 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758273AbaJ3Gid (ORCPT + 26 others); Thu, 30 Oct 2014 02:38:33 -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-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sbranden@broadcom.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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);