Commit 2ded0d471912a7d6510899b1858cd9913f12b912

Authored by Simon Glass
Committed by Tom Rini
1 parent c6f548d232

fs: Tell probe functions where to put their results

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>

Showing 1 changed file with 12 additions and 8 deletions Side-by-side Diff

... ... @@ -27,7 +27,8 @@
27 27 static disk_partition_t fs_partition;
28 28 static int fs_type = FS_TYPE_ANY;
29 29  
30   -static inline int fs_probe_unsupported(void)
  30 +static inline int fs_probe_unsupported(block_dev_desc_t *fs_dev_desc,
  31 + disk_partition_t *fs_partition)
31 32 {
32 33 printf("** Unrecognized filesystem type **\n");
33 34 return -1;
34 35  
... ... @@ -49,9 +50,10 @@
49 50 }
50 51  
51 52 #ifdef CONFIG_FS_FAT
52   -static int fs_probe_fat(void)
  53 +static int fs_probe_fat(block_dev_desc_t *fs_dev_desc,
  54 + disk_partition_t *fs_partition)
53 55 {
54   - return fat_set_blk_dev(fs_dev_desc, &fs_partition);
  56 + return fat_set_blk_dev(fs_dev_desc, fs_partition);
55 57 }
56 58  
57 59 static void fs_close_fat(void)
58 60  
59 61  
... ... @@ -88,11 +90,12 @@
88 90 #endif
89 91  
90 92 #ifdef CONFIG_FS_EXT4
91   -static int fs_probe_ext(void)
  93 +static int fs_probe_ext(block_dev_desc_t *fs_dev_desc,
  94 + disk_partition_t *fs_partition)
92 95 {
93   - ext4fs_set_blk_dev(fs_dev_desc, &fs_partition);
  96 + ext4fs_set_blk_dev(fs_dev_desc, fs_partition);
94 97  
95   - if (!ext4fs_mount(fs_partition.size)) {
  98 + if (!ext4fs_mount(fs_partition->size)) {
96 99 ext4fs_close();
97 100 return -1;
98 101 }
... ... @@ -153,7 +156,8 @@
153 156  
154 157 struct fstype_info {
155 158 int fstype;
156   - int (*probe)(void);
  159 + int (*probe)(block_dev_desc_t *fs_dev_desc,
  160 + disk_partition_t *fs_partition);
157 161 int (*ls)(const char *dirname);
158 162 int (*read)(const char *filename, ulong addr, int offset, int len);
159 163 void (*close)(void);
... ... @@ -230,7 +234,7 @@
230 234 fstype != info->fstype)
231 235 continue;
232 236  
233   - if (!info->probe()) {
  237 + if (!info->probe(fs_dev_desc, &fs_partition)) {
234 238 fs_type = info->fstype;
235 239 return 0;
236 240 }