From patchwork Sat May 4 20:27:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanjay Singh Rawat X-Patchwork-Id: 16710 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gh0-f198.google.com (mail-gh0-f198.google.com [209.85.160.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E782C23904 for ; Sat, 4 May 2013 20:28:09 +0000 (UTC) Received: by mail-gh0-f198.google.com with SMTP id r13sf4197499ghr.9 for ; Sat, 04 May 2013 13:27:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=tqVTEYKAi4IP56Rrh9OuigA8tCrGMhiVgOAKk5Vrnnw=; b=GTcLKgHj9q1Nvj0pBAftpE+Al0CXecBwrksFAkRV165iCoAfgLSOxJEQsfsSOUaQS8 GEmwuyTmOhOMaZMJ4jtMxbf5HYKXpilSvbO1QWc14NzjYHreg9kCPeyuUD+/ofkEwnS7 2ePdihfD/pySaUzQNhcgzFPg1dkPHmQvRzqnSvAXm0zPugRyPfMFybNnZ8ECOTjW2ZVo 5WlwCPlZzN7dhlaX4jgRHpBwRAGsogVBm4+i8vN5yhNoU2AtMXOehD6X/O2RaonaCbtD pVW4A3CzwFrijmn3YfCrz51kmrukIXR8FGo1d4UuESnBsQ43JA+Sq+GzbOPnqgORNrNn m8SA== X-Received: by 10.236.91.206 with SMTP id h54mr11662408yhf.27.1367699277121; Sat, 04 May 2013 13:27:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.47.16 with SMTP id z16ls2231509qem.26.gmail; Sat, 04 May 2013 13:27:56 -0700 (PDT) X-Received: by 10.52.93.78 with SMTP id cs14mr4489963vdb.17.1367699276850; Sat, 04 May 2013 13:27:56 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id dx8si7549666vcb.3.2013.05.04.13.27.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 04 May 2013 13:27:56 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.172 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.172; Received: by mail-vc0-f172.google.com with SMTP id hx10so2255225vcb.17 for ; Sat, 04 May 2013 13:27:56 -0700 (PDT) X-Received: by 10.58.48.166 with SMTP id m6mr5037925ven.59.1367699276487; Sat, 04 May 2013 13:27:56 -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.58.127.98 with SMTP id nf2csp73674veb; Sat, 4 May 2013 13:27:55 -0700 (PDT) X-Received: by 10.68.40.200 with SMTP id z8mr18915151pbk.210.1367699275263; Sat, 04 May 2013 13:27:55 -0700 (PDT) Received: from mail-da0-x22c.google.com (mail-da0-x22c.google.com [2607:f8b0:400e:c00::22c]) by mx.google.com with ESMTPS id jp9si10965266pbc.141.2013.05.04.13.27.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 04 May 2013 13:27:55 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c00::22c is neither permitted nor denied by best guess record for domain of sanjay.rawat@linaro.org) client-ip=2607:f8b0:400e:c00::22c; Received: by mail-da0-f44.google.com with SMTP id z8so1277343daj.31 for ; Sat, 04 May 2013 13:27:54 -0700 (PDT) X-Received: by 10.66.218.36 with SMTP id pd4mr20051294pac.143.1367699274692; Sat, 04 May 2013 13:27:54 -0700 (PDT) Received: from localhost.localdomain ([223.239.130.191]) by mx.google.com with ESMTPSA id vu10sm16935104pbc.27.2013.05.04.13.27.51 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 04 May 2013 13:27:53 -0700 (PDT) From: Sanjay Singh Rawat To: linaro-dev@lists.linaro.org Cc: patches@linaro.org, Sanjay Singh Rawat Subject: [PATCH powerdebug] clock: show only active clocks Date: Sun, 5 May 2013 01:57:58 +0530 Message-Id: <1367699278-406-1-git-send-email-sanjay.rawat@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQmqnIQdtJqF0aGpz0gYiIgczuG7Sf7RRmngVviTOT7lcvVqXe2aCktofg+K+StGm75VtSe5 X-Original-Sender: sanjay.rawat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.172 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: , - use the clk_summary file of CCF for showing clocks - add option to show active or all clocks Signed-off-by: Sanjay Singh Rawat --- clocks.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++------------ display.c | 3 +++ display.h | 1 + 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/clocks.c b/clocks.c index 95acf57..a0510b4 100644 --- a/clocks.c +++ b/clocks.c @@ -287,9 +287,8 @@ static int clock_print_header(void) int ret; if(clock_fw == CCF) { - if (asprintf(&buf, "%-35s %-10s %-12s %-10s %-11s %-15s %-14s %-14s", - "Name", "Flags", "Rate", "Usecount", "Children", "Prepare_Count", - "Enable_Count", "Notifier_Count") < 0) + if (asprintf(&buf, "%-30s %-10s %-12s %-10s (clock toggle key-'c')", + "Name", "Enable_Count", "Prepare_Count", "Rate") < 0) return -1; } else { @@ -297,23 +296,57 @@ static int clock_print_header(void) "Name", "Flags", "Rate", "Usecount", "Children") < 0) return -1; } - ret = display_column_name(buf); - free(buf); return ret; } +/* + * Display clocks by refering the clk_summary file of CCF + */ +static int display_clk_summary() +{ + FILE *fp; + char line[256]; + int afterheader; + char clock[30]; + int enable_cnt,prepare_cnt,rate; + + afterheader = 0; + fp = fopen("/sys/kernel/debug/clk/clk_summary","r"); + if (fp == NULL) { + printf("error: failed to open clock tree file\n"); + return -1; + } + + while (NULL != fgets(line,256,fp)) { + if (afterheader > 1) { + sscanf(line,"%s %d %d %d",clock,&enable_cnt,&prepare_cnt,&rate); + if (active_clks) { + if (enable_cnt) + display_print_line(CLOCK,afterheader, + line,0,clock_tree); + } + else + display_print_line(CLOCK,afterheader,line,1,clock_tree); + } + afterheader++; + } + return 0; +} + static int clock_print_info(struct tree *tree) { int ret, line = 0; display_reset_cursor(CLOCK); - clock_print_header(); - ret = tree_for_each(tree, clock_print_info_cb, &line); + if (clock_fw == CCF) + ret = display_clk_summary(); + else + ret = tree_for_each(tree, clock_print_info_cb, &line); display_refresh_pad(CLOCK); @@ -426,8 +459,10 @@ int clock_init(void) sprintf(clk_dir_path[CCF], "%s/clk", clk_dir_path[CCF]); sprintf(clk_dir_path[OCF], "%s/clock", clk_dir_path[OCF]); + if (!access(clk_dir_path[CCF], F_OK)) { clock_fw = CCF; + active_clks = true; strcpy(clk_dir_path[MAX],clk_dir_path[CCF]); } else if(!access(clk_dir_path[OCF], F_OK)) { @@ -437,12 +472,15 @@ int clock_init(void) else return -1; - clock_tree = tree_load(clk_dir_path[MAX], NULL, false); - if (!clock_tree) - return -1; + /* Not preparing tree for CCF, will use the clk_summary file */ + if(clock_fw != CCF) { + clock_tree = tree_load(clk_dir_path[MAX], NULL, false); + if (!clock_tree) + return -1; - if (fill_clock_tree()) - return -1; + if (fill_clock_tree()) + return -1; + } return display_register(CLOCK, &clock_ops); } diff --git a/display.c b/display.c index e9f4bf6..98544e6 100644 --- a/display.c +++ b/display.c @@ -416,6 +416,9 @@ static int display_keystroke(int fd, void *data) case 'r': case 'R': return display_refresh(current_win, true); + case 'c': + active_clks = active_clks ? false : true; + return display_refresh(current_win, true); default: return 0; } diff --git a/display.h b/display.h index 6362a48..24c9d59 100644 --- a/display.h +++ b/display.h @@ -33,4 +33,5 @@ extern int display_init(int wdefault); extern int display_register(int win, struct display_ops *ops); extern int display_column_name(const char *line); +bool active_clks; #define NAME_MAX 255