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

mtd: kill the nand_ecclayout struct

Now that all MTD drivers have moved to the mtd_ooblayout_ops model we can
safely remove the struct nand_ecclayout definition, and all the remaining
places where it was still used.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>

+7 -144
+6 -6
drivers/mtd/mtdchar.c
··· 465 465 } 466 466 467 467 /* 468 - * Copies (and truncates, if necessary) data from the larger struct, 469 - * nand_ecclayout, to the smaller, deprecated layout struct, 470 - * nand_ecclayout_user. This is necessary only to support the deprecated 471 - * API ioctl ECCGETLAYOUT while allowing all new functionality to use 472 - * nand_ecclayout flexibly (i.e. the struct may change size in new 473 - * releases without requiring major rewrites). 468 + * Copies (and truncates, if necessary) OOB layout information to the 469 + * deprecated layout struct, nand_ecclayout_user. This is necessary only to 470 + * support the deprecated API ioctl ECCGETLAYOUT while allowing all new 471 + * functionality to use mtd_ooblayout_ops flexibly (i.e. mtd_ooblayout_ops 472 + * can describe any kind of OOB layout with almost zero overhead from a 473 + * memory usage point of view). 474 474 */ 475 475 static int shrink_ecclayout(struct mtd_info *mtd, 476 476 struct nand_ecclayout_user *to)
-117
drivers/mtd/mtdcore.c
··· 1376 1376 } 1377 1377 EXPORT_SYMBOL_GPL(mtd_ooblayout_count_eccbytes); 1378 1378 1379 - /** 1380 - * mtd_ecclayout_ecc - Default ooblayout_ecc iterator implementation 1381 - * @mtd: MTD device structure 1382 - * @section: ECC section. Depending on the layout you may have all the ECC 1383 - * bytes stored in a single contiguous section, or one section 1384 - * per ECC chunk (and sometime several sections for a single ECC 1385 - * ECC chunk) 1386 - * @oobecc: OOB region struct filled with the appropriate ECC position 1387 - * information 1388 - * 1389 - * This function is just a wrapper around the mtd->ecclayout field and is 1390 - * here to ease the transition to the mtd_ooblayout_ops approach. 1391 - * All it does is convert the layout->eccpos information into proper oob 1392 - * region definitions. 1393 - * 1394 - * Returns zero on success, a negative error code otherwise. 1395 - */ 1396 - static int mtd_ecclayout_ecc(struct mtd_info *mtd, int section, 1397 - struct mtd_oob_region *oobecc) 1398 - { 1399 - int eccbyte = 0, cursection = 0, length = 0, eccpos = 0; 1400 - 1401 - if (!mtd->ecclayout) 1402 - return -ENOTSUPP; 1403 - 1404 - /* 1405 - * This logic allows us to reuse the ->ecclayout information and 1406 - * expose them as ECC regions (as done for the OOB free regions). 1407 - * 1408 - * TODO: this should be dropped as soon as we get rid of the 1409 - * ->ecclayout field. 1410 - */ 1411 - for (eccbyte = 0; eccbyte < mtd->ecclayout->eccbytes; eccbyte++) { 1412 - eccpos = mtd->ecclayout->eccpos[eccbyte]; 1413 - 1414 - if (eccbyte < mtd->ecclayout->eccbytes - 1) { 1415 - int neccpos = mtd->ecclayout->eccpos[eccbyte + 1]; 1416 - 1417 - if (eccpos + 1 == neccpos) { 1418 - length++; 1419 - continue; 1420 - } 1421 - } 1422 - 1423 - if (section == cursection) 1424 - break; 1425 - 1426 - length = 0; 1427 - cursection++; 1428 - } 1429 - 1430 - if (cursection != section || eccbyte >= mtd->ecclayout->eccbytes) 1431 - return -ERANGE; 1432 - 1433 - oobecc->length = length + 1; 1434 - oobecc->offset = eccpos - length; 1435 - 1436 - return 0; 1437 - } 1438 - 1439 - /** 1440 - * mtd_ecclayout_ecc - Default ooblayout_free iterator implementation 1441 - * @mtd: MTD device structure 1442 - * @section: Free section. Depending on the layout you may have all the free 1443 - * bytes stored in a single contiguous section, or one section 1444 - * per ECC chunk (and sometime several sections for a single ECC 1445 - * ECC chunk) 1446 - * @oobfree: OOB region struct filled with the appropriate free position 1447 - * information 1448 - * 1449 - * This function is just a wrapper around the mtd->ecclayout field and is 1450 - * here to ease the transition to the mtd_ooblayout_ops approach. 1451 - * All it does is convert the layout->oobfree information into proper oob 1452 - * region definitions. 1453 - * 1454 - * Returns zero on success, a negative error code otherwise. 1455 - */ 1456 - static int mtd_ecclayout_free(struct mtd_info *mtd, int section, 1457 - struct mtd_oob_region *oobfree) 1458 - { 1459 - struct nand_ecclayout *layout = mtd->ecclayout; 1460 - 1461 - if (!layout) 1462 - return -ENOTSUPP; 1463 - 1464 - if (section >= MTD_MAX_OOBFREE_ENTRIES_LARGE || 1465 - !layout->oobfree[section].length) 1466 - return -ERANGE; 1467 - 1468 - oobfree->offset = layout->oobfree[section].offset; 1469 - oobfree->length = layout->oobfree[section].length; 1470 - 1471 - return 0; 1472 - } 1473 - 1474 - static const struct mtd_ooblayout_ops mtd_ecclayout_wrapper_ops = { 1475 - .ecc = mtd_ecclayout_ecc, 1476 - .free = mtd_ecclayout_free, 1477 - }; 1478 - 1479 - /** 1480 - * mtd_set_ecclayout - Attach an ecclayout to an MTD device 1481 - * @mtd: MTD device structure 1482 - * @ecclayout: The ecclayout to attach to the device 1483 - * 1484 - * Returns zero on success, a negative error code otherwise. 1485 - */ 1486 - void mtd_set_ecclayout(struct mtd_info *mtd, struct nand_ecclayout *ecclayout) 1487 - { 1488 - if (!mtd || !ecclayout) 1489 - return; 1490 - 1491 - mtd->ecclayout = ecclayout; 1492 - mtd_set_ooblayout(mtd, &mtd_ecclayout_wrapper_ops); 1493 - } 1494 - EXPORT_SYMBOL_GPL(mtd_set_ecclayout); 1495 - 1496 1379 /* 1497 1380 * Method to access the protection register area, present in some flash 1498 1381 * devices. The user data is one time programmable but the factory data is read
-20
include/linux/mtd/mtd.h
··· 96 96 97 97 #define MTD_MAX_OOBFREE_ENTRIES_LARGE 32 98 98 #define MTD_MAX_ECCPOS_ENTRIES_LARGE 640 99 - /* 100 - * Internal ECC layout control structure. For historical reasons, there is a 101 - * similar, smaller struct nand_ecclayout_user (in mtd-abi.h) that is retained 102 - * for export to user-space via the ECCGETLAYOUT ioctl. 103 - * nand_ecclayout should be expandable in the future simply by the above macros. 104 - * 105 - * This structure is now deprecated, you should use struct nand_ecclayout_ops 106 - * to describe your OOB layout. 107 - */ 108 - struct nand_ecclayout { 109 - __u32 eccbytes; 110 - __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES_LARGE]; 111 - struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE]; 112 - }; 113 - 114 99 /** 115 100 * struct mtd_oob_region - oob region definition 116 101 * @offset: region offset ··· 184 199 // Kernel-only stuff starts here. 185 200 const char *name; 186 201 int index; 187 - 188 - /* [Deprecated] ECC layout structure pointer - read only! */ 189 - struct nand_ecclayout *ecclayout; 190 202 191 203 /* OOB layout description */ 192 204 const struct mtd_ooblayout_ops *ooblayout; ··· 289 307 u8 *oobbuf, int start, int nbytes); 290 308 int mtd_ooblayout_count_freebytes(struct mtd_info *mtd); 291 309 int mtd_ooblayout_count_eccbytes(struct mtd_info *mtd); 292 - 293 - void mtd_set_ecclayout(struct mtd_info *mtd, struct nand_ecclayout *ecclayout); 294 310 295 311 static inline void mtd_set_ooblayout(struct mtd_info *mtd, 296 312 const struct mtd_ooblayout_ops *ooblayout)
+1 -1
include/uapi/mtd/mtd-abi.h
··· 228 228 * complete set of ECC information. The ioctl truncates the larger internal 229 229 * structure to retain binary compatibility with the static declaration of the 230 230 * ioctl. Note that the "MTD_MAX_..._ENTRIES" macros represent the max size of 231 - * the user struct, not the MAX size of the internal struct nand_ecclayout. 231 + * the user struct, not the MAX size of the internal OOB layout representation. 232 232 */ 233 233 struct nand_ecclayout_user { 234 234 __u32 eccbytes;