Commit cbd87780 authored by Miquel Raynal's avatar Miquel Raynal

mtd: rawnand: Get rid of chip->ecc.priv

nand_ecc_ctrl embeds a private pointer which only has a meaning in the
sunxi driver. This structure will soon be deprecated, but as this
field is actually not needed, let's just drop it.

Cc: Maxime Ripard <mripard@kernel.org>
Cc: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Acked-by: default avatarMaxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/linux-mtd/20200929230124.31491-11-miquel.raynal@bootlin.com
parent 9994bb3f
...@@ -182,6 +182,7 @@ struct sunxi_nand_hw_ecc { ...@@ -182,6 +182,7 @@ struct sunxi_nand_hw_ecc {
* *
* @node: used to store NAND chips into a list * @node: used to store NAND chips into a list
* @nand: base NAND chip structure * @nand: base NAND chip structure
* @ecc: ECC controller structure
* @clk_rate: clk_rate required for this NAND chip * @clk_rate: clk_rate required for this NAND chip
* @timing_cfg: TIMING_CFG register value for this NAND chip * @timing_cfg: TIMING_CFG register value for this NAND chip
* @timing_ctl: TIMING_CTL register value for this NAND chip * @timing_ctl: TIMING_CTL register value for this NAND chip
...@@ -191,6 +192,7 @@ struct sunxi_nand_hw_ecc { ...@@ -191,6 +192,7 @@ struct sunxi_nand_hw_ecc {
struct sunxi_nand_chip { struct sunxi_nand_chip {
struct list_head node; struct list_head node;
struct nand_chip nand; struct nand_chip nand;
struct sunxi_nand_hw_ecc *ecc;
unsigned long clk_rate; unsigned long clk_rate;
u32 timing_cfg; u32 timing_cfg;
u32 timing_ctl; u32 timing_ctl;
...@@ -676,15 +678,15 @@ static void sunxi_nfc_randomizer_read_buf(struct nand_chip *nand, uint8_t *buf, ...@@ -676,15 +678,15 @@ static void sunxi_nfc_randomizer_read_buf(struct nand_chip *nand, uint8_t *buf,
static void sunxi_nfc_hw_ecc_enable(struct nand_chip *nand) static void sunxi_nfc_hw_ecc_enable(struct nand_chip *nand)
{ {
struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand);
struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller);
struct sunxi_nand_hw_ecc *data = nand->ecc.priv;
u32 ecc_ctl; u32 ecc_ctl;
ecc_ctl = readl(nfc->regs + NFC_REG_ECC_CTL); ecc_ctl = readl(nfc->regs + NFC_REG_ECC_CTL);
ecc_ctl &= ~(NFC_ECC_MODE_MSK | NFC_ECC_PIPELINE | ecc_ctl &= ~(NFC_ECC_MODE_MSK | NFC_ECC_PIPELINE |
NFC_ECC_BLOCK_SIZE_MSK); NFC_ECC_BLOCK_SIZE_MSK);
ecc_ctl |= NFC_ECC_EN | NFC_ECC_MODE(data->mode) | NFC_ECC_EXCEPTION | ecc_ctl |= NFC_ECC_EN | NFC_ECC_MODE(sunxi_nand->ecc->mode) |
NFC_ECC_PIPELINE; NFC_ECC_EXCEPTION | NFC_ECC_PIPELINE;
if (nand->ecc.size == 512) if (nand->ecc.size == 512)
ecc_ctl |= NFC_ECC_BLOCK_512; ecc_ctl |= NFC_ECC_BLOCK_512;
...@@ -1597,9 +1599,9 @@ static const struct mtd_ooblayout_ops sunxi_nand_ooblayout_ops = { ...@@ -1597,9 +1599,9 @@ static const struct mtd_ooblayout_ops sunxi_nand_ooblayout_ops = {
.free = sunxi_nand_ooblayout_free, .free = sunxi_nand_ooblayout_free,
}; };
static void sunxi_nand_hw_ecc_ctrl_cleanup(struct nand_ecc_ctrl *ecc) static void sunxi_nand_hw_ecc_ctrl_cleanup(struct sunxi_nand_chip *sunxi_nand)
{ {
kfree(ecc->priv); kfree(sunxi_nand->ecc);
} }
static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,
...@@ -1607,10 +1609,10 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, ...@@ -1607,10 +1609,10 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,
struct device_node *np) struct device_node *np)
{ {
static const u8 strengths[] = { 16, 24, 28, 32, 40, 48, 56, 60, 64 }; static const u8 strengths[] = { 16, 24, 28, 32, 40, 48, 56, 60, 64 };
struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand);
struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller);
struct mtd_info *mtd = nand_to_mtd(nand); struct mtd_info *mtd = nand_to_mtd(nand);
struct nand_device *nanddev = mtd_to_nanddev(mtd); struct nand_device *nanddev = mtd_to_nanddev(mtd);
struct sunxi_nand_hw_ecc *data;
int nsectors; int nsectors;
int ret; int ret;
int i; int i;
...@@ -1647,8 +1649,8 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, ...@@ -1647,8 +1649,8 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,
if (ecc->size != 512 && ecc->size != 1024) if (ecc->size != 512 && ecc->size != 1024)
return -EINVAL; return -EINVAL;
data = kzalloc(sizeof(*data), GFP_KERNEL); sunxi_nand->ecc = kzalloc(sizeof(*sunxi_nand->ecc), GFP_KERNEL);
if (!data) if (!sunxi_nand->ecc)
return -ENOMEM; return -ENOMEM;
/* Prefer 1k ECC chunk over 512 ones */ /* Prefer 1k ECC chunk over 512 ones */
...@@ -1675,7 +1677,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, ...@@ -1675,7 +1677,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,
goto err; goto err;
} }
data->mode = i; sunxi_nand->ecc->mode = i;
/* HW ECC always request ECC bytes for 1024 bytes blocks */ /* HW ECC always request ECC bytes for 1024 bytes blocks */
ecc->bytes = DIV_ROUND_UP(ecc->strength * fls(8 * 1024), 8); ecc->bytes = DIV_ROUND_UP(ecc->strength * fls(8 * 1024), 8);
...@@ -1693,7 +1695,6 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, ...@@ -1693,7 +1695,6 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,
ecc->read_oob = sunxi_nfc_hw_ecc_read_oob; ecc->read_oob = sunxi_nfc_hw_ecc_read_oob;
ecc->write_oob = sunxi_nfc_hw_ecc_write_oob; ecc->write_oob = sunxi_nfc_hw_ecc_write_oob;
mtd_set_ooblayout(mtd, &sunxi_nand_ooblayout_ops); mtd_set_ooblayout(mtd, &sunxi_nand_ooblayout_ops);
ecc->priv = data;
if (nfc->dmac) { if (nfc->dmac) {
ecc->read_page = sunxi_nfc_hw_ecc_read_page_dma; ecc->read_page = sunxi_nfc_hw_ecc_read_page_dma;
...@@ -1714,16 +1715,18 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, ...@@ -1714,16 +1715,18 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,
return 0; return 0;
err: err:
kfree(data); kfree(sunxi_nand->ecc);
return ret; return ret;
} }
static void sunxi_nand_ecc_cleanup(struct nand_ecc_ctrl *ecc) static void sunxi_nand_ecc_cleanup(struct sunxi_nand_chip *sunxi_nand)
{ {
struct nand_ecc_ctrl *ecc = &sunxi_nand->nand.ecc;
switch (ecc->engine_type) { switch (ecc->engine_type) {
case NAND_ECC_ENGINE_TYPE_ON_HOST: case NAND_ECC_ENGINE_TYPE_ON_HOST:
sunxi_nand_hw_ecc_ctrl_cleanup(ecc); sunxi_nand_hw_ecc_ctrl_cleanup(sunxi_nand);
break; break;
case NAND_ECC_ENGINE_TYPE_NONE: case NAND_ECC_ENGINE_TYPE_NONE:
default: default:
...@@ -2053,7 +2056,7 @@ static void sunxi_nand_chips_cleanup(struct sunxi_nfc *nfc) ...@@ -2053,7 +2056,7 @@ static void sunxi_nand_chips_cleanup(struct sunxi_nfc *nfc)
ret = mtd_device_unregister(nand_to_mtd(chip)); ret = mtd_device_unregister(nand_to_mtd(chip));
WARN_ON(ret); WARN_ON(ret);
nand_cleanup(chip); nand_cleanup(chip);
sunxi_nand_ecc_cleanup(&chip->ecc); sunxi_nand_ecc_cleanup(sunxi_nand);
list_del(&sunxi_nand->node); list_del(&sunxi_nand->node);
} }
} }
......
...@@ -302,7 +302,6 @@ static const struct nand_ecc_caps __name = { \ ...@@ -302,7 +302,6 @@ static const struct nand_ecc_caps __name = { \
* @prepad: padding information for syndrome based ECC generators * @prepad: padding information for syndrome based ECC generators
* @postpad: padding information for syndrome based ECC generators * @postpad: padding information for syndrome based ECC generators
* @options: ECC specific options (see NAND_ECC_XXX flags defined above) * @options: ECC specific options (see NAND_ECC_XXX flags defined above)
* @priv: pointer to private ECC control data
* @calc_buf: buffer for calculated ECC, size is oobsize. * @calc_buf: buffer for calculated ECC, size is oobsize.
* @code_buf: buffer for ECC read from flash, size is oobsize. * @code_buf: buffer for ECC read from flash, size is oobsize.
* @hwctl: function to control hardware ECC generator. Must only * @hwctl: function to control hardware ECC generator. Must only
...@@ -355,7 +354,6 @@ struct nand_ecc_ctrl { ...@@ -355,7 +354,6 @@ struct nand_ecc_ctrl {
int prepad; int prepad;
int postpad; int postpad;
unsigned int options; unsigned int options;
void *priv;
u8 *calc_buf; u8 *calc_buf;
u8 *code_buf; u8 *code_buf;
void (*hwctl)(struct nand_chip *chip, int mode); void (*hwctl)(struct nand_chip *chip, int mode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment