From patchwork Sat Sep 28 19:19:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Otavio Salvador X-Patchwork-Id: 278761 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 7F7BE2C00BA for ; Sun, 29 Sep 2013 05:26:10 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0111B4A0BF; Sat, 28 Sep 2013 21:26:09 +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 nHWatm7T8wbm; Sat, 28 Sep 2013 21:26:08 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 596884A0C2; Sat, 28 Sep 2013 21:26:02 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 61F924A0C2 for ; Sat, 28 Sep 2013 21:25:55 +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 Olq1KJZqEFDz for ; Sat, 28 Sep 2013 21:25:49 +0200 (CEST) X-Greylist: delayed 359 seconds by postgrey-1.27 at theia; Sat, 28 Sep 2013 21:25:42 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-qa0-f43.google.com (mail-qa0-f43.google.com [209.85.216.43]) by theia.denx.de (Postfix) with ESMTPS id 2980D4A0BF for ; Sat, 28 Sep 2013 21:25:42 +0200 (CEST) Received: by mail-qa0-f43.google.com with SMTP id k15so1342997qaq.9 for ; Sat, 28 Sep 2013 12:25:41 -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=xPqZ0JuvX7xkUCQcLUDb27VvjQJ2OJpIqkitm3QNtq0=; b=R75ekjKLlNtGiFk4ct24u477NQlZi7gsz17A1lrx6/QTJ20aNpIfZjdUhUr+gSVRpg KORdhK01BT4Jzzto6UuiGlETqa3k2KE72i9DJkvR9waPdLqnmTCCoaUSyFS9qKJShikG J2b1Rd8PHXJoer7C59oqfGNujQJMC7lVQ1hZgRivh+Idxzis+gRF5270ZymXXeYnaMfm tELwi7ghmFKgO/OiLvU5ErDnRylzclHy0WrVvl4j+oXc4ivrEr2qNmG9imd2+9Yw3G1T M+3yPENbwR00BfQqFoguvupHcIYJGh6R3nZ5OvwW2aCLH0tMdTkbjPVKo6l1sK6QmKPb auYw== X-Received: by 10.49.1.42 with SMTP id 10mr17741588qej.58.1380395991536; Sat, 28 Sep 2013 12:19:51 -0700 (PDT) Received: from nano.lab.ossystems.com.br ([177.194.209.11]) by mx.google.com with ESMTPSA id h2sm25188812qev.0.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 28 Sep 2013 12:19:50 -0700 (PDT) From: Otavio Salvador To: U-Boot Mailing List Date: Sat, 28 Sep 2013 16:19:25 -0300 Message-Id: <1380395965-14125-6-git-send-email-otavio@ossystems.com.br> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <1380395965-14125-1-git-send-email-otavio@ossystems.com.br> References: <1380395965-14125-1-git-send-email-otavio@ossystems.com.br> Organization: O.S. Systems Software LTDA. Cc: Otavio Salvador Subject: [U-Boot] [PATCH v2 6/6] 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 --- Changes in v2: None 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)