[PATCH 4/6] mtd: Introduce SPI NAND framework
Ezequiel Garcia
ezequiel.garcia at imgtec.com
Mon Dec 15 16:08:37 PST 2014
On 12/15/2014 06:18 PM, Daniel Ehrenberg wrote:
> 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?
>
Yes, it looks like I missed that.
Thanks for the feedback,
--
Ezequiel
More information about the linux-mtd
mailing list