From patchwork Tue Apr 22 09:07:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanjay Singh Rawat X-Patchwork-Id: 28770 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 95B62203AC for ; Tue, 22 Apr 2014 09:07:36 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id w8sf20249121qac.4 for ; Tue, 22 Apr 2014 02:07:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=v4liIeQPqhmfJt+vzCkaBuY7QmI/f4hrPLZQqGqOwBc=; b=kP7EW+K2ozfODa4xukwkOADYjSNR5o4yiOu45LklBvDXgS1g/4awyRmYTWZVHJouKS A9BWsqi/9pi6T2yy9pVdwUebbNhvdSVtj/GKuIhypyjI3Ywv7Pyj0zlUqINWuMyy0kRa UW6cys/1M+8bQIk0vSLIx504QEOHSHbL+swX9enXu57YN2YsUNv5ueSOqRkSy0OHHZ1B P1J/CmtjXyQBp+l/PmosNxkHXx1g06UNxXAsaA1xs+AFOf2wHZC7m+j0n4WCOlZxcUmo ycOY9CDQMbE00tthHoMWgFAoCwbvhcVmFKbDuipv9tCP+qcLhGfMBAFQEFbOW7mkGB7f vv3A== X-Gm-Message-State: ALoCoQl9TR42SJDhdYChWgbX+fFLZTNylW9wk6j5y6k2OSvyvVC0BdCGhJTfsu9l6ABAeLZmC27/ X-Received: by 10.236.118.38 with SMTP id k26mr21431820yhh.35.1398157656393; Tue, 22 Apr 2014 02:07:36 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.71 with SMTP id d65ls5936qgf.17.gmail; Tue, 22 Apr 2014 02:07:36 -0700 (PDT) X-Received: by 10.52.104.7 with SMTP id ga7mr5826308vdb.29.1398157656247; Tue, 22 Apr 2014 02:07:36 -0700 (PDT) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id i19si872029vco.163.2014.04.22.02.07.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Apr 2014 02:07:36 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id pa12so9248260veb.15 for ; Tue, 22 Apr 2014 02:07:36 -0700 (PDT) X-Received: by 10.58.154.10 with SMTP id vk10mr35881251veb.18.1398157656165; Tue, 22 Apr 2014 02:07:36 -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.220.221.72 with SMTP id ib8csp8393vcb; Tue, 22 Apr 2014 02:07:35 -0700 (PDT) X-Received: by 10.66.233.72 with SMTP id tu8mr8764686pac.112.1398157655449; Tue, 22 Apr 2014 02:07:35 -0700 (PDT) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by mx.google.com with ESMTPS id wg2si7135168pab.167.2014.04.22.02.07.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Apr 2014 02:07:35 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.43 is neither permitted nor denied by best guess record for domain of sanjay.rawat@linaro.org) client-ip=209.85.220.43; Received: by mail-pa0-f43.google.com with SMTP id bj1so4724341pad.16 for ; Tue, 22 Apr 2014 02:07:35 -0700 (PDT) X-Received: by 10.66.164.201 with SMTP id ys9mr43349954pab.40.1398157654718; Tue, 22 Apr 2014 02:07:34 -0700 (PDT) Received: from srawat-Latitude-E6420.LGE.NET ([203.247.149.152]) by mx.google.com with ESMTPSA id qx11sm198908174pab.35.2014.04.22.02.07.31 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Apr 2014 02:07:34 -0700 (PDT) From: Sanjay Singh Rawat To: private-pmwg@linaro.org Cc: Sanjay Singh Rawat Subject: [PATCH POWERDEBUG] display error on module pads Date: Tue, 22 Apr 2014 14:37:17 +0530 Message-Id: <1398157637-22242-1-git-send-email-sanjay.rawat@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sanjay.rawat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.170 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: , - Currently errors are displayed on stdout. This patch put the error on subscreens. - bug 1298171 Signed-off-by: Sanjay Singh Rawat --- Not doing for clock window, as clock is the base window. Test exits if the clock files are not found. --- display.c | 9 +++++++++ display.h | 2 +- gpio.c | 17 ++++++++++++++++- regulator.c | 20 +++++++++++++++++++- sensor.c | 19 ++++++++++++++++++- 5 files changed, 63 insertions(+), 4 deletions(-) diff --git a/display.c b/display.c index c0afe03..0000ee9 100644 --- a/display.c +++ b/display.c @@ -270,6 +270,15 @@ int display_reset_cursor(int win) return wmove(windata[win].pad, 0, 0); } +void display_message(int win, char *buf) +{ + display_reset_cursor(win); + wattron(windata[win].pad, WA_BOLD); + wprintw(windata[win].pad, "%s\n", buf); + wattroff(windata[win].pad, WA_BOLD); + display_refresh_pad(win); +} + int display_print_line(int win, int line, char *str, int bold, void *data) { int attr = 0; diff --git a/display.h b/display.h index b28d26e..95cb846 100644 --- a/display.h +++ b/display.h @@ -25,7 +25,7 @@ struct display_ops { extern int display_print_line(int window, int line, char *str, int bold, void *data); - +extern void display_message(int window, char *buf); extern int display_refresh_pad(int window); extern int display_reset_cursor(int window); extern void *display_get_row_data(int window); diff --git a/gpio.c b/gpio.c index 7cc16f7..aa002ce 100644 --- a/gpio.c +++ b/gpio.c @@ -45,6 +45,7 @@ struct gpio_info { } *gpios_info; static struct tree *gpio_tree = NULL; +static bool gpio_error = false; static struct gpio_info *gpio_alloc(void) { @@ -258,6 +259,11 @@ static int gpio_print_info(struct tree *tree) static int gpio_display(bool refresh) { + if (gpio_error) { + display_message(GPIO, "error: path " SYSFS_GPIO " not found"); + return -2; + } + if (refresh && read_gpio_info(gpio_tree)) return -1; @@ -319,6 +325,15 @@ static struct display_ops gpio_ops = { */ int gpio_init(void) { + int ret = 0; + + ret = display_register(GPIO, &gpio_ops); + if (!ret) + printf("error: gpio display register failed"); + + if (access(SYSFS_GPIO, F_OK)) + gpio_error = true; /* set the flag */ + gpio_tree = tree_load(SYSFS_GPIO, gpio_filter_cb, false); if (!gpio_tree) return -1; @@ -326,5 +341,5 @@ int gpio_init(void) if (fill_gpio_tree()) return -1; - return display_register(GPIO, &gpio_ops); + return ret; } diff --git a/regulator.c b/regulator.c index 9cd89fd..8cf9288 100644 --- a/regulator.c +++ b/regulator.c @@ -28,6 +28,8 @@ #include #include #include +#include + #include "display.h" #include "powerdebug.h" #include "tree.h" @@ -68,6 +70,7 @@ static struct regulator_data regdata[] = { }; static struct tree *reg_tree; +static bool regulator_error = false; static struct regulator_info *regulator_alloc(void) { @@ -220,6 +223,12 @@ static int regulator_print_info(struct tree *tree) static int regulator_display(bool refresh) { + if (regulator_error) { + display_message(REGULATOR, + "error: path " SYSFS_REGULATOR " not found"); + return -2; + } + if (refresh && read_regulator_info(reg_tree)) return -1; @@ -255,6 +264,15 @@ static struct display_ops regulator_ops = { int regulator_init(void) { + int ret = 0; + + ret = display_register(REGULATOR, ®ulator_ops); + if (!ret) + printf("error: regulator display register failed"); + + if (access(SYSFS_REGULATOR, F_OK)) + regulator_error = true; /* set the flag */ + reg_tree = tree_load(SYSFS_REGULATOR, regulator_filter_cb, false); if (!reg_tree) return -1; @@ -262,5 +280,5 @@ int regulator_init(void) if (fill_regulator_tree()) return -1; - return display_register(REGULATOR, ®ulator_ops); + return ret; } diff --git a/sensor.c b/sensor.c index 0645d25..e4174eb 100644 --- a/sensor.c +++ b/sensor.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "powerdebug.h" #include "display.h" @@ -31,6 +32,7 @@ #define SYSFS_SENSOR "/sys/class/hwmon" static struct tree *sensor_tree; +static bool sensor_error = false; struct temp_info { char name[NAME_MAX]; @@ -272,6 +274,12 @@ static int sensor_print_info(struct tree *tree) static int sensor_display(bool refresh) { + if (sensor_error) { + display_message(SENSOR, + "error: path " SYSFS_SENSOR " not found"); + return -2; + } + if (refresh && read_sensor_info(sensor_tree)) return -1; @@ -284,6 +292,15 @@ static struct display_ops sensor_ops = { int sensor_init(void) { + int ret = 0; + + ret = display_register(SENSOR, &sensor_ops); + if (!ret) + printf("error: sensor display register failed"); + + if (access(SYSFS_SENSOR, F_OK)) + sensor_error = true; /* set the flag */ + sensor_tree = tree_load(SYSFS_SENSOR, sensor_filter_cb, false); if (!sensor_tree) return -1; @@ -291,5 +308,5 @@ int sensor_init(void) if (fill_sensor_tree()) return -1; - return display_register(SENSOR, &sensor_ops); + return ret; }