aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files/drivers/mtd
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2016-02-01 12:41:41 +0000
committerRafał Miłecki <zajec5@gmail.com>2016-02-01 12:41:41 +0000
commite1491b341b212000bc26f68b55d9a060b9c48625 (patch)
treecb58aca4643c016200b5a1ab1d3b297e7f226f7f /target/linux/generic/files/drivers/mtd
parent704473864eac18db32ac5a6d96b8eb36c556351b (diff)
downloadupstream-e1491b341b212000bc26f68b55d9a060b9c48625.tar.gz
upstream-e1491b341b212000bc26f68b55d9a060b9c48625.tar.bz2
upstream-e1491b341b212000bc26f68b55d9a060b9c48625.zip
kernel: mtdsplit: modify rootfs helpers to provide partition type
Our mtdsplit parsers may want to create partition with name choice based on partition file system (e.g. SquashFS vs. JFFS2). This patch allows passing extra argument pointing to variable that will be set properly. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> SVN-Revision: 48598
Diffstat (limited to 'target/linux/generic/files/drivers/mtd')
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c22
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h18
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_brnimage.c2
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_eva.c2
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c4
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_lzma.c4
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_seama.c4
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_tplink.c4
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c8
9 files changed, 42 insertions, 26 deletions
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c
index 162739f472..4f6b46e28b 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c
@@ -70,7 +70,8 @@ static ssize_t mtd_next_eb(struct mtd_info *mtd, size_t offset)
return mtd_rounddown_to_eb(offset, mtd) + mtd->erasesize;
}
-int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset)
+int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset,
+ enum mtdsplit_part_type *type)
{
u32 magic;
size_t retlen;
@@ -84,25 +85,32 @@ int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset)
if (retlen != sizeof(magic))
return -EIO;
- if (le32_to_cpu(magic) != SQUASHFS_MAGIC &&
- magic != 0x19852003)
- return -EINVAL;
+ if (le32_to_cpu(magic) == SQUASHFS_MAGIC) {
+ if (type)
+ *type = MTDSPLIT_PART_TYPE_SQUASHFS;
+ return 0;
+ } else if (magic == 0x19852003) {
+ if (type)
+ *type = MTDSPLIT_PART_TYPE_JFFS2;
+ return 0;
+ }
- return 0;
+ return -EINVAL;
}
EXPORT_SYMBOL_GPL(mtd_check_rootfs_magic);
int mtd_find_rootfs_from(struct mtd_info *mtd,
size_t from,
size_t limit,
- size_t *ret_offset)
+ size_t *ret_offset,
+ enum mtdsplit_part_type *type)
{
size_t offset;
int err;
for (offset = from; offset < limit;
offset = mtd_next_eb(mtd, offset)) {
- err = mtd_check_rootfs_magic(mtd, offset);
+ err = mtd_check_rootfs_magic(mtd, offset, type);
if (err)
continue;
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h
index 7ee88b0bb4..b757758685 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h
@@ -18,17 +18,25 @@
#define ROOTFS_SPLIT_NAME "rootfs_data"
+enum mtdsplit_part_type {
+ MTDSPLIT_PART_TYPE_UNK = 0,
+ MTDSPLIT_PART_TYPE_SQUASHFS,
+ MTDSPLIT_PART_TYPE_JFFS2,
+};
+
#ifdef CONFIG_MTD_SPLIT
int mtd_get_squashfs_len(struct mtd_info *master,
size_t offset,
size_t *squashfs_len);
-int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset);
+int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset,
+ enum mtdsplit_part_type *type);
int mtd_find_rootfs_from(struct mtd_info *mtd,
size_t from,
size_t limit,
- size_t *ret_offset);
+ size_t *ret_offset,
+ enum mtdsplit_part_type *type);
#else
static inline int mtd_get_squashfs_len(struct mtd_info *master,
@@ -38,7 +46,8 @@ static inline int mtd_get_squashfs_len(struct mtd_info *master,
return -ENODEV;
}
-static inline int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset)
+static inline int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset,
+ enum mtdsplit_part_type *type)
{
return -EINVAL;
}
@@ -46,7 +55,8 @@ static inline int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset)
static inline int mtd_find_rootfs_from(struct mtd_info *mtd,
size_t from,
size_t limit,
- size_t *ret_offset)
+ size_t *ret_offset,
+ enum mtdsplit_part_type *type)
{
return -ENODEV;
}
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_brnimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_brnimage.c
index 7ddd69b7b7..c0887722d7 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_brnimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_brnimage.c
@@ -38,7 +38,7 @@ static int mtdsplit_parse_brnimage(struct mtd_info *master,
for (rootfs_offset = 0; rootfs_offset < master->size;
rootfs_offset += BRNIMAGE_ALIGN_BYTES) {
- ret = mtd_check_rootfs_magic(master, rootfs_offset);
+ ret = mtd_check_rootfs_magic(master, rootfs_offset, NULL);
if (!ret)
break;
}
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_eva.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_eva.c
index d262e6083e..3edc104f4e 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_eva.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_eva.c
@@ -59,7 +59,7 @@ static int mtdsplit_parse_eva(struct mtd_info *master,
if (rootfs_offset >= master->size)
return -EINVAL;
- err = mtd_check_rootfs_magic(master, rootfs_offset);
+ err = mtd_check_rootfs_magic(master, rootfs_offset, NULL);
if (err)
return err;
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
index d1087f6246..57954061cd 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
@@ -93,8 +93,8 @@ mtdsplit_fit_parse(struct mtd_info *mtd, struct mtd_partition **pparts,
}
/* Search for the rootfs partition after the FIT image */
- ret = mtd_find_rootfs_from(mtd, fit_offset + fit_size,
- mtd->size, &rootfs_offset);
+ ret = mtd_find_rootfs_from(mtd, fit_offset + fit_size, mtd->size,
+ &rootfs_offset, NULL);
if (ret) {
pr_info("no rootfs found after FIT image in \"%s\"\n",
mtd->name);
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_lzma.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_lzma.c
index 64dc7cb31c..f3d8c040c2 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_lzma.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_lzma.c
@@ -58,8 +58,8 @@ static int mtdsplit_parse_lzma(struct mtd_info *master,
if (t)
return -EINVAL;
- err = mtd_find_rootfs_from(master, master->erasesize,
- master->size, &rootfs_offset);
+ err = mtd_find_rootfs_from(master, master->erasesize, master->size,
+ &rootfs_offset, NULL);
if (err)
return err;
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_seama.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_seama.c
index 4ff361c4f2..228b8997ad 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_seama.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_seama.c
@@ -56,7 +56,7 @@ static int mtdsplit_parse_seama(struct mtd_info *master,
return -EINVAL;
/* Check for the rootfs right after Seama entity with a kernel. */
- err = mtd_check_rootfs_magic(master, kernel_ent_size);
+ err = mtd_check_rootfs_magic(master, kernel_ent_size, NULL);
if (!err) {
rootfs_offset = kernel_ent_size;
} else {
@@ -67,7 +67,7 @@ static int mtdsplit_parse_seama(struct mtd_info *master,
* Start the search from an arbitrary offset.
*/
err = mtd_find_rootfs_from(master, SEAMA_MIN_ROOTFS_OFFS,
- master->size, &rootfs_offset);
+ master->size, &rootfs_offset, NULL);
if (err)
return err;
}
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_tplink.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_tplink.c
index 00c2d39a81..c65e60a3e2 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_tplink.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_tplink.c
@@ -122,7 +122,7 @@ static int mtdsplit_parse_tplink(struct mtd_info *master,
return -EINVAL;
/* Find the rootfs after the kernel. */
- err = mtd_check_rootfs_magic(master, kernel_size);
+ err = mtd_check_rootfs_magic(master, kernel_size, NULL);
if (!err) {
rootfs_offset = kernel_size;
} else {
@@ -131,7 +131,7 @@ static int mtdsplit_parse_tplink(struct mtd_info *master,
* Start the search from an arbitrary offset.
*/
err = mtd_find_rootfs_from(master, TPLINK_MIN_ROOTFS_OFFS,
- master->size, &rootfs_offset);
+ master->size, &rootfs_offset, NULL);
if (err)
return err;
}
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
index b815869a6b..c30ee6ad74 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -147,10 +147,8 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
rf_part = 1;
/* find the roots after the uImage */
- ret = mtd_find_rootfs_from(master,
- uimage_offset + uimage_size,
- master->size,
- &rootfs_offset);
+ ret = mtd_find_rootfs_from(master, uimage_offset + uimage_size,
+ master->size, &rootfs_offset, NULL);
if (ret) {
pr_debug("no rootfs after uImage in \"%s\"\n",
master->name);
@@ -164,7 +162,7 @@ static int __mtdsplit_parse_uimage(struct mtd_info *master,
uimage_part = 1;
/* check rootfs presence at offset 0 */
- ret = mtd_check_rootfs_magic(master, 0);
+ ret = mtd_check_rootfs_magic(master, 0, NULL);
if (ret) {
pr_debug("no rootfs before uImage in \"%s\"\n",
master->name);