From patchwork Wed Aug 12 11:00:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 52344 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 937D82031F for ; Wed, 12 Aug 2015 11:01:07 +0000 (UTC) Received: by wilj18 with SMTP id j18sf5387550wil.0 for ; Wed, 12 Aug 2015 04:01:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=3L0NVG3HasqcC0Hbh2rwfP/I4k4z9aF51WRiaQzityQ=; b=DBpRwzkZGR3P34tM1hPU/M4O0t+TGgrAdx8a3+08SirVr5MEoqsF0eNa0YWfSOYVmp zTFVUhqaYtULTlwWwPVXG7P3dXCHLsf+TzslmugC2YfpSRg3tuH1Q5tKuf5OSQLupvG6 g5SRoqvx69N9pTiX7/zE2vXL3hsLt/mAlTKbPQiz91x2HuDrCGgXRk3Y+QHdrImiZ8YH Aw7AV76nktRKWlpX6H9j8p6vIsq8bKb8LaUFYbVkqOOyife32ci2ejiAx0IHCpaAdRn8 ibxx3Ix4eHDRv8v9FQ4r7j0GZJMwsEisLDyEYaF7zLbipEVk7WLKJMJJ9UAkGf5KYena lz7A== X-Gm-Message-State: ALoCoQmFBgkTXyth7Y0hArgeGXNj7FcgxLGSN17k37SqUl1rT12J71xDCM4fYg1mbUg1PA2KSPvR X-Received: by 10.180.83.226 with SMTP id t2mr6813661wiy.5.1439377266873; Wed, 12 Aug 2015 04:01:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.73 with SMTP id 9ls25299lak.17.gmail; Wed, 12 Aug 2015 04:01:06 -0700 (PDT) X-Received: by 10.112.138.199 with SMTP id qs7mr31116612lbb.21.1439377266610; Wed, 12 Aug 2015 04:01:06 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id o10si3871387laf.161.2015.08.12.04.01.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Aug 2015 04:01:06 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lagz9 with SMTP id z9so6933254lag.3 for ; Wed, 12 Aug 2015 04:01:06 -0700 (PDT) X-Received: by 10.152.4.163 with SMTP id l3mr31820550lal.35.1439377266336; Wed, 12 Aug 2015 04:01:06 -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.7.198 with SMTP id l6csp250041lba; Wed, 12 Aug 2015 04:01:05 -0700 (PDT) X-Received: by 10.66.65.234 with SMTP id a10mr66724962pat.2.1439377264384; Wed, 12 Aug 2015 04:01:04 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k12si8920824pbq.59.2015.08.12.04.01.03; Wed, 12 Aug 2015 04:01:04 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934246AbbHLLA5 (ORCPT + 28 others); Wed, 12 Aug 2015 07:00:57 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:36464 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934051AbbHLLAx (ORCPT ); Wed, 12 Aug 2015 07:00:53 -0400 Received: by pacrr5 with SMTP id rr5so12429059pac.3 for ; Wed, 12 Aug 2015 04:00:52 -0700 (PDT) X-Received: by 10.68.250.36 with SMTP id yz4mr67282773pbc.78.1439377252582; Wed, 12 Aug 2015 04:00:52 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id k10sm5993764pbq.63.2015.08.12.04.00.51 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 12 Aug 2015 04:00:52 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, dan.carpenter@oracle.com, nm@ti.com, sboyd@codeaurora.org, Viresh Kumar , Greg Kroah-Hartman , Len Brown , linux-kernel@vger.kernel.org (open list), Pavel Machek Subject: [PATCH V3 2/2] PM / OPP: Fix static checker warning (broken 64bit big endian systems) Date: Wed, 12 Aug 2015 16:30:19 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: 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: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) smtp.mailfrom=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: , Dan Carpenter reported (generated with static checker): drivers/base/power/opp.c:949 _opp_add_static_v2() warn: passing casted pointer '&new_opp->clock_latency_ns' to 'of_property_read_u32()' 64 vs 32. This code will break on 64 bit, big endian machines. Fix this by reading the value in a u32 type variable first and then assigning it to the unsigned long variable. Reported-by: Dan Carpenter Suggested-by: Stephen Boyd Signed-off-by: Viresh Kumar --- drivers/base/power/opp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 4d6c4576f7ae..72dc59248876 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -918,6 +918,7 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np) struct device_opp *dev_opp; struct dev_pm_opp *new_opp; u64 rate; + u32 val; int ret; /* Hold our list modification lock here */ @@ -946,14 +947,15 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np) new_opp->np = np; new_opp->dynamic = false; new_opp->available = true; - of_property_read_u32(np, "clock-latency-ns", - (u32 *)&new_opp->clock_latency_ns); + of_property_read_u32(np, "clock-latency-ns", &val); + new_opp->clock_latency_ns = val; ret = opp_get_microvolt(new_opp, dev); if (ret) goto free_opp; - of_property_read_u32(np, "opp-microamp", (u32 *)&new_opp->u_amp); + of_property_read_u32(np, "opp-microamp", &val); + new_opp->u_amp = val; ret = _opp_add(dev, new_opp, dev_opp); if (ret)