1 From 9d54c8a33eec78289b1b3f6e10874719c27ce0a7 Mon Sep 17 00:00:00 2001
2 From: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
3 Date: Tue, 25 Feb 2014 13:25:22 -0300
4 Subject: [PATCH] UBI: R/O block driver on top of UBI volumes
6 This commit introduces read-only block device emulation on top of UBI volumes.
8 Given UBI takes care of wear leveling and bad block management it's possible
9 to add a thin layer to enable block device access to UBI volumes.
10 This allows to use a block-oriented filesystem on a flash device.
12 The UBI block devices are meant to be used in conjunction with any
13 regular, block-oriented file system (e.g. ext4), although it's primarily
14 targeted at read-only file systems, such as squashfs.
16 Block devices are created upon user request through new ioctls:
17 UBI_IOCVOLATTBLK to attach and UBI_IOCVOLDETBLK to detach.
18 Also, a new UBI module parameter is added 'ubi.block'. This parameter is
19 needed in order to attach a block device on boot-up time, allowing to
20 mount the rootfs on a ubiblock device.
21 For instance, you could have these kernel parameters:
23 ubi.mtd=5 ubi.block=0,0 root=/dev/ubiblock0_0
25 Or, if you compile ubi as a module:
27 $ modprobe ubi mtd=/dev/mtd5 block=/dev/ubi0_0
29 Artem: amend commentaries and massage the patch a little bit.
31 Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
32 Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
34 drivers/mtd/ubi/Kconfig | 15 +
35 drivers/mtd/ubi/Makefile | 1 +
36 drivers/mtd/ubi/block.c | 646 ++++++++++++++++++++++++++++++++++++++++++++
37 drivers/mtd/ubi/build.c | 11 +
38 drivers/mtd/ubi/cdev.c | 20 ++
39 drivers/mtd/ubi/ubi.h | 14 +
40 include/uapi/mtd/ubi-user.h | 11 +
41 7 files changed, 718 insertions(+)
42 create mode 100644 drivers/mtd/ubi/block.c
44 --- a/drivers/mtd/ubi/Kconfig
45 +++ b/drivers/mtd/ubi/Kconfig
46 @@ -87,4 +87,19 @@ config MTD_UBI_GLUEBI
47 work on top of UBI. Do not enable this unless you use legacy
51 + bool "Read-only block devices on top of UBI volumes"
54 + This option enables read-only UBI block devices support. UBI block
55 + devices will be layered on top of UBI volumes, which means that the
56 + UBI driver will transparently handle things like bad eraseblocks and
57 + bit-flips. You can put any block-oriented file system on top of UBI
58 + volumes in read-only mode (e.g., ext4), but it is probably most
59 + practical for read-only file systems, like squashfs.
61 + When selected, this feature will be built in the UBI driver.
63 + If in doubt, say "N".
66 --- a/drivers/mtd/ubi/Makefile
67 +++ b/drivers/mtd/ubi/Makefile
68 @@ -3,5 +3,6 @@ obj-$(CONFIG_MTD_UBI) += ubi.o
69 ubi-y += vtbl.o vmt.o upd.o build.o cdev.o kapi.o eba.o io.o wl.o attach.o
70 ubi-y += misc.o debug.o
71 ubi-$(CONFIG_MTD_UBI_FASTMAP) += fastmap.o
72 +ubi-$(CONFIG_MTD_UBI_BLOCK) += block.o
74 obj-$(CONFIG_MTD_UBI_GLUEBI) += gluebi.o
76 +++ b/drivers/mtd/ubi/block.c
79 + * Copyright (c) 2014 Ezequiel Garcia
80 + * Copyright (c) 2011 Free Electrons
82 + * Driver parameter handling strongly based on drivers/mtd/ubi/build.c
83 + * Copyright (c) International Business Machines Corp., 2006
84 + * Copyright (c) Nokia Corporation, 2007
85 + * Authors: Artem Bityutskiy, Frank Haverkamp
87 + * This program is free software; you can redistribute it and/or modify
88 + * it under the terms of the GNU General Public License as published by
89 + * the Free Software Foundation, version 2.
91 + * This program is distributed in the hope that it will be useful,
92 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
93 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
94 + * the GNU General Public License for more details.
98 + * Read-only block devices on top of UBI volumes
100 + * A simple implementation to allow a block device to be layered on top of a
101 + * UBI volume. The implementation is provided by creating a static 1-to-1
102 + * mapping between the block device and the UBI volume.
104 + * The addressed byte is obtained from the addressed block sector, which is
105 + * mapped linearly into the corresponding LEB:
107 + * LEB number = addressed byte / LEB size
109 + * This feature is compiled in the UBI core, and adds a new 'block' parameter
110 + * to allow early block device attaching. Runtime block attach/detach for UBI
111 + * volumes is provided through two new UBI ioctls: UBI_IOCVOLATTBLK and
112 + * UBI_IOCVOLDETBLK.
115 +#include <linux/module.h>
116 +#include <linux/init.h>
117 +#include <linux/err.h>
118 +#include <linux/kernel.h>
119 +#include <linux/list.h>
120 +#include <linux/mutex.h>
121 +#include <linux/slab.h>
122 +#include <linux/vmalloc.h>
123 +#include <linux/mtd/ubi.h>
124 +#include <linux/workqueue.h>
125 +#include <linux/blkdev.h>
126 +#include <linux/hdreg.h>
127 +#include <asm/div64.h>
129 +#include "ubi-media.h"
132 +/* Maximum number of supported devices */
133 +#define UBIBLOCK_MAX_DEVICES 32
135 +/* Maximum length of the 'block=' parameter */
136 +#define UBIBLOCK_PARAM_LEN 63
138 +/* Maximum number of comma-separated items in the 'block=' parameter */
139 +#define UBIBLOCK_PARAM_COUNT 2
141 +struct ubiblock_param {
144 + char name[UBIBLOCK_PARAM_LEN+1];
147 +/* Numbers of elements set in the @ubiblock_param array */
148 +static int ubiblock_devs __initdata;
150 +/* MTD devices specification parameters */
151 +static struct ubiblock_param ubiblock_param[UBIBLOCK_MAX_DEVICES] __initdata;
154 + struct ubi_volume_desc *desc;
160 + struct gendisk *gd;
161 + struct request_queue *rq;
163 + struct workqueue_struct *wq;
164 + struct work_struct work;
166 + struct mutex dev_mutex;
167 + spinlock_t queue_lock;
168 + struct list_head list;
171 +/* Linked list of all ubiblock instances */
172 +static LIST_HEAD(ubiblock_devices);
173 +static DEFINE_MUTEX(devices_mutex);
174 +static int ubiblock_major;
176 +static int __init ubiblock_set_param(const char *val,
177 + const struct kernel_param *kp)
181 + struct ubiblock_param *param;
182 + char buf[UBIBLOCK_PARAM_LEN];
183 + char *pbuf = &buf[0];
184 + char *tokens[UBIBLOCK_PARAM_COUNT];
189 + len = strnlen(val, UBIBLOCK_PARAM_LEN);
191 + ubi_warn("block: empty 'block=' parameter - ignored\n");
195 + if (len == UBIBLOCK_PARAM_LEN) {
196 + ubi_err("block: parameter \"%s\" is too long, max. is %d\n",
197 + val, UBIBLOCK_PARAM_LEN);
203 + /* Get rid of the final newline */
204 + if (buf[len - 1] == '\n')
205 + buf[len - 1] = '\0';
207 + for (i = 0; i < UBIBLOCK_PARAM_COUNT; i++)
208 + tokens[i] = strsep(&pbuf, ",");
210 + param = &ubiblock_param[ubiblock_devs];
212 + /* Two parameters: can be 'ubi, vol_id' or 'ubi, vol_name' */
213 + ret = kstrtoint(tokens[0], 10, ¶m->ubi_num);
217 + /* Second param can be a number or a name */
218 + ret = kstrtoint(tokens[1], 10, ¶m->vol_id);
220 + param->vol_id = -1;
221 + strcpy(param->name, tokens[1]);
225 + /* One parameter: must be device path */
226 + strcpy(param->name, tokens[0]);
227 + param->ubi_num = -1;
228 + param->vol_id = -1;
236 +static const struct kernel_param_ops ubiblock_param_ops = {
237 + .set = ubiblock_set_param,
239 +module_param_cb(block, &ubiblock_param_ops, NULL, 0);
240 +MODULE_PARM_DESC(block, "Attach block devices to UBI volumes. Parameter format: block=<path|dev,num|dev,name>.\n"
241 + "Multiple \"block\" parameters may be specified.\n"
242 + "UBI volumes may be specified by their number, name, or path to the device node.\n"
244 + "Using the UBI volume path:\n"
245 + "ubi.block=/dev/ubi0_0\n"
246 + "Using the UBI device, and the volume name:\n"
247 + "ubi.block=0,rootfs\n"
248 + "Using both UBI device number and UBI volume number:\n"
249 + "ubi.block=0,0\n");
251 +static struct ubiblock *find_dev_nolock(int ubi_num, int vol_id)
253 + struct ubiblock *dev;
255 + list_for_each_entry(dev, &ubiblock_devices, list)
256 + if (dev->ubi_num == ubi_num && dev->vol_id == vol_id)
261 +static int ubiblock_read_to_buf(struct ubiblock *dev, char *buffer,
262 + int leb, int offset, int len)
266 + ret = ubi_read(dev->desc, leb, buffer, offset, len);
268 + ubi_err("%s ubi_read error %d",
269 + dev->gd->disk_name, ret);
275 +static int ubiblock_read(struct ubiblock *dev, char *buffer,
276 + sector_t sec, int len)
278 + int ret, leb, offset;
279 + int bytes_left = len;
281 + loff_t pos = sec << 9;
283 + /* Get LEB:offset address to read from */
284 + offset = do_div(pos, dev->leb_size);
287 + while (bytes_left) {
289 + * We can only read one LEB at a time. Therefore if the read
290 + * length is larger than one LEB size, we split the operation.
292 + if (offset + to_read > dev->leb_size)
293 + to_read = dev->leb_size - offset;
295 + ret = ubiblock_read_to_buf(dev, buffer, leb, offset, to_read);
300 + bytes_left -= to_read;
301 + to_read = bytes_left;
308 +static int do_ubiblock_request(struct ubiblock *dev, struct request *req)
313 + if (req->cmd_type != REQ_TYPE_FS)
316 + if (blk_rq_pos(req) + blk_rq_cur_sectors(req) >
317 + get_capacity(req->rq_disk))
320 + if (rq_data_dir(req) != READ)
321 + return -ENOSYS; /* Write not implemented */
323 + sec = blk_rq_pos(req);
324 + len = blk_rq_cur_bytes(req);
327 + * Let's prevent the device from being removed while we're doing I/O
328 + * work. Notice that this means we serialize all the I/O operations,
329 + * but it's probably of no impact given the NAND core serializes
330 + * flash access anyway.
332 + mutex_lock(&dev->dev_mutex);
333 + ret = ubiblock_read(dev, req->buffer, sec, len);
334 + mutex_unlock(&dev->dev_mutex);
339 +static void ubiblock_do_work(struct work_struct *work)
341 + struct ubiblock *dev =
342 + container_of(work, struct ubiblock, work);
343 + struct request_queue *rq = dev->rq;
344 + struct request *req;
347 + spin_lock_irq(rq->queue_lock);
349 + req = blk_fetch_request(rq);
352 + spin_unlock_irq(rq->queue_lock);
353 + res = do_ubiblock_request(dev, req);
354 + spin_lock_irq(rq->queue_lock);
357 + * If we're done with this request,
358 + * we need to fetch a new one
360 + if (!__blk_end_request_cur(req, res))
361 + req = blk_fetch_request(rq);
364 + spin_unlock_irq(rq->queue_lock);
367 +static void ubiblock_request(struct request_queue *rq)
369 + struct ubiblock *dev;
370 + struct request *req;
372 + dev = rq->queuedata;
375 + while ((req = blk_fetch_request(rq)) != NULL)
376 + __blk_end_request_all(req, -ENODEV);
378 + queue_work(dev->wq, &dev->work);
381 +static int ubiblock_open(struct block_device *bdev, fmode_t mode)
383 + struct ubiblock *dev = bdev->bd_disk->private_data;
386 + mutex_lock(&dev->dev_mutex);
387 + if (dev->refcnt > 0) {
389 + * The volume is already open, just increase the reference
396 + * We want users to be aware they should only mount us as read-only.
397 + * It's just a paranoid check, as write requests will get rejected
400 + if (mode & FMODE_WRITE) {
405 + dev->desc = ubi_open_volume(dev->ubi_num, dev->vol_id, UBI_READONLY);
406 + if (IS_ERR(dev->desc)) {
407 + ubi_err("%s failed to open ubi volume %d_%d",
408 + dev->gd->disk_name, dev->ubi_num, dev->vol_id);
409 + ret = PTR_ERR(dev->desc);
416 + mutex_unlock(&dev->dev_mutex);
420 + mutex_unlock(&dev->dev_mutex);
424 +static void ubiblock_release(struct gendisk *gd, fmode_t mode)
426 + struct ubiblock *dev = gd->private_data;
428 + mutex_lock(&dev->dev_mutex);
430 + if (dev->refcnt == 0) {
431 + ubi_close_volume(dev->desc);
434 + mutex_unlock(&dev->dev_mutex);
437 +static int ubiblock_getgeo(struct block_device *bdev, struct hd_geometry *geo)
439 + /* Some tools might require this information */
441 + geo->cylinders = 1;
442 + geo->sectors = get_capacity(bdev->bd_disk);
447 +static const struct block_device_operations ubiblock_ops = {
448 + .owner = THIS_MODULE,
449 + .open = ubiblock_open,
450 + .release = ubiblock_release,
451 + .getgeo = ubiblock_getgeo,
454 +int ubiblock_add(struct ubi_volume_info *vi)
456 + struct ubiblock *dev;
457 + struct gendisk *gd;
461 + /* Check that the volume isn't already handled */
462 + mutex_lock(&devices_mutex);
463 + if (find_dev_nolock(vi->ubi_num, vi->vol_id)) {
464 + mutex_unlock(&devices_mutex);
467 + mutex_unlock(&devices_mutex);
469 + dev = kzalloc(sizeof(struct ubiblock), GFP_KERNEL);
473 + mutex_init(&dev->dev_mutex);
475 + dev->ubi_num = vi->ubi_num;
476 + dev->vol_id = vi->vol_id;
477 + dev->leb_size = vi->usable_leb_size;
479 + /* Initialize the gendisk of this ubiblock device */
480 + gd = alloc_disk(1);
482 + ubi_err("block: alloc_disk failed");
487 + gd->fops = &ubiblock_ops;
488 + gd->major = ubiblock_major;
489 + gd->first_minor = dev->ubi_num * UBI_MAX_VOLUMES + dev->vol_id;
490 + gd->private_data = dev;
491 + sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
492 + disk_capacity = (vi->size * vi->usable_leb_size) >> 9;
493 + set_capacity(gd, disk_capacity);
496 + spin_lock_init(&dev->queue_lock);
497 + dev->rq = blk_init_queue(ubiblock_request, &dev->queue_lock);
499 + ubi_err("block: blk_init_queue failed");
504 + dev->rq->queuedata = dev;
505 + dev->gd->queue = dev->rq;
508 + * Create one workqueue per volume (per registered block device).
509 + * Rembember workqueues are cheap, they're not threads.
511 + dev->wq = alloc_workqueue(gd->disk_name, 0, 0);
513 + goto out_free_queue;
514 + INIT_WORK(&dev->work, ubiblock_do_work);
516 + mutex_lock(&devices_mutex);
517 + list_add_tail(&dev->list, &ubiblock_devices);
518 + mutex_unlock(&devices_mutex);
520 + /* Must be the last step: anyone can call file ops from now on */
522 + ubi_msg("%s created from ubi%d:%d(%s)",
523 + dev->gd->disk_name, dev->ubi_num, dev->vol_id, vi->name);
527 + blk_cleanup_queue(dev->rq);
536 +static void ubiblock_cleanup(struct ubiblock *dev)
538 + del_gendisk(dev->gd);
539 + blk_cleanup_queue(dev->rq);
540 + ubi_msg("%s released", dev->gd->disk_name);
544 +int ubiblock_del(struct ubi_volume_info *vi)
546 + struct ubiblock *dev;
548 + mutex_lock(&devices_mutex);
549 + dev = find_dev_nolock(vi->ubi_num, vi->vol_id);
551 + mutex_unlock(&devices_mutex);
555 + /* Found a device, let's lock it so we can check if it's busy */
556 + mutex_lock(&dev->dev_mutex);
557 + if (dev->refcnt > 0) {
558 + mutex_unlock(&dev->dev_mutex);
559 + mutex_unlock(&devices_mutex);
563 + /* Remove from device list */
564 + list_del(&dev->list);
565 + mutex_unlock(&devices_mutex);
567 + /* Flush pending work and stop this workqueue */
568 + destroy_workqueue(dev->wq);
570 + ubiblock_cleanup(dev);
571 + mutex_unlock(&dev->dev_mutex);
576 +static void ubiblock_resize(struct ubi_volume_info *vi)
578 + struct ubiblock *dev;
582 + * Need to lock the device list until we stop using the device,
583 + * otherwise the device struct might get released in 'ubiblock_del()'.
585 + mutex_lock(&devices_mutex);
586 + dev = find_dev_nolock(vi->ubi_num, vi->vol_id);
588 + mutex_unlock(&devices_mutex);
592 + mutex_lock(&dev->dev_mutex);
593 + disk_capacity = (vi->size * vi->usable_leb_size) >> 9;
594 + set_capacity(dev->gd, disk_capacity);
595 + ubi_msg("%s resized to %d LEBs", dev->gd->disk_name, vi->size);
596 + mutex_unlock(&dev->dev_mutex);
597 + mutex_unlock(&devices_mutex);
600 +static int ubiblock_notify(struct notifier_block *nb,
601 + unsigned long notification_type, void *ns_ptr)
603 + struct ubi_notification *nt = ns_ptr;
605 + switch (notification_type) {
606 + case UBI_VOLUME_ADDED:
608 + * We want to enforce explicit block device attaching for
609 + * volumes, so when a volume is added we do nothing.
612 + case UBI_VOLUME_REMOVED:
613 + ubiblock_del(&nt->vi);
615 + case UBI_VOLUME_RESIZED:
616 + ubiblock_resize(&nt->vi);
624 +static struct notifier_block ubiblock_notifier = {
625 + .notifier_call = ubiblock_notify,
628 +static struct ubi_volume_desc * __init
629 +open_volume_desc(const char *name, int ubi_num, int vol_id)
632 + /* No ubi num, name must be a vol device path */
633 + return ubi_open_volume_path(name, UBI_READONLY);
634 + else if (vol_id == -1)
635 + /* No vol_id, must be vol_name */
636 + return ubi_open_volume_nm(ubi_num, name, UBI_READONLY);
638 + return ubi_open_volume(ubi_num, vol_id, UBI_READONLY);
641 +static int __init ubiblock_attach_from_param(void)
644 + struct ubiblock_param *p;
645 + struct ubi_volume_desc *desc;
646 + struct ubi_volume_info vi;
648 + for (i = 0; i < ubiblock_devs; i++) {
649 + p = &ubiblock_param[i];
651 + desc = open_volume_desc(p->name, p->ubi_num, p->vol_id);
652 + if (IS_ERR(desc)) {
653 + ubi_err("block: can't open volume, err=%ld\n",
655 + ret = PTR_ERR(desc);
659 + ubi_get_volume_info(desc, &vi);
660 + ubi_close_volume(desc);
662 + ret = ubiblock_add(&vi);
664 + ubi_err("block: can't add '%s' volume, err=%d\n",
672 +static void ubiblock_detach_all(void)
674 + struct ubiblock *next;
675 + struct ubiblock *dev;
677 + list_for_each_entry_safe(dev, next, &ubiblock_devices, list) {
678 + /* Flush pending work and stop workqueue */
679 + destroy_workqueue(dev->wq);
680 + /* The module is being forcefully removed */
681 + WARN_ON(dev->desc);
682 + /* Remove from device list */
683 + list_del(&dev->list);
684 + ubiblock_cleanup(dev);
689 +int __init ubiblock_init(void)
693 + ubiblock_major = register_blkdev(0, "ubiblock");
694 + if (ubiblock_major < 0)
695 + return ubiblock_major;
697 + /* Attach block devices from 'block=' module param */
698 + ret = ubiblock_attach_from_param();
703 + * Block devices needs to be attached to volumes explicitly
704 + * upon user request. So we ignore existing volumes.
706 + ret = ubi_register_volume_notifier(&ubiblock_notifier, 1);
712 + unregister_blkdev(ubiblock_major, "ubiblock");
714 + ubiblock_detach_all();
718 +void __exit ubiblock_exit(void)
720 + ubi_unregister_volume_notifier(&ubiblock_notifier);
721 + ubiblock_detach_all();
722 + unregister_blkdev(ubiblock_major, "ubiblock");
724 --- a/drivers/mtd/ubi/build.c
725 +++ b/drivers/mtd/ubi/build.c
726 @@ -1298,6 +1298,15 @@ static int __init ubi_init(void)
730 + err = ubiblock_init();
732 + ubi_err("block: cannot initialize, error %d", err);
734 + /* See comment above re-ubi_is_module(). */
735 + if (ubi_is_module())
742 @@ -1326,6 +1335,8 @@ static void __exit ubi_exit(void)
748 for (i = 0; i < UBI_MAX_DEVICES; i++)
749 if (ubi_devices[i]) {
750 mutex_lock(&ubi_devices_mutex);
751 --- a/drivers/mtd/ubi/cdev.c
752 +++ b/drivers/mtd/ubi/cdev.c
753 @@ -561,6 +561,26 @@ static long vol_cdev_ioctl(struct file *
757 + /* Attach a block device to an UBI volume */
758 + case UBI_IOCVOLATTBLK:
760 + struct ubi_volume_info vi;
762 + ubi_get_volume_info(desc, &vi);
763 + err = ubiblock_add(&vi);
767 + /* Dettach a block device from an UBI volume */
768 + case UBI_IOCVOLDETBLK:
770 + struct ubi_volume_info vi;
772 + ubi_get_volume_info(desc, &vi);
773 + err = ubiblock_del(&vi);
780 --- a/drivers/mtd/ubi/ubi.h
781 +++ b/drivers/mtd/ubi/ubi.h
782 @@ -864,6 +864,20 @@ int ubi_update_fastmap(struct ubi_device
783 int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
787 +#ifdef CONFIG_MTD_UBI_BLOCK
788 +int ubiblock_init(void);
789 +void ubiblock_exit(void);
790 +int ubiblock_add(struct ubi_volume_info *vi);
791 +int ubiblock_del(struct ubi_volume_info *vi);
793 +static inline int ubiblock_init(void) { return 0; }
794 +static inline void ubiblock_exit(void) {}
795 +static inline int ubiblock_add(struct ubi_volume_info *vi) { return -ENOTTY; }
796 +static inline int ubiblock_del(struct ubi_volume_info *vi) { return -ENOTTY; }
801 * ubi_rb_for_each_entry - walk an RB-tree.
802 * @rb: a pointer to type 'struct rb_node' to use as a loop counter
803 --- a/include/uapi/mtd/ubi-user.h
804 +++ b/include/uapi/mtd/ubi-user.h
806 * used. A pointer to a &struct ubi_set_vol_prop_req object is expected to be
807 * passed. The object describes which property should be set, and to which value
810 + * Block devices on UBI volumes
811 + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
813 + * To attach or detach a block device from an UBI volume the %UBI_IOCVOLATTBLK
814 + * and %UBI_IOCVOLDETBLK ioctl commands should be used, respectively.
815 + * These commands take no arguments.
820 /* Set an UBI volume property */
821 #define UBI_IOCSETVOLPROP _IOW(UBI_VOL_IOC_MAGIC, 6, \
822 struct ubi_set_vol_prop_req)
823 +/* Attach a block device to an UBI volume */
824 +#define UBI_IOCVOLATTBLK _IO(UBI_VOL_IOC_MAGIC, 7)
825 +/* Detach a block device from an UBI volume */
826 +#define UBI_IOCVOLDETBLK _IO(UBI_VOL_IOC_MAGIC, 8)
828 /* Maximum MTD device name length supported by UBI */
829 #define MAX_UBI_MTD_NAME_LEN 127