|
47 | 47 | #define MTD_PARAM_LEN_MAX 64
|
48 | 48 |
|
49 | 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 | 52 | /* Maximum value for the number of bad PEBs per 1024 PEBs */
|
53 | 53 | #define MAX_MTD_UBI_BEB_LIMIT 768
|
|
67 | 67 | */
|
68 | 68 | struct mtd_dev_param {
|
69 | 69 | char name[MTD_PARAM_LEN_MAX];
|
| 70 | + int ubi_num; |
70 | 71 | int vid_hdr_offs;
|
71 | 72 | int max_beb_per1024;
|
72 | 73 | };
|
@@ -1269,7 +1270,7 @@ static int __init ubi_init(void)
|
1269 | 1270 | }
|
1270 | 1271 |
|
1271 | 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 | 1274 | p->vid_hdr_offs, p->max_beb_per1024);
|
1274 | 1275 | mutex_unlock(&ubi_devices_mutex);
|
1275 | 1276 | if (err < 0) {
|
@@ -1387,7 +1388,7 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
|
1387 | 1388 | struct mtd_dev_param *p;
|
1388 | 1389 | char buf[MTD_PARAM_LEN_MAX];
|
1389 | 1390 | char *pbuf = &buf[0];
|
1390 |
| - char *tokens[MTD_PARAM_MAX_COUNT]; |
| 1391 | + char *tokens[MTD_PARAM_MAX_COUNT], *token; |
1391 | 1392 |
|
1392 | 1393 | if (!val)
|
1393 | 1394 | return -EINVAL;
|
@@ -1427,37 +1428,53 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
|
1427 | 1428 | p = &mtd_dev_param[mtd_devs];
|
1428 | 1429 | strcpy(&p->name[0], tokens[0]);
|
1429 | 1430 |
|
1430 |
| - if (tokens[1]) |
1431 |
| - p->vid_hdr_offs = bytes_str_to_int(tokens[1]); |
| 1431 | + token = tokens[1]; |
| 1432 | + if (token) { |
| 1433 | + p->vid_hdr_offs = bytes_str_to_int(token); |
1432 | 1434 |
|
1433 |
| - if (p->vid_hdr_offs < 0) |
1434 |
| - return p->vid_hdr_offs; |
| 1435 | + if (p->vid_hdr_offs < 0) |
| 1436 | + return p->vid_hdr_offs; |
| 1437 | + } |
1435 | 1438 |
|
1436 |
| - if (tokens[2]) { |
1437 |
| - int err = kstrtoint(tokens[2], 10, &p->max_beb_per1024); |
| 1439 | + token = tokens[2]; |
| 1440 | + if (token) { |
| 1441 | + int err = kstrtoint(token, 10, &p->max_beb_per1024); |
1438 | 1442 |
|
1439 | 1443 | if (err) {
|
1440 | 1444 | ubi_err("bad value for max_beb_per1024 parameter: %s",
|
1441 |
| - tokens[2]); |
| 1445 | + token); |
1442 | 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 | 1461 | mtd_devs += 1;
|
1447 | 1462 | return 0;
|
1448 | 1463 | }
|
1449 | 1464 |
|
1450 | 1465 | module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000);
|
1451 |
| -MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024]].\n" |
| 1466 | +MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024[,ubi_num]]].\n" |
1452 | 1467 | "Multiple \"mtd\" parameters may be specified.\n"
|
1453 | 1468 | "MTD devices may be specified by their number, name, or path to the MTD character device node.\n"
|
1454 | 1469 | "Optional \"vid_hdr_offs\" parameter specifies UBI VID header position to be used by UBI. (default value if 0)\n"
|
1455 | 1470 | "Optional \"max_beb_per1024\" parameter specifies the maximum expected bad eraseblock per 1024 eraseblocks. (default value ("
|
1456 | 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 | 1473 | "\n"
|
1458 | 1474 | "Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n"
|
1459 | 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 | 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 | 1478 | "\t(e.g. if the NAND *chipset* has 4096 PEB, 100 will be reserved for this UBI device).");
|
1462 | 1479 | #ifdef CONFIG_MTD_UBI_FASTMAP
|
1463 | 1480 | module_param(fm_autoconvert, bool, 0644);
|
|
0 commit comments