From patchwork Mon Aug 17 13:50:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 52474 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by patches.linaro.org (Postfix) with ESMTPS id AB0EC22DB1 for ; Mon, 17 Aug 2015 13:50:31 +0000 (UTC) Received: by wilj18 with SMTP id j18sf26390959wil.0 for ; Mon, 17 Aug 2015 06:50:31 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Rkp6QqQMcdqeh64ZHI3FKpgzc1WSgv7+WuZhmRBIeV8=; b=Q6iBlYblHNptZPPCOfvFbl1lL9w8CiLxi3Bks5l21Jyft5JZL21mCzyOGOuGnTk2r7 6RSSrtE2x2cv0hCwm8u9lSTY1vOraNiib7PD7G8JMmfnTkRjx6MKXBpzzFRouw69s9s4 5NCAPDB+1YZzuE/CzHDHivSbXmeNEIkJg8Ec5beoJ+/OGr5ZtDkCDltTcgkkSOn2i222 H87Ua8VbIAiwTrhRo/MT1pfgJdq0w3hyaQUGIXpnhBjyfLGwFSBdayN4UfOyl/QIDFgl MzPJ+x1q1mahHiTFiTKNqQQH8kS7YatYpkY6uPhIeLDhbZ9cRJdA9utBrUZapp6xtFNz kNYA== X-Gm-Message-State: ALoCoQnhzpNEA8dx9cxtq4hCL4aSn2G9LYZ7goRQzBPB2781T0B1FWDwB31ZvTM++JNP/Bc1MEZj X-Received: by 10.112.189.105 with SMTP id gh9mr431937lbc.16.1439819430975; Mon, 17 Aug 2015 06:50:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.180.227 with SMTP id dr3ls606324lac.45.gmail; Mon, 17 Aug 2015 06:50:30 -0700 (PDT) X-Received: by 10.112.176.228 with SMTP id cl4mr1263357lbc.106.1439819430827; Mon, 17 Aug 2015 06:50:30 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id ld1si11715480lab.51.2015.08.17.06.50.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Aug 2015 06:50:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbbsx3 with SMTP id sx3so82467943lbb.0 for ; Mon, 17 Aug 2015 06:50:30 -0700 (PDT) X-Received: by 10.152.28.193 with SMTP id d1mr1247941lah.72.1439819430699; Mon, 17 Aug 2015 06:50:30 -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 l6csp1460689lba; Mon, 17 Aug 2015 06:50:29 -0700 (PDT) X-Received: by 10.68.231.133 with SMTP id tg5mr2948167pbc.138.1439819429494; Mon, 17 Aug 2015 06:50:29 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fz12si24750595pdb.140.2015.08.17.06.50.28; Mon, 17 Aug 2015 06:50:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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 S1751874AbbHQNu1 (ORCPT + 13 others); Mon, 17 Aug 2015 09:50:27 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:34650 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750911AbbHQNu0 (ORCPT ); Mon, 17 Aug 2015 09:50:26 -0400 Received: by pdbfa8 with SMTP id fa8so56130258pdb.1 for ; Mon, 17 Aug 2015 06:50:25 -0700 (PDT) X-Received: by 10.70.34.171 with SMTP id a11mr2915913pdj.18.1439819425864; Mon, 17 Aug 2015 06:50:25 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id hb1sm14765182pbd.36.2015.08.17.06.50.24 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 17 Aug 2015 06:50:24 -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 V4 2/2] PM / OPP: Fix static checker warning (broken 64bit big endian systems) Date: Mon, 17 Aug 2015 19:20:20 +0530 Message-Id: <0a41aca3107cea2d9fac3f4536e5c7f4acd90f7d.1439818955.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.4.0 In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@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.217.181 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 --- V3->V4: - Assign values only if of_property_read_u32() is successful. drivers/base/power/opp.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 4d6c4576f7ae..803d8b7ced89 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,16 @@ 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); + + if (!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); + if (!of_property_read_u32(new_opp->np, "opp-microamp", &val)) + new_opp->u_amp = val; ret = _opp_add(dev, new_opp, dev_opp); if (ret)