From patchwork Thu Jul 25 10:55:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunshaojie X-Patchwork-Id: 18570 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gh0-f200.google.com (mail-gh0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8D78725DF6 for ; Thu, 25 Jul 2013 10:55:28 +0000 (UTC) Received: by mail-gh0-f200.google.com with SMTP id 10sf1445733ghy.7 for ; Thu, 25 Jul 2013 03:55:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to: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=MrvotGV9Mam5dJnhhiupKxvfcVurNsaYUhxwNDzbEso=; b=MCpAaiMEhKznRDGZVLzZCOKceX4xjK9TrsRzj8m3Bz3mwFCYKuI5mtab54HaU/CFtD qfgNmSuZn4wChQWmKRMYv4HKWFL/RPyUyNECYo9cjrJrerB0lTcbS950zuhl78iOsmdx OTpJkbb+dLN4ITB19pkAPxFXb4OZfoD75XQWp38O5DHs+Vs/B6buJ3iR+naNl4HNZW6+ uIzarghkd/aUrFDNr+JwmRAupIZrwhiSukldQP1pX9EMuWUNxBKZV5XMLhCovO+i8VUd /ADiEMn6wLlB2CzvL99U84utQhprpC1yfm2IQSreZn1GVBrOc6AlOuGJsJArXI8qmsZW 7WOw== X-Received: by 10.236.190.72 with SMTP id d48mr113823yhn.0.1374749728098; Thu, 25 Jul 2013 03:55:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.97.197 with SMTP id ec5ls553695qeb.26.gmail; Thu, 25 Jul 2013 03:55:28 -0700 (PDT) X-Received: by 10.52.34.40 with SMTP id w8mr14523576vdi.7.1374749727927; Thu, 25 Jul 2013 03:55:27 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id y4si12168333vej.37.2013.07.25.03.55.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Jul 2013 03:55:27 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.182 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.182; Received: by mail-vc0-f182.google.com with SMTP id hf12so48277vcb.27 for ; Thu, 25 Jul 2013 03:55:27 -0700 (PDT) X-Received: by 10.52.120.77 with SMTP id la13mr14580802vdb.23.1374749727832; Thu, 25 Jul 2013 03:55:27 -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.165.8 with SMTP id yu8csp71200veb; Thu, 25 Jul 2013 03:55:27 -0700 (PDT) X-Received: by 10.68.78.101 with SMTP id a5mr13613122pbx.115.1374749726784; Thu, 25 Jul 2013 03:55:26 -0700 (PDT) Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by mx.google.com with ESMTPS id aq4si29853048pbd.116.2013.07.25.03.55.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Jul 2013 03:55:26 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.173 is neither permitted nor denied by best guess record for domain of shaojie.sun@linaro.org) client-ip=209.85.192.173; Received: by mail-pd0-f173.google.com with SMTP id bv13so1550771pdb.4 for ; Thu, 25 Jul 2013 03:55:26 -0700 (PDT) X-Received: by 10.68.204.194 with SMTP id la2mr47660420pbc.71.1374749726262; Thu, 25 Jul 2013 03:55:26 -0700 (PDT) Received: from localhost.localdomain ([58.251.159.202]) by mx.google.com with ESMTPSA id y9sm53307137pbb.46.2013.07.25.03.55.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Jul 2013 03:55:25 -0700 (PDT) From: Shaojie Sun To: anjay.rawat@linaro.org Cc: private-pmwg@linaro.org, patches@linaro.org, Shaojie Sun Subject: [PATCH] POWERDEBUG: show gpio direction and egde in string. Date: Thu, 25 Jul 2013 18:55:10 +0800 Message-Id: <1374749710-21426-1-git-send-email-shaojie.sun@linaro.com> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQlh23cDq9Jjr6TlBCgWNzZjEHzTlGfJUahrBLi6IrV5UJaRtywaQU3uPncNKJIL7ei+cmAF X-Original-Sender: shaojie.sun@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.182 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: , In gpio sysfs, direction and egde is shown in string. dierction value is "in" or "out". And egde value is "none", "falling", "rising" or "both". So string must be shown also in powerdebug tool. Signed-off-by: Shaojie Sun --- gpio.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/gpio.c b/gpio.c index f7d2a10..3ecc393 100644 --- a/gpio.c +++ b/gpio.c @@ -33,12 +33,14 @@ #define SYSFS_GPIO "/sys/class/gpio" +#define MAX_VALUE_BYTE 10 + struct gpio_info { bool expanded; int active_low; int value; - int direction; - int edge; + char direction[MAX_VALUE_BYTE]; + char edge[MAX_VALUE_BYTE]; char *prefix; } *gpios_info; @@ -51,6 +53,8 @@ static struct gpio_info *gpio_alloc(void) gi = malloc(sizeof(*gi)); if (gi) { memset(gi, -1, sizeof(*gi)); + memset(gi->direction, 0, MAX_VALUE_BYTE); + memset(gi->edge, 0, MAX_VALUE_BYTE); gi->prefix = NULL; } @@ -89,8 +93,8 @@ static inline int read_gpio_cb(struct tree *t, void *data) file_read_value(t->path, "active_low", "%d", &gpio->active_low); file_read_value(t->path, "value", "%d", &gpio->value); - file_read_value(t->path, "edge", "%d", &gpio->edge); - file_read_value(t->path, "direction", "%d", &gpio->direction); + file_read_value(t->path, "edge", "%8s", &gpio->edge); + file_read_value(t->path, "direction", "%4s", &gpio->direction); return 0; } @@ -150,11 +154,11 @@ static int dump_gpio_cb(struct tree *t, void *data) if (gpio->value != -1) printf(", value:%d", gpio->value); - if (gpio->edge != -1) - printf(", edge:%d", gpio->edge); + if (gpio->edge[0] != 0) + printf(", edge:%s", gpio->edge); - if (gpio->direction != -1) - printf(", direction:%d", gpio->direction); + if (gpio->direction[0] != 0) + printf(", direction:%s", gpio->direction); printf(" )\n"); @@ -183,7 +187,7 @@ static char *gpio_line(struct tree *t) struct gpio_info *gpio = t->private; char *gpioline; - if (asprintf(&gpioline, "%-20s %-10d %-10d %-10d %-10d", t-> name, + if (asprintf(&gpioline, "%-20s %-10d %-10d %-10s %-10s", t->name, gpio->value, gpio->active_low, gpio->edge, gpio->direction) < 0) return NULL;