From patchwork Thu Feb 11 20:46:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Rubini X-Patchwork-Id: 71724 X-Patchwork-Delegate: albert.aribaud@free.fr Return-Path: X-Original-To: wd@gemini.denx.de Delivered-To: wd@gemini.denx.de Received: from diddl.denx.de (diddl.denx.de [10.0.0.6]) by gemini.denx.de (Postfix) with ESMTP id 90EF4E917A6 for ; Thu, 11 Feb 2010 21:48:31 +0100 (CET) Received: from diddl.denx.de (localhost.localdomain [127.0.0.1]) by diddl.denx.de (Postfix) with ESMTP id 8280FC7FA5C0 for ; Thu, 11 Feb 2010 21:48:31 +0100 (CET) Received: from pop.mnet-online.de by diddl.denx.de with POP3 (fetchmail-6.3.9) for (single-drop); Thu, 11 Feb 2010 21:48:31 +0100 (CET) Received: from murder (svr19.m-online.net [192.168.3.147]) by backend2 (Cyrus v2.2.12) with LMTPA; Thu, 11 Feb 2010 21:47:10 +0100 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend3.pop.m-online.net (Cyrus v2.2.13) with LMTPA; Thu, 11 Feb 2010 21:47:09 +0100 Received: from scanner-4.m-online.net (scanner-4.m-online.net [192.168.1.18]) by mail.m-online.net (Postfix) with ESMTP id 96C63200113; Thu, 11 Feb 2010 21:47:09 +0100 (CET) Received: from mxin-2.m-online.net ([192.168.1.21]) by scanner-4.m-online.net (scanner-4.m-online.net [192.168.1.18]) (amavisd-new, port 10026) with ESMTP id 15247-07-5; Thu, 11 Feb 2010 21:47:07 +0100 (CET) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-2.m-online.net (Postfix) with ESMTP id A73AE46C0B1; Thu, 11 Feb 2010 21:47:06 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 163D0280E2; Thu, 11 Feb 2010 21:46:53 +0100 (CET) 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 vWdj304Jkmor; Thu, 11 Feb 2010 21:46:52 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 741DE280E3; Thu, 11 Feb 2010 21:46:47 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 39975280B8 for ; Thu, 11 Feb 2010 21:46:44 +0100 (CET) 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 NpHt9gg+O48v for ; Thu, 11 Feb 2010 21:46:43 +0100 (CET) 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.gnudd.com (mail2.gnudd.com [213.203.150.91]) by theia.denx.de (Postfix) with ESMTPS id 50B04280CF for ; Thu, 11 Feb 2010 21:46:42 +0100 (CET) Received: from mail.gnudd.com (localhost [127.0.0.1]) by mail.gnudd.com (8.14.3/8.14.3/Debian-5) with ESMTP id o1BKkdQY020267; Thu, 11 Feb 2010 21:46:39 +0100 Received: (from rubini@localhost) by mail.gnudd.com (8.14.3/8.14.3/Submit) id o1BKkdMY020266; Thu, 11 Feb 2010 21:46:39 +0100 Date: Thu, 11 Feb 2010 21:46:39 +0100 From: Alessandro Rubini To: u-boot@lists.denx.de Message-ID: <676d5729204f4fba02730fd8db55e4fb433fedb5.1265920498.git.rubini@unipv.it> MIME-Version: 1.0 Content-Disposition: inline X-Face: #Q; A)@_4.#>0+_%y]7aBr:c"ndLp&#+2?]J; lkse\^)FP^Lr5@O0{)J; 'nny4%74.fM'n)M >ISCj.KmsL/HTxz!:Ju'pnj'Gz&. Organization: GnuDD, Device Drivers, Embedded Systems, Courses References: In-Reply-To: Subject: [U-Boot] [PATCH 1/2] ep93xx leds: remove arrays in data section X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Virus-Scanned: by amavisd-new at m-online.net This code is used at early boot, and using arrays for status generates references to RAM addresses that are not working. The patch avoids such structures using a preprocessor macro and by reading status from hardware in the toggle function. Meanwhile, inline functions are turned to static to save code space. Signed-off-by: Alessandro Rubini Acked-by: Matthias Kaehlcke --- cpu/arm920t/ep93xx/led.c | 29 +++++++++-------------------- 1 files changed, 9 insertions(+), 20 deletions(-) diff --git a/cpu/arm920t/ep93xx/led.c b/cpu/arm920t/ep93xx/led.c index 7e2c897..8b2df04 100644 --- a/cpu/arm920t/ep93xx/led.c +++ b/cpu/arm920t/ep93xx/led.c @@ -25,24 +25,21 @@ #include #include -static uint8_t saved_state[2] = {STATUS_LED_OFF, STATUS_LED_OFF}; -static uint32_t gpio_pin[2] = {1 << STATUS_LED_GREEN, - 1 << STATUS_LED_RED}; +/* We can't use arrays in data segment at early boot, but we know n is 0-1 */ +#define GPIO_PIN(n) (1 << (n)) -inline void switch_LED_on(uint8_t led) +static inline void switch_LED_on(uint8_t led) { register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE; - writel(readl(&gpio->pedr) | gpio_pin[led], &gpio->pedr); - saved_state[led] = STATUS_LED_ON; + writel(readl(&gpio->pedr) | GPIO_PIN(led), &gpio->pedr); } -inline void switch_LED_off(uint8_t led) +static inline void switch_LED_off(uint8_t led) { register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE; - writel(readl(&gpio->pedr) & ~gpio_pin[led], &gpio->pedr); - saved_state[led] = STATUS_LED_OFF; + writel(readl(&gpio->pedr) & ~GPIO_PIN(led), &gpio->pedr); } void red_LED_on(void) @@ -72,17 +69,9 @@ void __led_init(led_id_t mask, int state) void __led_toggle(led_id_t mask) { - if (STATUS_LED_RED == mask) { - if (STATUS_LED_ON == saved_state[STATUS_LED_RED]) - red_LED_off(); - else - red_LED_on(); - } else if (STATUS_LED_GREEN == mask) { - if (STATUS_LED_ON == saved_state[STATUS_LED_GREEN]) - green_LED_off(); - else - green_LED_on(); - } + register struct gpio_regs *gpio = (struct gpio_regs *)GPIO_BASE; + + writel(readl(&gpio->pedr) ^ GPIO_PIN(mask), &gpio->pedr); } void __led_set(led_id_t mask, int state)