diff options
Diffstat (limited to 'drivers/mtd/mtdcore.c')
-rw-r--r-- | drivers/mtd/mtdcore.c | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index d201feeb3ca6..e4831b4159db 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -298,6 +298,47 @@ static ssize_t mtd_ecc_step_size_show(struct device *dev, | |||
298 | } | 298 | } |
299 | static DEVICE_ATTR(ecc_step_size, S_IRUGO, mtd_ecc_step_size_show, NULL); | 299 | static DEVICE_ATTR(ecc_step_size, S_IRUGO, mtd_ecc_step_size_show, NULL); |
300 | 300 | ||
301 | static ssize_t mtd_ecc_stats_corrected_show(struct device *dev, | ||
302 | struct device_attribute *attr, char *buf) | ||
303 | { | ||
304 | struct mtd_info *mtd = dev_get_drvdata(dev); | ||
305 | struct mtd_ecc_stats *ecc_stats = &mtd->ecc_stats; | ||
306 | |||
307 | return snprintf(buf, PAGE_SIZE, "%u\n", ecc_stats->corrected); | ||
308 | } | ||
309 | static DEVICE_ATTR(corrected_bits, S_IRUGO, | ||
310 | mtd_ecc_stats_corrected_show, NULL); | ||
311 | |||
312 | static ssize_t mtd_ecc_stats_errors_show(struct device *dev, | ||
313 | struct device_attribute *attr, char *buf) | ||
314 | { | ||
315 | struct mtd_info *mtd = dev_get_drvdata(dev); | ||
316 | struct mtd_ecc_stats *ecc_stats = &mtd->ecc_stats; | ||
317 | |||
318 | return snprintf(buf, PAGE_SIZE, "%u\n", ecc_stats->failed); | ||
319 | } | ||
320 | static DEVICE_ATTR(ecc_failures, S_IRUGO, mtd_ecc_stats_errors_show, NULL); | ||
321 | |||
322 | static ssize_t mtd_badblocks_show(struct device *dev, | ||
323 | struct device_attribute *attr, char *buf) | ||
324 | { | ||
325 | struct mtd_info *mtd = dev_get_drvdata(dev); | ||
326 | struct mtd_ecc_stats *ecc_stats = &mtd->ecc_stats; | ||
327 | |||
328 | return snprintf(buf, PAGE_SIZE, "%u\n", ecc_stats->badblocks); | ||
329 | } | ||
330 | static DEVICE_ATTR(bad_blocks, S_IRUGO, mtd_badblocks_show, NULL); | ||
331 | |||
332 | static ssize_t mtd_bbtblocks_show(struct device *dev, | ||
333 | struct device_attribute *attr, char *buf) | ||
334 | { | ||
335 | struct mtd_info *mtd = dev_get_drvdata(dev); | ||
336 | struct mtd_ecc_stats *ecc_stats = &mtd->ecc_stats; | ||
337 | |||
338 | return snprintf(buf, PAGE_SIZE, "%u\n", ecc_stats->bbtblocks); | ||
339 | } | ||
340 | static DEVICE_ATTR(bbt_blocks, S_IRUGO, mtd_bbtblocks_show, NULL); | ||
341 | |||
301 | static struct attribute *mtd_attrs[] = { | 342 | static struct attribute *mtd_attrs[] = { |
302 | &dev_attr_type.attr, | 343 | &dev_attr_type.attr, |
303 | &dev_attr_flags.attr, | 344 | &dev_attr_flags.attr, |
@@ -310,6 +351,10 @@ static struct attribute *mtd_attrs[] = { | |||
310 | &dev_attr_name.attr, | 351 | &dev_attr_name.attr, |
311 | &dev_attr_ecc_strength.attr, | 352 | &dev_attr_ecc_strength.attr, |
312 | &dev_attr_ecc_step_size.attr, | 353 | &dev_attr_ecc_step_size.attr, |
354 | &dev_attr_corrected_bits.attr, | ||
355 | &dev_attr_ecc_failures.attr, | ||
356 | &dev_attr_bad_blocks.attr, | ||
357 | &dev_attr_bbt_blocks.attr, | ||
313 | &dev_attr_bitflip_threshold.attr, | 358 | &dev_attr_bitflip_threshold.attr, |
314 | NULL, | 359 | NULL, |
315 | }; | 360 | }; |
@@ -998,12 +1043,22 @@ int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len) | |||
998 | } | 1043 | } |
999 | EXPORT_SYMBOL_GPL(mtd_is_locked); | 1044 | EXPORT_SYMBOL_GPL(mtd_is_locked); |
1000 | 1045 | ||
1001 | int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs) | 1046 | int mtd_block_isreserved(struct mtd_info *mtd, loff_t ofs) |
1002 | { | 1047 | { |
1003 | if (!mtd->_block_isbad) | 1048 | if (ofs < 0 || ofs > mtd->size) |
1049 | return -EINVAL; | ||
1050 | if (!mtd->_block_isreserved) | ||
1004 | return 0; | 1051 | return 0; |
1052 | return mtd->_block_isreserved(mtd, ofs); | ||
1053 | } | ||
1054 | EXPORT_SYMBOL_GPL(mtd_block_isreserved); | ||
1055 | |||
1056 | int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs) | ||
1057 | { | ||
1005 | if (ofs < 0 || ofs > mtd->size) | 1058 | if (ofs < 0 || ofs > mtd->size) |
1006 | return -EINVAL; | 1059 | return -EINVAL; |
1060 | if (!mtd->_block_isbad) | ||
1061 | return 0; | ||
1007 | return mtd->_block_isbad(mtd, ofs); | 1062 | return mtd->_block_isbad(mtd, ofs); |
1008 | } | 1063 | } |
1009 | EXPORT_SYMBOL_GPL(mtd_block_isbad); | 1064 | EXPORT_SYMBOL_GPL(mtd_block_isbad); |