[U-Boot,04/11] fs: Tell probe functions where to put their results

Submitted by Simon Glass on Dec. 26, 2012, 7:53 p.m.

Details

Message ID 1356551618-8280-5-git-send-email-sjg@chromium.org
State Accepted, archived
Delegated to: Tom Rini
Headers show

Commit Message

Simon Glass Dec. 26, 2012, 7:53 p.m.
Rather than rely on global variables for the probe functions, pass in
the information that we need filled in. This allows us to potentially
keep the variables private to fs.c in the future, and the meaning of
the probe function is clearer.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 fs/fs.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

Comments

Tom Rini March 1, 2013, 5:36 p.m.
On Wed, Dec 26, 2012 at 11:53:31AM -0800, Simon Glass wrote:

> Rather than rely on global variables for the probe functions, pass in
> the information that we need filled in. This allows us to potentially
> keep the variables private to fs.c in the future, and the meaning of
> the probe function is clearer.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@ti.com>

Patch hide | download patch | download mbox

diff --git a/fs/fs.c b/fs/fs.c
index 856d8ba..3561727 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -27,7 +27,8 @@  static block_dev_desc_t *fs_dev_desc;
 static disk_partition_t fs_partition;
 static int fs_type = FS_TYPE_ANY;
 
-static inline int fs_probe_unsupported(void)
+static inline int fs_probe_unsupported(block_dev_desc_t *fs_dev_desc,
+				      disk_partition_t *fs_partition)
 {
 	printf("** Unrecognized filesystem type **\n");
 	return -1;
@@ -49,9 +50,10 @@  static inline void fs_close_unsupported(void)
 }
 
 #ifdef CONFIG_FS_FAT
-static int fs_probe_fat(void)
+static int fs_probe_fat(block_dev_desc_t *fs_dev_desc,
+			disk_partition_t *fs_partition)
 {
-	return fat_set_blk_dev(fs_dev_desc, &fs_partition);
+	return fat_set_blk_dev(fs_dev_desc, fs_partition);
 }
 
 static void fs_close_fat(void)
@@ -88,11 +90,12 @@  static inline void fs_close_fat(void)
 #endif
 
 #ifdef CONFIG_FS_EXT4
-static int fs_probe_ext(void)
+static int fs_probe_ext(block_dev_desc_t *fs_dev_desc,
+			disk_partition_t *fs_partition)
 {
-	ext4fs_set_blk_dev(fs_dev_desc, &fs_partition);
+	ext4fs_set_blk_dev(fs_dev_desc, fs_partition);
 
-	if (!ext4fs_mount(fs_partition.size)) {
+	if (!ext4fs_mount(fs_partition->size)) {
 		ext4fs_close();
 		return -1;
 	}
@@ -153,7 +156,8 @@  static inline void fs_close_ext(void)
 
 struct fstype_info {
 	int fstype;
-	int (*probe)(void);
+	int (*probe)(block_dev_desc_t *fs_dev_desc,
+		     disk_partition_t *fs_partition);
 	int (*ls)(const char *dirname);
 	int (*read)(const char *filename, ulong addr, int offset, int len);
 	void (*close)(void);
@@ -230,7 +234,7 @@  int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype)
 				fstype != info->fstype)
 			continue;
 
-		if (!info->probe()) {
+		if (!info->probe(fs_dev_desc, &fs_partition)) {
 			fs_type = info->fstype;
 			return 0;
 		}