26 #include <linux/module.h>
27 #include <linux/types.h>
28 #include <linux/kernel.h>
29 #include <linux/slab.h>
30 #include <linux/string.h>
58 static u32 word_sum(
void *words,
int num)
79 if (ret >= 0 && sz !=
sizeof(
fs))
93 if (
fs.signature != 0xa0ffff9f)
99 if (word_sum(&
fs,
sizeof(
fs) /
sizeof(
u32)) != 0xffffffff)
108 *iis_start =
fs.image_info_base &
mask;
109 *img_start =
fs.image_start &
mask;
115 if (*iis_start >= ptr)
122 if (*img_start > off)
134 memset(iis, 0,
sizeof(*iis));
139 if (sz !=
sizeof(*iis)) {
149 for (i = 0; i <
sizeof(iis->
name); i++)
150 if (iis->
name[i] ==
'\0')
153 if (i <
sizeof(iis->
name))
164 static int parse_afs_partitions(
struct mtd_info *mtd,
177 mask = mtd->
size - 1;
184 for (idx = off = sz = 0; off < mtd->
size; off += mtd->
erasesize) {
186 u_int iis_ptr, img_ptr;
188 ret = afs_read_footer(mtd, &img_ptr, &iis_ptr, off, mask);
194 ret = afs_read_iis(mtd, &iis, iis_ptr);
212 str = (
char *)(parts + idx);
217 for (idx = off = 0; off < mtd->
size; off += mtd->
erasesize) {
219 u_int iis_ptr, img_ptr;
222 ret = afs_read_footer(mtd, &img_ptr, &iis_ptr, off, mask);
229 ret = afs_read_iis(mtd, &iis, iis_ptr);
242 printk(
" mtd%d: at 0x%08x, %5lluKiB, %8u, %s\n",
243 idx, img_ptr, parts[idx].
size / 1024,
256 return idx ? idx :
ret;
261 .parse_fn = parse_afs_partitions,
265 static int __init afs_parser_init(
void)
270 static void __exit afs_parser_exit(
void)