From patchwork Sun Oct 7 15:56:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Herrmann X-Patchwork-Id: 189850 X-Patchwork-Delegate: trini@ti.com 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 39F4D2C0281 for ; Mon, 8 Oct 2012 02:57:48 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7A540280EA; Sun, 7 Oct 2012 17:57:35 +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 4fTZWx-cPanf; Sun, 7 Oct 2012 17:57:35 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6B2B0280AE; Sun, 7 Oct 2012 17:57:04 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4EA49280CA for ; Sun, 7 Oct 2012 17:56:53 +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 Z5o4GGgj6+-B for ; Sun, 7 Oct 2012 17:56:50 +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-wg0-f52.google.com (mail-wg0-f52.google.com [74.125.82.52]) by theia.denx.de (Postfix) with ESMTPS id 8FDD628097 for ; Sun, 7 Oct 2012 17:56:45 +0200 (CEST) Received: by mail-wg0-f52.google.com with SMTP id fg15so2653894wgb.9 for ; Sun, 07 Oct 2012 08:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=1H/rNjTUI3ZAMxOTxBZlJcG3Td3M78MyC55/ib/2PCA=; b=b7Q/YOebE6soj13Lm/l8DT5uai5AHbIFyR6s2aAhchz22MCT5TviG6TS+qd8Q2h1Pl khme9+hxwIHgjfBzd8k6XpsXzWQV8CDkUBkt45SYmbn9TavNuobxIwFNcXSE6h7O3639 RANeJyjdO0Os0GxaAoZnYBMCEC9l84CUpZEW0uwlt1jDPVqaKYqqzQa5Er4gSxa+cGlI H+2ywAJwIqO9ZFNWZX4Fd1T+nypZDj/LFi7nrZOwWM7wUm07ZRBvD740CPavQgUWDwl9 6QjqBGxnhwpAiSAdCaOg/vbDR73dTcCTHk9kCdJ3v1A5CeBqM9r91Q3mFRtORwJ6Ngtw 2FfQ== Received: by 10.180.24.4 with SMTP id q4mr15113077wif.19.1349625405679; Sun, 07 Oct 2012 08:56:45 -0700 (PDT) Received: from Bloomfield.kolej.mff.cuni.cz (pavelherrmann.kolej.mff.cuni.cz. [78.128.197.20]) by mx.google.com with ESMTPS id ay10sm16450042wib.2.2012.10.07.08.56.44 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 07 Oct 2012 08:56:45 -0700 (PDT) From: Pavel Herrmann To: u-boot@lists.denx.de Date: Sun, 7 Oct 2012 17:56:10 +0200 Message-Id: <1349625374-12391-7-git-send-email-morpheus.ibis@gmail.com> X-Mailer: git-send-email 1.7.12 In-Reply-To: <1349625374-12391-1-git-send-email-morpheus.ibis@gmail.com> References: <1349625374-12391-1-git-send-email-morpheus.ibis@gmail.com> Cc: marex@denx.de Subject: [U-Boot] [PATCH 06/10] make ide_led() a weak alias 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 Make ide_led() a weak alias instead of global/local function/empty macro based on CONFIG_IDE_LED value and/or board-specific CONFIGs, to get rid of board-specific code in cmd_ide.c Define dummy values to get rid of compoler errors in case where ide_led() used to be an empty macro Signed-off-by: Pavel Herrmann --- common/cmd_ide.c | 63 ++++++++++++++++++++++++-------------------------------- 1 file changed, 27 insertions(+), 36 deletions(-) diff --git a/common/cmd_ide.c b/common/cmd_ide.c index 89849d5..2f3b077 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -81,19 +81,6 @@ static int ide_bus_ok[CONFIG_SYS_IDE_MAXBUS]; block_dev_desc_t ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE]; /* ------------------------------------------------------------------------- */ -#ifdef CONFIG_IDE_LED -# if !defined(CONFIG_BMS2003) && \ - !defined(CONFIG_CPC45) && \ - !defined(CONFIG_KUP4K) && \ - !defined(CONFIG_KUP4X) -static void ide_led (uchar led, uchar status); -#else -extern void ide_led (uchar led, uchar status); -#endif -#else -#define ide_led(a,b) /* dummy */ -#endif - #ifdef CONFIG_IDE_RESET static void ide_reset (void); #else @@ -290,6 +277,33 @@ int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) /* ------------------------------------------------------------------------- */ +void __ide_led(uchar led, uchar status) +{ +#if defined(CONFIG_IDE_LED) && defined(PER8_BASE) /* required by LED_PORT */ + static uchar led_buffer; /* Buffer for current LED status */ + + uchar *led_port = LED_PORT; + + if (status) /* switch LED on */ + led_buffer |= led; + else /* switch LED off */ + led_buffer &= ~led; + + *led_port = led_buffer; +#endif +} + +void ide_led(uchar led, uchar status) + __attribute__ ((weak, alias("__ide_led"))); + +#ifndef CONFIG_IDE_LED /* define LED macros, they are not used anyways */ +# define DEVICE_LED(x) 0 +# define LED_IDE1 1 +# define LED_IDE2 2 +#endif + +/* ------------------------------------------------------------------------- */ + inline void __ide_outb(int dev, int port, unsigned char val) { debug("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n", @@ -442,9 +456,7 @@ void ide_init(void) curr_device = -1; for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) { -#ifdef CONFIG_IDE_LED int led = (IDE_BUS(i) == 0) ? LED_IDE1 : LED_IDE2; -#endif ide_dev_desc[i].type = DEV_TYPE_UNKNOWN; ide_dev_desc[i].if_type = IF_TYPE_IDE; ide_dev_desc[i].dev = i; @@ -1146,27 +1158,6 @@ static void ide_reset(void) /* ------------------------------------------------------------------------- */ -#if defined(CONFIG_IDE_LED) && \ - !defined(CONFIG_CPC45) && \ - !defined(CONFIG_KUP4K) && \ - !defined(CONFIG_KUP4X) - -static uchar led_buffer; /* Buffer for current LED status */ - -static void ide_led(uchar led, uchar status) -{ - uchar *led_port = LED_PORT; - - if (status) /* switch LED on */ - led_buffer |= led; - else /* switch LED off */ - led_buffer &= ~led; - - *led_port = led_buffer; -} - -#endif /* CONFIG_IDE_LED */ - #if defined(CONFIG_OF_IDE_FIXUP) int ide_device_present(int dev) {