From patchwork Thu Feb 7 10:43:34 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: 14663 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 5428423EAD for ; Thu, 7 Feb 2013 10:43:54 +0000 (UTC) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by fiordland.canonical.com (Postfix) with ESMTP id DF263A183AB for ; Thu, 7 Feb 2013 10:43:52 +0000 (UTC) Received: by mail-ve0-f179.google.com with SMTP id da11so2105362veb.38 for ; Thu, 07 Feb 2013 02:43:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=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; bh=GAnwXUBGBsJXlzHs8wwAQRusoE/VtX3RNrcE1JKq1xU=; b=etXswR2eLJorKz+KhdnJfgK0WaXZs0LNXE2GhnASk461dzLkarNlk9t8Z5IjpNR7P0 D5VDvOVjo6MdddDM0Somaxq5k1VWCf9RNN90ksr76NKNnfTg5hDLgFPnqTur0Tb7SaVN QTPiz1tVUgJETCeRiAef06mDQndU+fAsWYvg6DPkOh46UsQPTkeDrNBfosqT4vYIpJ6G aKRa3qf4f/EUGpnub2N+46tjWr4pjusXYu7SC+k7OFGMZtEXVJQdqoj5pVnNkbrptpa8 d5I6noo6JFWaNm+4oIeBxDAlMi7dSPjnp7m+yKQyJLrbJFEBX6FMe5BXvtRCnE1zjKQz bFpQ== X-Received: by 10.52.21.146 with SMTP id v18mr782467vde.79.1360233832384; Thu, 07 Feb 2013 02:43:52 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.252.8 with SMTP id zo8csp81891vec; Thu, 7 Feb 2013 02:43:51 -0800 (PST) X-Received: by 10.66.72.97 with SMTP id c1mr4543677pav.48.1360233831164; Thu, 07 Feb 2013 02:43:51 -0800 (PST) Received: from mail-da0-f41.google.com (mail-da0-f41.google.com [209.85.210.41]) by mx.google.com with ESMTPS id b9si34132047pax.136.2013.02.07.02.43.50 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Feb 2013 02:43:51 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.41 is neither permitted nor denied by best guess record for domain of sanjay.rawat@linaro.org) client-ip=209.85.210.41; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.41 is neither permitted nor denied by best guess record for domain of sanjay.rawat@linaro.org) smtp.mail=sanjay.rawat@linaro.org Received: by mail-da0-f41.google.com with SMTP id e20so1133722dak.14 for ; Thu, 07 Feb 2013 02:43:50 -0800 (PST) X-Received: by 10.66.75.200 with SMTP id e8mr4407026paw.72.1360233830370; Thu, 07 Feb 2013 02:43:50 -0800 (PST) Received: from srawat-Latitude-E6420.LGE.NET ([203.247.149.152]) by mx.google.com with ESMTPS id t4sm3731704pax.0.2013.02.07.02.43.47 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Feb 2013 02:43:49 -0800 (PST) From: Sanjay Singh Rawat To: linaro-dev@lists.linaro.org Cc: patches@linaro.org, Sanjay Singh Rawat Subject: [powerdebug,1/1] clock: support common clock framework Date: Thu, 7 Feb 2013 16:13:34 +0530 Message-Id: <1360233814-23746-1-git-send-email-sanjay.rawat@linaro.com> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQn+t1gN4OjStczrO9zHUxmOGWEbyr4s7cpzkWTWmv6/+ZLnjV2xSAMc2pYClaqdyU5MNecH In common clock framework (merged in 3.8-rc1) the directory and attributes are changed, adapt to the new clock entries in debugfs. Signed-off-by: Sanjay Singh Rawat --- clocks.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 13 deletions(-) diff --git a/clocks.c b/clocks.c index 2611a0d..95acf57 100644 --- a/clocks.c +++ b/clocks.c @@ -42,9 +42,19 @@ struct clock_info { int usecount; bool expanded; char *prefix; + int preparecount; + int enablecount; + int notifiercount; } *clocks_info; +enum clock_fw_type{ + CCF, /* common clock framework */ + OCF, /* old clock framework */ + MAX, +}; + static struct tree *clock_tree = NULL; +static int clock_fw; static int locate_debugfs(char *clk_path) { @@ -144,9 +154,18 @@ static inline int read_clock_cb(struct tree *t, void *data) { struct clock_info *clk = t->private; - file_read_value(t->path, "flags", "%x", &clk->flags); - file_read_value(t->path, "rate", "%d", &clk->rate); - file_read_value(t->path, "usecount", "%d", &clk->usecount); + 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_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, "usecount", "%d", &clk->usecount); + } return 0; } @@ -206,9 +225,17 @@ static char *clock_line(struct tree *t) if (asprintf(&clkrate, "%d%s", rate, clkunit) < 0) goto free_clkname; - if (asprintf(&clkline, "%-55s 0x%-16x %-12s %-9d %-8d", clkname, - clk->flags, clkrate, clk->usecount, t->nrchild) < 0) - goto free_clkrate; + if(clock_fw == CCF) { + if (asprintf(&clkline, "%-35s 0x%-8x %-12s %-10d %-11d %-15d %-14d %-10d", + clkname, clk->flags, clkrate, clk->usecount, t->nrchild, + clk->preparecount, clk->enablecount, clk->notifiercount) < 0) + goto free_clkrate; + } + else { + if (asprintf(&clkline, "%-55s 0x%-16x %-12s %-9d %-8d", + clkname, clk->flags, clkrate, clk->usecount, t->nrchild) < 0) + goto free_clkrate; + } free_clkrate: free(clkrate); @@ -259,9 +286,17 @@ static int clock_print_header(void) char *buf; int ret; - if (asprintf(&buf, "%-55s %-16s %-12s %-9s %-8s", + 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) + return -1; + } + else { + if (asprintf(&buf, "%-55s %-16s %-12s %-9s %-8s", "Name", "Flags", "Rate", "Usecount", "Children") < 0) return -1; + } ret = display_column_name(buf); @@ -384,17 +419,25 @@ static struct display_ops clock_ops = { */ int clock_init(void) { - char clk_dir_path[PATH_MAX]; + char clk_dir_path[MAX+1][PATH_MAX]; - if (locate_debugfs(clk_dir_path)) + if (locate_debugfs(clk_dir_path[CCF]) || locate_debugfs(clk_dir_path[OCF])) return -1; - sprintf(clk_dir_path, "%s/clock", clk_dir_path); - - if (access(clk_dir_path, F_OK)) + 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; + strcpy(clk_dir_path[MAX],clk_dir_path[CCF]); + } + else if(!access(clk_dir_path[OCF], F_OK)) { + clock_fw = OCF; + strcpy(clk_dir_path[MAX],clk_dir_path[OCF]); + } + else return -1; - clock_tree = tree_load(clk_dir_path, NULL, false); + clock_tree = tree_load(clk_dir_path[MAX], NULL, false); if (!clock_tree) return -1;