[PATCH v6 11/15] nand: spi: add basic operations support

Boris Brezillon boris.brezillon at free-electrons.com
Wed Oct 11 06:35:59 PDT 2017


Hi Peter,

I'm resurrecting this series, and I still have on question on this
patch (probably not my last question ;-)).

On Wed, 24 May 2017 15:07:07 +0800
Peter Pan <peterpandong at micron.com> wrote:



> +/**
> + * spinand_do_write_ops - write data from buffer to device
> + * @mtd: MTD device structure
> + * @to: offset to write to
> + * @ops: oob operations description structure
> + */
> +static int spinand_do_write_ops(struct mtd_info *mtd, loff_t to,
> +				struct mtd_oob_ops *ops)
> +{
> +	struct spinand_device *spinand = mtd_to_spinand(mtd);
> +	struct nand_device *nand = mtd_to_nand(mtd);
> +	int ret = 0;
> +
> +	ret = nand_check_address(nand, to);
> +	if (ret) {
> +		dev_err(spinand->dev, "%s: invalid write address\n", __func__);
> +		return ret;
> +	}
> +
> +	ret = nand_check_oob_ops(nand, to, ops);
> +	if (ret) {
> +		dev_err(spinand->dev,
> +			"%s: invalid oob operation input\n", __func__);
> +		return ret;
> +	}
> +
> +	if (nand_oob_ops_across_page(mtd_to_nand(mtd), ops)) {
> +		dev_err(spinand->dev,
> +			"%s: try to across page when writing with OOB\n",
> +			__func__);
> +		return -EINVAL;
> +	}

Why do you prevent writing more than one OOB region?

> +
> +	mutex_lock(&spinand->lock);
> +	ret = spinand_write_pages(mtd, to, ops);
> +	mutex_unlock(&spinand->lock);
> +
> +	return ret;
> +}



More information about the linux-mtd mailing list