kernel/3.1[02]: move MTD root device setup code to mtdcore
The current code only allows to automatically set root device on MTD partitions. Move the code to MTD core to allow to use it with all MTD devices. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@38643 3c298f89-4303-0410-b956-a3cf2f4a3e73master
parent
0986dff6ec
commit
49c7b92ff6
|
@ -35,16 +35,15 @@
|
|||
depends on m
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -29,6 +29,8 @@
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <linux/kmod.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/partitions.h>
|
||||
+#include <linux/root_dev.h>
|
||||
+#include <linux/magic.h>
|
||||
#include <linux/err.h>
|
||||
|
||||
#include "mtdcore.h"
|
||||
@@ -45,13 +47,14 @@ struct mtd_part {
|
||||
@@ -45,13 +46,14 @@ struct mtd_part {
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
|
@ -60,7 +59,7 @@
|
|||
/*
|
||||
* MTD methods which simply translate the effective address and pass through
|
||||
* to the _real_ device.
|
||||
@@ -533,8 +536,10 @@ out_register:
|
||||
@@ -533,8 +535,10 @@ out_register:
|
||||
return slave;
|
||||
}
|
||||
|
||||
|
@ -73,7 +72,7 @@
|
|||
{
|
||||
struct mtd_partition part;
|
||||
struct mtd_part *p, *new;
|
||||
@@ -566,21 +571,24 @@ int mtd_add_partition(struct mtd_info *m
|
||||
@@ -566,21 +570,24 @@ int mtd_add_partition(struct mtd_info *m
|
||||
end = offset + length;
|
||||
|
||||
mutex_lock(&mtd_partitions_mutex);
|
||||
|
@ -108,7 +107,7 @@
|
|||
|
||||
return ret;
|
||||
err_inv:
|
||||
@@ -590,6 +598,12 @@ err_inv:
|
||||
@@ -590,6 +597,12 @@ err_inv:
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_add_partition);
|
||||
|
||||
|
@ -121,7 +120,7 @@
|
|||
int mtd_del_partition(struct mtd_info *master, int partno)
|
||||
{
|
||||
struct mtd_part *slave, *next;
|
||||
@@ -613,6 +627,151 @@ int mtd_del_partition(struct mtd_info *m
|
||||
@@ -613,6 +626,144 @@ int mtd_del_partition(struct mtd_info *m
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_del_partition);
|
||||
|
||||
|
@ -252,13 +251,6 @@
|
|||
+ if (!strcmp(part->mtd.name, "rootfs")) {
|
||||
+ rootfs_found = 1;
|
||||
+
|
||||
+ if (config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
|
||||
+ ROOT_DEV == 0) {
|
||||
+ printk(KERN_NOTICE "mtd: partition \"rootfs\" "
|
||||
+ "set to be root filesystem\n");
|
||||
+ ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, part->mtd.index);
|
||||
+ }
|
||||
+
|
||||
+ if (config_enabled(CONFIG_MTD_ROOTFS_SPLIT))
|
||||
+ split_rootfs_data(master, part);
|
||||
+ }
|
||||
|
@ -273,7 +265,7 @@
|
|||
/*
|
||||
* This function, given a master MTD object and a partition table, creates
|
||||
* and registers slave MTD objects which are bound to the master according to
|
||||
@@ -642,6 +801,7 @@ int add_mtd_partitions(struct mtd_info *
|
||||
@@ -642,6 +793,7 @@ int add_mtd_partitions(struct mtd_info *
|
||||
mutex_unlock(&mtd_partitions_mutex);
|
||||
|
||||
add_mtd_device(&slave->mtd);
|
||||
|
|
|
@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
|
|||
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -831,6 +831,30 @@ static struct mtd_part_parser *get_parti
|
||||
@@ -823,6 +823,30 @@ static struct mtd_part_parser *get_parti
|
||||
|
||||
#define put_partition_parser(p) do { module_put((p)->owner); } while (0)
|
||||
|
||||
|
@ -42,7 +42,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
|
|||
int register_mtd_parser(struct mtd_part_parser *p)
|
||||
{
|
||||
spin_lock(&part_parser_lock);
|
||||
@@ -907,6 +931,38 @@ int parse_mtd_partitions(struct mtd_info
|
||||
@@ -899,6 +923,38 @@ int parse_mtd_partitions(struct mtd_info
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -627,6 +627,37 @@ int mtd_del_partition(struct mtd_info *m
|
||||
@@ -626,6 +626,37 @@ int mtd_del_partition(struct mtd_info *m
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_del_partition);
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
|||
static inline unsigned long
|
||||
mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
|
||||
{
|
||||
@@ -686,6 +717,10 @@ static void split_rootfs_data(struct mtd
|
||||
@@ -685,6 +716,10 @@ static void split_rootfs_data(struct mtd
|
||||
unsigned int split_size;
|
||||
int ret;
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
|||
ret = split_squashfs(master, part->offset, &split_offset);
|
||||
if (ret)
|
||||
return;
|
||||
@@ -735,6 +770,12 @@ static void split_uimage(struct mtd_info
|
||||
@@ -734,6 +769,12 @@ static void split_uimage(struct mtd_info
|
||||
|
||||
static void split_firmware(struct mtd_info *master, struct mtd_part *part)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -34,6 +34,7 @@
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <linux/err.h>
|
||||
|
||||
#include "mtdcore.h"
|
||||
|
@ -8,7 +8,7 @@
|
|||
|
||||
/* Our partition linked list */
|
||||
static LIST_HEAD(mtd_partitions);
|
||||
@@ -669,43 +670,16 @@ mtd_pad_erasesize(struct mtd_info *mtd,
|
||||
@@ -668,43 +669,16 @@ mtd_pad_erasesize(struct mtd_info *mtd,
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -435,14 +435,12 @@ static struct mtd_part *allocate_partiti
|
||||
@@ -434,14 +434,12 @@ static struct mtd_part *allocate_partiti
|
||||
if (slave->offset == MTDPART_OFS_APPEND)
|
||||
slave->offset = cur_offset;
|
||||
if (slave->offset == MTDPART_OFS_NXTBLK) {
|
||||
|
@ -18,7 +18,7 @@
|
|||
}
|
||||
if (slave->offset == MTDPART_OFS_RETAIN) {
|
||||
slave->offset = cur_offset;
|
||||
@@ -995,6 +993,24 @@ int mtd_is_partition(const struct mtd_in
|
||||
@@ -987,6 +985,24 @@ int mtd_is_partition(const struct mtd_in
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_is_partition);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -36,6 +36,8 @@
|
||||
@@ -35,6 +35,8 @@
|
||||
#include "mtdcore.h"
|
||||
#include "mtdsplit.h"
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
|||
/* Our partition linked list */
|
||||
static LIST_HEAD(mtd_partitions);
|
||||
static DEFINE_MUTEX(mtd_partitions_mutex);
|
||||
@@ -232,13 +234,60 @@ static int part_erase(struct mtd_info *m
|
||||
@@ -231,13 +233,60 @@ static int part_erase(struct mtd_info *m
|
||||
struct mtd_part *part = PART(mtd);
|
||||
int ret;
|
||||
|
||||
|
@ -70,7 +70,7 @@
|
|||
return ret;
|
||||
}
|
||||
|
||||
@@ -246,7 +295,25 @@ void mtd_erase_callback(struct erase_inf
|
||||
@@ -245,7 +294,25 @@ void mtd_erase_callback(struct erase_inf
|
||||
{
|
||||
if (instr->mtd->_erase == part_erase) {
|
||||
struct mtd_part *part = PART(instr->mtd);
|
||||
|
@ -96,7 +96,7 @@
|
|||
if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
|
||||
instr->fail_addr -= part->offset;
|
||||
instr->addr -= part->offset;
|
||||
@@ -504,18 +571,24 @@ static struct mtd_part *allocate_partiti
|
||||
@@ -503,18 +570,24 @@ static struct mtd_part *allocate_partiti
|
||||
if ((slave->mtd.flags & MTD_WRITEABLE) &&
|
||||
mtd_mod_by_eb(slave->offset, &slave->mtd)) {
|
||||
/* Doesn't start on a boundary of major erase size */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -332,7 +332,14 @@ static int part_lock(struct mtd_info *mt
|
||||
@@ -331,7 +331,14 @@ static int part_lock(struct mtd_info *mt
|
||||
static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
|
||||
{
|
||||
struct mtd_part *part = PART(mtd);
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
--- a/drivers/mtd/mtdcore.c
|
||||
+++ b/drivers/mtd/mtdcore.c
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <linux/backing-dev.h>
|
||||
#include <linux/gfp.h>
|
||||
#include <linux/slab.h>
|
||||
+#include <linux/root_dev.h>
|
||||
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/partitions.h>
|
||||
@@ -408,6 +409,15 @@ int add_mtd_device(struct mtd_info *mtd)
|
||||
of this try_ nonsense, and no bitching about it
|
||||
either. :) */
|
||||
__module_get(THIS_MODULE);
|
||||
+
|
||||
+ if (!strcmp(mtd->name, "rootfs") &&
|
||||
+ config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
|
||||
+ ROOT_DEV == 0) {
|
||||
+ pr_notice("mtd: device %d (%s) set to be root filesystem\n",
|
||||
+ mtd->index, mtd->name);
|
||||
+ ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
|
||||
fail_added:
|
|
@ -35,16 +35,15 @@
|
|||
depends on m
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -29,6 +29,8 @@
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <linux/kmod.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/partitions.h>
|
||||
+#include <linux/root_dev.h>
|
||||
+#include <linux/magic.h>
|
||||
#include <linux/err.h>
|
||||
|
||||
#include "mtdcore.h"
|
||||
@@ -45,13 +47,14 @@ struct mtd_part {
|
||||
@@ -45,13 +46,14 @@ struct mtd_part {
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
|
@ -60,7 +59,7 @@
|
|||
/*
|
||||
* MTD methods which simply translate the effective address and pass through
|
||||
* to the _real_ device.
|
||||
@@ -534,8 +537,10 @@ out_register:
|
||||
@@ -534,8 +536,10 @@ out_register:
|
||||
return slave;
|
||||
}
|
||||
|
||||
|
@ -73,7 +72,7 @@
|
|||
{
|
||||
struct mtd_partition part;
|
||||
struct mtd_part *p, *new;
|
||||
@@ -567,21 +572,24 @@ int mtd_add_partition(struct mtd_info *m
|
||||
@@ -567,21 +571,24 @@ int mtd_add_partition(struct mtd_info *m
|
||||
end = offset + length;
|
||||
|
||||
mutex_lock(&mtd_partitions_mutex);
|
||||
|
@ -108,7 +107,7 @@
|
|||
|
||||
return ret;
|
||||
err_inv:
|
||||
@@ -591,6 +599,12 @@ err_inv:
|
||||
@@ -591,6 +598,12 @@ err_inv:
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_add_partition);
|
||||
|
||||
|
@ -121,7 +120,7 @@
|
|||
int mtd_del_partition(struct mtd_info *master, int partno)
|
||||
{
|
||||
struct mtd_part *slave, *next;
|
||||
@@ -614,6 +628,151 @@ int mtd_del_partition(struct mtd_info *m
|
||||
@@ -614,6 +627,144 @@ int mtd_del_partition(struct mtd_info *m
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_del_partition);
|
||||
|
||||
|
@ -252,13 +251,6 @@
|
|||
+ if (!strcmp(part->mtd.name, "rootfs")) {
|
||||
+ rootfs_found = 1;
|
||||
+
|
||||
+ if (config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
|
||||
+ ROOT_DEV == 0) {
|
||||
+ printk(KERN_NOTICE "mtd: partition \"rootfs\" "
|
||||
+ "set to be root filesystem\n");
|
||||
+ ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, part->mtd.index);
|
||||
+ }
|
||||
+
|
||||
+ if (config_enabled(CONFIG_MTD_ROOTFS_SPLIT))
|
||||
+ split_rootfs_data(master, part);
|
||||
+ }
|
||||
|
@ -273,7 +265,7 @@
|
|||
/*
|
||||
* This function, given a master MTD object and a partition table, creates
|
||||
* and registers slave MTD objects which are bound to the master according to
|
||||
@@ -643,6 +802,7 @@ int add_mtd_partitions(struct mtd_info *
|
||||
@@ -643,6 +794,7 @@ int add_mtd_partitions(struct mtd_info *
|
||||
mutex_unlock(&mtd_partitions_mutex);
|
||||
|
||||
add_mtd_device(&slave->mtd);
|
||||
|
|
|
@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
|
|||
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -832,6 +832,30 @@ static struct mtd_part_parser *get_parti
|
||||
@@ -824,6 +824,30 @@ static struct mtd_part_parser *get_parti
|
||||
|
||||
#define put_partition_parser(p) do { module_put((p)->owner); } while (0)
|
||||
|
||||
|
@ -42,7 +42,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
|
|||
int register_mtd_parser(struct mtd_part_parser *p)
|
||||
{
|
||||
spin_lock(&part_parser_lock);
|
||||
@@ -908,6 +932,38 @@ int parse_mtd_partitions(struct mtd_info
|
||||
@@ -900,6 +924,38 @@ int parse_mtd_partitions(struct mtd_info
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -628,6 +628,37 @@ int mtd_del_partition(struct mtd_info *m
|
||||
@@ -627,6 +627,37 @@ int mtd_del_partition(struct mtd_info *m
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_del_partition);
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
|||
static inline unsigned long
|
||||
mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
|
||||
{
|
||||
@@ -687,6 +718,10 @@ static void split_rootfs_data(struct mtd
|
||||
@@ -686,6 +717,10 @@ static void split_rootfs_data(struct mtd
|
||||
unsigned int split_size;
|
||||
int ret;
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
|||
ret = split_squashfs(master, part->offset, &split_offset);
|
||||
if (ret)
|
||||
return;
|
||||
@@ -736,6 +771,12 @@ static void split_uimage(struct mtd_info
|
||||
@@ -735,6 +770,12 @@ static void split_uimage(struct mtd_info
|
||||
|
||||
static void split_firmware(struct mtd_info *master, struct mtd_part *part)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -34,6 +34,7 @@
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <linux/err.h>
|
||||
|
||||
#include "mtdcore.h"
|
||||
|
@ -8,7 +8,7 @@
|
|||
|
||||
/* Our partition linked list */
|
||||
static LIST_HEAD(mtd_partitions);
|
||||
@@ -670,43 +671,16 @@ mtd_pad_erasesize(struct mtd_info *mtd,
|
||||
@@ -669,43 +670,16 @@ mtd_pad_erasesize(struct mtd_info *mtd,
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -435,14 +435,12 @@ static struct mtd_part *allocate_partiti
|
||||
@@ -434,14 +434,12 @@ static struct mtd_part *allocate_partiti
|
||||
if (slave->offset == MTDPART_OFS_APPEND)
|
||||
slave->offset = cur_offset;
|
||||
if (slave->offset == MTDPART_OFS_NXTBLK) {
|
||||
|
@ -18,7 +18,7 @@
|
|||
}
|
||||
if (slave->offset == MTDPART_OFS_RETAIN) {
|
||||
slave->offset = cur_offset;
|
||||
@@ -996,6 +994,24 @@ int mtd_is_partition(const struct mtd_in
|
||||
@@ -988,6 +986,24 @@ int mtd_is_partition(const struct mtd_in
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_is_partition);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -36,6 +36,8 @@
|
||||
@@ -35,6 +35,8 @@
|
||||
#include "mtdcore.h"
|
||||
#include "mtdsplit.h"
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
|||
/* Our partition linked list */
|
||||
static LIST_HEAD(mtd_partitions);
|
||||
static DEFINE_MUTEX(mtd_partitions_mutex);
|
||||
@@ -232,13 +234,60 @@ static int part_erase(struct mtd_info *m
|
||||
@@ -231,13 +233,60 @@ static int part_erase(struct mtd_info *m
|
||||
struct mtd_part *part = PART(mtd);
|
||||
int ret;
|
||||
|
||||
|
@ -70,7 +70,7 @@
|
|||
return ret;
|
||||
}
|
||||
|
||||
@@ -246,7 +295,25 @@ void mtd_erase_callback(struct erase_inf
|
||||
@@ -245,7 +294,25 @@ void mtd_erase_callback(struct erase_inf
|
||||
{
|
||||
if (instr->mtd->_erase == part_erase) {
|
||||
struct mtd_part *part = PART(instr->mtd);
|
||||
|
@ -96,7 +96,7 @@
|
|||
if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN)
|
||||
instr->fail_addr -= part->offset;
|
||||
instr->addr -= part->offset;
|
||||
@@ -504,18 +571,24 @@ static struct mtd_part *allocate_partiti
|
||||
@@ -503,18 +570,24 @@ static struct mtd_part *allocate_partiti
|
||||
if ((slave->mtd.flags & MTD_WRITEABLE) &&
|
||||
mtd_mod_by_eb(slave->offset, &slave->mtd)) {
|
||||
/* Doesn't start on a boundary of major erase size */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -332,7 +332,14 @@ static int part_lock(struct mtd_info *mt
|
||||
@@ -331,7 +331,14 @@ static int part_lock(struct mtd_info *mt
|
||||
static int part_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
|
||||
{
|
||||
struct mtd_part *part = PART(mtd);
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
--- a/drivers/mtd/mtdcore.c
|
||||
+++ b/drivers/mtd/mtdcore.c
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <linux/backing-dev.h>
|
||||
#include <linux/gfp.h>
|
||||
#include <linux/slab.h>
|
||||
+#include <linux/root_dev.h>
|
||||
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/partitions.h>
|
||||
@@ -419,6 +420,15 @@ int add_mtd_device(struct mtd_info *mtd)
|
||||
of this try_ nonsense, and no bitching about it
|
||||
either. :) */
|
||||
__module_get(THIS_MODULE);
|
||||
+
|
||||
+ if (!strcmp(mtd->name, "rootfs") &&
|
||||
+ config_enabled(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
|
||||
+ ROOT_DEV == 0) {
|
||||
+ pr_notice("mtd: device %d (%s) set to be root filesystem\n",
|
||||
+ mtd->index, mtd->name);
|
||||
+ ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, mtd->index);
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
|
||||
fail_added:
|
Loading…
Reference in New Issue