[PATCH 4/6] mtd: Introduce SPI NAND framework

Daniel Ehrenberg dehrenberg at google.com
Mon Dec 15 13:18:01 PST 2014


On Tue, Dec 2, 2014 at 4:58 AM, Ezequiel Garcia
<ezequiel.garcia at imgtec.com> wrote:
> +static int spi_nand_read_page(struct spi_nand *snand, unsigned int page_addr,
> +                             unsigned int page_offset, size_t length)
> +{
> +       unsigned int corrected = 0, ecc_error = 0;
> +       int ret;
> +
> +       /* Load a page into the cache register */
> +       ret = snand->load_page(snand, page_addr);
> +       if (ret < 0) {
> +               dev_err(snand->dev, "error %d loading page 0x%x to cache\n",
> +                       ret, page_addr);
> +               return ret;
> +       }
> +
> +       ret = spi_nand_wait_till_ready(snand);
> +       if (ret < 0)
> +               return ret;
> +
> +       if (snand->ecc) {
> +               snand->get_ecc_status(ret, &corrected, &ecc_error);
> +               snand->bitflips = corrected;
> +
> +               /*
> +                * If there's an ECC error, print a message and notify MTD
> +                * about it. Then complete the read, to load actual data on
> +                * the buffer (instead of the status result).
> +                */
> +               if (ecc_error) {
> +                       dev_err(snand->dev,
> +                               "internal ECC error reading page 0x%x\n",
> +                               page_addr);
> +                       snand->mtd.ecc_stats.failed++;
> +               }
> +       }
> +
> +       /* Get page from the device cache into our internal buffer */
> +       ret = snand->read_cache(snand, page_offset, length, snand->data_buf);
> +       if (ret < 0) {
> +               dev_err(snand->dev, "error %d reading page 0x%x from cache\n",
> +                       ret, page_addr);
> +               return ret;
> +       }
> +       return 0;
> +}

Should you increment snand->mtd.corrected by corrected in this function?

Dan



More information about the linux-mtd mailing list