From patchwork Sat Sep 28 03:24:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Otavio Salvador X-Patchwork-Id: 278710 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 942D02C0333 for ; Sat, 28 Sep 2013 13:52:38 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0D00F4A080; Sat, 28 Sep 2013 05:52:37 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RxTUBDQz7X+d; Sat, 28 Sep 2013 05:52:36 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6ADDA4A081; Sat, 28 Sep 2013 05:52:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5AB9C4A081 for ; Sat, 28 Sep 2013 05:52:24 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZNQl5KOL8TGD for ; Sat, 28 Sep 2013 05:52:18 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-yh0-f50.google.com (mail-yh0-f50.google.com [209.85.213.50]) by theia.denx.de (Postfix) with ESMTPS id 31E5A4A080 for ; Sat, 28 Sep 2013 05:52:11 +0200 (CEST) Received: by mail-yh0-f50.google.com with SMTP id a41so1301085yho.9 for ; Fri, 27 Sep 2013 20:52:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :organization; bh=VzTV14hwVx1CeoSnvdO3ljmlrIQm5Jn1FPYXRcs2uW4=; b=BpKo168Jb5ByiOVrb80Q0fxgiayYuDZ7ToPDKcwFh99/dZqto5xFXH9xc8PWq4KQ5D MeSFht+WI0ltqAfpM/ZpBQLYQFT5dAf8sJNC3UFu5aKUxEC00fGuNHioFRBt9zu9cOSk c6oAumUA9Z1gfpfQ6M353Pe6FHM7fepj1LXTGfebhJx9IjzWwWLoj489dVCEIPpOLeeG Io4h4LAK8siTxzXwkT8XfYkQmt65dZyw1+8XX+KTsDw0ICXQN2IQDglIeZdFmJOMvydT j7trbpZ4ShMpkGzrqd6SvJuqTl3GCwci6oToMbD+cgj9NnmABbp6ASv8a761U7x6G8S6 /PdA== X-Received: by 10.236.171.195 with SMTP id r43mr10282699yhl.56.1380338687917; Fri, 27 Sep 2013 20:24:47 -0700 (PDT) Received: from nano.lab.ossystems.com.br ([177.194.209.11]) by mx.google.com with ESMTPSA id v45sm15980678yha.2.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Sep 2013 20:24:47 -0700 (PDT) From: Otavio Salvador To: U-Boot Mailing List Date: Sat, 28 Sep 2013 00:24:18 -0300 Message-Id: <1380338659-7896-7-git-send-email-otavio@ossystems.com.br> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1380338659-7896-1-git-send-email-otavio@ossystems.com.br> References: <1380338659-7896-1-git-send-email-otavio@ossystems.com.br> Organization: O.S. Systems Software LTDA. Cc: Otavio Salvador Subject: [U-Boot] [PATCH 7/7] cmd_led: Add support for inverted BIT leds X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Signed-off-by: Otavio Salvador --- common/cmd_led.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/common/cmd_led.c b/common/cmd_led.c index c48603c..d541f2f 100644 --- a/common/cmd_led.c +++ b/common/cmd_led.c @@ -18,6 +18,7 @@ struct led_tbl_s { char *string; /* String for use in the command */ led_id_t mask; /* Mask used for calling __led_set() */ + int invert; /* Is the LED inverted? */ void (*off)(void); /* Optional function for turning LED off */ void (*on)(void); /* Optional function for turning LED on */ void (*toggle)(void);/* Optional function for toggling LED */ @@ -28,31 +29,31 @@ typedef struct led_tbl_s led_tbl_t; static const led_tbl_t led_commands[] = { #ifdef CONFIG_BOARD_SPECIFIC_LED #ifdef STATUS_LED_BIT - { "0", STATUS_LED_BIT, NULL, NULL, NULL }, + { "0", STATUS_LED_BIT, STATUS_LED_INVERT, NULL, NULL, NULL }, #endif #ifdef STATUS_LED_BIT1 - { "1", STATUS_LED_BIT1, NULL, NULL, NULL }, + { "1", STATUS_LED_BIT1, STATUS_LED_INVERT1, NULL, NULL, NULL }, #endif #ifdef STATUS_LED_BIT2 - { "2", STATUS_LED_BIT2, NULL, NULL, NULL }, + { "2", STATUS_LED_BIT2, STATUS_LED_INVERT2, NULL, NULL, NULL }, #endif #ifdef STATUS_LED_BIT3 - { "3", STATUS_LED_BIT3, NULL, NULL, NULL }, + { "3", STATUS_LED_BIT3, STATUS_LED_INVERT3, NULL, NULL, NULL }, #endif #endif #ifdef STATUS_LED_GREEN - { "green", STATUS_LED_GREEN, green_led_off, green_led_on, NULL }, + { "green", STATUS_LED_GREEN, 0, green_led_off, green_led_on, NULL }, #endif #ifdef STATUS_LED_YELLOW - { "yellow", STATUS_LED_YELLOW, yellow_led_off, yellow_led_on, NULL }, + { "yellow", STATUS_LED_YELLOW, 0, yellow_led_off, yellow_led_on, NULL }, #endif #ifdef STATUS_LED_RED - { "red", STATUS_LED_RED, red_led_off, red_led_on, NULL }, + { "red", STATUS_LED_RED, 0, red_led_off, red_led_on, NULL }, #endif #ifdef STATUS_LED_BLUE - { "blue", STATUS_LED_BLUE, blue_led_off, blue_led_on, NULL }, + { "blue", STATUS_LED_BLUE, 0, blue_led_off, blue_led_on, NULL }, #endif - { NULL, 0, NULL, NULL, NULL } + { NULL, 0, 0, NULL, NULL, NULL } }; enum led_cmd { LED_ON, LED_OFF, LED_TOGGLE }; @@ -95,14 +96,18 @@ int do_led (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) led_commands[i].on(); else __led_set(led_commands[i].mask, - STATUS_LED_ON); + (led_commands[i].invert + ? STATUS_LED_OFF + : STATUS_LED_ON)); break; case LED_OFF: if (led_commands[i].off) led_commands[i].off(); else __led_set(led_commands[i].mask, - STATUS_LED_OFF); + (led_commands[i].invert + ? STATUS_LED_ON + : STATUS_LED_OFF)); break; case LED_TOGGLE: if (led_commands[i].toggle)