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

mtd: spinand: add spinand_read_cfg() helper

Put REG_CFG reading code in spinand_read_cfg().
This function will be needed by the future SPI-NAND resume ops.

Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210602094913.26472-2-patrice.chotard@foss.st.com

authored by

Patrice Chotard and committed by
Miquel Raynal
ff0cd841 ae94c495

+20 -9
+20 -9
drivers/mtd/nand/spi/core.c
··· 138 138 return 0; 139 139 } 140 140 141 - static int spinand_init_cfg_cache(struct spinand_device *spinand) 141 + static int spinand_read_cfg(struct spinand_device *spinand) 142 142 { 143 143 struct nand_device *nand = spinand_to_nand(spinand); 144 - struct device *dev = &spinand->spimem->spi->dev; 145 144 unsigned int target; 146 145 int ret; 147 - 148 - spinand->cfg_cache = devm_kcalloc(dev, 149 - nand->memorg.ntargets, 150 - sizeof(*spinand->cfg_cache), 151 - GFP_KERNEL); 152 - if (!spinand->cfg_cache) 153 - return -ENOMEM; 154 146 155 147 for (target = 0; target < nand->memorg.ntargets; target++) { 156 148 ret = spinand_select_target(spinand, target); ··· 158 166 if (ret) 159 167 return ret; 160 168 } 169 + 170 + return 0; 171 + } 172 + 173 + static int spinand_init_cfg_cache(struct spinand_device *spinand) 174 + { 175 + struct nand_device *nand = spinand_to_nand(spinand); 176 + struct device *dev = &spinand->spimem->spi->dev; 177 + 178 + spinand->cfg_cache = devm_kcalloc(dev, 179 + nand->memorg.ntargets, 180 + sizeof(*spinand->cfg_cache), 181 + GFP_KERNEL); 182 + if (!spinand->cfg_cache) 183 + return -ENOMEM; 161 184 162 185 return 0; 163 186 } ··· 1121 1114 spinand->oobbuf = spinand->databuf + nanddev_page_size(nand); 1122 1115 1123 1116 ret = spinand_init_cfg_cache(spinand); 1117 + if (ret) 1118 + goto err_free_bufs; 1119 + 1120 + ret = spinand_read_cfg(spinand); 1124 1121 if (ret) 1125 1122 goto err_free_bufs; 1126 1123