diff mbox

[U-Boot] fs: handle CONFIG_NEEDS_MANUAL_RELOC

Message ID 1351619447-4767-1-git-send-email-swarren@wwwdotorg.org
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Stephen Warren Oct. 30, 2012, 5:50 p.m. UTC
From: Stephen Warren <swarren@nvidia.com>

Without this, fstypes[].probe points at the wrong place, so calling the
function results in undefined behaviour.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
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(-)

Comments

Andreas Bießmann Oct. 31, 2012, 9:47 a.m. UTC | #1
Dear Stephen Warren,

On 30.10.2012 18:50, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> Without this, fstypes[].probe points at the wrong place, so calling the
> function results in undefined behaviour.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>

Tested on AVR32 (atstk1002)

Tested-by: Andreas Bießmann <andreas.devel@googlemail.com>

> ---
> Note: I have compile-tested this with the relocation code forcibly
> enabled, but have no way of actually testing the result.
> ---

Best regards

Andreas Bießmann
Tom Rini Nov. 4, 2012, 6:28 p.m. UTC | #2
On Wed, Oct 31, 2012 at 10:47:22AM +0100, Andreas Bie?mann wrote:
> Dear Stephen Warren,
> 
> On 30.10.2012 18:50, Stephen Warren wrote:
> > From: Stephen Warren <swarren@nvidia.com>
> > 
> > Without this, fstypes[].probe points at the wrong place, so calling the
> > function results in undefined behaviour.
> > 
> > Signed-off-by: Stephen Warren <swarren@nvidia.com>
> 
> Tested on AVR32 (atstk1002)
> 
> Tested-by: Andreas Bie?mann <andreas.devel@googlemail.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

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 <fat.h>
 #include <fs.h>
 
+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);