Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753602AbbF2Vdo (ORCPT ); Mon, 29 Jun 2015 17:33:44 -0400 Received: from mail-gw1-out.broadcom.com ([216.31.210.62]:20984 "EHLO mail-gw1-out.broadcom.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753702AbbF2Vdf (ORCPT ); Mon, 29 Jun 2015 17:33:35 -0400 X-IronPort-AV: E=Sophos;i="5.15,372,1432623600"; d="scan'208";a="68808010" Message-ID: <5591B9AC.7060003@broadcom.com> Date: Mon, 29 Jun 2015 14:33:32 -0700 From: Ray Jui User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Michael Turquette , Stephen Boyd , Dan Carpenter CC: , , Scott Branden , , Subject: Re: [PATCH 2/2] clk: iproc: fix bit manipulation arithmetic References: <1435613410-18698-1-git-send-email-rjui@broadcom.com> <1435613410-18698-3-git-send-email-rjui@broadcom.com> In-Reply-To: <1435613410-18698-3-git-send-email-rjui@broadcom.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1615 Lines: 41 + Michael's new email On 6/29/2015 2:30 PM, Ray Jui wrote: > A 32-bit variable should be type casted to 64-bit before arithmetic > operation and assigning it to a 64-bit variable > > Reported-by: Dan Carpenter > Signed-off-by: Ray Jui > --- > drivers/clk/bcm/clk-iproc-pll.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/clk/bcm/clk-iproc-pll.c b/drivers/clk/bcm/clk-iproc-pll.c > index a8d971b..2dda4e8 100644 > --- a/drivers/clk/bcm/clk-iproc-pll.c > +++ b/drivers/clk/bcm/clk-iproc-pll.c > @@ -366,7 +366,7 @@ static unsigned long iproc_pll_recalc_rate(struct clk_hw *hw, > val = readl(pll->pll_base + ctrl->ndiv_int.offset); > ndiv_int = (val >> ctrl->ndiv_int.shift) & > bit_mask(ctrl->ndiv_int.width); > - ndiv = ndiv_int << ctrl->ndiv_int.shift; > + ndiv = (u64)ndiv_int << ctrl->ndiv_int.shift; > > if (ctrl->flags & IPROC_CLK_PLL_HAS_NDIV_FRAC) { > val = readl(pll->pll_base + ctrl->ndiv_frac.offset); > @@ -374,7 +374,8 @@ static unsigned long iproc_pll_recalc_rate(struct clk_hw *hw, > bit_mask(ctrl->ndiv_frac.width); > > if (ndiv_frac != 0) > - ndiv = (ndiv_int << ctrl->ndiv_int.shift) | ndiv_frac; > + ndiv = ((u64)ndiv_int << ctrl->ndiv_int.shift) | > + ndiv_frac; > } > > val = readl(pll->pll_base + ctrl->pdiv.offset); > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/