aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorRob Herring2012-08-23 06:31:46 -0500
committerTom Rini2012-09-25 16:46:55 -0500
commit81180819b842602f29f325298ee3e522beda3e0a (patch)
tree14c47ee7042a0e8b28f50c695d8b386f16cf6144 /fs
parent945010629641b00cca95d1fed4f63009a2b4a113 (diff)
downloadu-boot-81180819b842602f29f325298ee3e522beda3e0a.tar.gz
u-boot-81180819b842602f29f325298ee3e522beda3e0a.tar.xz
u-boot-81180819b842602f29f325298ee3e522beda3e0a.zip
cmd_extX: use common get_device_and_partition function
Convert ext2/4 load, ls, and write functions to use common device and partition parsing function. With the common function "dev:part" can come from the environment and a '-' can be used in that case. Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/dev.c32
-rw-r--r--fs/ext4/ext4_common.h1
-rw-r--r--fs/ext4/ext4fs.c1
3 files changed, 13 insertions, 21 deletions
diff --git a/fs/ext4/dev.c b/fs/ext4/dev.c
index 9e85228eda..1596a92b9a 100644
--- a/fs/ext4/dev.c
+++ b/fs/ext4/dev.c
@@ -38,26 +38,20 @@
38 38
39#include <common.h> 39#include <common.h>
40#include <config.h> 40#include <config.h>
41#include <ext4fs.h>
41#include <ext_common.h> 42#include <ext_common.h>
42 43
44unsigned long part_offset;
45
43static block_dev_desc_t *ext4fs_block_dev_desc; 46static block_dev_desc_t *ext4fs_block_dev_desc;
44static disk_partition_t part_info; 47static disk_partition_t *part_info;
45 48
46int ext4fs_set_blk_dev(block_dev_desc_t *rbdd, int part) 49void ext4fs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info)
47{ 50{
48 ext4fs_block_dev_desc = rbdd; 51 ext4fs_block_dev_desc = rbdd;
49 52 part_info = info;
50 if (part == 0) { 53 part_offset = info->start;
51 /* disk doesn't use partition table */ 54 get_fs()->total_sect = (info->size * info->blksz) / SECTOR_SIZE;
52 part_info.start = 0;
53 part_info.size = rbdd->lba;
54 part_info.blksz = rbdd->blksz;
55 } else {
56 if (get_partition_info(ext4fs_block_dev_desc,
57 part, &part_info))
58 return 0;
59 }
60 return part_info.size;
61} 55}
62 56
63int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf) 57int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf)
@@ -68,7 +62,7 @@ int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf)
68 /* Check partition boundaries */ 62 /* Check partition boundaries */
69 if ((sector < 0) 63 if ((sector < 0)
70 || ((sector + ((byte_offset + byte_len - 1) >> SECTOR_BITS)) >= 64 || ((sector + ((byte_offset + byte_len - 1) >> SECTOR_BITS)) >=
71 part_info.size)) { 65 part_info->size)) {
72 printf("%s read outside partition %d\n", __func__, sector); 66 printf("%s read outside partition %d\n", __func__, sector);
73 return 0; 67 return 0;
74 } 68 }
@@ -88,7 +82,7 @@ int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf)
88 /* read first part which isn't aligned with start of sector */ 82 /* read first part which isn't aligned with start of sector */
89 if (ext4fs_block_dev_desc-> 83 if (ext4fs_block_dev_desc->
90 block_read(ext4fs_block_dev_desc->dev, 84 block_read(ext4fs_block_dev_desc->dev,
91 part_info.start + sector, 1, 85 part_info->start + sector, 1,
92 (unsigned long *) sec_buf) != 1) { 86 (unsigned long *) sec_buf) != 1) {
93 printf(" ** ext2fs_devread() read error **\n"); 87 printf(" ** ext2fs_devread() read error **\n");
94 return 0; 88 return 0;
@@ -111,14 +105,14 @@ int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf)
111 105
112 block_len = SECTOR_SIZE; 106 block_len = SECTOR_SIZE;
113 ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc->dev, 107 ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc->dev,
114 part_info.start + sector, 108 part_info->start + sector,
115 1, (unsigned long *)p); 109 1, (unsigned long *)p);
116 memcpy(buf, p, byte_len); 110 memcpy(buf, p, byte_len);
117 return 1; 111 return 1;
118 } 112 }
119 113
120 if (ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc->dev, 114 if (ext4fs_block_dev_desc->block_read(ext4fs_block_dev_desc->dev,
121 part_info.start + sector, 115 part_info->start + sector,
122 block_len / SECTOR_SIZE, 116 block_len / SECTOR_SIZE,
123 (unsigned long *) buf) != 117 (unsigned long *) buf) !=
124 block_len / SECTOR_SIZE) { 118 block_len / SECTOR_SIZE) {
@@ -134,7 +128,7 @@ int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf)
134 /* read rest of data which are not in whole sector */ 128 /* read rest of data which are not in whole sector */
135 if (ext4fs_block_dev_desc-> 129 if (ext4fs_block_dev_desc->
136 block_read(ext4fs_block_dev_desc->dev, 130 block_read(ext4fs_block_dev_desc->dev,
137 part_info.start + sector, 1, 131 part_info->start + sector, 1,
138 (unsigned long *) sec_buf) != 1) { 132 (unsigned long *) sec_buf) != 1) {
139 printf("* %s read error - last part\n", __func__); 133 printf("* %s read error - last part\n", __func__);
140 return 0; 134 return 0;
diff --git a/fs/ext4/ext4_common.h b/fs/ext4/ext4_common.h
index 0af625db2b..f728134186 100644
--- a/fs/ext4/ext4_common.h
+++ b/fs/ext4/ext4_common.h
@@ -62,7 +62,6 @@ static inline void *zalloc(size_t size)
62 return p; 62 return p;
63} 63}
64 64
65extern unsigned long part_offset;
66int ext4fs_read_inode(struct ext2_data *data, int ino, 65int ext4fs_read_inode(struct ext2_data *data, int ino,
67 struct ext2_inode *inode); 66 struct ext2_inode *inode);
68int ext4fs_read_file(struct ext2fs_node *node, int pos, 67int ext4fs_read_file(struct ext2fs_node *node, int pos,
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index c366e6f099..93dcb7e8fa 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -43,7 +43,6 @@
43#include "ext4_common.h" 43#include "ext4_common.h"
44 44
45int ext4fs_symlinknest; 45int ext4fs_symlinknest;
46block_dev_desc_t *ext4_dev_desc;
47struct ext_filesystem ext_fs; 46struct ext_filesystem ext_fs;
48 47
49struct ext_filesystem *get_fs(void) 48struct ext_filesystem *get_fs(void)