diff options
author | Rob Herring | 2012-08-23 06:31:46 -0500 |
---|---|---|
committer | Tom Rini | 2012-09-25 16:46:55 -0500 |
commit | 81180819b842602f29f325298ee3e522beda3e0a (patch) | |
tree | 14c47ee7042a0e8b28f50c695d8b386f16cf6144 /fs | |
parent | 945010629641b00cca95d1fed4f63009a2b4a113 (diff) | |
download | u-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.c | 32 | ||||
-rw-r--r-- | fs/ext4/ext4_common.h | 1 | ||||
-rw-r--r-- | fs/ext4/ext4fs.c | 1 |
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 | ||
44 | unsigned long part_offset; | ||
45 | |||
43 | static block_dev_desc_t *ext4fs_block_dev_desc; | 46 | static block_dev_desc_t *ext4fs_block_dev_desc; |
44 | static disk_partition_t part_info; | 47 | static disk_partition_t *part_info; |
45 | 48 | ||
46 | int ext4fs_set_blk_dev(block_dev_desc_t *rbdd, int part) | 49 | void 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 | ||
63 | int ext4fs_devread(int sector, int byte_offset, int byte_len, char *buf) | 57 | int 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 | ||
65 | extern unsigned long part_offset; | ||
66 | int ext4fs_read_inode(struct ext2_data *data, int ino, | 65 | int ext4fs_read_inode(struct ext2_data *data, int ino, |
67 | struct ext2_inode *inode); | 66 | struct ext2_inode *inode); |
68 | int ext4fs_read_file(struct ext2fs_node *node, int pos, | 67 | int 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 | ||
45 | int ext4fs_symlinknest; | 45 | int ext4fs_symlinknest; |
46 | block_dev_desc_t *ext4_dev_desc; | ||
47 | struct ext_filesystem ext_fs; | 46 | struct ext_filesystem ext_fs; |
48 | 47 | ||
49 | struct ext_filesystem *get_fs(void) | 48 | struct ext_filesystem *get_fs(void) |