From patchwork Wed Jun 15 13:50:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 1943 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 46DE724B33 for ; Wed, 15 Jun 2011 13:52:49 +0000 (UTC) Received: from mail-vw0-f52.google.com (mail-vw0-f52.google.com [209.85.212.52]) by fiordland.canonical.com (Postfix) with ESMTP id 166FFA180BB for ; Wed, 15 Jun 2011 13:52:48 +0000 (UTC) Received: by mail-vw0-f52.google.com with SMTP id 16so416308vws.11 for ; Wed, 15 Jun 2011 06:52:48 -0700 (PDT) Received: by 10.52.175.197 with SMTP id cc5mr778712vdc.287.1308145968880; Wed, 15 Jun 2011 06:52:48 -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.52.183.130 with SMTP id em2cs126649vdc; Wed, 15 Jun 2011 06:52:48 -0700 (PDT) Received: by 10.227.198.199 with SMTP id ep7mr641522wbb.40.1308145966425; Wed, 15 Jun 2011 06:52:46 -0700 (PDT) Received: from smtp.smtpout.orange.fr (smtp05.smtpout.orange.fr [80.12.242.127]) by mx.google.com with ESMTP id ej18si1392264wbb.23.2011.06.15.06.52.45; Wed, 15 Jun 2011 06:52:46 -0700 (PDT) Received-SPF: neutral (google.com: 80.12.242.127 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=80.12.242.127; Authentication-Results: mx.google.com; spf=neutral (google.com: 80.12.242.127 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: from monster.dhcp.lxc ([92.134.76.78]) by mwinf5d28 with ME id wDsa1g00D1hMfSL03DslES; Wed, 15 Jun 2011 15:52:45 +0200 From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: linaro-dev@lists.linaro.org, patches@linaro.org Subject: [powerdebug 20/22] Remove the useless define Date: Wed, 15 Jun 2011 15:50:54 +0200 Message-Id: <1308145856-6112-20-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308145856-6112-1-git-send-email-daniel.lezcano@linaro.org> References: <1308145856-6112-1-git-send-email-daniel.lezcano@linaro.org> The less we have define for pm blocks the easier is to add more pm blocks. Signed-off-by: Daniel Lezcano --- display.c | 24 +++++++++++++++--------- display.h | 2 ++ powerdebug.h | 4 ---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/display.c b/display.c index 5fad059..5fd14c7 100644 --- a/display.c +++ b/display.c @@ -21,8 +21,6 @@ #include "regulator.h" #include "display.h" -#define TOTAL_FEATURE_WINS 3 /* Regulator, Clock and Sensor (for now) */ - #define print(w, x, y, fmt, args...) do { mvwprintw(w, y, x, fmt, ##args); } while (0) enum { PT_COLOR_DEFAULT = 1, @@ -63,10 +61,11 @@ struct windata { int cursor; }; +/* Warning this is linked with the enum { CLOCK, REGULATOR, ... } */ struct windata windata[] = { - { .name = "Clocks" }, - { .name = "Regulators" }, - { .name = "Sensors" }, + [CLOCK] = { .name = "Clocks" }, + [REGULATOR] = { .name = "Regulators" }, + [SENSOR] = { .name = "Sensors" }, }; static void display_fini(void) @@ -78,6 +77,7 @@ static int show_header_footer(int win) { int i; int curr_pointer = 0; + size_t array_size = sizeof(windata) / sizeof(windata[0]); wattrset(header_win, COLOR_PAIR(PT_COLOR_HEADER_BAR)); wbkgd(header_win, COLOR_PAIR(PT_COLOR_HEADER_BAR)); @@ -86,7 +86,7 @@ static int show_header_footer(int win) print(header_win, curr_pointer, 0, "PowerDebug %s", VERSION); curr_pointer += 20; - for (i = 0; i < TOTAL_FEATURE_WINS; i++) { + for (i = 0; i < array_size; i++) { if (win == i) wattron(header_win, A_REVERSE); else @@ -216,7 +216,9 @@ void print_sensor_header(void) int display_register(int win, struct display_ops *ops) { - if (win < 0 || win >= TOTAL_FEATURE_WINS) + size_t array_size = sizeof(windata) / sizeof(windata[0]); + + if (win < 0 || win >= array_size) return -1; windata[win].ops = ops; @@ -242,17 +244,21 @@ int display_select(void) int display_next_panel(void) { + size_t array_size = sizeof(windata) / sizeof(windata[0]); + current_win++; - current_win %= TOTAL_FEATURE_WINS; + current_win %= array_size; return current_win; } int display_prev_panel(void) { + size_t array_size = sizeof(windata) / sizeof(windata[0]); + current_win--; if (current_win < 0) - current_win = TOTAL_FEATURE_WINS - 1; + current_win = array_size - 1; return current_win; } diff --git a/display.h b/display.h index ebd501a..f354195 100644 --- a/display.h +++ b/display.h @@ -13,6 +13,8 @@ * - initial API and implementation *******************************************************************************/ +enum { CLOCK, REGULATOR, SENSOR }; + struct display_ops { int (*display)(void); int (*select)(void); diff --git a/powerdebug.h b/powerdebug.h index fb066ce..73e3581 100644 --- a/powerdebug.h +++ b/powerdebug.h @@ -15,8 +15,4 @@ #define VERSION "0.4.1" -enum { CLOCK, REGULATOR, SENSOR }; - -extern void find_parents_for_clock(char *clkname, int complete); -