From 04f692f68d87060b27b37e790080e0e11054fedd Mon Sep 17 00:00:00 2001 From: Mike Dunn Date: Sun, 13 May 2012 09:53:27 -0700 Subject: [PATCH] mtd-www: add blurb about API changes and -EUCLEAN to doc/general Here's my attempt at the documentation requested by Artem. There was no discussion of the API, so it seemed like some general info was needed before discussing EUCLEAN. Also mentioned the switch to the API wrappers. Signed-off-by: Mike Dunn Signed-off-by: Artem Bityutskiy --- doc/general.xml | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/doc/general.xml b/doc/general.xml index ea09556..ba76c4f 100644 --- a/doc/general.xml +++ b/doc/general.xml @@ -13,6 +13,7 @@

Table of contents

  1. MTD overview
  2. +
  3. MTD API
  4. MTD tests
  5. The mtdblock driver
  6. Old MTD documentation
  7. @@ -50,7 +51,10 @@ discusses this in more details.

    full information about each MTD device in the system. This interface is easily extensible and developers are encouraged to use the sysfs interface instead of older ioctl or - /proc/mtd interfaces, when possible. + /proc/mtd interfaces, when possible. The sysfs + interface for the mtd subsystem is documentated in the kernel, and + currently can be found at + Documentation/ABI/testing/sysfs-class-mtd.
  8. The /proc/mtd proc file system file provides general MTD information. This is a legacy interface and the sysfs interface @@ -69,6 +73,37 @@ not maintained very much.

    +

    MTD API

    + +

    The MTD subsystem API is defined in include/linux/mtd/mtd.h. +The methods and data structures in this file are used by higher layer kernel +code such as flash file systems to access and control the mtd devices, and also +by device driver authors to interface their device to the mtd subsystem. The +various methods by which a driver provides access to the device are defined +within struct mtd_info. Prior to kernel version 3.4, higher layers +called the driver methods directly by way of a pointer to struct +mtd_info. As of kernel 3.4, these methods are implemented within the mtd +subsystem core code, which then calls the corresponding driver methods. Users +of kernel 3.4 and later should not call the driver methods directly, but instead +use those prototyped in mtd.h outside of struct +mtd_info. These methods include mtd_read(), +mtd_write(), etc.

    + +Absent an error, the API methods will return zero, with one notable exception. +mtd_read() may return -EUCLEAN in some circumstances. +This return code is applicable mainly to NAND flash devices, and is used to +indicate that some bit errors were corrected by the device's ECC facility. +Prior to kernel version 3.4, -EUCLEAN was returned if one or more +bit errors were corrected during the read operation. As of kernel 3.4, the +meaning is more nuanced, and can be broadly interpreted to mean "a dangerously +high number of bit errors were corrected". The -EUCLEAN return +code is intended to help higher layers detect degradation of erase blocks. The +conditions by which mtd_read() returns -EUCLEAN can be +tuned using the bitflip_threshold element of the sysfs interface. +Please see the kernel documentation for the MTD sysfs interface (referenced +above) before adjusting this value. + +

    MTD tests

    The MTD subsystem includes a set of tests which you may run to verify your -- 2.49.0