[RFC PATCH v2 1/6] mtd: nand: provide several helpers to do common NAND operations

Boris Brezillon boris.brezillon at free-electrons.com
Wed Nov 8 08:37:53 PST 2017


On Tue,  7 Nov 2017 15:54:14 +0100
Miquel Raynal <miquel.raynal at free-electrons.com> wrote:

> +
> +/**
> + * nand_read_oob_op - Do a READ OOB operation
> + * @chip: The NAND chip
> + * @page: page to read
> + * @offset_in_page: offset within the page

Please rename this parameter ooboffs or something that clarifies the
fact that this offset is relative to the start of the OOB area and not
the start of the page.

> + * @buf: buffer used to store the data
> + * @len: length of the buffer
> + *
> + * This function issues a READ OOB operation.
> + * This function does not select/unselect the CS line.
> + *
> + * Returns 0 for success or negative error code otherwise
> + */
> +int nand_read_oob_op(struct nand_chip *chip, unsigned int page,
> +		     unsigned int offset_in_page, void *buf, unsigned int len)
> +{
> +	struct mtd_info *mtd = nand_to_mtd(chip);
> +
> +	if (len && !buf)
> +		return -EINVAL;
> +
> +	if (offset_in_page + len > mtd->oobsize)
> +		return -EINVAL;
> +
> +	chip->cmdfunc(mtd, NAND_CMD_READOOB, offset_in_page, page);
> +	if (len)
> +		chip->read_buf(mtd, buf, len);
> +
> +	return 0;



More information about the linux-mtd mailing list