aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/pending-4.9/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch
diff options
context:
space:
mode:
authorJohn Crispin <john@phrozen.org>2016-12-25 20:11:34 +0100
committerJohn Crispin <john@phrozen.org>2017-08-05 08:46:36 +0200
commit74d00a8c3849c1340efd713eb94b786e304c201f (patch)
treede481743de61c34da96ab5f9dba3af3edcfb8260 /target/linux/generic/pending-4.9/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch
parentde350550ef648d9728351b986b0516fa29465c45 (diff)
downloadupstream-74d00a8c3849c1340efd713eb94b786e304c201f.tar.gz
upstream-74d00a8c3849c1340efd713eb94b786e304c201f.tar.bz2
upstream-74d00a8c3849c1340efd713eb94b786e304c201f.zip
kernel: split patches folder up into backport, pending and hack folders
* properly format/comment all patches * merge debloat patches * merge Kconfig patches * merge swconfig patches * merge hotplug patches * drop 200-fix_localversion.patch - upstream * drop 222-arm_zimage_none.patch - unused * drop 252-mv_cesa_depends.patch - no longer required * drop 410-mtd-move-forward-declaration-of-struct-mtd_info.patch - unused * drop 661-fq_codel_keep_dropped_stats.patch - outdated * drop 702-phy_add_aneg_done_function.patch - upstream * drop 840-rtc7301.patch - unused * drop 841-rtc_pt7c4338.patch - upstream * drop 921-use_preinit_as_init.patch - unused * drop spio-gpio-old and gpio-mmc - unused Signed-off-by: John Crispin <john@phrozen.org>
Diffstat (limited to 'target/linux/generic/pending-4.9/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch')
-rw-r--r--target/linux/generic/pending-4.9/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch73
1 files changed, 73 insertions, 0 deletions
diff --git a/target/linux/generic/pending-4.9/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch b/target/linux/generic/pending-4.9/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch
new file mode 100644
index 0000000000..a8dcad458f
--- /dev/null
+++ b/target/linux/generic/pending-4.9/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch
@@ -0,0 +1,73 @@
+From: Daniel Golle <daniel@makrotopia.org>
+Subject: ubi: auto-attach mtd device named "ubi" or "data" on boot
+
+Signed-off-by: Daniel Golle <daniel@makrotopia.org>
+---
+ drivers/mtd/ubi/build.c | 36 ++++++++++++++++++++++++++++++++++++
+ 1 file changed, 36 insertions(+)
+
+--- a/drivers/mtd/ubi/build.c
++++ b/drivers/mtd/ubi/build.c
+@@ -1212,6 +1212,49 @@ static struct mtd_info * __init open_mtd
+ return mtd;
+ }
+
++/*
++ * This function tries attaching mtd partitions named either "ubi" or "data"
++ * during boot.
++ */
++static void __init ubi_auto_attach(void)
++{
++ int err;
++ struct mtd_info *mtd;
++
++ /* try attaching mtd device named "ubi" or "data" */
++ mtd = open_mtd_device("ubi");
++ if (IS_ERR(mtd))
++ mtd = open_mtd_device("data");
++
++ if (!IS_ERR(mtd)) {
++ size_t len;
++ char magic[4];
++
++ /* check for a valid ubi magic */
++ err = mtd_read(mtd, 0, 4, &len, (void *) magic);
++ if (!err && len == 4 && strncmp(magic, "UBI#", 4)) {
++ pr_err("UBI error: no valid UBI magic found inside mtd%d", mtd->index);
++ put_mtd_device(mtd);
++ return;
++ }
++
++ /* auto-add only media types where UBI makes sense */
++ if (mtd->type == MTD_NANDFLASH ||
++ mtd->type == MTD_NORFLASH ||
++ mtd->type == MTD_DATAFLASH ||
++ mtd->type == MTD_MLCNANDFLASH) {
++ mutex_lock(&ubi_devices_mutex);
++ pr_notice("UBI: auto-attach mtd%d\n", mtd->index);
++ err = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO, 0, 0);
++ mutex_unlock(&ubi_devices_mutex);
++ if (err < 0) {
++ pr_err("UBI error: cannot attach mtd%d", mtd->index);
++ put_mtd_device(mtd);
++ }
++ }
++ }
++}
++
+ static int __init ubi_init(void)
+ {
+ int err, i, k;
+@@ -1295,6 +1338,12 @@ static int __init ubi_init(void)
+ }
+ }
+
++ /* auto-attach mtd devices only if built-in to the kernel and no ubi.mtd
++ * parameter was given */
++ if (IS_ENABLED(CONFIG_MTD_ROOTFS_ROOT_DEV) &&
++ !ubi_is_module() && !mtd_devs)
++ ubi_auto_attach();
++
+ err = ubiblock_init();
+ if (err) {
+ pr_err("UBI error: block: cannot initialize, error %d", err);