From patchwork Wed Aug 21 09:47:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunshaojie X-Patchwork-Id: 19364 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 774AC248E6 for ; Wed, 21 Aug 2013 09:48:16 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id z20sf173803yhz.1 for ; Wed, 21 Aug 2013 02:48:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=eYWJUSkKQFzido5aFy8wGbcEJqso7lJH2tkxY1U0fyU=; b=RHJ2gxD1aXTDYwgchRvL49S/WLRB1aFy19rYPta2bEMUrZm7/Hvcle5W+1eD9LYrXb +IIpcZqaJ1UJAqQW0XDkR3BI7ihyAQDzmmbGrH1w00YiOqaYgWJCrd5QxJDsY4g1DfRx lt/ICn9jRCz8WRQari1dc3B6Bs9sa+rgoZGdvl+SYclk+xzkVvy5PPCMpilS12bRe3SY BsGQesDiUrmS6xhe/CHlPDpflOwN1C4//Q70MqQqVj3l1LfOeZMgTKa7lJyFsu6qMKZM 9PVaQ6WWtHdBVExc3xwNZENnq5ZjuBJVOvyrZl+0ezmKelTuKU6RSQUtg4V6rU233SS5 tHQw== X-Received: by 10.236.156.138 with SMTP id m10mr2352996yhk.26.1377078495898; Wed, 21 Aug 2013 02:48:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.121.163 with SMTP id ll3ls579071qeb.33.gmail; Wed, 21 Aug 2013 02:48:15 -0700 (PDT) X-Received: by 10.52.73.162 with SMTP id m2mr4758929vdv.24.1377078495740; Wed, 21 Aug 2013 02:48:15 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id dp3si1867713vcb.21.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Aug 2013 02:48:15 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id kw10so121564vcb.15 for ; Wed, 21 Aug 2013 02:48:15 -0700 (PDT) X-Gm-Message-State: ALoCoQkcrZvrNohUItzTIt8IS2vxYdu7VzKBEWxqg3ztGpx2TWdu/bkdvI1s08liv7OaIsCG94Gl X-Received: by 10.220.171.129 with SMTP id h1mr202192vcz.28.1377078495633; Wed, 21 Aug 2013 02:48:15 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp209479vcz; Wed, 21 Aug 2013 02:48:15 -0700 (PDT) X-Received: by 10.68.252.233 with SMTP id zv9mr6810425pbc.69.1377078494351; Wed, 21 Aug 2013 02:48:14 -0700 (PDT) Received: from mail-pd0-f177.google.com (mail-pd0-f177.google.com [209.85.192.177]) by mx.google.com with ESMTPS id hg4si4607986pbc.135.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Aug 2013 02:48:14 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.177 is neither permitted nor denied by best guess record for domain of shaojie.sun@linaro.org) client-ip=209.85.192.177; Received: by mail-pd0-f177.google.com with SMTP id y10so226408pdj.36 for ; Wed, 21 Aug 2013 02:48:13 -0700 (PDT) X-Received: by 10.66.168.7 with SMTP id zs7mr8680828pab.152.1377078493805; Wed, 21 Aug 2013 02:48:13 -0700 (PDT) Received: from localhost.localdomain ([58.251.159.202]) by mx.google.com with ESMTPSA id y6sm7329894pbl.23.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 21 Aug 2013 02:48:13 -0700 (PDT) From: Shaojie Sun To: sanjay.rawat@linaro.org Cc: patches@linaro.org, private-pmwg@linaro.org, sunshaojie@huawei.com, Shaojie Sun Subject: [PATCH POWERDEBUG 1/2] modify clock rate from int to unsigned int. Date: Wed, 21 Aug 2013 17:47:45 +0800 Message-Id: <1377078465-22880-1-git-send-email-shaojie.sun@linaro.com> X-Mailer: git-send-email 1.7.9.5 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shaojie.sun@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When clock is large than 2GHz, clock rate will overflow for using int type. So change clock rate type to unsigned int. Then clock rate can reach 4GHz. Signed-off-by: Shaojie Sun --- clocks.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/clocks.c b/clocks.c index 95acf57..203411a 100644 --- a/clocks.c +++ b/clocks.c @@ -36,9 +36,14 @@ #include "tree.h" #include "utils.h" +#ifndef uint +#define uint unsigned int +#endif + + struct clock_info { int flags; - int rate; + uint rate; int usecount; bool expanded; char *prefix; @@ -73,9 +78,9 @@ static struct clock_info *clock_alloc(void) return ci; } -static inline const char *clock_rate(int *rate) +static inline const char *clock_rate(uint *rate) { - int r; + uint r; /* GHZ */ r = *rate >> 30; @@ -107,7 +112,7 @@ static int dump_clock_cb(struct tree *t, void *data) struct clock_info *pclk; const char *unit; int ret = 0; - int rate = clk->rate; + uint rate = clk->rate; if (!t->parent) { printf("/\n"); @@ -125,7 +130,7 @@ static int dump_clock_cb(struct tree *t, void *data) unit = clock_rate(&rate); - printf("%s%s-- %s (flags:0x%x, usecount:%d, rate: %d %s)\n", + printf("%s%s-- %s (flags:0x%x, usecount:%d, rate: %u %s)\n", clk->prefix, !t->next ? "`" : "", t->name, clk->flags, clk->usecount, rate, unit); @@ -156,14 +161,14 @@ static inline int read_clock_cb(struct tree *t, void *data) if(clock_fw == CCF) { file_read_value(t->path, "clk_flags", "%x", &clk->flags); - file_read_value(t->path, "clk_rate", "%d", &clk->rate); + file_read_value(t->path, "clk_rate", "%u", &clk->rate); file_read_value(t->path, "clk_prepare_count", "%d", &clk->preparecount); file_read_value(t->path, "clk_enable_count", "%d", &clk->enablecount); file_read_value(t->path, "clk_notifier_count", "%d", &clk->notifiercount); } else { file_read_value(t->path, "flags", "%x", &clk->flags); - file_read_value(t->path, "rate", "%d", &clk->rate); + file_read_value(t->path, "rate", "%u", &clk->rate); file_read_value(t->path, "usecount", "%d", &clk->usecount); } @@ -211,7 +216,7 @@ static int is_collapsed(struct tree *t, void *data) static char *clock_line(struct tree *t) { struct clock_info *clk; - int rate; + uint rate; const char *clkunit; char *clkrate, *clkname, *clkline = NULL;