From patchwork Thu Jul 25 11:02:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sunshaojie X-Patchwork-Id: 18571 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f69.google.com (mail-qe0-f69.google.com [209.85.128.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 519AA25DF6 for ; Thu, 25 Jul 2013 11:02:20 +0000 (UTC) Received: by mail-qe0-f69.google.com with SMTP id a11sf525717qen.0 for ; Thu, 25 Jul 2013 04:02:19 -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=AE+HLAaDrJScxQbB2Pg9DwjsHcDJr67795zAY6QY3yi+ydSelFE71Yq0pQ+ey3ScDQ 3IIZFKdgI1onrNAnwJ1FT6wDA1Skvc5eGXWbfuG1FMdC4vx1rpN1gbl7pfUMgbow/IB4 BXq9+W4udFTcbIqsC+n4MzY6rgRR4b3SsojMu/bSBzeFZ5X3ncLG1wMSeOXwIns9/m4A PqzI7G660w6xI1hRU44sW/RaX4mRGzO4Qq3Inqyh31+ulcksd09VBMQlIO428GRldn5p ZMsUr9rfM5s0tn7Z5+ilvLrpIwhSeOFdcSkXj6D/RA7Na1bwr7ZSyn3qP+zu2oiD8XHm DWvg== X-Received: by 10.236.54.135 with SMTP id i7mr23837956yhc.33.1374750139657; Thu, 25 Jul 2013 04:02:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.25.1 with SMTP id y1ls577981qef.87.gmail; Thu, 25 Jul 2013 04:02:19 -0700 (PDT) X-Received: by 10.58.182.103 with SMTP id ed7mr17732383vec.70.1374750139565; Thu, 25 Jul 2013 04:02:19 -0700 (PDT) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx.google.com with ESMTPS id st7si12177969vec.49.2013.07.25.04.02.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Jul 2013 04:02:19 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.54 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.54; Received: by mail-vb0-f54.google.com with SMTP id q16so373491vbe.13 for ; Thu, 25 Jul 2013 04:02:19 -0700 (PDT) X-Received: by 10.52.77.5 with SMTP id o5mr14533936vdw.46.1374750139481; Thu, 25 Jul 2013 04:02:19 -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 yu8csp71469veb; Thu, 25 Jul 2013 04:02:18 -0700 (PDT) X-Received: by 10.66.26.132 with SMTP id l4mr44364220pag.138.1374750138459; Thu, 25 Jul 2013 04:02:18 -0700 (PDT) Received: from mail-pb0-f45.google.com (mail-pb0-f45.google.com [209.85.160.45]) by mx.google.com with ESMTPS id yk3si3126414pac.41.2013.07.25.04.02.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Jul 2013 04:02:18 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.45 is neither permitted nor denied by best guess record for domain of shaojie.sun@linaro.org) client-ip=209.85.160.45; Received: by mail-pb0-f45.google.com with SMTP id mc8so611712pbc.18 for ; Thu, 25 Jul 2013 04:02:18 -0700 (PDT) X-Received: by 10.66.122.67 with SMTP id lq3mr48733561pab.147.1374750137831; Thu, 25 Jul 2013 04:02:17 -0700 (PDT) Received: from localhost.localdomain ([58.251.159.202]) by mx.google.com with ESMTPSA id ht5sm53390765pbb.29.2013.07.25.04.02.14 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Jul 2013 04:02:17 -0700 (PDT) From: Shaojie Sun To: sanjay.rawat@linaro.org Cc: private-pmwg@linaro.org, patches@linaro.org, sunshaojie@huawei.com, Shaojie Sun Subject: [PATCH] POWERDEBUG: show gpio direction and egde in string. Date: Thu, 25 Jul 2013 19:02:08 +0800 Message-Id: <1374750128-21547-1-git-send-email-shaojie.sun@linaro.com> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQni6tdljKDG7Gk2v/B3HIRe36tAOrr89fEVvznhR3IcnHI7EJtU/RpySMR6CsOSEJrrO2AR X-Original-Sender: shaojie.sun@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.54 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;