Skip to content

Commit aab616e

Browse files
author
Boris Brezillon
committed
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>
1 parent 7f2b092 commit aab616e

4 files changed

Lines changed: 7 additions & 144 deletions

File tree

‎drivers/mtd/mtdchar.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -465,12 +465,12 @@ static int mtdchar_readoob(struct file *file, struct mtd_info *mtd,
465465
}
466466

467467
/*
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).
474474
*/
475475
static int shrink_ecclayout(struct mtd_info *mtd,
476476
struct nand_ecclayout_user *to)

‎drivers/mtd/mtdcore.c‎

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,123 +1376,6 @@ int mtd_ooblayout_count_eccbytes(struct mtd_info *mtd)
13761376
}
13771377
EXPORT_SYMBOL_GPL(mtd_ooblayout_count_eccbytes);
13781378

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-
14961379
/*
14971380
* Method to access the protection register area, present in some flash
14981381
* devices. The user data is one time programmable but the factory data is read

‎include/linux/mtd/mtd.h‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,6 @@ struct mtd_oob_ops {
9696

9797
#define MTD_MAX_OOBFREE_ENTRIES_LARGE 32
9898
#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-
11499
/**
115100
* struct mtd_oob_region - oob region definition
116101
* @offset: region offset
@@ -200,9 +185,6 @@ struct mtd_info {
200185
const char *name;
201186
int index;
202187

203-
/* [Deprecated] ECC layout structure pointer - read only! */
204-
struct nand_ecclayout *ecclayout;
205-
206188
/* OOB layout description */
207189
const struct mtd_ooblayout_ops *ooblayout;
208190

@@ -308,8 +290,6 @@ int mtd_ooblayout_set_databytes(struct mtd_info *mtd, const u8 *databuf,
308290
int mtd_ooblayout_count_freebytes(struct mtd_info *mtd);
309291
int mtd_ooblayout_count_eccbytes(struct mtd_info *mtd);
310292

311-
void mtd_set_ecclayout(struct mtd_info *mtd, struct nand_ecclayout *ecclayout);
312-
313293
static inline void mtd_set_ooblayout(struct mtd_info *mtd,
314294
const struct mtd_ooblayout_ops *ooblayout)
315295
{

‎include/uapi/mtd/mtd-abi.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ struct nand_oobfree {
228228
* complete set of ECC information. The ioctl truncates the larger internal
229229
* structure to retain binary compatibility with the static declaration of the
230230
* 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.
232232
*/
233233
struct nand_ecclayout_user {
234234
__u32 eccbytes;

0 commit comments

Comments
 (0)