From patchwork Thu Aug 25 13:47:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 3679 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 F0B3823F22 for ; Thu, 25 Aug 2011 13:47:14 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id C299CA188C7 for ; Thu, 25 Aug 2011 13:47:14 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id 11so2482455yxi.11 for ; Thu, 25 Aug 2011 06:47:14 -0700 (PDT) Received: by 10.151.122.13 with SMTP id z13mr940230ybm.269.1314280034523; Thu, 25 Aug 2011 06:47:14 -0700 (PDT) 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.151.27.20 with SMTP id e20cs238192ybj; Thu, 25 Aug 2011 06:47:14 -0700 (PDT) Received: by 10.227.113.71 with SMTP id z7mr2625103wbp.77.1314280029880; Thu, 25 Aug 2011 06:47:09 -0700 (PDT) Received: from mtagate2.uk.ibm.com (mtagate2.uk.ibm.com [194.196.100.162]) by mx.google.com with ESMTPS id ft21si1580388wbb.82.2011.08.25.06.47.09 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 25 Aug 2011 06:47:09 -0700 (PDT) Received-SPF: neutral (google.com: 194.196.100.162 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=194.196.100.162; Authentication-Results: mx.google.com; spf=neutral (google.com: 194.196.100.162 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p7PDl8EI020802 for ; Thu, 25 Aug 2011 13:47:08 GMT Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p7PDl7VZ2593012 for ; Thu, 25 Aug 2011 14:47:08 +0100 Received: from d06av05.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p7PDl7rm013673 for ; Thu, 25 Aug 2011 07:47:07 -0600 Received: from smtp.lab.toulouse-stg.fr.ibm.com (srv01.lab.toulouse-stg.fr.ibm.com [9.101.4.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p7PDl7cc013662; Thu, 25 Aug 2011 07:47:07 -0600 Received: from localhost.localdomain (sig-9-145-110-19.uk.ibm.com [9.145.110.19]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id 5314E21101F; Thu, 25 Aug 2011 15:47:06 +0200 (CEST) From: Daniel Lezcano To: linaro-dev@lists.linaro.org Subject: [powerdebug 6/7] plug the gpio subsys with the main function Date: Thu, 25 Aug 2011 15:47:06 +0200 Message-Id: <1314280027-7547-6-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1314280027-7547-1-git-send-email-daniel.lezcano@linaro.org> References: <1314280027-7547-1-git-send-email-daniel.lezcano@linaro.org> Let's create the command options parameters and plug the gpio code with the main code. Signed-off-by: Daniel Lezcano --- powerdebug.c | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) diff --git a/powerdebug.c b/powerdebug.c index b4575c4..cc9e871 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -24,6 +24,7 @@ #include "display.h" #include "clocks.h" #include "sensor.h" +#include "gpio.h" #include "mainloop.h" #include "powerdebug.h" @@ -54,9 +55,10 @@ void version() /* * Options: - * -r, --regulator : regulator + * -r, --regulator : regulators * -s, --sensor : sensors * -c, --clock : clocks + * -g, --gpio : gpios * -p, --findparents : clockname whose parents have to be found * -t, --time : ticktime * -d, --dump : dump @@ -70,6 +72,7 @@ static struct option long_options[] = { { "regulator", 0, 0, 'r' }, { "sensor", 0, 0, 's' }, { "clock", 0, 0, 'c' }, + { "gpio", 0, 0, 'g' }, { "findparents", 1, 0, 'p' }, { "time", 1, 0, 't' }, { "dump", 0, 0, 'd' }, @@ -84,6 +87,7 @@ struct powerdebug_options { bool regulators; bool sensors; bool clocks; + bool gpios; bool dump; unsigned int ticktime; int selectedwindow; @@ -101,7 +105,7 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) while (1) { int optindex = 0; - c = getopt_long(argc, argv, "rscp:t:dvVh", + c = getopt_long(argc, argv, "rscgp:t:dvVh", long_options, &optindex); if (c == -1) break; @@ -119,6 +123,10 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) options->clocks = true; options->selectedwindow = CLOCK; break; + case 'g': + options->gpios = true; + options->selectedwindow = GPIO; + break; case 'p': options->clkname = strdup(optarg); if (!options->clkname) { @@ -149,8 +157,10 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) } /* No system specified to be dump, let's default to all */ - if (!options->regulators && !options->clocks && !options->sensors) - options->regulators = options->clocks = options->sensors = true; + if (!options->regulators && !options->clocks && + !options->sensors && !options->gpios) + options->regulators = options->clocks = + options->sensors = options->gpios = true; if (options->selectedwindow == -1) options->selectedwindow = CLOCK; @@ -169,6 +179,9 @@ static int powerdebug_dump(struct powerdebug_options *options) if (options->sensors) sensor_dump(); + if (options->gpios) + gpio_dump(); + return 0; } @@ -234,6 +247,11 @@ int main(int argc, char **argv) options->sensors = false; } + if (gpio_init()) { + printf("failed to initialize gpios\n"); + options->gpios = false; + } + ret = options->dump ? powerdebug_dump(options) : powerdebug_display(options);