diff options
author | Boris BREZILLON <boris.brezillon@free-electrons.com> | 2015-12-10 09:00:41 +0100 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2016-01-07 10:23:41 -0800 |
commit | d699ed250c07384840263bbbf69cf7b90b45470c (patch) | |
tree | 954ed7cebade37cdf63b87df7e00d6713545c2c1 /drivers/mtd | |
parent | d9dccc68c5cae4ef7b4a617a93a87b11c6f0c53a (diff) |
mtd: nand: make use of nand_set/get_controller_data() helpers
New helpers have been added to avoid directly accessing chip->field. Use
them where appropriate.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Brian: fixed a few rebase conflicts]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'drivers/mtd')
26 files changed, 260 insertions, 257 deletions
diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c index 1a18938565ac..68b58c85789c 100644 --- a/drivers/mtd/nand/ams-delta.c +++ b/drivers/mtd/nand/ams-delta.c @@ -65,7 +65,7 @@ static struct mtd_partition partition_info[] = { static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) { struct nand_chip *this = mtd_to_nand(mtd); - void __iomem *io_base = this->priv; + void __iomem *io_base = (void __iomem *)nand_get_controller_data(this); writew(0, io_base + OMAP_MPUIO_IO_CNTL); writew(byte, this->IO_ADDR_W); @@ -78,7 +78,7 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd) { u_char res; struct nand_chip *this = mtd_to_nand(mtd); - void __iomem *io_base = this->priv; + void __iomem *io_base = (void __iomem *)nand_get_controller_data(this); gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 0); ndelay(40); @@ -206,7 +206,7 @@ static int ams_delta_init(struct platform_device *pdev) goto out_free; } - this->priv = io_base; + nand_set_controller_data(this, (void *)io_base); /* Set address of NAND IO lines */ this->IO_ADDR_R = io_base + OMAP_MPUIO_INPUT_LATCH; diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index b216bf521349..bddcf83d6859 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c @@ -182,7 +182,7 @@ static void atmel_nand_disable(struct atmel_nand_host *host) static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); if (ctrl & NAND_CTRL_CHANGE) { if (ctrl & NAND_NCE) @@ -205,7 +205,7 @@ static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl static int atmel_nand_device_ready(struct mtd_info *mtd) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); return gpio_get_value(host->board.rdy_pin) ^ !!host->board.rdy_pin_active_low; @@ -215,7 +215,7 @@ static int atmel_nand_device_ready(struct mtd_info *mtd) static int atmel_nand_set_enable_ready_pins(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(chip); int res = 0; if (gpio_is_valid(host->board.rdy_pin)) { @@ -267,7 +267,7 @@ static int atmel_nand_set_enable_ready_pins(struct mtd_info *mtd) static void atmel_read_buf8(struct mtd_info *mtd, u8 *buf, int len) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) { memcpy(buf, host->nfc->data_in_sram, len); @@ -280,7 +280,7 @@ static void atmel_read_buf8(struct mtd_info *mtd, u8 *buf, int len) static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) { memcpy(buf, host->nfc->data_in_sram, len); @@ -354,7 +354,7 @@ static int atmel_nand_dma_op(struct mtd_info *mtd, void *buf, int len, struct dma_async_tx_descriptor *tx = NULL; dma_cookie_t cookie; struct nand_chip *chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(chip); void *p = buf; int err = -EIO; enum dma_data_direction dir = is_read ? DMA_FROM_DEVICE : DMA_TO_DEVICE; @@ -427,7 +427,7 @@ err_buf: static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len) { struct nand_chip *chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(chip); if (use_dma && len > mtd->oobsize) /* only use DMA for bigger than oob size: better performances */ @@ -443,7 +443,7 @@ static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len) static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len) { struct nand_chip *chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(chip); if (use_dma && len > mtd->oobsize) /* only use DMA for bigger than oob size: better performances */ @@ -535,7 +535,7 @@ static int pmecc_data_alloc(struct atmel_nand_host *host) static void pmecc_gen_syndrome(struct mtd_info *mtd, int sector) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); int i; uint32_t value; @@ -552,7 +552,7 @@ static void pmecc_gen_syndrome(struct mtd_info *mtd, int sector) static void pmecc_substitute(struct mtd_info *mtd) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); int16_t __iomem *alpha_to = host->pmecc_alpha_to; int16_t __iomem *index_of = host->pmecc_index_of; int16_t *partial_syn = host->pmecc_partial_syn; @@ -594,7 +594,7 @@ static void pmecc_substitute(struct mtd_info *mtd) static void pmecc_get_sigma(struct mtd_info *mtd) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); int16_t *lmu = host->pmecc_lmu; int16_t *si = host->pmecc_si; @@ -752,7 +752,7 @@ static void pmecc_get_sigma(struct mtd_info *mtd) static int pmecc_err_location(struct mtd_info *mtd) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); unsigned long end_time; const int cap = host->pmecc_corr_cap; const int num = 2 * cap + 1; @@ -804,7 +804,7 @@ static void pmecc_correct_data(struct mtd_info *mtd, uint8_t *buf, uint8_t *ecc, int sector_num, int extra_bytes, int err_nbr) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); int i = 0; int byte_pos, bit_pos, sector_size, pos; uint32_t tmp; @@ -850,7 +850,7 @@ static int pmecc_correction(struct mtd_info *mtd, u32 pmecc_stat, uint8_t *buf, u8 *ecc) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); int i, err_nbr; uint8_t *buf_pos; int max_bitflips = 0; @@ -920,7 +920,7 @@ static void pmecc_enable(struct atmel_nand_host *host, int ecc_op) static int atmel_nand_pmecc_read_page(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { - struct atmel_nand_host *host = chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(chip); int eccsize = chip->ecc.size * chip->ecc.steps; uint8_t *oob = chip->oob_poi; uint32_t *eccpos = chip->ecc.layout->eccpos; @@ -958,7 +958,7 @@ static int atmel_nand_pmecc_write_page(struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf, int oob_required, int page) { - struct atmel_nand_host *host = chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(chip); uint32_t *eccpos = chip->ecc.layout->eccpos; int i, j; unsigned long end_time; @@ -994,7 +994,7 @@ static int atmel_nand_pmecc_write_page(struct mtd_info *mtd, static void atmel_pmecc_core_init(struct mtd_info *mtd) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); uint32_t val = 0; struct nand_ecclayout *ecc_layout; @@ -1310,7 +1310,7 @@ static int atmel_nand_calculate(struct mtd_info *mtd, const u_char *dat, unsigned char *ecc_code) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); unsigned int ecc_value; /* get the first 2 ECC bytes */ @@ -1356,7 +1356,7 @@ static int atmel_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, * Workaround: Reset the parity registers before reading the * actual data. */ - struct atmel_nand_host *host = chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(chip); if (host->board.need_reset_workaround) ecc_writel(host->ecc, CR, ATMEL_ECC_RST); @@ -1414,7 +1414,7 @@ static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *isnull) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); unsigned int ecc_status; unsigned int ecc_word, ecc_bit; @@ -1480,7 +1480,7 @@ static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat, static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); if (host->board.need_reset_workaround) ecc_writel(host->ecc, CR, ATMEL_ECC_RST); @@ -1773,7 +1773,7 @@ static int nfc_device_ready(struct mtd_info *mtd) { u32 status, mask; struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); status = nfc_read_status(host); mask = nfc_readl(host->nfc->hsmc_regs, IMR); @@ -1789,7 +1789,7 @@ static int nfc_device_ready(struct mtd_info *mtd) static void nfc_select_chip(struct mtd_info *mtd, int chip) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = nand_chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(nand_chip); if (chip == -1) nfc_writel(host->nfc->hsmc_regs, CTRL, NFC_CTRL_DISABLE); @@ -1841,7 +1841,7 @@ static void nfc_nand_command(struct mtd_info *mtd, unsigned int command, int column, int page_addr) { struct nand_chip *chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(chip); unsigned long timeout; unsigned int nfc_addr_cmd = 0; @@ -1967,7 +1967,7 @@ static int nfc_sram_write_page(struct mtd_info *mtd, struct nand_chip *chip, { int cfg, len; int status = 0; - struct atmel_nand_host *host = chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(chip); void *sram = host->nfc->sram_bank0 + nfc_get_sram_off(host); /* Subpage write is not supported */ @@ -2028,7 +2028,7 @@ static int nfc_sram_write_page(struct mtd_info *mtd, struct nand_chip *chip, static int nfc_sram_init(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); - struct atmel_nand_host *host = chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(chip); int res = 0; /* Initialize the NFC CFG register */ @@ -2127,7 +2127,8 @@ static int atmel_nand_probe(struct platform_device *pdev) sizeof(struct atmel_nand_data)); } - nand_chip->priv = host; /* link the private data structures */ + /* link the private data structures */ + nand_set_controller_data(nand_chip, host); mtd->dev.parent = &pdev->dev; /* Set address of NAND IO lines */ diff --git a/drivers/mtd/nand/bcm47xxnflash/main.c b/drivers/mtd/nand/bcm47xxnflash/main.c index b44f821b1a3a..fb31429b70a9 100644 --- a/drivers/mtd/nand/bcm47xxnflash/main.c +++ b/drivers/mtd/nand/bcm47xxnflash/main.c @@ -34,7 +34,7 @@ static int bcm47xxnflash_probe(struct platform_device *pdev) if (!b47n) return -ENOMEM; - b47n->nand_chip.priv = b47n; + nand_set_controller_data(&b47n->nand_chip, b47n); mtd = nand_to_mtd(&b47n->nand_chip); mtd->dev.parent = &pdev->dev; b47n->cc = container_of(nflash, struct bcma_drv_cc, nflash); diff --git a/drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c b/drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c index 652478035a7d..f1da4ea88f2c 100644 --- a/drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c +++ b/drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c @@ -90,7 +90,7 @@ static void bcm47xxnflash_ops_bcm4706_read(struct mtd_info *mtd, uint8_t *buf, int len) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; + struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); u32 ctlcode; u32 *dest = (u32 *)buf; @@ -140,7 +140,7 @@ static void bcm47xxnflash_ops_bcm4706_write(struct mtd_info *mtd, const uint8_t *buf, int len) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; + struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); struct bcma_drv_cc *cc = b47n->cc; u32 ctlcode; @@ -174,7 +174,7 @@ static void bcm47xxnflash_ops_bcm4706_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; + struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); u32 code = 0; if (cmd == NAND_CMD_NONE) @@ -200,7 +200,7 @@ static void bcm47xxnflash_ops_bcm4706_select_chip(struct mtd_info *mtd, static int bcm47xxnflash_ops_bcm4706_dev_ready(struct mtd_info *mtd) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; + struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); return !!(bcma_cc_read32(b47n->cc, BCMA_CC_NFLASH_CTL) & NCTL_READY); } @@ -217,7 +217,7 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd, int page_addr) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; + struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); struct bcma_drv_cc *cc = b47n->cc; u32 ctlcode; int i; @@ -313,7 +313,7 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd, static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct mtd_info *mtd) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; + struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); struct bcma_drv_cc *cc = b47n->cc; u32 tmp = 0; @@ -342,7 +342,7 @@ static void bcm47xxnflash_ops_bcm4706_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; + struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); switch (b47n->curr_command) { case NAND_CMD_READ0: @@ -358,7 +358,7 @@ static void bcm47xxnflash_ops_bcm4706_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) { struct nand_chip *nand_chip = mtd_to_nand(mtd); - struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; + struct bcm47xxnflash *b47n = nand_get_controller_data(nand_chip); switch (b47n->curr_command) { case NAND_CMD_SEQIN: diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c index 89d9414c5593..7f6b30e615b7 100644 --- a/drivers/mtd/nand/bf5xx_nand.c +++ b/drivers/mtd/nand/bf5xx_nand.c @@ -781,7 +781,7 @@ static int bf5xx_nand_probe(struct platform_device *pdev) chip->cmd_ctrl = bf5xx_nand_hwcontrol; chip->dev_ready = bf5xx_nand_devready; - chip->priv = mtd; + nand_set_controller_data(chip, mtd); chip->controller = &info->controller; chip->IO_ADDR_R = (void __iomem *) NFC_READ; diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c b/drivers/mtd/nand/brcmnand/brcmnand.c index aea08816d3ac..844fc07d22cd 100644 --- a/drivers/mtd/nand/brcmnand/brcmnand.c +++ b/drivers/mtd/nand/brcmnand/brcmnand.c @@ -877,7 +877,7 @@ static struct nand_ecclayout *brcmstb_choose_ecc_layout( static void brcmnand_wp(struct mtd_info *mtd, int wp) { struct nand_chip *chip = mtd_to_nand(mtd); - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_controller *ctrl = host->ctrl; if ((ctrl->features & BRCMNAND_HAS_WP) && wp_on == 1) { @@ -1043,7 +1043,7 @@ static void brcmnand_cmd_ctrl(struct mtd_info *mtd, int dat, static int brcmnand_waitfunc(struct mtd_info *mtd, struct nand_chip *this) { struct nand_chip *chip = mtd_to_nand(mtd); - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_controller *ctrl = host->ctrl; unsigned long timeo = msecs_to_jiffies(100); @@ -1117,7 +1117,7 @@ static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command, int column, int page_addr) { struct nand_chip *chip = mtd_to_nand(mtd); - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_controller *ctrl = host->ctrl; u64 addr = (u64)page_addr << chip->page_shift; int native_cmd = 0; @@ -1223,7 +1223,7 @@ static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command, static uint8_t brcmnand_read_byte(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_controller *ctrl = host->ctrl; uint8_t ret = 0; int addr, offs; @@ -1290,7 +1290,7 @@ static void brcmnand_write_buf(struct mtd_info *mtd, const uint8_t *buf, { int i; struct nand_chip *chip = mtd_to_nand(mtd); - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); switch (host->last_cmd) { case NAND_CMD_SET_FEATURES: @@ -1400,7 +1400,7 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip, u64 addr, unsigned int trans, u32 *buf, u8 *oob, u64 *err_addr) { - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_controller *ctrl = host->ctrl; int i, j, ret = 0; @@ -1463,7 +1463,7 @@ static int brcmnand_read_by_pio(struct mtd_info *mtd, struct nand_chip *chip, static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip, u64 addr, unsigned int trans, u32 *buf, u8 *oob) { - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_controller *ctrl = host->ctrl; u64 err_addr = 0; int err; @@ -1513,7 +1513,7 @@ static int brcmnand_read(struct mtd_info *mtd, struct nand_chip *chip, static int brcmnand_read_page(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); u8 *oob = oob_required ? (u8 *)chip->oob_poi : NULL; return brcmnand_read(mtd, chip, host->last_addr, @@ -1523,7 +1523,7 @@ static int brcmnand_read_page(struct mtd_info *mtd, struct nand_chip *chip, static int brcmnand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); u8 *oob = oob_required ? (u8 *)chip->oob_poi : NULL; int ret; @@ -1545,7 +1545,7 @@ static int brcmnand_read_oob(struct mtd_info *mtd, struct nand_chip *chip, static int brcmnand_read_oob_raw(struct mtd_info *mtd, struct nand_chip *chip, int page) { - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); brcmnand_set_ecc_enabled(host, 0); brcmnand_read(mtd, chip, (u64)page << chip->page_shift, @@ -1558,7 +1558,7 @@ static int brcmnand_read_oob_raw(struct mtd_info *mtd, struct nand_chip *chip, static int brcmnand_write(struct mtd_info *mtd, struct nand_chip *chip, u64 addr, const u32 *buf, u8 *oob) { - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); struct brcmnand_controller *ctrl = host->ctrl; unsigned int i, j, trans = mtd->writesize >> FC_SHIFT; int status, ret = 0; @@ -1629,7 +1629,7 @@ out: static int brcmnand_write_page(struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf, int oob_required, int page) { - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); void *oob = oob_required ? chip->oob_poi : NULL; brcmnand_write(mtd, chip, host->last_addr, (const u32 *)buf, oob); @@ -1640,7 +1640,7 @@ static int brcmnand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf, int oob_required, int page) { - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); void *oob = oob_required ? chip->oob_poi : NULL; brcmnand_set_ecc_enabled(host, 0); @@ -1659,7 +1659,7 @@ static int brcmnand_write_oob(struct mtd_info *mtd, struct nand_chip *chip, static int brcmnand_write_oob_raw(struct mtd_info *mtd, struct nand_chip *chip, int page) { - struct brcmnand_host *host = chip->priv; + struct brcmnand_host *host = nand_get_controller_data(chip); int ret; brcmnand_set_ecc_enabled(host, 0); @@ -1923,7 +1923,7 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn) chip = &host->chip; nand_set_flash_node(chip, dn); - chip->priv = host; + nand_set_controller_data(chip, host); mtd->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "brcmnand.%d", host->cs); mtd->owner = THIS_MODULE; diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c index 00c15e22d827..aa1a616b9fb6 100644 --- a/drivers/mtd/nand/cafe_nand.c +++ b/drivers/mtd/nand/cafe_nand.c @@ -102,7 +102,7 @@ static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL }; static int cafe_device_ready(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); - struct cafe_priv *cafe = chip->priv; + struct cafe_priv *cafe = nand_get_controller_data(chip); int result = !!(cafe_readl(cafe, NAND_STATUS) & 0x40000000); uint32_t irqs = cafe_readl(cafe, NAND_IRQ); @@ -119,7 +119,7 @@ static int cafe_device_ready(struct mtd_info *mtd) static void cafe_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) { struct nand_chip *chip = mtd_to_nand(mtd); - struct cafe_priv *cafe = chip->priv; + struct cafe_priv *cafe = nand_get_controller_data(chip); if (usedma) memcpy(cafe->dmabuf + cafe->datalen, buf, len); @@ -135,7 +135,7 @@ static void cafe_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) { struct nand_chip *chip = mtd_to_nand(mtd); - struct cafe_priv *cafe = chip->priv; + struct cafe_priv *cafe = nand_get_controller_data(chip); if (usedma) memcpy(buf, cafe->dmabuf + cafe->datalen, len); @@ -150,7 +150,7 @@ static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) static uint8_t cafe_read_byte(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); - struct cafe_priv *cafe = chip->priv; + struct cafe_priv *cafe = nand_get_controller_data(chip); uint8_t d; cafe_read_buf(mtd, &d, 1); @@ -163,7 +163,7 @@ static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command, int column, int page_addr) { struct nand_chip *chip = mtd_to_nand(mtd); - struct cafe_priv *cafe = chip->priv; + struct cafe_priv *cafe = nand_get_controller_data(chip); int adrbytes = 0; uint32_t ctl1; uint32_t doneint = 0x80000000; @@ -319,7 +319,7 @@ static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command, static void cafe_select_chip(struct mtd_info *mtd, int chipnr) { struct nand_chip *chip = mtd_to_nand(mtd); - struct cafe_priv *cafe = chip->priv; + struct cafe_priv *cafe = nand_get_controller_data(chip); cafe_dev_dbg(&cafe->pdev->dev, "select_chip %d\n", chipnr); @@ -335,7 +335,7 @@ static irqreturn_t cafe_nand_interrupt(int irq, void *id) { struct mtd_info *mtd = id; struct nand_chip *chip = mtd_to_nand(mtd); - struct cafe_priv *cafe = chip->priv; + struct cafe_priv *cafe = nand_get_controller_data(chip); uint32_t irqs = cafe_readl(cafe, NAND_IRQ); cafe_writel(cafe, irqs & ~0x90000000, NAND_IRQ); if (!irqs) @@ -384,7 +384,7 @@ static int cafe_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip, static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { - struct cafe_priv *cafe = chip->priv; + struct cafe_priv *cafe = nand_get_controller_data(chip); unsigned int max_bitflips = 0; cafe_dev_dbg(&cafe->pdev->dev, "ECC result %08x SYN1,2 %08x\n", @@ -526,7 +526,7 @@ static int cafe_nand_write_page_lowlevel(struct mtd_info *mtd, const uint8_t *buf, int oob_required, int page) { - struct cafe_priv *cafe = chip->priv; + struct cafe_priv *cafe = nand_get_controller_data(chip); chip->write_buf(mtd, buf, mtd->writesize); chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); @@ -611,7 +611,7 @@ static int cafe_nand_probe(struct pci_dev *pdev, mtd = nand_to_mtd(&cafe->nand); mtd->dev.parent = &pdev->dev; - cafe->nand.priv = cafe; + nand_set_controller_data(&cafe->nand, cafe); cafe->pdev = pdev; cafe->mmio = pci_iomap(pdev, 0, 0); @@ -800,7 +800,7 @@ static void cafe_nand_remove(struct pci_dev *pdev) { struct mtd_info *mtd = pci_get_drvdata(pdev); struct nand_chip *chip = mtd_to_nand(mtd); - struct cafe_priv *cafe = chip->priv; + struct cafe_priv *cafe = nand_get_controller_data(chip); /* Disable NAND IRQ in global IRQ mask register */ cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK); @@ -828,7 +828,7 @@ static int cafe_nand_resume(struct pci_dev *pdev) uint32_t ctrl; struct mtd_info *mtd = pci_get_drvdata(pdev); struct nand_chip *chip = mtd_to_nand(mtd); - struct cafe_priv *cafe = chip->priv; + struct cafe_priv *cafe = nand_get_controller_data(chip); /* Start off by resetting the NAND controller completely */ cafe_writel(cafe, 1, NAND_RESET); diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index 4f4aa3555a6f..f170f3c31b34 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c @@ -296,7 +296,7 @@ static inline int DoC_WaitReady(struct doc_priv *doc) static void doc2000_write_byte(struct mtd_info *mtd, u_char datum) { struct nand_chip *this = mtd_to_nand(mtd); - struct doc_priv *doc = this->priv; + struct doc_priv *doc = nand_get_controller_data(this); void __iomem *docptr = doc->virtadr; if (debug) @@ -308,7 +308,7 @@ static void doc2000_write_byte(struct mtd_info *mtd, u_char datum) static u_char doc2000_read_byte(struct mtd_info *mtd) { struct nand_chip *this = mtd_to_nand(mtd); - struct doc_priv *doc = this->priv; + struct doc_priv *doc = nand_get_controller_data(this); void __iomem *docptr = doc->virtadr; u_char ret; @@ -323,7 +323,7 @@ static u_char doc2000_read_byte(struct mtd_info *mtd) static void doc2000_writebuf(struct mtd_info *mtd, const u_char *buf, int len) { struct nand_chip *this = mtd_to_nand(mtd); - struct doc_priv *doc = this->priv; + struct doc_priv *doc = nand_get_controller_data(this); void __iomem *docptr = doc->virtadr; int i; if (debug) @@ -340,7 +340,7 @@ static void doc2000_writebuf(struct mtd_info *mtd, const u_char *buf, int len) static void doc2000_readbuf(struct mtd_info *mtd, u_char *buf, int len) { struct nand_chip *this = mtd_to_nand(mtd); - struct doc_priv *doc = this->priv; + struct doc_priv *doc = nand_get_controller_data(this); void __iomem *docptr = doc->virtadr; int i; @@ -355,7 +355,7 @@ static void doc2000_readbuf(struct mtd_info *mtd, u_char *buf, int len) static void doc2000_readbuf_dword(struct mtd_info *mtd, u_char *buf, int len) { struct nand_chip *this = mtd_to_nand(mtd); - struct doc_priv *doc = this->priv; + struct doc_priv *doc = nand_get_controller_data(this); void __iomem *docptr = doc->virtadr; int i; @@ -376,7 +376,7 @@ static void doc2000_readbuf_dword(struct mtd_info *mtd, u_char *buf, int len) static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr) { struct nand_chip *this = mtd_to_nand(mtd); - struct doc_priv *doc = this->priv; + struct doc_priv *doc = nand_get_controller_data(this); uint16_t ret; doc200x_select_chip(mtd, nr); @@ -422,7 +422,7 @@ static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr) static void __init doc2000_count_chips(struct mtd_info *mtd) { struct nand_chip *this = mtd_to_nand(mtd); - struct doc_priv *doc = this->priv; + struct doc_priv *doc = nand_get_controller_data(this); uint16_t mfrid; int i; @@ -443,7 +443,7 @@ static void __init doc2000_count_chips(struct mtd_info *mtd) static int doc200x_wait(struct mtd_info *mtd, struct nand_chip *this) { - struct doc_priv *doc = this->priv; + struct doc_priv *doc = nand_get_controller_data(this); int status; @@ -458,7 +458,7 @@ static int doc200x_wait(struct mtd_info *mtd, struct nand_chip *this) static void doc2001_write_byte(struct mtd_info *mtd, u_char datum) { struct nand_chip *this = mtd_to_nand(mtd); - struct doc_priv *doc = this->priv; + struct doc_priv *doc = nand_get_controller_data(this); void __iomem *docptr = doc->virtadr; WriteDOC(datum, docptr, CDSNSlowIO); @@ -469,7 +469,7 @@ static void doc2001_write_byte(struct mtd_info *mtd, u_char datum) static u_char doc2001_read_byte(struct mtd_info *mtd) { struct nand_chip *this = mtd_to_nand(mtd); - struct doc_priv *doc = this->priv; + struct doc_priv *doc = nand_get_controller_data(this); void __iomem *docptr = doc->virtadr; //ReadDOC(docptr, CDSNSlowIO); @@ -483,7 +483,7 @@ static u_char doc2001_read_byte |