From patchwork Tue Oct 30 17:50:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 195580 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 D651D2C0093 for ; Wed, 31 Oct 2012 04:51:04 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F3A604A393; Tue, 30 Oct 2012 18:51:02 +0100 (CET) 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 xgehzxAfDjUn; Tue, 30 Oct 2012 18:51:02 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 27B4F4A300; Tue, 30 Oct 2012 18:51:01 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 787D34A300 for ; Tue, 30 Oct 2012 18:50:59 +0100 (CET) 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 O5iLo+Tj-t-X for ; Tue, 30 Oct 2012 18:50:57 +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 avon.wwwdotorg.org (avon.wwwdotorg.org [70.85.31.133]) by theia.denx.de (Postfix) with ESMTPS id 7D8224A1FD for ; Tue, 30 Oct 2012 18:50:55 +0100 (CET) Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id 7DABA622F; Tue, 30 Oct 2012 11:51:21 -0600 (MDT) Received: from localhost.localdomain (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id D87A1E40F8; Tue, 30 Oct 2012 11:50:52 -0600 (MDT) From: Stephen Warren To: Tom Rini Date: Tue, 30 Oct 2012 11:50:47 -0600 Message-Id: <1351619447-4767-1-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <508FB481.3020101@gmail.com> References: <508FB481.3020101@gmail.com> X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.96.5 at avon.wwwdotorg.org X-Virus-Status: Clean Cc: Stephen Warren , u-boot@lists.denx.de, Rob Herring Subject: [U-Boot] [PATCH] fs: handle CONFIG_NEEDS_MANUAL_RELOC 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 From: Stephen Warren Without this, fstypes[].probe points at the wrong place, so calling the function results in undefined behaviour. Signed-off-by: Stephen Warren Tested-by: Andreas Bießmann --- Note: I have compile-tested this with the relocation code forcibly enabled, but have no way of actually testing the result. --- fs/fs.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index 23ffa25..e148a07 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -21,6 +21,8 @@ #include #include +DECLARE_GLOBAL_DATA_PTR; + static block_dev_desc_t *fs_dev_desc; static disk_partition_t fs_partition; static int fs_type = FS_TYPE_ANY; @@ -141,7 +143,7 @@ static inline void fs_close_ext(void) #define fs_read_ext fs_read_unsupported #endif -static const struct { +static struct { int fstype; int (*probe)(void); } fstypes[] = { @@ -158,6 +160,15 @@ static const struct { int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype) { int part, i; +#ifdef CONFIG_NEEDS_MANUAL_RELOC + static int relocated; + + if (!relocated) { + for (i = 0; i < ARRAY_SIZE(fstypes); i++) + fstypes[i].probe += gd->reloc_off; + relocated = 1; + } +#endif part = get_device_and_partition(ifname, dev_part_str, &fs_dev_desc, &fs_partition, 1);