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

Configure Feed

Select the types of activity you want to include in your feed.

mtd: rawnand: sunxi: move ECC strenghts in sunxi_nfc_caps

H6/H616 has more ECC strenghts than A10/A23.

Move the ECC strenghts array to sunxi_nfc_caps to make it ready for
H6/H616 support.

No functional change.

Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Richard Genoud <richard.genoud@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

authored by

Richard Genoud and committed by
Miquel Raynal
94dc08ad 1be7ac78

+16 -4
+16 -4
drivers/mtd/nand/raw/sunxi_nand.c
··· 224 224 * through MBUS on A23/A33 needs extra configuration. 225 225 * @reg_io_data: I/O data register 226 226 * @dma_maxburst: DMA maxburst 227 + * @ecc_strengths: Available ECC strengths array 228 + * @nstrengths: Size of @ecc_strengths 227 229 */ 228 230 struct sunxi_nfc_caps { 229 231 bool has_mdma; 230 232 unsigned int reg_io_data; 231 233 unsigned int dma_maxburst; 234 + const u8 *ecc_strengths; 235 + unsigned int nstrengths; 232 236 }; 233 237 234 238 /** ··· 1634 1630 struct nand_ecc_ctrl *ecc, 1635 1631 struct device_node *np) 1636 1632 { 1637 - static const u8 strengths[] = { 16, 24, 28, 32, 40, 48, 56, 60, 64 }; 1638 1633 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); 1639 1634 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); 1635 + const u8 *strengths = nfc->caps->ecc_strengths; 1640 1636 struct mtd_info *mtd = nand_to_mtd(nand); 1641 1637 struct nand_device *nanddev = mtd_to_nanddev(mtd); 1642 1638 int nsectors; ··· 1660 1656 1661 1657 ecc->strength = bytes * 8 / fls(8 * ecc->size); 1662 1658 1663 - for (i = 0; i < ARRAY_SIZE(strengths); i++) { 1659 + for (i = 0; i < nfc->caps->nstrengths; i++) { 1664 1660 if (strengths[i] > ecc->strength) 1665 1661 break; 1666 1662 } ··· 1681 1677 } 1682 1678 1683 1679 /* Add ECC info retrieval from DT */ 1684 - for (i = 0; i < ARRAY_SIZE(strengths); i++) { 1680 + for (i = 0; i < nfc->caps->nstrengths; i++) { 1685 1681 if (ecc->strength <= strengths[i]) { 1686 1682 /* 1687 1683 * Update ecc->strength value with the actual strength ··· 1692 1688 } 1693 1689 } 1694 1690 1695 - if (i >= ARRAY_SIZE(strengths)) { 1691 + if (i >= nfc->caps->nstrengths) { 1696 1692 dev_err(nfc->dev, "unsupported strength\n"); 1697 1693 return -ENOTSUPP; 1698 1694 } ··· 2182 2178 dma_release_channel(nfc->dmac); 2183 2179 } 2184 2180 2181 + static const u8 sunxi_ecc_strengths_a10[] = { 2182 + 16, 24, 28, 32, 40, 48, 56, 60, 64 2183 + }; 2184 + 2185 2185 static const struct sunxi_nfc_caps sunxi_nfc_a10_caps = { 2186 2186 .reg_io_data = NFC_REG_A10_IO_DATA, 2187 2187 .dma_maxburst = 4, 2188 + .ecc_strengths = sunxi_ecc_strengths_a10, 2189 + .nstrengths = ARRAY_SIZE(sunxi_ecc_strengths_a10), 2188 2190 }; 2189 2191 2190 2192 static const struct sunxi_nfc_caps sunxi_nfc_a23_caps = { 2191 2193 .has_mdma = true, 2192 2194 .reg_io_data = NFC_REG_A23_IO_DATA, 2193 2195 .dma_maxburst = 8, 2196 + .ecc_strengths = sunxi_ecc_strengths_a10, 2197 + .nstrengths = ARRAY_SIZE(sunxi_ecc_strengths_a10), 2194 2198 }; 2195 2199 2196 2200 static const struct of_device_id sunxi_nfc_ids[] = {