Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'upstream-3.11-rc1' of git://git.infradead.org/linux-ubi

Pull ubi fixes from Artem Bityutskiy:
"A couple of fixes and clean-ups, allow for assigning user-defined UBI
device numbers when attaching MTD devices by using the "mtd=" module
parameter"

* tag 'upstream-3.11-rc1' of git://git.infradead.org/linux-ubi:
UBI: support ubi_num on mtd.ubi command line
UBI: fastmap break out of used PEB search
UBI: document UBI_IOCVOLUP better in user header
UBI: do not abort init when ubi.mtd devices cannot be found
UBI: drop redundant "UBI error" string

+47 -21
+40 -19
drivers/mtd/ubi/build.c
··· 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 }; ··· 1262 1261 mtd = open_mtd_device(p->name); 1263 1262 if (IS_ERR(mtd)) { 1264 1263 err = PTR_ERR(mtd); 1265 - goto out_detach; 1264 + ubi_err("cannot open mtd %s, error %d", p->name, err); 1265 + /* See comment below re-ubi_is_module(). */ 1266 + if (ubi_is_module()) 1267 + goto out_detach; 1268 + continue; 1266 1269 } 1267 1270 1268 1271 mutex_lock(&ubi_devices_mutex); 1269 - err = ubi_attach_mtd_dev(mtd, UBI_DEV_NUM_AUTO, 1272 + err = ubi_attach_mtd_dev(mtd, p->ubi_num, 1270 1273 p->vid_hdr_offs, p->max_beb_per1024); 1271 1274 mutex_unlock(&ubi_devices_mutex); 1272 1275 if (err < 0) { ··· 1314 1309 out_class: 1315 1310 class_destroy(ubi_class); 1316 1311 out: 1317 - ubi_err("UBI error: cannot initialize UBI, error %d", err); 1312 + ubi_err("cannot initialize UBI, error %d", err); 1318 1313 return err; 1319 1314 } 1320 1315 late_initcall(ubi_init); ··· 1351 1346 1352 1347 result = simple_strtoul(str, &endp, 0); 1353 1348 if (str == endp || result >= INT_MAX) { 1354 - ubi_err("UBI error: incorrect bytes count: \"%s\"\n", str); 1349 + ubi_err("incorrect bytes count: \"%s\"\n", str); 1355 1350 return -EINVAL; 1356 1351 } 1357 1352 ··· 1367 1362 case '\0': 1368 1363 break; 1369 1364 default: 1370 - ubi_err("UBI error: incorrect bytes count: \"%s\"\n", str); 1365 + ubi_err("incorrect bytes count: \"%s\"\n", str); 1371 1366 return -EINVAL; 1372 1367 } 1373 1368 ··· 1388 1383 struct mtd_dev_param *p; 1389 1384 char buf[MTD_PARAM_LEN_MAX]; 1390 1385 char *pbuf = &buf[0]; 1391 - char *tokens[MTD_PARAM_MAX_COUNT]; 1386 + char *tokens[MTD_PARAM_MAX_COUNT], *token; 1392 1387 1393 1388 if (!val) 1394 1389 return -EINVAL; 1395 1390 1396 1391 if (mtd_devs == UBI_MAX_DEVICES) { 1397 - ubi_err("UBI error: too many parameters, max. is %d\n", 1392 + ubi_err("too many parameters, max. is %d\n", 1398 1393 UBI_MAX_DEVICES); 1399 1394 return -EINVAL; 1400 1395 } 1401 1396 1402 1397 len = strnlen(val, MTD_PARAM_LEN_MAX); 1403 1398 if (len == MTD_PARAM_LEN_MAX) { 1404 - ubi_err("UBI error: parameter \"%s\" is too long, max. is %d\n", 1399 + ubi_err("parameter \"%s\" is too long, max. is %d\n", 1405 1400 val, MTD_PARAM_LEN_MAX); 1406 1401 return -EINVAL; 1407 1402 } ··· 1421 1416 tokens[i] = strsep(&pbuf, ","); 1422 1417 1423 1418 if (pbuf) { 1424 - ubi_err("UBI error: too many arguments at \"%s\"\n", val); 1419 + ubi_err("too many arguments at \"%s\"\n", val); 1425 1420 return -EINVAL; 1426 1421 } 1427 1422 1428 1423 p = &mtd_dev_param[mtd_devs]; 1429 1424 strcpy(&p->name[0], tokens[0]); 1430 1425 1431 - if (tokens[1]) 1432 - p->vid_hdr_offs = bytes_str_to_int(tokens[1]); 1426 + token = tokens[1]; 1427 + if (token) { 1428 + p->vid_hdr_offs = bytes_str_to_int(token); 1433 1429 1434 - if (p->vid_hdr_offs < 0) 1435 - return p->vid_hdr_offs; 1430 + if (p->vid_hdr_offs < 0) 1431 + return p->vid_hdr_offs; 1432 + } 1436 1433 1437 - if (tokens[2]) { 1438 - int err = kstrtoint(tokens[2], 10, &p->max_beb_per1024); 1434 + token = tokens[2]; 1435 + if (token) { 1436 + int err = kstrtoint(token, 10, &p->max_beb_per1024); 1439 1437 1440 1438 if (err) { 1441 - ubi_err("UBI error: bad value for max_beb_per1024 parameter: %s", 1442 - tokens[2]); 1439 + ubi_err("bad value for max_beb_per1024 parameter: %s", 1440 + token); 1443 1441 return -EINVAL; 1444 1442 } 1445 1443 } 1444 + 1445 + token = tokens[3]; 1446 + if (token) { 1447 + int err = kstrtoint(token, 10, &p->ubi_num); 1448 + 1449 + if (err) { 1450 + ubi_err("bad value for ubi_num parameter: %s", token); 1451 + return -EINVAL; 1452 + } 1453 + } else 1454 + p->ubi_num = UBI_DEV_NUM_AUTO; 1446 1455 1447 1456 mtd_devs += 1; 1448 1457 return 0; 1449 1458 } 1450 1459 1451 1460 module_param_call(mtd, ubi_mtd_param_parse, NULL, NULL, 000); 1452 - MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024]].\n" 1461 + MODULE_PARM_DESC(mtd, "MTD devices to attach. Parameter format: mtd=<name|num|path>[,<vid_hdr_offs>[,max_beb_per1024[,ubi_num]]].\n" 1453 1462 "Multiple \"mtd\" parameters may be specified.\n" 1454 1463 "MTD devices may be specified by their number, name, or path to the MTD character device node.\n" 1455 1464 "Optional \"vid_hdr_offs\" parameter specifies UBI VID header position to be used by UBI. (default value if 0)\n" 1456 1465 "Optional \"max_beb_per1024\" parameter specifies the maximum expected bad eraseblock per 1024 eraseblocks. (default value (" 1457 1466 __stringify(CONFIG_MTD_UBI_BEB_LIMIT) ") if 0)\n" 1467 + "Optional \"ubi_num\" parameter specifies UBI device number which have to be assigned to the newly created UBI device (assigned automatically by default)\n" 1458 1468 "\n" 1459 1469 "Example 1: mtd=/dev/mtd0 - attach MTD device /dev/mtd0.\n" 1460 1470 "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" 1461 1471 "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" 1472 + "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" 1462 1473 "\t(e.g. if the NAND *chipset* has 4096 PEB, 100 will be reserved for this UBI device)."); 1463 1474 #ifdef CONFIG_MTD_UBI_FASTMAP 1464 1475 module_param(fm_autoconvert, bool, 0644);
+3 -1
drivers/mtd/ubi/fastmap.c
··· 727 727 728 728 aeb = NULL; 729 729 list_for_each_entry(tmp_aeb, &used, u.list) { 730 - if (tmp_aeb->pnum == pnum) 730 + if (tmp_aeb->pnum == pnum) { 731 731 aeb = tmp_aeb; 732 + break; 733 + } 732 734 } 733 735 734 736 /* This can happen if a PEB is already in an EBA known
+4 -1
include/uapi/mtd/ubi-user.h
··· 173 173 174 174 #define UBI_VOL_IOC_MAGIC 'O' 175 175 176 - /* Start UBI volume update */ 176 + /* Start UBI volume update 177 + * Note: This actually takes a pointer (__s64*), but we can't change 178 + * that without breaking the ABI on 32bit systems 179 + */ 177 180 #define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, __s64) 178 181 /* LEB erasure command, used for debugging, disabled by default */ 179 182 #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, __s32)