aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2013-05-03 14:55:23 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-07-01 01:32:57 -0400
commit83ff59a066637a6c28844bbf43009459408240f4 (patch)
tree8439e89c624bd6af365d632acaa0015a78cacfa5 /drivers/mtd/ubi
parent584d4623357db8f79029db76ec2b4953418018f0 (diff)
UBI: support ubi_num on mtd.ubi command line
I want to be able to add UBI volumes with specific numbers, but the command line API doesn't have that atm. Add an additional token to support it. Artem: amended the patch a little bit. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r--drivers/mtd/ubi/build.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 8ff08ecb9383..a3503821d0c7 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -47,7 +47,7 @@
47#define MTD_PARAM_LEN_MAX 64 47#define MTD_PARAM_LEN_MAX 64
48 48
49/* Maximum number of comma-separated items in the 'mtd=' parameter */ 49/* Maximum number of comma-separated items in the 'mtd=' parameter */
50#define MTD_PARAM_MAX_COUNT 3 50#define MTD_PARAM_MAX_COUNT 4
51 51
52/* Maximum value for the number of bad PEBs per 1024 PEBs */ 52/* Maximum value for the number of bad PEBs per 1024 PEBs */
53#define MAX_MTD_UBI_BEB_LIMIT 768 53#define MAX_MTD_UBI_BEB_LIMIT 768
@@ -67,6 +67,7 @@
67 */ 67 */
68struct mtd_dev_param { 68struct mtd_dev_param {
69 char name[MTD_PARAM_LEN_MAX]; 69 char name[MTD_PARAM_LEN_MAX];
70 int ubi_num;
70 int vid_hdr_offs; 71 int vid_hdr_offs;
71 int max_beb_per1024; 72 int max_beb_per1024;
72}; 73};
@@ -1269,7 +1270,7 @@ static int __init ubi_init(void)
1269 } 1270 }
1270 1271
1271 mutex_lock(&ubi_devices_mutex); 1272 mutex_lock(&ubi_devices_mutex);
1272 err = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO, 1273 err = ubi_attach_mtd_dev(mtd, p->ubi_num,
1273 p->vid_hdr_offs, p->max_beb_per1024); 1274 p->vid_hdr_offs, p->max_beb_per1024);
1274 mutex_unlock(&ubi_devices_mutex); 1275 mutex_unlock(&ubi_devices_mutex);
1275 if (err < 0) { 1276 if (err < 0) {
@@ -1387,7 +1388,7 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
1387 struct mtd_dev_param *p; 1388 struct mtd_dev_param *p;
1388 char buf[MTD_PARAM_LEN_MAX]; 1389 char buf[MTD_PARAM_LEN_MAX];
1389 char *pbuf = &buf[0]; 1390 char *pbuf = &buf[0];
1390 char *tokens[MTD_PARAM_MAX_COUNT]; 1391 char *tokens[MTD_PARAM_MAX_COUNT], *token;
1391 1392
1392 if (!val) 1393 if (!val)
1393 return -EINVAL; 1394 return -EINVAL;
@@ -1427,37 +1428,53 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
1427 p = &mtd_dev_param[mtd_devs]; 1428 p = &mtd_dev_param[mtd_devs];
1428 strcpy(&p->name[0], tokens[0]); 1429 strcpy(&p->name[0], tokens[0]);
1429 1430
1430 if (tokens[1]) 1431 token = tokens[1];
1431 p->vid_hdr_offs = bytes_str_to_int(tokens[1]); 1432 if (token) {
1433 p->vid_hdr_offs = bytes_str_to_int(token);
1432 1434
1433 if (p->vid_hdr_offs < 0) 1435 if (p->vid_hdr_offs < 0)
1434 return p->vid_hdr_offs; 1436 return p->vid_hdr_offs;
1437 }
1435 1438
1436 if (tokens[2]) { 1439 token = tokens[2];
1437 int err = kstrtoint(tokens[2], 10, &p->max_beb_per1024); 1440 if (token) {
1441 int err = kstrtoint(token, 10, &p->max_beb_per1024);
1438 1442
1439 if (err) { 1443 if (err) {
1440 ubi_err("bad value for max_beb_per1024 parameter: %s", 1444 ubi_err("bad value for max_beb_per1024 parameter: %s",
1441 tokens[2]); 1445 token);
1442 return -EINVAL; 1446 return -EINVAL;
1443 } 1447 }
1444 } 1448 }
1445 1449
1450 token = tokens[3];
1451 if (token) {
1452 int err = kstrtoint(token, 10, &p->ubi_num);
1453
1454 if (err) {
1455 ubi_err("bad value for ubi_num parameter: %s", token);
1456 return -EINVAL;
1457 }
1458 } else
1459 p->ubi_num = UBI_DEV_NUM_AUTO;
1460
1446 mtd_devs += 1; 1461 mtd_devs += 1;
1447 return 0; 1462 return 0;
1448} 1463}
1449 1464
1450module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000); 1465module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000);
1451MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024]].\n" 1466MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024[,ubi_num]]].\n"
1452 "Multiple \"mtd\" parameters may be specified.\n" 1467 "Multiple \"mtd\" parameters may be specified.\n"
1453 "MTD devices may be specified by their number, name, or path to the MTD character device node.\n" 1468 "MTD devices may be specified by their number, name, or path to the MTD character device node.\n"
1454 "Optional \"vid_hdr_offs\" parameter specifies UBI VID header position to be used by UBI. (default value if 0)\n" 1469 "Optional \"vid_hdr_offs\" parameter specifies UBI VID header position to be used by UBI. (default value if 0)\n"
1455 "Optional \"max_beb_per1024\" parameter specifies the maximum expected bad eraseblock per 1024 eraseblocks. (default value (" 1470 "Optional \"max_beb_per1024\" parameter specifies the maximum expected bad eraseblock per 1024 eraseblocks. (default value ("
1456 __stringify(CONFIG_MTD_UBI_BEB_LIMIT) ") if 0)\n" 1471 __stringify(CONFIG_MTD_UBI_BEB_LIMIT) ") if 0)\n"
1472 "Optional \"ubi_num\" parameter specifies UBI device number which have to be assigned to the newly created UBI device (assigned automatically by default)\n"
1457 "\n" 1473 "\n"
1458 "Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n" 1474 "Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n"
1459 "Example 2: mtd=content,1984 mtd=4 - attach MTD device with name \"content\" using VID header offset 1984, and MTD device number 4 with default VID header offset.\n" 1475 "Example 2: mtd=content,1984 mtd=4 - attach MTD device with name \"content\" using VID header offset 1984, and MTD device number 4 with default VID header offset.\n"
1460 "Example 3: mtd=/dev/mtd1,0,25 - attach MTD device /dev/mtd1 using default VID header offset and reserve 25*nand_size_in_blocks/1024 erase blocks for bad block handling.\n" 1476 "Example 3: mtd=/dev/mtd1,0,25 - attach MTD device /dev/mtd1 using default VID header offset and reserve 25*nand_size_in_blocks/1024 erase blocks for bad block handling.\n"
1477 "Example 4: mtd=/dev/mtd1,0,0,5 - attach MTD device /dev/mtd1 to UBI 5 and using default values for the other fields.\n"
1461 "\t(e.g. if the NAND *chipset* has 4096 PEB, 100 will be reserved for this UBI device)."); 1478 "\t(e.g. if the NAND *chipset* has 4096 PEB, 100 will be reserved for this UBI device).");
1462#ifdef CONFIG_MTD_UBI_FASTMAP 1479#ifdef CONFIG_MTD_UBI_FASTMAP
1463module_param(fm_autoconvert, bool, 0644); 1480module_param(fm_autoconvert, bool, 0644);