Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: spi-mem: Add an ecc parameter to the spi_mem_op structure

Soon the SPI-NAND core will need a way to request a SPI controller to
enable ECC support for a given operation. This is because of the
pipelined integration of certain ECC engines, which are directly managed
by the SPI controller itself.

Introduce a spi_mem_op additional field for this purpose: ecc.

So far this field is left unset and checked to be false by all
the SPI controller drivers in their ->supports_op() hook, as they all
call spi_mem_default_supports_op().

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Link: https://lore.kernel.org/linux-mtd/20220127091808.1043392-7-miquel.raynal@bootlin.com

+9
+5
drivers/spi/spi-mem.c
··· 178 178 return false; 179 179 } 180 180 181 + if (op->data.ecc) { 182 + if (!spi_mem_controller_is_capable(ctlr, ecc)) 183 + return false; 184 + } 185 + 181 186 return spi_mem_check_buswidth(mem, op); 182 187 } 183 188 EXPORT_SYMBOL_GPL(spi_mem_default_supports_op);
+4
include/linux/spi/spi-mem.h
··· 89 89 * @dummy.dtr: whether the dummy bytes should be sent in DTR mode or not 90 90 * @data.buswidth: number of IO lanes used to send/receive the data 91 91 * @data.dtr: whether the data should be sent in DTR mode or not 92 + * @data.ecc: whether error correction is required or not 92 93 * @data.dir: direction of the transfer 93 94 * @data.nbytes: number of data bytes to send/receive. Can be zero if the 94 95 * operation does not involve transferring data ··· 120 119 struct { 121 120 u8 buswidth; 122 121 u8 dtr : 1; 122 + u8 ecc : 1; 123 123 enum spi_mem_data_dir dir; 124 124 unsigned int nbytes; 125 125 union { ··· 290 288 /** 291 289 * struct spi_controller_mem_caps - SPI memory controller capabilities 292 290 * @dtr: Supports DTR operations 291 + * @ecc: Supports operations with error correction 293 292 */ 294 293 struct spi_controller_mem_caps { 295 294 bool dtr; 295 + bool ecc; 296 296 }; 297 297 298 298 #define spi_mem_controller_is_capable(ctlr, cap) \