summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris BREZILLON <boris.brezillon@free-electrons.com>2015-12-01 06:03:04 -0500
committerBrian Norris <computersforpeace@gmail.com>2015-12-08 15:24:36 -0500
commit4bd4ebcc540c35d4477b098cf26394f976551464 (patch)
tree2ceb0ef03c53f3f65d881a1d15d2445b602bdb38
parenta83dfa92850e521dfb6485ad4aa3c7c1fb52f06e (diff)
mtd: nand: make use of mtd_to_nand() in NAND drivers
mtd_to_nand() was recently introduced to avoid direct accesses to the mtd->priv field. Update all NAND drivers to use it. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--drivers/mtd/nand/ams-delta.c4
-rw-r--r--drivers/mtd/nand/atmel_nand.c50
-rw-r--r--drivers/mtd/nand/au1550nd.c22
-rw-r--r--drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c16
-rw-r--r--drivers/mtd/nand/bf5xx_nand.c12
-rw-r--r--drivers/mtd/nand/brcmnand/brcmnand.c12
-rw-r--r--drivers/mtd/nand/cafe_nand.c18
-rw-r--r--drivers/mtd/nand/cmx270_nand.c8
-rw-r--r--drivers/mtd/nand/cs553x_nand.c18
-rw-r--r--drivers/mtd/nand/davinci_nand.c8
-rw-r--r--drivers/mtd/nand/diskonchip.c66
-rw-r--r--drivers/mtd/nand/docg4.c34
-rw-r--r--drivers/mtd/nand/fsl_elbc_nand.c14
-rw-r--r--drivers/mtd/nand/fsl_ifc_nand.c18
-rw-r--r--drivers/mtd/nand/fsl_upm.c4
-rw-r--r--drivers/mtd/nand/fsmc_nand.c10
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-nand.c18
-rw-r--r--drivers/mtd/nand/hisi504_nand.c16
-rw-r--r--drivers/mtd/nand/jz4740_nand.c4
-rw-r--r--drivers/mtd/nand/lpc32xx_mlc.c6
-rw-r--r--drivers/mtd/nand/lpc32xx_slc.c14
-rw-r--r--drivers/mtd/nand/mpc5121_nfc.c24
-rw-r--r--drivers/mtd/nand/mxc_nand.c34
-rw-r--r--drivers/mtd/nand/ndfc.c14
-rw-r--r--drivers/mtd/nand/nuc900_nand.c2
-rw-r--r--drivers/mtd/nand/omap2.c12
-rw-r--r--drivers/mtd/nand/orion_nand.c4
-rw-r--r--drivers/mtd/nand/pasemi_nand.c8
-rw-r--r--drivers/mtd/nand/pxa3xx_nand.c18
-rw-r--r--drivers/mtd/nand/r852.c2
-rw-r--r--drivers/mtd/nand/s3c2410.c6
-rw-r--r--drivers/mtd/nand/sharpsl.c2
-rw-r--r--drivers/mtd/nand/sm_common.c2
-rw-r--r--drivers/mtd/nand/socrates_nand.c8
-rw-r--r--drivers/mtd/nand/sunxi_nand.c26
-rw-r--r--drivers/mtd/nand/tmio_nand.c2
-rw-r--r--drivers/mtd/nand/txx9ndfmc.c12
-rw-r--r--drivers/mtd/nand/xway_nand.c4
38 files changed, 276 insertions, 276 deletions
diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
index 842f8fe91b56..b2b49c42920c 100644
--- a/drivers/mtd/nand/ams-delta.c
+++ b/drivers/mtd/nand/ams-delta.c
@@ -64,7 +64,7 @@ static struct mtd_partition partition_info[] = {
64 64
65static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) 65static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte)
66{ 66{
67 struct nand_chip *this = mtd->priv; 67 struct nand_chip *this = mtd_to_nand(mtd);
68 void __iomem *io_base = this->priv; 68 void __iomem *io_base = this->priv;
69 69
70 writew(0, io_base + OMAP_MPUIO_IO_CNTL); 70 writew(0, io_base + OMAP_MPUIO_IO_CNTL);
@@ -77,7 +77,7 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte)
77static u_char ams_delta_read_byte(struct mtd_info *mtd) 77static u_char ams_delta_read_byte(struct mtd_info *mtd)
78{ 78{
79 u_char res; 79 u_char res;
80 struct nand_chip *this = mtd->priv; 80 struct nand_chip *this = mtd_to_nand(mtd);
81 void __iomem *io_base = this->priv; 81 void __iomem *io_base = this->priv;
82 82
83 gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 0); 83 gpio_set_value(AMS_DELTA_GPIO_PIN_NAND_NRE, 0);
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index f4e1f915c696..edd191a6ee53 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)
182 */ 182 */
183static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) 183static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
184{ 184{
185 struct nand_chip *nand_chip = mtd->priv; 185 struct nand_chip *nand_chip = mtd_to_nand(mtd);
186 struct atmel_nand_host *host = nand_chip->priv; 186 struct atmel_nand_host *host = nand_chip->priv;
187 187
188 if (ctrl & NAND_CTRL_CHANGE) { 188 if (ctrl & NAND_CTRL_CHANGE) {
@@ -205,7 +205,7 @@ static void atmel_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl
205 */ 205 */
206static int atmel_nand_device_ready(struct mtd_info *mtd) 206static int atmel_nand_device_ready(struct mtd_info *mtd)
207{ 207{
208 struct nand_chip *nand_chip = mtd->priv; 208 struct nand_chip *nand_chip = mtd_to_nand(mtd);
209 struct atmel_nand_host *host = nand_chip->priv; 209 struct atmel_nand_host *host = nand_chip->priv;
210 210
211 return gpio_get_value(host->board.rdy_pin) ^ 211 return gpio_get_value(host->board.rdy_pin) ^
@@ -215,7 +215,7 @@ static int atmel_nand_device_ready(struct mtd_info *mtd)
215/* Set up for hardware ready pin and enable pin. */ 215/* Set up for hardware ready pin and enable pin. */
216static int atmel_nand_set_enable_ready_pins(struct mtd_info *mtd) 216static int atmel_nand_set_enable_ready_pins(struct mtd_info *mtd)
217{ 217{
218 struct nand_chip *chip = mtd->priv; 218 struct nand_chip *chip = mtd_to_nand(mtd);
219 struct atmel_nand_host *host = chip->priv; 219 struct atmel_nand_host *host = chip->priv;
220 int res = 0; 220 int res = 0;
221 221
@@ -267,7 +267,7 @@ static int atmel_nand_set_enable_ready_pins(struct mtd_info *mtd)
267 */ 267 */
268static void atmel_read_buf8(struct mtd_info *mtd, u8 *buf, int len) 268static void atmel_read_buf8(struct mtd_info *mtd, u8 *buf, int len)
269{ 269{
270 struct nand_chip *nand_chip = mtd->priv; 270 struct nand_chip *nand_chip = mtd_to_nand(mtd);
271 struct atmel_nand_host *host = nand_chip->priv; 271 struct atmel_nand_host *host = nand_chip->priv;
272 272
273 if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) { 273 if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) {
@@ -280,7 +280,7 @@ static void atmel_read_buf8(struct mtd_info *mtd, u8 *buf, int len)
280 280
281static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len) 281static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len)
282{ 282{
283 struct nand_chip *nand_chip = mtd->priv; 283 struct nand_chip *nand_chip = mtd_to_nand(mtd);
284 struct atmel_nand_host *host = nand_chip->priv; 284 struct atmel_nand_host *host = nand_chip->priv;
285 285
286 if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) { 286 if (host->nfc && host->nfc->use_nfc_sram && host->nfc->data_in_sram) {
@@ -293,14 +293,14 @@ static void atmel_read_buf16(struct mtd_info *mtd, u8 *buf, int len)
293 293
294static void atmel_write_buf8(struct mtd_info *mtd, const u8 *buf, int len) 294static void atmel_write_buf8(struct mtd_info *mtd, const u8 *buf, int len)
295{ 295{
296 struct nand_chip *nand_chip = mtd->priv; 296 struct nand_chip *nand_chip = mtd_to_nand(mtd);
297 297
298 __raw_writesb(nand_chip->IO_ADDR_W, buf, len); 298 __raw_writesb(nand_chip->IO_ADDR_W, buf, len);
299} 299}
300 300
301static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len) 301static void atmel_write_buf16(struct mtd_info *mtd, const u8 *buf, int len)
302{ 302{
303 struct nand_chip *nand_chip = mtd->priv; 303 struct nand_chip *nand_chip = mtd_to_nand(mtd);
304 304
305 __raw_writesw(nand_chip->IO_ADDR_W, buf, len / 2); 305 __raw_writesw(nand_chip->IO_ADDR_W, buf, len / 2);
306} 306}
@@ -352,7 +352,7 @@ static int atmel_nand_dma_op(struct mtd_info *mtd, void *buf, int len,
352 dma_addr_t dma_src_addr, dma_dst_addr, phys_addr; 352 dma_addr_t dma_src_addr, dma_dst_addr, phys_addr;
353 struct dma_async_tx_descriptor *tx = NULL; 353 struct dma_async_tx_descriptor *tx = NULL;
354 dma_cookie_t cookie; 354 dma_cookie_t cookie;
355 struct nand_chip *chip = mtd->priv; 355 struct nand_chip *chip = mtd_to_nand(mtd);
356 struct atmel_nand_host *host = chip->priv; 356 struct atmel_nand_host *host = chip->priv;
357 void *p = buf; 357 void *p = buf;
358 int err = -EIO; 358 int err = -EIO;
@@ -425,7 +425,7 @@ err_buf:
425 425
426static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len) 426static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
427{ 427{
428 struct nand_chip *chip = mtd->priv; 428 struct nand_chip *chip = mtd_to_nand(mtd);
429 struct atmel_nand_host *host = chip->priv; 429 struct atmel_nand_host *host = chip->priv;
430 430
431 if (use_dma && len > mtd->oobsize) 431 if (use_dma && len > mtd->oobsize)
@@ -441,7 +441,7 @@ static void atmel_read_buf(struct mtd_info *mtd, u8 *buf, int len)
441 441
442static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len) 442static void atmel_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
443{ 443{
444 struct nand_chip *chip = mtd->priv; 444 struct nand_chip *chip = mtd_to_nand(mtd);
445 struct atmel_nand_host *host = chip->priv; 445 struct atmel_nand_host *host = chip->priv;
446 446
447 if (use_dma && len > mtd->oobsize) 447 if (use_dma && len > mtd->oobsize)
@@ -533,7 +533,7 @@ static int pmecc_data_alloc(struct atmel_nand_host *host)
533 533
534static void pmecc_gen_syndrome(struct mtd_info *mtd, int sector) 534static void pmecc_gen_syndrome(struct mtd_info *mtd, int sector)
535{ 535{
536 struct nand_chip *nand_chip = mtd->priv; 536 struct nand_chip *nand_chip = mtd_to_nand(mtd);
537 struct atmel_nand_host *host = nand_chip->priv; 537 struct atmel_nand_host *host = nand_chip->priv;
538 int i; 538 int i;
539 uint32_t value; 539 uint32_t value;
@@ -550,7 +550,7 @@ static void pmecc_gen_syndrome(struct mtd_info *mtd, int sector)
550 550
551static void pmecc_substitute(struct mtd_info *mtd) 551static void pmecc_substitute(struct mtd_info *mtd)
552{ 552{
553 struct nand_chip *nand_chip = mtd->priv; 553 struct nand_chip *nand_chip = mtd_to_nand(mtd);
554 struct atmel_nand_host *host = nand_chip->priv; 554 struct atmel_nand_host *host = nand_chip->priv;
555 int16_t __iomem *alpha_to = host->pmecc_alpha_to; 555 int16_t __iomem *alpha_to = host->pmecc_alpha_to;
556 int16_t __iomem *index_of = host->pmecc_index_of; 556 int16_t __iomem *index_of = host->pmecc_index_of;
@@ -592,7 +592,7 @@ static void pmecc_substitute(struct mtd_info *mtd)
592 592
593static void pmecc_get_sigma(struct mtd_info *mtd) 593static void pmecc_get_sigma(struct mtd_info *mtd)
594{ 594{
595 struct nand_chip *nand_chip = mtd->priv; 595 struct nand_chip *nand_chip = mtd_to_nand(mtd);
596 struct atmel_nand_host *host = nand_chip->priv; 596 struct atmel_nand_host *host = nand_chip->priv;
597 597
598 int16_t *lmu = host->pmecc_lmu; 598 int16_t *lmu = host->pmecc_lmu;
@@ -750,7 +750,7 @@ static void pmecc_get_sigma(struct mtd_info *mtd)
750 750
751static int pmecc_err_location(struct mtd_info *mtd) 751static int pmecc_err_location(struct mtd_info *mtd)
752{ 752{
753 struct nand_chip *nand_chip = mtd->priv; 753 struct nand_chip *nand_chip = mtd_to_nand(mtd);
754 struct atmel_nand_host *host = nand_chip->priv; 754 struct atmel_nand_host *host = nand_chip->priv;
755 unsigned long end_time; 755 unsigned long end_time;
756 const int cap = host->pmecc_corr_cap; 756 const int cap = host->pmecc_corr_cap;
@@ -802,7 +802,7 @@ static int pmecc_err_location(struct mtd_info *mtd)
802static void pmecc_correct_data(struct mtd_info *mtd, uint8_t *buf, uint8_t *ecc, 802static void pmecc_correct_data(struct mtd_info *mtd, uint8_t *buf, uint8_t *ecc,
803 int sector_num, int extra_bytes, int err_nbr) 803 int sector_num, int extra_bytes, int err_nbr)
804{ 804{
805 struct nand_chip *nand_chip = mtd->priv; 805 struct nand_chip *nand_chip = mtd_to_nand(mtd);
806 struct atmel_nand_host *host = nand_chip->priv; 806 struct atmel_nand_host *host = nand_chip->priv;
807 int i = 0; 807 int i = 0;
808 int byte_pos, bit_pos, sector_size, pos; 808 int byte_pos, bit_pos, sector_size, pos;
@@ -848,7 +848,7 @@ static void pmecc_correct_data(struct mtd_info *mtd, uint8_t *buf, uint8_t *ecc,
848static int pmecc_correction(struct mtd_info *mtd, u32 pmecc_stat, uint8_t *buf, 848static int pmecc_correction(struct mtd_info *mtd, u32 pmecc_stat, uint8_t *buf,
849 u8 *ecc) 849 u8 *ecc)
850{ 850{
851 struct nand_chip *nand_chip = mtd->priv; 851 struct nand_chip *nand_chip = mtd_to_nand(mtd);
852 struct atmel_nand_host *host = nand_chip->priv; 852 struct atmel_nand_host *host = nand_chip->priv;
853 int i, err_nbr; 853 int i, err_nbr;
854 uint8_t *buf_pos; 854 uint8_t *buf_pos;
@@ -992,7 +992,7 @@ static int atmel_nand_pmecc_write_page(struct mtd_info *mtd,
992 992
993static void atmel_pmecc_core_init(struct mtd_info *mtd) 993static void atmel_pmecc_core_init(struct mtd_info *mtd)
994{ 994{
995 struct nand_chip *nand_chip = mtd->priv; 995 struct nand_chip *nand_chip = mtd_to_nand(mtd);
996 struct atmel_nand_host *host = nand_chip->priv; 996 struct atmel_nand_host *host = nand_chip->priv;
997 uint32_t val = 0; 997 uint32_t val = 0;
998 struct nand_ecclayout *ecc_layout; 998 struct nand_ecclayout *ecc_layout;
@@ -1308,7 +1308,7 @@ err:
1308static int atmel_nand_calculate(struct mtd_info *mtd, 1308static int atmel_nand_calculate(struct mtd_info *mtd,
1309 const u_char *dat, unsigned char *ecc_code) 1309 const u_char *dat, unsigned char *ecc_code)
1310{ 1310{
1311 struct nand_chip *nand_chip = mtd->priv; 1311 struct nand_chip *nand_chip = mtd_to_nand(mtd);
1312 struct atmel_nand_host *host = nand_chip->priv; 1312 struct atmel_nand_host *host = nand_chip->priv;
1313 unsigned int ecc_value; 1313 unsigned int ecc_value;
1314 1314
@@ -1412,7 +1412,7 @@ static int atmel_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip,
1412static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat, 1412static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,
1413 u_char *read_ecc, u_char *isnull) 1413 u_char *read_ecc, u_char *isnull)
1414{ 1414{
1415 struct nand_chip *nand_chip = mtd->priv; 1415 struct nand_chip *nand_chip = mtd_to_nand(mtd);
1416 struct atmel_nand_host *host = nand_chip->priv; 1416 struct atmel_nand_host *host = nand_chip->priv;
1417 unsigned int ecc_status; 1417 unsigned int ecc_status;
1418 unsigned int ecc_word, ecc_bit; 1418 unsigned int ecc_word, ecc_bit;
@@ -1478,7 +1478,7 @@ static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,
1478 */ 1478 */
1479static void atmel_nand_hwctl(struct mtd_info *mtd, int mode) 1479static void atmel_nand_hwctl(struct mtd_info *mtd, int mode)
1480{ 1480{
1481 struct nand_chip *nand_chip = mtd->priv; 1481 struct nand_chip *nand_chip = mtd_to_nand(mtd);
1482 struct atmel_nand_host *host = nand_chip->priv; 1482 struct atmel_nand_host *host = nand_chip->priv;
1483 1483
1484 if (host->board.need_reset_workaround) 1484 if (host->board.need_reset_workaround)
@@ -1771,7 +1771,7 @@ static int nfc_send_command(struct atmel_nand_host *host,
1771static int nfc_device_ready(struct mtd_info *mtd) 1771static int nfc_device_ready(struct mtd_info *mtd)
1772{ 1772{
1773 u32 status, mask; 1773 u32 status, mask;
1774 struct nand_chip *nand_chip = mtd->priv; 1774 struct nand_chip *nand_chip = mtd_to_nand(mtd);
1775 struct atmel_nand_host *host = nand_chip->priv; 1775 struct atmel_nand_host *host = nand_chip->priv;
1776 1776
1777 status = nfc_read_status(host); 1777 status = nfc_read_status(host);
@@ -1787,7 +1787,7 @@ static int nfc_device_ready(struct mtd_info *mtd)
1787 1787
1788static void nfc_select_chip(struct mtd_info *mtd, int chip) 1788static void nfc_select_chip(struct mtd_info *mtd, int chip)
1789{ 1789{
1790 struct nand_chip *nand_chip = mtd->priv; 1790 struct nand_chip *nand_chip = mtd_to_nand(mtd);
1791 struct atmel_nand_host *host = nand_chip->priv; 1791 struct atmel_nand_host *host = nand_chip->priv;
1792 1792
1793 if (chip == -1) 1793 if (chip == -1)
@@ -1799,7 +1799,7 @@ static void nfc_select_chip(struct mtd_info *mtd, int chip)
1799static int nfc_make_addr(struct mtd_info *mtd, int command, int column, 1799static int nfc_make_addr(struct mtd_info *mtd, int command, int column,
1800 int page_addr, unsigned int *addr1234, unsigned int *cycle0) 1800 int page_addr, unsigned int *addr1234, unsigned int *cycle0)
1801{ 1801{
1802 struct nand_chip *chip = mtd->priv; 1802 struct nand_chip *chip = mtd_to_nand(mtd);
1803 1803
1804 int acycle = 0; 1804 int acycle = 0;
1805 unsigned char addr_bytes[8]; 1805 unsigned char addr_bytes[8];
@@ -1839,7 +1839,7 @@ static int nfc_make_addr(struct mtd_info *mtd, int command, int column,
1839static void nfc_nand_command(struct mtd_info *mtd, unsigned int command, 1839static void nfc_nand_command(struct mtd_info *mtd, unsigned int command,
1840 int column, int page_addr) 1840 int column, int page_addr)
1841{ 1841{
1842 struct nand_chip *chip = mtd->priv; 1842 struct nand_chip *chip = mtd_to_nand(mtd);
1843 struct atmel_nand_host *host = chip->priv; 1843 struct atmel_nand_host *host = chip->priv;
1844 unsigned long timeout; 1844 unsigned long timeout;
1845 unsigned int nfc_addr_cmd = 0; 1845 unsigned int nfc_addr_cmd = 0;
@@ -2026,7 +2026,7 @@ static int nfc_sram_write_page(struct mtd_info *mtd, struct nand_chip *chip,
2026 2026
2027static int nfc_sram_init(struct mtd_info *mtd) 2027static int nfc_sram_init(struct mtd_info *mtd)
2028{ 2028{
2029 struct nand_chip *chip = mtd->priv; 2029 struct nand_chip *chip = mtd_to_nand(mtd);
2030 struct atmel_nand_host *host = chip->priv; 2030 struct atmel_nand_host *host = chip->priv;
2031 int res = 0; 2031 int res = 0;
2032 2032
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
index 08a130f63faf..73fceb8743a2 100644
--- a/drivers/mtd/nand/au1550nd.c
+++ b/drivers/mtd/nand/au1550nd.c
@@ -39,7 +39,7 @@ struct au1550nd_ctx {
39 */ 39 */
40static u_char au_read_byte(struct mtd_info *mtd) 40static u_char au_read_byte(struct mtd_info *mtd)
41{ 41{
42 struct nand_chip *this = mtd->priv; 42 struct nand_chip *this = mtd_to_nand(mtd);
43 u_char ret = readb(this->IO_ADDR_R); 43 u_char ret = readb(this->IO_ADDR_R);
44 wmb(); /* drain writebuffer */ 44 wmb(); /* drain writebuffer */
45 return ret; 45 return ret;
@@ -54,7 +54,7 @@ static u_char au_read_byte(struct mtd_info *mtd)
54 */ 54 */
55static void au_write_byte(struct mtd_info *mtd, u_char byte) 55static void au_write_byte(struct mtd_info *mtd, u_char byte)
56{ 56{
57 struct nand_chip *this = mtd->priv; 57 struct nand_chip *this = mtd_to_nand(mtd);
58 writeb(byte, this->IO_ADDR_W); 58 writeb(byte, this->IO_ADDR_W);
59 wmb(); /* drain writebuffer */ 59 wmb(); /* drain writebuffer */
60} 60}
@@ -67,7 +67,7 @@ static void au_write_byte(struct mtd_info *mtd, u_char byte)
67 */ 67 */
68static u_char au_read_byte16(struct mtd_info *mtd) 68static u_char au_read_byte16(struct mtd_info *mtd)
69{ 69{
70 struct nand_chip *this = mtd->priv; 70 struct nand_chip *this = mtd_to_nand(mtd);
71 u_char ret = (u_char) cpu_to_le16(readw(this->IO_ADDR_R)); 71 u_char ret = (u_char) cpu_to_le16(readw(this->IO_ADDR_R));
72 wmb(); /* drain writebuffer */ 72 wmb(); /* drain writebuffer */
73 return ret; 73 return ret;
@@ -82,7 +82,7 @@ static u_char au_read_byte16(struct mtd_info *mtd)
82 */ 82 */
83static void au_write_byte16(struct mtd_info *mtd, u_char byte) 83static void au_write_byte16(struct mtd_info *mtd, u_char byte)
84{ 84{
85 struct nand_chip *this = mtd->priv; 85 struct nand_chip *this = mtd_to_nand(mtd);
86 writew(le16_to_cpu((u16) byte), this->IO_ADDR_W); 86 writew(le16_to_cpu((u16) byte), this->IO_ADDR_W);
87 wmb(); /* drain writebuffer */ 87 wmb(); /* drain writebuffer */
88} 88}
@@ -95,7 +95,7 @@ static void au_write_byte16(struct mtd_info *mtd, u_char byte)
95 */ 95 */
96static u16 au_read_word(struct mtd_info *mtd) 96static u16 au_read_word(struct mtd_info *mtd)
97{ 97{
98 struct nand_chip *this = mtd->priv; 98 struct nand_chip *this = mtd_to_nand(mtd);
99 u16 ret = readw(this->IO_ADDR_R); 99 u16 ret = readw(this->IO_ADDR_R);
100 wmb(); /* drain writebuffer */ 100 wmb(); /* drain writebuffer */
101 return ret; 101 return ret;
@@ -112,7 +112,7 @@ static u16 au_read_word(struct mtd_info *mtd)
112static void au_write_buf(struct mtd_info *mtd, const u_char *buf, int len) 112static void au_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
113{ 113{
114 int i; 114 int i;
115 struct nand_chip *this = mtd->priv; 115 struct nand_chip *this = mtd_to_nand(mtd);
116 116
117 for (i = 0; i < len; i++) { 117 for (i = 0; i < len; i++) {
118 writeb(buf[i], this->IO_ADDR_W); 118 writeb(buf[i], this->IO_ADDR_W);
@@ -131,7 +131,7 @@ static void au_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
131static void au_read_buf(struct mtd_info *mtd, u_char *buf, int len) 131static void au_read_buf(struct mtd_info *mtd, u_char *buf, int len)
132{ 132{
133 int i; 133 int i;
134 struct nand_chip *this = mtd->priv; 134 struct nand_chip *this = mtd_to_nand(mtd);
135 135
136 for (i = 0; i < len; i++) { 136 for (i = 0; i < len; i++) {
137 buf[i] = readb(this->IO_ADDR_R); 137 buf[i] = readb(this->IO_ADDR_R);
@@ -150,7 +150,7 @@ static void au_read_buf(struct mtd_info *mtd, u_char *buf, int len)
150static void au_write_buf16(struct mtd_info *mtd, const u_char *buf, int len) 150static void au_write_buf16(struct mtd_info *mtd, const u_char *buf, int len)
151{ 151{
152 int i; 152 int i;
153 struct nand_chip *this = mtd->priv; 153 struct nand_chip *this = mtd_to_nand(mtd);
154 u16 *p = (u16 *) buf; 154 u16 *p = (u16 *) buf;
155 len >>= 1; 155 len >>= 1;
156 156
@@ -172,7 +172,7 @@ static void au_write_buf16(struct mtd_info *mtd, const u_char *buf, int len)
172static void au_read_buf16(struct mtd_info *mtd, u_char *buf, int len) 172static void au_read_buf16(struct mtd_info *mtd, u_char *buf, int len)
173{ 173{
174 int i; 174 int i;
175 struct nand_chip *this = mtd->priv; 175 struct nand_chip *this = mtd_to_nand(mtd);
176 u16 *p = (u16 *) buf; 176 u16 *p = (u16 *) buf;
177 len >>= 1; 177 len >>= 1;
178 178
@@ -198,7 +198,7 @@ static void au_read_buf16(struct mtd_info *mtd, u_char *buf, int len)
198static void au1550_hwcontrol(struct mtd_info *mtd, int cmd) 198static void au1550_hwcontrol(struct mtd_info *mtd, int cmd)
199{ 199{
200 struct au1550nd_ctx *ctx = container_of(mtd, struct au1550nd_ctx, info); 200 struct au1550nd_ctx *ctx = container_of(mtd, struct au1550nd_ctx, info);
201 struct nand_chip *this = mtd->priv; 201 struct nand_chip *this = mtd_to_nand(mtd);
202 202
203 switch (cmd) { 203 switch (cmd) {
204 204
@@ -268,7 +268,7 @@ static void au1550_select_chip(struct mtd_info *mtd, int chip)
268static void au1550_command(struct mtd_info *mtd, unsigned command, int column, int page_addr) 268static void au1550_command(struct mtd_info *mtd, unsigned command, int column, int page_addr)
269{ 269{
270 struct au1550nd_ctx *ctx = container_of(mtd, struct au1550nd_ctx, info); 270 struct au1550nd_ctx *ctx = container_of(mtd, struct au1550nd_ctx, info);
271 struct nand_chip *this = mtd->priv; 271 struct nand_chip *this = mtd_to_nand(mtd);
272 int ce_override = 0, i; 272 int ce_override = 0, i;
273 unsigned long flags = 0; 273 unsigned long flags = 0;
274 274
diff --git a/drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c b/drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c
index 592befc7ffa1..e5b2e48658c4 100644
--- a/drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c
+++ b/drivers/mtd/nand/bcm47xxnflash/ops_bcm4706.c
@@ -89,7 +89,7 @@ static int bcm47xxnflash_ops_bcm4706_poll(struct bcma_drv_cc *cc)
89static void bcm47xxnflash_ops_bcm4706_read(struct mtd_info *mtd, uint8_t *buf, 89static void bcm47xxnflash_ops_bcm4706_read(struct mtd_info *mtd, uint8_t *buf,
90 int len) 90 int len)
91{ 91{
92 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; 92 struct nand_chip *nand_chip = mtd_to_nand(mtd);
93 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; 93 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv;
94 94
95 u32 ctlcode; 95 u32 ctlcode;
@@ -139,7 +139,7 @@ static void bcm47xxnflash_ops_bcm4706_read(struct mtd_info *mtd, uint8_t *buf,
139static void bcm47xxnflash_ops_bcm4706_write(struct mtd_info *mtd, 139static void bcm47xxnflash_ops_bcm4706_write(struct mtd_info *mtd,
140 const uint8_t *buf, int len) 140 const uint8_t *buf, int len)
141{ 141{
142 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; 142 struct nand_chip *nand_chip = mtd_to_nand(mtd);
143 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; 143 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv;
144 struct bcma_drv_cc *cc = b47n->cc; 144 struct bcma_drv_cc *cc = b47n->cc;
145 145
@@ -173,7 +173,7 @@ static void bcm47xxnflash_ops_bcm4706_write(struct mtd_info *mtd,
173static void bcm47xxnflash_ops_bcm4706_cmd_ctrl(struct mtd_info *mtd, int cmd, 173static void bcm47xxnflash_ops_bcm4706_cmd_ctrl(struct mtd_info *mtd, int cmd,
174 unsigned int ctrl) 174 unsigned int ctrl)
175{ 175{
176 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; 176 struct nand_chip *nand_chip = mtd_to_nand(mtd);
177 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; 177 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv;
178 u32 code = 0; 178 u32 code = 0;
179 179
@@ -199,7 +199,7 @@ static void bcm47xxnflash_ops_bcm4706_select_chip(struct mtd_info *mtd,
199 199
200static int bcm47xxnflash_ops_bcm4706_dev_ready(struct mtd_info *mtd) 200static int bcm47xxnflash_ops_bcm4706_dev_ready(struct mtd_info *mtd)
201{ 201{
202 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; 202 struct nand_chip *nand_chip = mtd_to_nand(mtd);
203 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; 203 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv;
204 204
205 return !!(bcma_cc_read32(b47n->cc, BCMA_CC_NFLASH_CTL) & NCTL_READY); 205 return !!(bcma_cc_read32(b47n->cc, BCMA_CC_NFLASH_CTL) & NCTL_READY);
@@ -216,7 +216,7 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd,
216 unsigned command, int column, 216 unsigned command, int column,
217 int page_addr) 217 int page_addr)
218{ 218{
219 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; 219 struct nand_chip *nand_chip = mtd_to_nand(mtd);
220 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; 220 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv;
221 struct bcma_drv_cc *cc = b47n->cc; 221 struct bcma_drv_cc *cc = b47n->cc;
222 u32 ctlcode; 222 u32 ctlcode;
@@ -312,7 +312,7 @@ static void bcm47xxnflash_ops_bcm4706_cmdfunc(struct mtd_info *mtd,
312 312
313static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct mtd_info *mtd) 313static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct mtd_info *mtd)
314{ 314{
315 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; 315 struct nand_chip *nand_chip = mtd_to_nand(mtd);
316 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; 316 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv;
317 struct bcma_drv_cc *cc = b47n->cc; 317 struct bcma_drv_cc *cc = b47n->cc;
318 u32 tmp = 0; 318 u32 tmp = 0;
@@ -341,7 +341,7 @@ static u8 bcm47xxnflash_ops_bcm4706_read_byte(struct mtd_info *mtd)
341static void bcm47xxnflash_ops_bcm4706_read_buf(struct mtd_info *mtd, 341static void bcm47xxnflash_ops_bcm4706_read_buf(struct mtd_info *mtd,
342 uint8_t *buf, int len) 342 uint8_t *buf, int len)
343{ 343{
344 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; 344 struct nand_chip *nand_chip = mtd_to_nand(mtd);
345 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; 345 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv;
346 346
347 switch (b47n->curr_command) { 347 switch (b47n->curr_command) {
@@ -357,7 +357,7 @@ static void bcm47xxnflash_ops_bcm4706_read_buf(struct mtd_info *mtd,
357static void bcm47xxnflash_ops_bcm4706_write_buf(struct mtd_info *mtd, 357static void bcm47xxnflash_ops_bcm4706_write_buf(struct mtd_info *mtd,
358 const uint8_t *buf, int len) 358 const uint8_t *buf, int len)
359{ 359{
360 struct nand_chip *nand_chip = (struct nand_chip *)mtd->priv; 360 struct nand_chip *nand_chip = mtd_to_nand(mtd);
361 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv; 361 struct bcm47xxnflash *b47n = (struct bcm47xxnflash *)nand_chip->priv;
362 362
363 switch (b47n->curr_command) { 363 switch (b47n->curr_command) {
diff --git a/drivers/mtd/nand/bf5xx_nand.c b/drivers/mtd/nand/bf5xx_nand.c
index 61bd2160717c..d9da5edb011e 100644
--- a/drivers/mtd/nand/bf5xx_nand.c
+++ b/drivers/mtd/nand/bf5xx_nand.c
@@ -304,7 +304,7 @@ static int bf5xx_nand_correct_data_256(struct mtd_info *mtd, u_char *dat,
304static int bf5xx_nand_correct_data(struct mtd_info *mtd, u_char *dat, 304static int bf5xx_nand_correct_data(struct mtd_info *mtd, u_char *dat,
305 u_char *read_ecc, u_char *calc_ecc) 305 u_char *read_ecc, u_char *calc_ecc)
306{ 306{
307 struct nand_chip *chip = mtd->priv; 307 struct nand_chip *chip = mtd_to_nand(mtd);
308 int ret; 308 int ret;
309 309
310 ret = bf5xx_nand_correct_data_256(mtd, dat, read_ecc, calc_ecc); 310 ret = bf5xx_nand_correct_data_256(mtd, dat, read_ecc, calc_ecc);
@@ -329,7 +329,7 @@ static int bf5xx_nand_calculate_ecc(struct mtd_info *mtd,
329 const u_char *dat, u_char *ecc_code) 329 const u_char *dat, u_char *ecc_code)
330{ 330{
331 struct bf5xx_nand_info *info = mtd_to_nand_info(mtd); 331 struct bf5xx_nand_info *info = mtd_to_nand_info(mtd);
332 struct nand_chip *chip = mtd->priv; 332 struct nand_chip *chip = mtd_to_nand(mtd);
333 u16 ecc0, ecc1; 333 u16 ecc0, ecc1;
334 u32 code[2]; 334 u32 code[2];
335 u8 *p; 335 u8 *p;
@@ -466,7 +466,7 @@ static void bf5xx_nand_dma_rw(struct mtd_info *mtd,
466 uint8_t *buf, int is_read) 466 uint8_t *buf, int is_read)
467{ 467{
468 struct bf5xx_nand_info *info = mtd_to_nand_info(mtd); 468 struct bf5xx_nand_info *info = mtd_to_nand_info(mtd);
469 struct nand_chip *chip = mtd->priv; 469 struct nand_chip *chip = mtd_to_nand(mtd);
470 unsigned short val; 470 unsigned short val;
471 471
472 dev_dbg(info->device, " mtd->%p, buf->%p, is_read %d\n", 472 dev_dbg(info->device, " mtd->%p, buf->%p, is_read %d\n",
@@ -532,7 +532,7 @@ static void bf5xx_nand_dma_read_buf(struct mtd_info *mtd,
532 uint8_t *buf, int len) 532 uint8_t *buf, int len)
533{ 533{
534 struct bf5xx_nand_info *info = mtd_to_nand_info(mtd); 534 struct bf5xx_nand_info *info = mtd_to_nand_info(mtd);
535 struct nand_chip *chip = mtd->priv; 535 struct nand_chip *chip = mtd_to_nand(mtd);
536 536
537 dev_dbg(info->device, "mtd->%p, buf->%p, int %d\n", mtd, buf, len); 537 dev_dbg(info->device, "mtd->%p, buf->%p, int %d\n", mtd, buf, len);
538 538
@@ -546,7 +546,7 @@ static void bf5xx_nand_dma_write_buf(struct mtd_info *mtd,
546 const uint8_t *buf, int len) 546 const uint8_t *buf, int len)
547{ 547{
548 struct bf5xx_nand_info *info = mtd_to_nand_info(mtd); 548 struct bf5xx_nand_info *info = mtd_to_nand_info(mtd);
549 struct nand_chip *chip = mtd->priv; 549 struct nand_chip *chip = mtd_to_nand(mtd);
550 550
551 dev_dbg(info->device, "mtd->%p, buf->%p, len %d\n", mtd, buf, len); 551 dev_dbg(info->device, "mtd->%p, buf->%p, len %d\n", mtd, buf, len);
552 552
@@ -685,7 +685,7 @@ static int bf5xx_nand_remove(struct platform_device *pdev)
685 685
686static int bf5xx_nand_scan(struct mtd_info *mtd) 686static int bf5xx_nand_scan(struct mtd_info *mtd)
687{ 687{
688 struct nand_chip *chip = mtd->priv; 688 struct nand_chip *chip = mtd_to_nand(mtd);
689 int ret; 689 int ret;
690 690
691 ret = nand_scan_ident(mtd, 1, NULL); 691 ret = nand_scan_ident(mtd, 1, NULL);
diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c b/drivers/mtd/nand/brcmnand/brcmnand.c
index 35d78f739d91..190a99a66010 100644
--- a/drivers/mtd/nand/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/brcmnand/brcmnand.c
@@ -873,7 +873,7 @@ static struct nand_ecclayout *brcmstb_choose_ecc_layout(
873 873
874static void brcmnand_wp(struct mtd_info *mtd, int wp) 874static void brcmnand_wp(struct mtd_info *mtd, int wp)
875{ 875{
876 struct nand_chip *chip = mtd->priv; 876 struct nand_chip *chip = mtd_to_nand(mtd);
877 struct brcmnand_host *host = chip->priv; 877 struct brcmnand_host *host = chip->priv;
878 struct brcmnand_controller *ctrl = host->ctrl; 878 struct brcmnand_controller *ctrl = host->ctrl;
879 879
@@ -1039,7 +1039,7 @@ static void brcmnand_cmd_ctrl(struct mtd_info *mtd, int dat,
1039 1039
1040static int brcmnand_waitfunc(struct mtd_info *mtd, struct nand_chip *this) 1040static int brcmnand_waitfunc(struct mtd_info *mtd, struct nand_chip *this)
1041{ 1041{
1042 struct nand_chip *chip = mtd->priv; 1042 struct nand_chip *chip = mtd_to_nand(mtd);
1043 struct brcmnand_host *host = chip->priv; 1043 struct brcmnand_host *host = chip->priv;
1044 struct brcmnand_controller *ctrl = host->ctrl; 1044 struct brcmnand_controller *ctrl = host->ctrl;
1045 unsigned long timeo = msecs_to_jiffies(100); 1045 unsigned long timeo = msecs_to_jiffies(100);
@@ -1113,7 +1113,7 @@ static int brcmnand_low_level_op(struct brcmnand_host *host,
1113static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command, 1113static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command,
1114 int column, int page_addr) 1114 int column, int page_addr)
1115{ 1115{
1116 struct nand_chip *chip = mtd->priv; 1116 struct nand_chip *chip = mtd_to_nand(mtd);
1117 struct brcmnand_host *host = chip->priv; 1117 struct brcmnand_host *host = chip->priv;
1118 struct brcmnand_controller *ctrl = host->ctrl; 1118 struct brcmnand_controller *ctrl = host->ctrl;
1119 u64 addr = (u64)page_addr << chip->page_shift; 1119 u64 addr = (u64)page_addr << chip->page_shift;
@@ -1219,7 +1219,7 @@ static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command,
1219 1219
1220static uint8_t brcmnand_read_byte(struct mtd_info *mtd) 1220static uint8_t brcmnand_read_byte(struct mtd_info *mtd)
1221{ 1221{
1222 struct nand_chip *chip = mtd->priv; 1222 struct nand_chip *chip = mtd_to_nand(mtd);
1223 struct brcmnand_host *host = chip->priv; 1223 struct brcmnand_host *host = chip->priv;
1224 struct brcmnand_controller *ctrl = host->ctrl; 1224 struct brcmnand_controller *ctrl = host->ctrl;
1225 uint8_t ret = 0; 1225 uint8_t ret = 0;
@@ -1286,7 +1286,7 @@ static void brcmnand_write_buf(struct mtd_info *mtd, const uint8_t *buf,
1286 int len) 1286 int len)
1287{ 1287{
1288 int i; 1288 int i;
1289 struct nand_chip *chip = mtd->priv; 1289 struct nand_chip *chip = mtd_to_nand(mtd);
1290 struct brcmnand_host *host = chip->priv; 1290 struct brcmnand_host *host = chip->priv;
1291 1291
1292 switch (host->last_cmd) { 1292 switch (host->last_cmd) {
@@ -2061,7 +2061,7 @@ static int brcmnand_resume(struct device *dev)
2061 2061
2062 list_for_each_entry(host, &ctrl->host_list, node) { 2062 list_for_each_entry(host, &ctrl->host_list, node) {
2063 struct mtd_info *mtd = &host->mtd; 2063 struct mtd_info *mtd = &host->mtd;
2064 struct nand_chip *chip = mtd->priv; 2064 struct nand_chip *chip = mtd_to_nand(mtd);
2065 2065
2066 brcmnand_save_restore_cs_config(host, 1); 2066 brcmnand_save_restore_cs_config(host, 1);
2067 2067
diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
index cce3ac4939b6..77c92f1b985f 100644
--- a/drivers/mtd/nand/cafe_nand.c
+++ b/drivers/mtd/nand/cafe_nand.c
@@ -101,7 +101,7 @@ static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
101 101
102static int cafe_device_ready(struct mtd_info *mtd) 102static int cafe_device_ready(struct mtd_info *mtd)
103{ 103{
104 struct nand_chip *chip = mtd->priv; 104 struct nand_chip *chip = mtd_to_nand(mtd);
105 struct cafe_priv *cafe = chip->priv; 105 struct cafe_priv *cafe = chip->priv;
106 int result = !!(cafe_readl(cafe, NAND_STATUS) & 0x40000000); 106 int result = !!(cafe_readl(cafe, NAND_STATUS) & 0x40000000);
107 uint32_t irqs = cafe_readl(cafe, NAND_IRQ); 107 uint32_t irqs = cafe_readl(cafe, NAND_IRQ);
@@ -118,7 +118,7 @@ static int cafe_device_ready(struct mtd_info *mtd)
118 118
119static void cafe_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) 119static void cafe_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
120{ 120{
121 struct nand_chip *chip = mtd->priv; 121 struct nand_chip *chip = mtd_to_nand(mtd);
122 struct cafe_priv *cafe = chip->priv; 122 struct cafe_priv *cafe = chip->priv;
123 123
124 if (usedma) 124 if (usedma)
@@ -134,7 +134,7 @@ static void cafe_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
134 134
135static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) 135static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
136{ 136{
137 struct nand_chip *chip = mtd->priv; 137 struct nand_chip *chip = mtd_to_nand(mtd);
138 struct cafe_priv *cafe = chip->priv; 138 struct cafe_priv *cafe = chip->priv;
139 139
140 if (usedma) 140 if (usedma)
@@ -149,7 +149,7 @@ static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
149 149
150static uint8_t cafe_read_byte(struct mtd_info *mtd) 150static uint8_t cafe_read_byte(struct mtd_info *mtd)
151{ 151{
152 struct nand_chip *chip = mtd->priv; 152 struct nand_chip *chip = mtd_to_nand(mtd);
153 struct cafe_priv *cafe = chip->priv; 153 struct cafe_priv *cafe = chip->priv;
154 uint8_t d; 154 uint8_t d;
155 155
@@ -162,7 +162,7 @@ static uint8_t cafe_read_byte(struct mtd_info *mtd)
162static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command, 162static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command,
163 int column, int page_addr) 163 int column, int page_addr)
164{ 164{
165 struct nand_chip *chip = mtd->priv; 165 struct nand_chip *chip = mtd_to_nand(mtd);
166 struct cafe_priv *cafe = chip->priv; 166 struct cafe_priv *cafe = chip->priv;
167 int adrbytes = 0; 167 int adrbytes = 0;
168 uint32_t ctl1; 168 uint32_t ctl1;
@@ -318,7 +318,7 @@ static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command,
318 318
319static void cafe_select_chip(struct mtd_info *mtd, int chipnr) 319static void cafe_select_chip(struct mtd_info *mtd, int chipnr)
320{ 320{
321 struct nand_chip *chip = mtd->priv; 321 struct nand_chip *chip = mtd_to_nand(mtd);
322 struct cafe_priv *cafe = chip->priv; 322 struct cafe_priv *cafe = chip->priv;
323 323
324 cafe_dev_dbg(&cafe->pdev->dev, "select_chip %d\n", chipnr); 324 cafe_dev_dbg(&cafe->pdev->dev, "select_chip %d\n", chipnr);
@@ -334,7 +334,7 @@ static void cafe_select_chip(struct mtd_info *mtd, int chipnr)
334static irqreturn_t cafe_nand_interrupt(int irq, void *id) 334static irqreturn_t cafe_nand_interrupt(int irq, void *id)
335{ 335{
336 struct mtd_info *mtd = id; 336 struct mtd_info *mtd = id;
337 struct nand_chip *chip = mtd->priv; 337 struct nand_chip *chip = mtd_to_nand(mtd);
338 struct cafe_priv *cafe = chip->priv; 338 struct cafe_priv *cafe = chip->priv;
339 uint32_t irqs = cafe_readl(cafe, NAND_IRQ); 339 uint32_t irqs = cafe_readl(cafe, NAND_IRQ);
340 cafe_writel(cafe, irqs & ~0x90000000, NAND_IRQ); 340 cafe_writel(cafe, irqs & ~0x90000000, NAND_IRQ);
@@ -800,7 +800,7 @@ static int cafe_nand_probe(struct pci_dev *pdev,
800static void cafe_nand_remove(struct pci_dev *pdev) 800static void cafe_nand_remove(struct pci_dev *pdev)
801{ 801{
802 struct mtd_info *mtd = pci_get_drvdata(pdev); 802 struct mtd_info *mtd = pci_get_drvdata(pdev);
803 struct nand_chip *chip = mtd->priv; 803 struct nand_chip *chip = mtd_to_nand(mtd);
804 struct cafe_priv *cafe = chip->priv; 804 struct cafe_priv *cafe = chip->priv;
805 805
806 /* Disable NAND IRQ in global IRQ mask register */ 806 /* Disable NAND IRQ in global IRQ mask register */
@@ -828,7 +828,7 @@ static int cafe_nand_resume(struct pci_dev *pdev)
828{ 828{
829 uint32_t ctrl; 829 uint32_t ctrl;
830 struct mtd_info *mtd = pci_get_drvdata(pdev); 830 struct mtd_info *mtd = pci_get_drvdata(pdev);
831 struct nand_chip *chip = mtd->priv; 831 struct nand_chip *chip = mtd_to_nand(mtd);
832 struct cafe_priv *cafe = chip->priv; 832 struct cafe_priv *cafe = chip->priv;
833 833
834 /* Start off by resetting the NAND controller completely */ 834 /* Start off by resetting the NAND controller completely */
diff --git a/drivers/mtd/nand/cmx270_nand.c b/drivers/mtd/nand/cmx270_nand.c
index 66ec95e6ca6c..43bded66bc44 100644
--- a/drivers/mtd/nand/cmx270_nand.c
+++ b/drivers/mtd/nand/cmx270_nand.c
@@ -53,7 +53,7 @@ static struct mtd_partition partition_info[] = {
53 53
54static u_char cmx270_read_byte(struct mtd_info *mtd) 54static u_char cmx270_read_byte(struct mtd_info *mtd)
55{ 55{
56 struct nand_chip *this = mtd->priv; 56 struct nand_chip *this = mtd_to_nand(mtd);
57 57
58 return (readl(this->IO_ADDR_R) >> 16); 58 return (readl(this->IO_ADDR_R) >> 16);
59} 59}
@@ -61,7 +61,7 @@ static u_char cmx270_read_byte(struct mtd_info *mtd)
61static void cmx270_write_buf(struct mtd_info *mtd, const u_char *buf, int len) 61static void cmx270_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
62{ 62{
63 int i; 63 int i;
64 struct nand_chip *this = mtd->priv; 64 struct nand_chip *this = mtd_to_nand(mtd);
65 65
66 for (i=0; i<len; i++) 66 for (i=0; i<len; i++)
67 writel((*buf++ << 16), this->IO_ADDR_W); 67 writel((*buf++ << 16), this->IO_ADDR_W);
@@ -70,7 +70,7 @@ static void cmx270_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
70static void cmx270_read_buf(struct mtd_info *mtd, u_char *buf, int len) 70static void cmx270_read_buf(struct mtd_info *mtd, u_char *buf, int len)
71{ 71{
72 int i; 72 int i;
73 struct nand_chip *this = mtd->priv; 73 struct nand_chip *this = mtd_to_nand(mtd);
74 74
75 for (i=0; i<len; i++) 75 for (i=0; i<len; i++)
76 *buf++ = readl(this->IO_ADDR_R) >> 16; 76 *buf++ = readl(this->IO_ADDR_R) >> 16;
@@ -94,7 +94,7 @@ static void nand_cs_off(void)
94static void cmx270_hwcontrol(struct mtd_info *mtd, int dat, 94static void cmx270_hwcontrol(struct mtd_info *mtd, int dat,
95 unsigned int ctrl) 95 unsigned int ctrl)
96{ 96{
97 struct nand_chip* this = mtd->priv; 97 struct nand_chip *this = mtd_to_nand(mtd);
98 unsigned int nandaddr = (unsigned int)this->IO_ADDR_W; 98 unsigned int nandaddr = (unsigned int)this->IO_ADDR_W;
99 99
100 dsb(); 100 dsb();
diff --git a/drivers/mtd/nand/cs553x_nand.c b/drivers/mtd/nand/cs553x_nand.c
index aec6045058c7..8904d685b257 100644
--- a/drivers/mtd/nand/cs553x_nand.c
+++ b/drivers/mtd/nand/cs553x_nand.c
@@ -97,7 +97,7 @@
97 97
98static void cs553x_read_buf(struct mtd_info *mtd, u_char *buf, int len) 98static void cs553x_read_buf(struct mtd_info *mtd, u_char *buf, int len)
99{ 99{
100 struct nand_chip *this = mtd->priv; 100 struct nand_chip *this = mtd_to_nand(mtd);
101 101
102 while (unlikely(len > 0x800)) { 102 while (unlikely(len > 0x800)) {
103 memcpy_fromio(buf, this->IO_ADDR_R, 0x800); 103 memcpy_fromio(buf, this->IO_ADDR_R, 0x800);
@@ -109,7 +109,7 @@ static void cs553x_read_buf(struct mtd_info *mtd, u_char *buf, int len)
109 109
110static void cs553x_write_buf(struct mtd_info *mtd, const u_char *buf, int len) 110static void cs553x_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
111{ 111{
112 struct nand_chip *this = mtd->priv; 112 struct nand_chip *this = mtd_to_nand(mtd);
113 113
114 while (unlikely(len > 0x800)) { 114 while (unlikely(len > 0x800)) {
115 memcpy_toio(this->IO_ADDR_R, buf, 0x800); 115 memcpy_toio(this->IO_ADDR_R, buf, 0x800);
@@ -121,13 +121,13 @@ static void cs553x_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
121 121
122static unsigned char cs553x_read_byte(struct mtd_info *mtd) 122static unsigned char cs553x_read_byte(struct mtd_info *mtd)
123{ 123{
124 struct nand_chip *this = mtd->priv; 124 struct nand_chip *this = mtd_to_nand(mtd);
125 return readb(this->IO_ADDR_R); 125 return readb(this->IO_ADDR_R);
126} 126}
127 127
128static void cs553x_write_byte(struct mtd_info *mtd, u_char byte) 128static void cs553x_write_byte(struct mtd_info *mtd, u_char byte)
129{ 129{
130 struct nand_chip *this = mtd->priv; 130 struct nand_chip *this = mtd_to_nand(mtd);
131 int i = 100000; 131 int i = 100000;
132 132
133 while (i && readb(this->IO_ADDR_R + MM_NAND_STS) & CS_NAND_CTLR_BUSY) { 133 while (i && readb(this->IO_ADDR_R + MM_NAND_STS) & CS_NAND_CTLR_BUSY) {
@@ -140,7 +140,7 @@ static void cs553x_write_byte(struct mtd_info *mtd, u_char byte)
140static void cs553x_hwcontrol(struct mtd_info *mtd, int cmd, 140static void cs553x_hwcontrol(struct mtd_info *mtd, int cmd,
141 unsigned int ctrl) 141 unsigned int ctrl)
142{ 142{
143 struct nand_chip *this = mtd->priv; 143 struct nand_chip *this = mtd_to_nand(mtd);
144 void __iomem *mmio_base = this->IO_ADDR_R; 144 void __iomem *mmio_base = this->IO_ADDR_R;
145 if (ctrl & NAND_CTRL_CHANGE) { 145 if (ctrl & NAND_CTRL_CHANGE) {
146 unsigned char ctl = (ctrl & ~NAND_CTRL_CHANGE ) ^ 0x01; 146 unsigned char ctl = (ctrl & ~NAND_CTRL_CHANGE ) ^ 0x01;
@@ -152,7 +152,7 @@ static void cs553x_hwcontrol(struct mtd_info *mtd, int cmd,
152 152
153static int cs553x_device_ready(struct mtd_info *mtd) 153static int cs553x_device_ready(struct mtd_info *mtd)
154{ 154{
155 struct nand_chip *this = mtd->priv; 155 struct nand_chip *this = mtd_to_nand(mtd);
156 void __iomem *mmio_base = this->IO_ADDR_R; 156 void __iomem *mmio_base = this->IO_ADDR_R;
157 unsigned char foo = readb(mmio_base + MM_NAND_STS); 157 unsigned char foo = readb(mmio_base + MM_NAND_STS);
158 158
@@ -161,7 +161,7 @@ static int cs553x_device_ready(struct mtd_info *mtd)
161 161
162static void cs_enable_hwecc(struct mtd_info *mtd, int mode) 162static void cs_enable_hwecc(struct mtd_info *mtd, int mode)
163{ 163{
164 struct nand_chip *this = mtd->priv; 164 struct nand_chip *this = mtd_to_nand(mtd);
165 void __iomem *mmio_base = this->IO_ADDR_R; 165 void __iomem *mmio_base = this->IO_ADDR_R;
166 166
167 writeb(0x07, mmio_base + MM_NAND_ECC_CTL); 167 writeb(0x07, mmio_base + MM_NAND_ECC_CTL);
@@ -170,7 +170,7 @@ static void cs_enable_hwecc(struct mtd_info *mtd, int mode)
170static int cs_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code) 170static int cs_calculate_ecc(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code)
171{ 171{
172 uint32_t ecc; 172 uint32_t ecc;
173 struct nand_chip *this = mtd->priv; 173 struct nand_chip *this = mtd_to_nand(mtd);
174 void __iomem *mmio_base = this->IO_ADDR_R; 174 void __iomem *mmio_base = this->IO_ADDR_R;
175 175
176 ecc = readl(mmio_base + MM_NAND_STS); 176 ecc = readl(mmio_base + MM_NAND_STS);
@@ -337,7 +337,7 @@ static void __exit cs553x_cleanup(void)
337 if (!mtd) 337 if (!mtd)
338 continue; 338 continue;
339 339
340 this = cs553x_mtd[i]->priv; 340 this = mtd_to_nand(cs553x_mtd[i]);
341 mmio_base = this->IO_ADDR_R; 341 mmio_base = this->IO_ADDR_R;
342 342
343 /* Release resources, unregister device */ 343 /* Release resources, unregister device */
diff --git a/drivers/mtd/nand/davinci_nand.c b/drivers/mtd/nand/davinci_nand.c
index 8e351af31e53..b5978d58e1df 100644
--- a/drivers/mtd/nand/davinci_nand.c
+++ b/drivers/mtd/nand/davinci_nand.c
@@ -106,7 +106,7 @@ static void nand_davinci_hwcontrol(struct mtd_info *mtd, int cmd,
106{ 106{
107 struct davinci_nand_info *info = to_davinci_nand(mtd); 107 struct davinci_nand_info *info = to_davinci_nand(mtd);
108 uint32_t addr = info->current_cs; 108 uint32_t addr = info->current_cs;
109 struct nand_chip *nand = mtd->priv; 109 struct nand_chip *nand = mtd_to_nand(mtd);
110 110
111 /* Did the control lines change? */ 111 /* Did the control lines change? */
112 if (ctrl & NAND_CTRL_CHANGE) { 112 if (ctrl & NAND_CTRL_CHANGE) {
@@ -192,7 +192,7 @@ static int nand_davinci_calculate_1bit(struct mtd_info *mtd,
192static int nand_davinci_correct_1bit(struct mtd_info *mtd, u_char *dat, 192static int nand_davinci_correct_1bit(struct mtd_info *mtd, u_char *dat,
193 u_char *read_ecc, u_char *calc_ecc) 193 u_char *read_ecc, u_char *calc_ecc)
194{ 194{
195 struct nand_chip *chip = mtd->priv; 195 struct nand_chip *chip = mtd_to_nand(mtd);
196 uint32_t eccNand = read_ecc[0] | (read_ecc[1] << 8) | 196 uint32_t eccNand = read_ecc[0] | (read_ecc[1] << 8) |
197 (read_ecc[2] << 16); 197 (read_ecc[2] << 16);
198 uint32_t eccCalc = calc_ecc[0] | (calc_ecc[1] << 8) | 198 uint32_t eccCalc = calc_ecc[0] | (calc_ecc[1] << 8) |
@@ -447,7 +447,7 @@ correct:
447 */ 447 */
448static void nand_davinci_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) 448static void nand_davinci_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
449{ 449{
450 struct nand_chip *chip = mtd->priv; 450 struct nand_chip *chip = mtd_to_nand(mtd);
451 451
452 if ((0x03 & ((unsigned)buf)) == 0 && (0x03 & len) == 0) 452 if ((0x03 & ((unsigned)buf)) == 0 && (0x03 & len) == 0)
453 ioread32_rep(chip->IO_ADDR_R, buf, len >> 2); 453 ioread32_rep(chip->IO_ADDR_R, buf, len >> 2);
@@ -460,7 +460,7 @@ static void nand_davinci_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
460static void nand_davinci_write_buf(struct mtd_info *mtd, 460static void nand_davinci_write_buf(struct mtd_info *mtd,
461 const uint8_t *buf, int len) 461 const uint8_t *buf, int len)
462{ 462{
463 struct nand_chip *chip = mtd->priv; 463 struct nand_chip *chip = mtd_to_nand(mtd);
464 464
465 if ((0x03 & ((unsigned)buf)) == 0 && (0x03 & len) == 0) 465 if ((0x03 & ((unsigned)buf)) == 0 && (0x03 & len) == 0)
466 iowrite32_rep(chip->IO_ADDR_R, buf, len >> 2); 466 iowrite32_rep(chip->IO_ADDR_R, buf, len >> 2);
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c
index 0802158a3f75..5f7bcc86486e 100644
--- a/drivers/mtd/nand/diskonchip.c
+++ b/drivers/mtd/nand/diskonchip.c
@@ -299,7 +299,7 @@ static inline int DoC_WaitReady(struct doc_priv *doc)
299 299
300static void doc2000_write_byte(struct mtd_info *mtd, u_char datum) 300static void doc2000_write_byte(struct mtd_info *mtd, u_char datum)
301{ 301{
302 struct nand_chip *this = mtd->priv; 302 struct nand_chip *this = mtd_to_nand(mtd);
303 struct doc_priv *doc = this->priv; 303 struct doc_priv *doc = this->priv;
304 void __iomem *docptr = doc->virtadr; 304 void __iomem *docptr = doc->virtadr;
305 305
@@ -311,7 +311,7 @@ static void doc2000_write_byte(struct mtd_info *mtd, u_char datum)
311 311
312static u_char doc2000_read_byte(struct mtd_info *mtd) 312static u_char doc2000_read_byte(struct mtd_info *mtd)
313{ 313{
314 struct nand_chip *this = mtd->priv; 314 struct nand_chip *this = mtd_to_nand(mtd);
315 struct doc_priv *doc = this->priv; 315 struct doc_priv *doc = this->priv;
316 void __iomem *docptr = doc->virtadr; 316 void __iomem *docptr = doc->virtadr;
317 u_char ret; 317 u_char ret;
@@ -326,7 +326,7 @@ static u_char doc2000_read_byte(struct mtd_info *mtd)
326 326
327static void doc2000_writebuf(struct mtd_info *mtd, const u_char *buf, int len) 327static void doc2000_writebuf(struct mtd_info *mtd, const u_char *buf, int len)
328{ 328{
329 struct nand_chip *this = mtd->priv; 329 struct nand_chip *this = mtd_to_nand(mtd);
330 struct doc_priv *doc = this->priv; 330 struct doc_priv *doc = this->priv;
331 void __iomem *docptr = doc->virtadr; 331 void __iomem *docptr = doc->virtadr;
332 int i; 332 int i;
@@ -343,7 +343,7 @@ static void doc2000_writebuf(struct mtd_info *mtd, const u_char *buf, int len)
343 343
344static void doc2000_readbuf(struct mtd_info *mtd, u_char *buf, int len) 344static void doc2000_readbuf(struct mtd_info *mtd, u_char *buf, int len)
345{ 345{
346 struct nand_chip *this = mtd->priv; 346 struct nand_chip *this = mtd_to_nand(mtd);
347 struct doc_priv *doc = this->priv; 347 struct doc_priv *doc = this->priv;
348 void __iomem *docptr = doc->virtadr; 348 void __iomem *docptr = doc->virtadr;
349 int i; 349 int i;
@@ -358,7 +358,7 @@ static void doc2000_readbuf(struct mtd_info *mtd, u_char *buf, int len)
358 358
359static void doc2000_readbuf_dword(struct mtd_info *mtd, u_char *buf, int len) 359static void doc2000_readbuf_dword(struct mtd_info *mtd, u_char *buf, int len)
360{ 360{
361 struct nand_chip *this = mtd->priv; 361 struct nand_chip *this = mtd_to_nand(mtd);
362 struct doc_priv *doc = this->priv; 362 struct doc_priv *doc = this->priv;
363 void __iomem *docptr = doc->virtadr; 363 void __iomem *docptr = doc->virtadr;
364 int i; 364 int i;
@@ -379,7 +379,7 @@ static void doc2000_readbuf_dword(struct mtd_info *mtd, u_char *buf, int len)
379 379
380static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr) 380static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr)
381{ 381{
382 struct nand_chip *this = mtd->priv; 382 struct nand_chip *this = mtd_to_nand(mtd);
383 struct doc_priv *doc = this->priv; 383 struct doc_priv *doc = this->priv;
384 uint16_t ret; 384 uint16_t ret;
385 385
@@ -425,7 +425,7 @@ static uint16_t __init doc200x_ident_chip(struct mtd_info *mtd, int nr)
425 425
426static void __init doc2000_count_chips(struct mtd_info *mtd) 426static void __init doc2000_count_chips(struct mtd_info *mtd)
427{ 427{
428 struct nand_chip *this = mtd->priv; 428 struct nand_chip *this = mtd_to_nand(mtd);
429 struct doc_priv *doc = this->priv; 429 struct doc_priv *doc = this->priv;
430 uint16_t mfrid; 430 uint16_t mfrid;
431 int i; 431 int i;
@@ -461,7 +461,7 @@ static int doc200x_wait(struct mtd_info *mtd, struct nand_chip *this)
461 461
462static void doc2001_write_byte(struct mtd_info *mtd, u_char datum) 462static void doc2001_write_byte(struct mtd_info *mtd, u_char datum)
463{ 463{
464 struct nand_chip *this = mtd->priv; 464 struct nand_chip *this = mtd_to_nand(mtd);
465 struct doc_priv *doc = this->priv; 465 struct doc_priv *doc = this->priv;
466 void __iomem *docptr = doc->virtadr; 466 void __iomem *docptr = doc->virtadr;
467 467
@@ -472,7 +472,7 @@ static void doc2001_write_byte(struct mtd_info *mtd, u_char datum)
472 472
473static u_char doc2001_read_byte(struct mtd_info *mtd) 473static u_char doc2001_read_byte(struct mtd_info *mtd)
474{ 474{
475 struct nand_chip *this = mtd->priv; 475 struct nand_chip *this = mtd_to_nand(mtd);
476 struct doc_priv *doc = this->priv; 476 struct doc_priv *doc = this->priv;
477 void __iomem *docptr = doc->virtadr; 477 void __iomem *docptr = doc->virtadr;
478 478
@@ -486,7 +486,7 @@ static u_char doc2001_read_byte(struct mtd_info *mtd)
486 486
487static void doc2001_writebuf(struct mtd_info *mtd, const u_char *buf, int len) 487static void doc2001_writebuf(struct mtd_info *mtd, const u_char *buf, int len)
488{ 488{
489 struct nand_chip *this = mtd->priv; 489 struct nand_chip *this = mtd_to_nand(mtd);
490 struct doc_priv *doc = this->priv; 490 struct doc_priv *doc = this->priv;
491 void __iomem *docptr = doc->virtadr; 491 void __iomem *docptr = doc->virtadr;
492 int i; 492 int i;
@@ -499,7 +499,7 @@ static void doc2001_writebuf(struct mtd_info *mtd, const u_char *buf, int len)
499 499
500static void doc2001_readbuf(struct mtd_info *mtd, u_char *buf, int len) 500static void doc2001_readbuf(struct mtd_info *mtd, u_char *buf, int len)
501{ 501{
502 struct nand_chip *this = mtd->priv; 502 struct nand_chip *this = mtd_to_nand(mtd);
503 struct doc_priv *doc = this->priv; 503 struct doc_priv *doc = this->priv;
504 void __iomem *docptr = doc->virtadr; 504 void __iomem *docptr = doc->virtadr;
505 int i; 505 int i;
@@ -516,7 +516,7 @@ static void doc2001_readbuf(struct mtd_info *mtd, u_char *buf, int len)
516 516
517static u_char doc2001plus_read_byte(struct mtd_info *mtd) 517static u_char doc2001plus_read_byte(struct mtd_info *mtd)
518{ 518{
519 struct nand_chip *this = mtd->priv; 519 struct nand_chip *this = mtd_to_nand(mtd);
520 struct doc_priv *doc = this->priv; 520 struct doc_priv *doc = this->priv;
521 void __iomem *docptr = doc->virtadr; 521 void __iomem *docptr = doc->virtadr;
522 u_char ret; 522 u_char ret;
@@ -531,7 +531,7 @@ static u_char doc2001plus_read_byte(struct mtd_info *mtd)
531 531
532static void doc2001plus_writebuf(struct mtd_info *mtd, const u_char *buf, int len) 532static void doc2001plus_writebuf(struct mtd_info *mtd, const u_char *buf, int len)
533{ 533{
534 struct nand_chip *this = mtd->priv; 534 struct nand_chip *this = mtd_to_nand(mtd);
535 struct doc_priv *doc = this->priv; 535 struct doc_priv *doc = this->priv;
536 void __iomem *docptr = doc->virtadr; 536 void __iomem *docptr = doc->virtadr;
537 int i; 537 int i;
@@ -549,7 +549,7 @@ static void doc2001plus_writebuf(struct mtd_info *mtd, const u_char *buf, int le
549 549
550static void doc2001plus_readbuf(struct mtd_info *mtd, u_char *buf, int len) 550static void doc2001plus_readbuf(struct mtd_info *mtd, u_char *buf, int len)
551{ 551{
552 struct nand_chip *this = mtd->priv; 552 struct nand_chip *this = mtd_to_nand(mtd);
553 struct doc_priv *doc = this->priv; 553 struct doc_priv *doc = this->priv;
554 void __iomem *docptr = doc->virtadr; 554 void __iomem *docptr = doc->virtadr;
555 int i; 555 int i;
@@ -580,7 +580,7 @@ static void doc2001plus_readbuf(struct mtd_info *mtd, u_char *buf, int len)
580 580
581static void doc2001plus_select_chip(struct mtd_info *mtd, int chip) 581static void doc2001plus_select_chip(struct mtd_info *mtd, int chip)
582{ 582{
583 struct nand_chip *this = mtd->priv; 583 struct nand_chip *this = mtd_to_nand(mtd);
584 struct doc_priv *doc = this->priv; 584 struct doc_priv *doc = this->priv;
585 void __iomem *docptr = doc->virtadr; 585 void __iomem *docptr = doc->virtadr;
586 int floor = 0; 586 int floor = 0;
@@ -607,7 +607,7 @@ static void doc2001plus_select_chip(struct mtd_info *mtd, int chip)
607 607
608static void doc200x_select_chip(struct mtd_info *mtd, int chip) 608static void doc200x_select_chip(struct mtd_info *mtd, int chip)
609{ 609{
610 struct nand_chip *this = mtd->priv; 610 struct nand_chip *this = mtd_to_nand(mtd);
611 struct doc_priv *doc = this->priv; 611 struct doc_priv *doc = this->priv;
612 void __iomem *docptr = doc->virtadr; 612 void __iomem *docptr = doc->virtadr;
613 int floor = 0; 613 int floor = 0;
@@ -638,7 +638,7 @@ static void doc200x_select_chip(struct mtd_info *mtd, int chip)
638static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd, 638static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd,
639 unsigned int ctrl) 639 unsigned int ctrl)
640{ 640{
641 struct nand_chip *this = mtd->priv; 641 struct nand_chip *this = mtd_to_nand(mtd);
642 struct doc_priv *doc = this->priv; 642 struct doc_priv *doc = this->priv;
643 void __iomem *docptr = doc->virtadr; 643 void __iomem *docptr = doc->virtadr;
644 644
@@ -661,7 +661,7 @@ static void doc200x_hwcontrol(struct mtd_info *mtd, int cmd,
661 661
662static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int column, int page_addr) 662static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int column, int page_addr)
663{ 663{
664 struct nand_chip *this = mtd->priv; 664 struct nand_chip *this = mtd_to_nand(mtd);
665 struct doc_priv *doc = this->priv; 665 struct doc_priv *doc = this->priv;
666 void __iomem *docptr = doc->virtadr; 666 void __iomem *docptr = doc->virtadr;
667 667
@@ -767,7 +767,7 @@ static void doc2001plus_command(struct mtd_info *mtd, unsigned command, int colu
767 767
768static int doc200x_dev_ready(struct mtd_info *mtd) 768static int doc200x_dev_ready(struct mtd_info *mtd)
769{ 769{
770 struct nand_chip *this = mtd->priv; 770 struct nand_chip *this = mtd_to_nand(mtd);
771 struct doc_priv *doc = this->priv; 771 struct doc_priv *doc = this->priv;
772 void __iomem *docptr = doc->virtadr; 772 void __iomem *docptr = doc->virtadr;
773 773
@@ -807,7 +807,7 @@ static int doc200x_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
807 807
808static void doc200x_enable_hwecc(struct mtd_info *mtd, int mode) 808static void doc200x_enable_hwecc(struct mtd_info *mtd, int mode)
809{ 809{
810 struct nand_chip *this = mtd->priv; 810 struct nand_chip *this = mtd_to_nand(mtd);
811 struct doc_priv *doc = this->priv; 811 struct doc_priv *doc = this->priv;
812 void __iomem *docptr = doc->virtadr; 812 void __iomem *docptr = doc->virtadr;
813 813
@@ -826,7 +826,7 @@ static void doc200x_enable_hwecc(struct mtd_info *mtd, int mode)
826 826
827static void doc2001plus_enable_hwecc(struct mtd_info *mtd, int mode) 827static void doc2001plus_enable_hwecc(struct mtd_info *mtd, int mode)
828{ 828{
829 struct nand_chip *this = mtd->priv; 829 struct nand_chip *this = mtd_to_nand(mtd);
830 struct doc_priv *doc = this->priv; 830 struct doc_priv *doc = this->priv;
831 void __iomem *docptr = doc->virtadr; 831 void __iomem *docptr = doc->virtadr;
832 832
@@ -846,7 +846,7 @@ static void doc2001plus_enable_hwecc(struct mtd_info *mtd, int mode)
846/* This code is only called on write */ 846/* This code is only called on write */
847static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, unsigned char *ecc_code) 847static int doc200x_calculate_ecc(struct mtd_info *mtd, const u_char *dat, unsigned char *ecc_code)
848{ 848{
849 struct nand_chip *this = mtd->priv; 849 struct nand_chip *this = mtd_to_nand(mtd);
850 struct doc_priv *doc = this->priv; 850 struct doc_priv *doc = this->priv;
851 void __iomem *docptr = doc->virtadr; 851 void __iomem *docptr = doc->virtadr;
852 int i; 852 int i;
@@ -907,7 +907,7 @@ static int doc200x_correct_data(struct mtd_info *mtd, u_char *dat,
907 u_char *read_ecc, u_char *isnull) 907 u_char *read_ecc, u_char *isnull)
908{ 908{
909 int i, ret = 0; 909 int i, ret = 0;
910 struct nand_chip *this = mtd->priv; 910 struct nand_chip *this = mtd_to_nand(mtd);
911 struct doc_priv *doc = this->priv; 911 struct doc_priv *doc = this->priv;
912 void __iomem *docptr = doc->virtadr; 912 void __iomem *docptr = doc->virtadr;
913 uint8_t calc_ecc[6]; 913 uint8_t calc_ecc[6];
@@ -1007,7 +1007,7 @@ static struct nand_ecclayout doc200x_oobinfo = {
1007 mh1_page in the DOC private structure. */ 1007 mh1_page in the DOC private structure. */
1008static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const char *id, int findmirror) 1008static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const char *id, int findmirror)
1009{ 1009{
1010 struct nand_chip *this = mtd->priv; 1010 struct nand_chip *this = mtd_to_nand(mtd);
1011 struct doc_priv *doc = this->priv; 1011 struct doc_priv *doc = this->priv;
1012 unsigned offs; 1012 unsigned offs;
1013 int ret; 1013 int ret;
@@ -1050,7 +1050,7 @@ static int __init find_media_headers(struct mtd_info *mtd, u_char *buf, const ch
1050 1050
1051static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts) 1051static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts)
1052{ 1052{
1053 struct nand_chip *this = mtd->priv; 1053 struct nand_chip *this = mtd_to_nand(mtd);
1054 struct doc_priv *doc = this->priv; 1054 struct doc_priv *doc = this->priv;
1055 int ret = 0; 1055 int ret = 0;
1056 u_char *buf; 1056 u_char *buf;
@@ -1152,7 +1152,7 @@ static inline int __init nftl_partscan(struct mtd_info *mtd, struct mtd_partitio
1152/* This is a stripped-down copy of the code in inftlmount.c */ 1152/* This is a stripped-down copy of the code in inftlmount.c */
1153static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts) 1153static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partition *parts)
1154{ 1154{
1155 struct nand_chip *this = mtd->priv; 1155 struct nand_chip *this = mtd_to_nand(mtd);
1156 struct doc_priv *doc = this->priv; 1156 struct doc_priv *doc = this->priv;
1157 int ret = 0; 1157 int ret = 0;
1158 u_char *buf; 1158 u_char *buf;
@@ -1272,7 +1272,7 @@ static inline int __init inftl_partscan(struct mtd_info *mtd, struct mtd_partiti
1272static int __init nftl_scan_bbt(struct mtd_info *mtd) 1272static int __init nftl_scan_bbt(struct mtd_info *mtd)
1273{ 1273{
1274 int ret, numparts; 1274 int ret, numparts;
1275 struct nand_chip *this = mtd->priv; 1275 struct nand_chip *this = mtd_to_nand(mtd);
1276 struct doc_priv *doc = this->priv; 1276 struct doc_priv *doc = this->priv;
1277 struct mtd_partition parts[2]; 1277 struct mtd_partition parts[2];
1278 1278
@@ -1307,7 +1307,7 @@ static int __init nftl_scan_bbt(struct mtd_info *mtd)
1307static int __init inftl_scan_bbt(struct mtd_info *mtd) 1307static int __init inftl_scan_bbt(struct mtd_info *mtd)
1308{ 1308{
1309 int ret, numparts; 1309 int ret, numparts;
1310 struct nand_chip *this = mtd->priv; 1310 struct nand_chip *this = mtd_to_nand(mtd);
1311 struct doc_priv *doc = this->priv; 1311 struct doc_priv *doc = this->priv;
1312 struct mtd_partition parts[5]; 1312 struct mtd_partition parts[5];
1313 1313
@@ -1360,7 +1360,7 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd)
1360 1360
1361static inline int __init doc2000_init(struct mtd_info *mtd) 1361static inline int __init doc2000_init(struct mtd_info *mtd)
1362{ 1362{
1363 struct nand_chip *this = mtd->priv; 1363 struct nand_chip *this = mtd_to_nand(mtd);
1364 struct doc_priv *doc = this->priv; 1364 struct doc_priv *doc = this->priv;
1365 1365
1366 this->read_byte = doc2000_read_byte; 1366 this->read_byte = doc2000_read_byte;
@@ -1376,7 +1376,7 @@ static inline int __init doc2000_init(struct mtd_info *mtd)
1376 1376
1377static inline int __init doc2001_init(struct mtd_info *mtd) 1377static inline int __init doc2001_init(struct mtd_info *mtd)
1378{ 1378{
1379 struct nand_chip *this = mtd->priv; 1379 struct nand_chip *this = mtd_to_nand(mtd);
1380 struct doc_priv *doc = this->priv; 1380 struct doc_priv *doc = this->priv;
1381 1381
1382 this->read_byte = doc2001_read_byte; 1382 this->read_byte = doc2001_read_byte;
@@ -1406,7 +1406,7 @@ static inline int __init doc2001_init(struct mtd_info *mtd)
1406 1406
1407static inline int __init doc2001plus_init(struct mtd_info *mtd) 1407static inline int __init doc2001plus_init(struct mtd_info *mtd)
1408{ 1408{
1409 struct nand_chip *this = mtd->priv; 1409 struct nand_chip *this = mtd_to_nand(mtd);
1410 struct doc_priv *doc = this->priv; 1410 struct doc_priv *doc = this->priv;
1411 1411
1412 this->read_byte = doc2001plus_read_byte; 1412 this->read_byte = doc2001plus_read_byte;
@@ -1523,7 +1523,7 @@ static int __init doc_probe(unsigned long physadr)
1523 for (mtd = doclist; mtd; mtd = doc->nextdoc) { 1523 for (mtd = doclist; mtd; mtd = doc->nextdoc) {
1524 unsigned char oldval; 1524 unsigned char oldval;
1525 unsigned char newval; 1525 unsigned char newval;
1526 nand = mtd->priv; 1526 nand = mtd_to_nand(mtd);
1527 doc = nand->priv; 1527 doc = nand->priv;
1528 /* Use the alias resolution register to determine if this is 1528 /* Use the alias resolution register to determine if this is
1529 in fact the same DOC aliased to a new address. If writes 1529 in fact the same DOC aliased to a new address. If writes
@@ -1643,7 +1643,7 @@ static void release_nanddoc(void)
1643 struct doc_priv *doc; 1643 struct doc_priv *doc;
1644 1644
1645 for (mtd = doclist; mtd; mtd = nextmtd) { 1645 for (mtd = doclist; mtd; mtd = nextmtd) {
1646 nand = mtd->priv; 1646 nand = mtd_to_nand(mtd);
1647 doc = nand->priv; 1647 doc = nand->priv;
1648 1648
1649 nextmtd = doc->nextdoc; 1649 nextmtd = doc->nextdoc;
diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
index 408cf69b854b..da93d7f5c821 100644
--- a/drivers/mtd/nand/docg4.c
+++ b/drivers/mtd/nand/docg4.c
@@ -242,7 +242,7 @@ static inline void write_nop(void __iomem *docptr)
242static void docg4_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) 242static void docg4_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
243{ 243{
244 int i; 244 int i;
245 struct nand_chip *nand = mtd->priv; 245 struct nand_chip *nand = mtd_to_nand(mtd);
246 uint16_t *p = (uint16_t *) buf; 246 uint16_t *p = (uint16_t *) buf;
247 len >>= 1; 247 len >>= 1;
248 248
@@ -253,7 +253,7 @@ static void docg4_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
253static void docg4_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len) 253static void docg4_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len)
254{ 254{
255 int i; 255 int i;
256 struct nand_chip *nand = mtd->priv; 256 struct nand_chip *nand = mtd_to_nand(mtd);
257 uint16_t *p = (uint16_t *) buf; 257 uint16_t *p = (uint16_t *) buf;
258 len >>= 1; 258 len >>= 1;
259 259
@@ -318,7 +318,7 @@ static void docg4_select_chip(struct mtd_info *mtd, int chip)
318 * Select among multiple cascaded chips ("floors"). Multiple floors are 318 * Select among multiple cascaded chips ("floors"). Multiple floors are
319 * not yet supported, so the only valid non-negative value is 0. 319 * not yet supported, so the only valid non-negative value is 0.
320 */ 320 */
321 struct nand_chip *nand = mtd->priv; 321 struct nand_chip *nand = mtd_to_nand(mtd);
322 struct docg4_priv *doc = nand->priv; 322 struct docg4_priv *doc = nand->priv;
323 void __iomem *docptr = doc->virtadr; 323 void __iomem *docptr = doc->virtadr;
324 324
@@ -337,7 +337,7 @@ static void reset(struct mtd_info *mtd)
337{ 337{
338 /* full device reset */ 338 /* full device reset */
339 339
340 struct nand_chip *nand = mtd->priv; 340 struct nand_chip *nand = mtd_to_nand(mtd);
341 struct docg4_priv *doc = nand->priv; 341 struct docg4_priv *doc = nand->priv;
342 void __iomem *docptr = doc->virtadr; 342 void __iomem *docptr = doc->virtadr;
343 343
@@ -375,7 +375,7 @@ static int correct_data(struct mtd_info *mtd, uint8_t *buf, int page)
375 * Up to four bitflips can be corrected. 375 * Up to four bitflips can be corrected.
376 */ 376 */
377 377
378 struct nand_chip *nand = mtd->priv; 378 struct nand_chip *nand = mtd_to_nand(mtd);
379 struct docg4_priv *doc = nand->priv; 379 struct docg4_priv *doc = nand->priv;
380 void __iomem *docptr = doc->virtadr; 380 void __iomem *docptr = doc->virtadr;
381 int i, numerrs, errpos[4]; 381 int i, numerrs, errpos[4];
@@ -464,7 +464,7 @@ static int correct_data(struct mtd_info *mtd, uint8_t *buf, int page)
464 464
465static uint8_t docg4_read_byte(struct mtd_info *mtd) 465static uint8_t docg4_read_byte(struct mtd_info *mtd)
466{ 466{
467 struct nand_chip *nand = mtd->priv; 467 struct nand_chip *nand = mtd_to_nand(mtd);
468 struct docg4_priv *doc = nand->priv; 468 struct docg4_priv *doc = nand->priv;
469 469
470 dev_dbg(doc->dev, "%s\n", __func__); 470 dev_dbg(doc->dev, "%s\n", __func__);
@@ -545,7 +545,7 @@ static int pageprog(struct mtd_info *mtd)
545 * internal buffer out to the flash array, or some such. 545 * internal buffer out to the flash array, or some such.
546 */ 546 */
547 547
548 struct nand_chip *nand = mtd->priv; 548 struct nand_chip *nand = mtd_to_nand(mtd);
549 struct docg4_priv *doc = nand->priv; 549 struct docg4_priv *doc = nand->priv;
550 void __iomem *docptr = doc->virtadr; 550 void __iomem *docptr = doc->virtadr;
551 int retval = 0; 551 int retval = 0;
@@ -582,7 +582,7 @@ static void sequence_reset(struct mtd_info *mtd)
582{ 582{
583 /* common starting sequence for all operations */ 583 /* common starting sequence for all operations */
584 584
585 struct nand_chip *nand = mtd->priv; 585 struct nand_chip *nand = mtd_to_nand(mtd);
586 struct docg4_priv *doc = nand->priv; 586 struct docg4_priv *doc = nand->priv;
587 void __iomem *docptr = doc->virtadr; 587 void __iomem *docptr = doc->virtadr;
588 588
@@ -599,7 +599,7 @@ static void read_page_prologue(struct mtd_info *mtd, uint32_t docg4_addr)
599{ 599{
600 /* first step in reading a page */ 600 /* first step in reading a page */
601 601
602 struct nand_chip *nand = mtd->priv; 602 struct nand_chip *nand = mtd_to_nand(mtd);
603 struct docg4_priv *doc = nand->priv; 603 struct docg4_priv *doc = nand->priv;
604 void __iomem *docptr = doc->virtadr; 604 void __iomem *docptr = doc->virtadr;
605 605
@@ -626,7 +626,7 @@ static void write_page_prologue(struct mtd_info *mtd, uint32_t docg4_addr)
626{ 626{
627 /* first step in writing a page */ 627 /* first step in writing a page */
628 628
629 struct nand_chip *nand = mtd->priv; 629 struct nand_chip *nand = mtd_to_nand(mtd);
630 struct docg4_priv *doc = nand->priv; 630 struct docg4_priv *doc = nand->priv;
631 void __iomem *docptr = doc->virtadr; 631 void __iomem *docptr = doc->virtadr;
632 632
@@ -691,7 +691,7 @@ static void docg4_command(struct mtd_info *mtd, unsigned command, int column,
691{ 691{
692 /* handle standard nand commands */ 692 /* handle standard nand commands */
693 693
694 struct nand_chip *nand = mtd->priv; 694 struct nand_chip *nand = mtd_to_nand(mtd);
695 struct docg4_priv *doc = nand->priv; 695 struct docg4_priv *doc = nand->priv;
696 uint32_t g4_addr = mtd_to_docg4_address(page_addr, column); 696 uint32_t g4_addr = mtd_to_docg4_address(page_addr, column);
697 697
@@ -874,7 +874,7 @@ static int docg4_read_oob(struct mtd_info *mtd, struct nand_chip *nand,
874 874
875static int docg4_erase_block(struct mtd_info *mtd, int page) 875static int docg4_erase_block(struct mtd_info *mtd, int page)
876{ 876{
877 struct nand_chip *nand = mtd->priv; 877 struct nand_chip *nand = mtd_to_nand(mtd);
878 struct docg4_priv *doc = nand->priv; 878 struct docg4_priv *doc = nand->priv;
879 void __iomem *docptr = doc->virtadr; 879 void __iomem *docptr = doc->virtadr;
880 uint16_t g4_page; 880 uint16_t g4_page;
@@ -1016,7 +1016,7 @@ static int __init read_factory_bbt(struct mtd_info *mtd)
1016 * update the memory-based bbt accordingly. 1016 * update the memory-based bbt accordingly.
1017 */ 1017 */
1018 1018
1019 struct nand_chip *nand = mtd->priv; 1019 struct nand_chip *nand = mtd_to_nand(mtd);
1020 struct docg4_priv *doc = nand->priv; 1020 struct docg4_priv *doc = nand->priv;
1021 uint32_t g4_addr = mtd_to_docg4_address(DOCG4_FACTORY_BBT_PAGE, 0); 1021 uint32_t g4_addr = mtd_to_docg4_address(DOCG4_FACTORY_BBT_PAGE, 0);
1022 uint8_t *buf; 1022 uint8_t *buf;
@@ -1089,7 +1089,7 @@ static int docg4_block_markbad(struct mtd_info *mtd, loff_t ofs)
1089 1089
1090 int ret, i; 1090 int ret, i;
1091 uint8_t *buf; 1091 uint8_t *buf;
1092 struct nand_chip *nand = mtd->priv; 1092 struct nand_chip *nand = mtd_to_nand(mtd);
1093 struct docg4_priv *doc = nand->priv; 1093 struct docg4_priv *doc = nand->priv;
1094 struct nand_bbt_descr *bbtd = nand->badblock_pattern; 1094 struct nand_bbt_descr *bbtd = nand->badblock_pattern;
1095 int page = (int)(ofs >> nand->page_shift); 1095 int page = (int)(ofs >> nand->page_shift);
@@ -1202,7 +1202,7 @@ static void __init init_mtd_structs(struct mtd_info *mtd)
1202 * things as well, such as call nand_set_defaults(). 1202 * things as well, such as call nand_set_defaults().
1203 */ 1203 */
1204 1204
1205 struct nand_chip *nand = mtd->priv; 1205 struct nand_chip *nand = mtd_to_nand(mtd);
1206 struct docg4_priv *doc = nand->priv; 1206 struct docg4_priv *doc = nand->priv;
1207 1207
1208 mtd->size = DOCG4_CHIP_SIZE; 1208 mtd->size = DOCG4_CHIP_SIZE;
@@ -1261,7 +1261,7 @@ static void __init init_mtd_structs(struct mtd_info *mtd)
1261 1261
1262static int __init read_id_reg(struct mtd_info *mtd) 1262static int __init read_id_reg(struct mtd_info *mtd)
1263{ 1263{
1264 struct nand_chip *nand = mtd->priv; 1264 struct nand_chip *nand = mtd_to_nand(mtd);
1265 struct docg4_priv *doc = nand->priv; 1265 struct docg4_priv *doc = nand->priv;
1266 void __iomem *docptr = doc->virtadr; 1266 void __iomem *docptr = doc->virtadr;
1267 uint16_t id1, id2; 1267 uint16_t id1, id2;
@@ -1357,7 +1357,7 @@ static int __init probe_docg4(struct platform_device *pdev)
1357 iounmap(virtadr); 1357 iounmap(virtadr);
1358 if (mtd) { 1358 if (mtd) {
1359 /* re-declarations avoid compiler warning */ 1359 /* re-declarations avoid compiler warning */
1360 struct nand_chip *nand = mtd->priv; 1360 struct nand_chip *nand = mtd_to_nand(mtd);
1361 struct docg4_priv *doc = nand->priv; 1361 struct docg4_priv *doc = nand->priv;
1362 nand_release(mtd); /* deletes partitions and mtd devices */ 1362 nand_release(mtd); /* deletes partitions and mtd devices */
1363 free_bch(doc->bch); 1363 free_bch(doc->bch);
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index bd6d49376382..ad6d5daacb83 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -144,7 +144,7 @@ static struct nand_bbt_descr bbt_mirror_descr = {
144 */ 144 */
145static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob) 145static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob)
146{ 146{
147 struct nand_chip *chip = mtd->priv; 147 struct nand_chip *chip = mtd_to_nand(mtd);
148 struct fsl_elbc_mtd *priv = chip->priv; 148 struct fsl_elbc_mtd *priv = chip->priv;
149 struct fsl_lbc_ctrl *ctrl = priv->ctrl; 149 struct fsl_lbc_ctrl *ctrl = priv->ctrl;
150 struct fsl_lbc_regs __iomem *lbc = ctrl->regs; 150 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
@@ -195,7 +195,7 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob)
195 */ 195 */
196static int fsl_elbc_run_command(struct mtd_info *mtd) 196static int fsl_elbc_run_command(struct mtd_info *mtd)
197{ 197{
198 struct nand_chip *chip = mtd->priv; 198 struct nand_chip *chip = mtd_to_nand(mtd);
199 struct fsl_elbc_mtd *priv = chip->priv; 199 struct fsl_elbc_mtd *priv = chip->priv;
200 struct fsl_lbc_ctrl *ctrl = priv->ctrl; 200 struct fsl_lbc_ctrl *ctrl = priv->ctrl;
201 struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = ctrl->nand; 201 struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = ctrl->nand;
@@ -300,7 +300,7 @@ static void fsl_elbc_do_read(struct nand_chip *chip, int oob)
300static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command, 300static void fsl_elbc_cmdfunc(struct mtd_info *mtd, unsigned int command,
301 int column, int page_addr) 301 int column, int page_addr)
302{ 302{
303 struct nand_chip *chip = mtd->priv; 303 struct nand_chip *chip = mtd_to_nand(mtd);
304 struct fsl_elbc_mtd *priv = chip->priv; 304 struct fsl_elbc_mtd *priv = chip->priv;
305 struct fsl_lbc_ctrl *ctrl = priv->ctrl; 305 struct fsl_lbc_ctrl *ctrl = priv->ctrl;
306 struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = ctrl->nand; 306 struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = ctrl->nand;
@@ -525,7 +525,7 @@ static void fsl_elbc_select_chip(struct mtd_info *mtd, int chip)
525 */ 525 */
526static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len) 526static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
527{ 527{
528 struct nand_chip *chip = mtd->priv; 528 struct nand_chip *chip = mtd_to_nand(mtd);
529 struct fsl_elbc_mtd *priv = chip->priv; 529 struct fsl_elbc_mtd *priv = chip->priv;
530 struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand; 530 struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
531 unsigned int bufsize = mtd->writesize + mtd->oobsize; 531 unsigned int bufsize = mtd->writesize + mtd->oobsize;
@@ -563,7 +563,7 @@ static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
563 */ 563 */
564static u8 fsl_elbc_read_byte(struct mtd_info *mtd) 564static u8 fsl_elbc_read_byte(struct mtd_info *mtd)
565{ 565{
566 struct nand_chip *chip = mtd->priv; 566 struct nand_chip *chip = mtd_to_nand(mtd);
567 struct fsl_elbc_mtd *priv = chip->priv; 567 struct fsl_elbc_mtd *priv = chip->priv;
568 struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand; 568 struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
569 569
@@ -580,7 +580,7 @@ static u8 fsl_elbc_read_byte(struct mtd_info *mtd)
580 */ 580 */
581static void fsl_elbc_read_buf(struct mtd_info *mtd, u8 *buf, int len) 581static void fsl_elbc_read_buf(struct mtd_info *mtd, u8 *buf, int len)
582{ 582{
583 struct nand_chip *chip = mtd->priv; 583 struct nand_chip *chip = mtd_to_nand(mtd);
584 struct fsl_elbc_mtd *priv = chip->priv; 584 struct fsl_elbc_mtd *priv = chip->priv;
585 struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand; 585 struct fsl_elbc_fcm_ctrl *elbc_fcm_ctrl = priv->ctrl->nand;
586 int avail; 586 int avail;
@@ -619,7 +619,7 @@ static int fsl_elbc_wait(struct mtd_info *mtd, struct nand_chip *chip)
619 619
620static int fsl_elbc_chip_init_tail(struct mtd_info *mtd) 620static int fsl_elbc_chip_init_tail(struct mtd_info *mtd)
621{ 621{
622 struct nand_chip *chip = mtd->priv; 622 struct nand_chip *chip = mtd_to_nand(mtd);
623 struct fsl_elbc_mtd *priv = chip->priv; 623 struct fsl_elbc_mtd *priv = chip->priv;
624 struct fsl_lbc_ctrl *ctrl = priv->ctrl; 624 struct fsl_lbc_ctrl *ctrl = priv->ctrl;
625 struct fsl_lbc_regs __iomem *lbc = ctrl->regs; 625 struct fsl_lbc_regs __iomem *lbc = ctrl->regs;
diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
index f2608315774a..3136842e88d5 100644
--- a/drivers/mtd/nand/fsl_ifc_nand.c
+++ b/drivers/mtd/nand/fsl_ifc_nand.c
@@ -230,7 +230,7 @@ static struct nand_bbt_descr bbt_mirror_descr = {
230 */ 230 */
231static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob) 231static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob)
232{ 232{
233 struct nand_chip *chip = mtd->priv; 233 struct nand_chip *chip = mtd_to_nand(mtd);
234 struct fsl_ifc_mtd *priv = chip->priv; 234 struct fsl_ifc_mtd *priv = chip->priv;
235 struct fsl_ifc_ctrl *ctrl = priv->ctrl; 235 struct fsl_ifc_ctrl *ctrl = priv->ctrl;
236 struct fsl_ifc_regs __iomem *ifc = ctrl->regs; 236 struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
@@ -253,7 +253,7 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob)
253 253
254static int is_blank(struct mtd_info *mtd, unsigned int bufnum) 254static int is_blank(struct mtd_info *mtd, unsigned int bufnum)
255{ 255{
256 struct nand_chip *chip = mtd->priv; 256 struct nand_chip *chip = mtd_to_nand(mtd);
257 struct fsl_ifc_mtd *priv = chip->priv; 257 struct fsl_ifc_mtd *priv = chip->priv;
258 u8 __iomem *addr = priv->vbase + bufnum * (mtd->writesize * 2); 258 u8 __iomem *addr = priv->vbase + bufnum * (mtd->writesize * 2);
259 u32 __iomem *mainarea = (u32 __iomem *)addr; 259 u32 __iomem *mainarea = (u32 __iomem *)addr;
@@ -292,7 +292,7 @@ static int check_read_ecc(struct mtd_info *mtd, struct fsl_ifc_ctrl *ctrl,
292 */ 292 */
293static void fsl_ifc_run_command(struct mtd_info *mtd) 293static void fsl_ifc_run_command(struct mtd_info *mtd)
294{ 294{
295 struct nand_chip *chip = mtd->priv; 295 struct nand_chip *chip = mtd_to_nand(mtd);
296 struct fsl_ifc_mtd *priv = chip->priv; 296 struct fsl_ifc_mtd *priv = chip->priv;
297 struct fsl_ifc_ctrl *ctrl = priv->ctrl; 297 struct fsl_ifc_ctrl *ctrl = priv->ctrl;
298 struct fsl_ifc_nand_ctrl *nctrl = ifc_nand_ctrl; 298 struct fsl_ifc_nand_ctrl *nctrl = ifc_nand_ctrl;
@@ -409,7 +409,7 @@ static void fsl_ifc_do_read(struct nand_chip *chip,
409/* cmdfunc send commands to the IFC NAND Machine */ 409/* cmdfunc send commands to the IFC NAND Machine */
410static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, 410static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command,
411 int column, int page_addr) { 411 int column, int page_addr) {
412 struct nand_chip *chip = mtd->priv; 412 struct nand_chip *chip = mtd_to_nand(mtd);
413 struct fsl_ifc_mtd *priv = chip->priv; 413 struct fsl_ifc_mtd *priv = chip->priv;
414 struct fsl_ifc_ctrl *ctrl = priv->ctrl; 414 struct fsl_ifc_ctrl *ctrl = priv->ctrl;
415 struct fsl_ifc_regs __iomem *ifc = ctrl->regs; 415 struct fsl_ifc_regs __iomem *ifc = ctrl->regs;
@@ -624,7 +624,7 @@ static void fsl_ifc_select_chip(struct mtd_info *mtd, int chip)
624 */ 624 */
625static void fsl_ifc_write_buf(struct mtd_info *mtd, const u8 *buf, int len) 625static void fsl_ifc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
626{ 626{
627 struct nand_chip *chip = mtd->priv; 627 struct nand_chip *chip = mtd_to_nand(mtd);
628 struct fsl_ifc_mtd *priv = chip->priv; 628 struct fsl_ifc_mtd *priv = chip->priv;
629 unsigned int bufsize = mtd->writesize + mtd->oobsize; 629 unsigned int bufsize = mtd->writesize + mtd->oobsize;
630 630
@@ -650,7 +650,7 @@ static void fsl_ifc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
650 */ 650 */
651static uint8_t fsl_ifc_read_byte(struct mtd_info *mtd) 651static uint8_t fsl_ifc_read_byte(struct mtd_info *mtd)
652{ 652{
653 struct nand_chip *chip = mtd->priv; 653 struct nand_chip *chip = mtd_to_nand(mtd);
654 struct fsl_ifc_mtd *priv = chip->priv; 654 struct fsl_ifc_mtd *priv = chip->priv;
655 unsigned int offset; 655 unsigned int offset;
656 656
@@ -673,7 +673,7 @@ static uint8_t fsl_ifc_read_byte(struct mtd_info *mtd)
673 */ 673 */
674static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd) 674static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd)
675{ 675{
676 struct nand_chip *chip = mtd->priv; 676 struct nand_chip *chip = mtd_to_nand(mtd);
677 struct fsl_ifc_mtd *priv = chip->priv; 677 struct fsl_ifc_mtd *priv = chip->priv;
678 uint16_t data; 678 uint16_t data;
679 679
@@ -696,7 +696,7 @@ static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd)
696 */ 696 */
697static void fsl_ifc_read_buf(struct mtd_info *mtd, u8 *buf, int len) 697static void fsl_ifc_read_buf(struct mtd_info *mtd, u8 *buf, int len)
698{ 698{
699 struct nand_chip *chip = mtd->priv; 699 struct nand_chip *chip = mtd_to_nand(mtd);
700 struct fsl_ifc_mtd *priv = chip->priv; 700 struct fsl_ifc_mtd *priv = chip->priv;
701 int avail; 701 int avail;
702 702
@@ -782,7 +782,7 @@ static int fsl_ifc_write_page(struct mtd_info *mtd, struct nand_chip *chip,
782 782
783static int fsl_ifc_chip_init_tail(struct mtd_info *mtd) 783static int fsl_ifc_chip_init_tail(struct mtd_info *mtd)
784{ 784{
785 struct nand_chip *chip = mtd->priv; 785 struct nand_chip *chip = mtd_to_nand(mtd);
786 struct fsl_ifc_mtd *priv = chip->priv; 786 struct fsl_ifc_mtd *priv = chip->priv;
787 787
788 dev_dbg(priv->dev, "%s: nand->numchips = %d\n", __func__, 788 dev_dbg(priv->dev, "%s: nand->numchips = %d\n", __func__,
diff --git a/drivers/mtd/nand/fsl_upm.c b/drivers/mtd/nand/fsl_upm.c
index b3f4a01621c1..68ec128e822c 100644
--- a/drivers/mtd/nand/fsl_upm.c
+++ b/drivers/mtd/nand/fsl_upm.c
@@ -79,7 +79,7 @@ static void fun_wait_rnb(struct fsl_upm_nand *fun)
79 79
80static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) 80static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
81{ 81{
82 struct nand_chip *chip = mtd->priv; 82 struct nand_chip *chip = mtd_to_nand(mtd);
83 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); 83 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
84 u32 mar; 84 u32 mar;
85 85
@@ -109,7 +109,7 @@ static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
109 109
110static void fun_select_chip(struct mtd_info *mtd, int mchip_nr) 110static void fun_select_chip(struct mtd_info *mtd, int mchip_nr)
111{ 111{
112 struct nand_chip *chip = mtd->priv; 112 struct nand_chip *chip = mtd_to_nand(mtd);
113 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd); 113 struct fsl_upm_nand *fun = to_fsl_upm_nand(mtd);
114 114
115 if (mchip_nr == -1) { 115 if (mchip_nr == -1) {
diff --git a/drivers/mtd/nand/fsmc_nand.c b/drivers/mtd/nand/fsmc_nand.c
index 59fc6d0c3910..1c6c399496c2 100644
--- a/drivers/mtd/nand/fsmc_nand.c
+++ b/drivers/mtd/nand/fsmc_nand.c
@@ -329,7 +329,7 @@ struct fsmc_nand_data {
329/* Assert CS signal based on chipnr */ 329/* Assert CS signal based on chipnr */
330static void fsmc_select_chip(struct mtd_info *mtd, int chipnr) 330static void fsmc_select_chip(struct mtd_info *mtd, int chipnr)
331{ 331{
332 struct nand_chip *chip = mtd->priv; 332 struct nand_chip *chip = mtd_to_nand(mtd);
333 struct fsmc_nand_data *host; 333 struct fsmc_nand_data *host;
334 334
335 host = container_of(mtd, struct fsmc_nand_data, mtd); 335 host = container_of(mtd, struct fsmc_nand_data, mtd);
@@ -358,7 +358,7 @@ static void fsmc_select_chip(struct mtd_info *mtd, int chipnr)
358 */ 358 */
359static void fsmc_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) 359static void fsmc_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
360{ 360{
361 struct nand_chip *this = mtd->priv; 361 struct nand_chip *this = mtd_to_nand(mtd);
362 struct fsmc_nand_data *host = container_of(mtd, 362 struct fsmc_nand_data *host = container_of(mtd,
363 struct fsmc_nand_data, mtd); 363 struct fsmc_nand_data, mtd);
364 void __iomem *regs = host->regs_va; 364 void __iomem *regs = host->regs_va;
@@ -629,7 +629,7 @@ unmap_dma:
629static void fsmc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) 629static void fsmc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
630{ 630{
631 int i; 631 int i;
632 struct nand_chip *chip = mtd->priv; 632 struct nand_chip *chip = mtd_to_nand(mtd);
633 633
634 if (IS_ALIGNED((uint32_t)buf, sizeof(uint32_t)) && 634 if (IS_ALIGNED((uint32_t)buf, sizeof(uint32_t)) &&
635 IS_ALIGNED(len, sizeof(uint32_t))) { 635 IS_ALIGNED(len, sizeof(uint32_t))) {
@@ -652,7 +652,7 @@ static void fsmc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
652static void fsmc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) 652static void fsmc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
653{ 653{
654 int i; 654 int i;
655 struct nand_chip *chip = mtd->priv; 655 struct nand_chip *chip = mtd_to_nand(mtd);
656 656
657 if (IS_ALIGNED((uint32_t)buf, sizeof(uint32_t)) && 657 if (IS_ALIGNED((uint32_t)buf, sizeof(uint32_t)) &&
658 IS_ALIGNED(len, sizeof(uint32_t))) { 658 IS_ALIGNED(len, sizeof(uint32_t))) {
@@ -784,7 +784,7 @@ static int fsmc_bch8_correct_data(struct mtd_info *mtd, uint8_t *dat,
784{ 784{
785 struct fsmc_nand_data *host = container_of(mtd, 785 struct fsmc_nand_data *host = container_of(mtd,
786 struct fsmc_nand_data, mtd); 786 struct fsmc_nand_data, mtd);
787 struct nand_chip *chip = mtd->priv; 787 struct nand_chip *chip = mtd_to_nand(mtd);
788 void __iomem *regs = host->regs_va; 788 void __iomem *regs = host->regs_va;
789 unsigned int bank = host->bank; 789 unsigned int bank = host->bank;
790 uint32_t err_idx[8]; 790 uint32_t err_idx[8];
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 5a9b6966e97c..802adb04bb97 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -140,7 +140,7 @@ static bool set_geometry_by_ecc_info(struct gpmi_nand_data *this)
140{ 140{
141 struct bch_geometry *geo = &this->bch_geometry; 141 struct bch_geometry *geo = &this->bch_geometry;
142 struct mtd_info *mtd = &this->mtd; 142 struct mtd_info *mtd = &this->mtd;
143 struct nand_chip *chip = mtd->priv; 143 struct nand_chip *chip = mtd_to_nand(mtd);
144 struct nand_oobfree *of = gpmi_hw_ecclayout.oobfree; 144 struct nand_oobfree *of = gpmi_hw_ecclayout.oobfree;
145 unsigned int block_mark_bit_offset; 145 unsigned int block_mark_bit_offset;
146 146
@@ -856,7 +856,7 @@ error_alloc:
856 856
857static void gpmi_cmd_ctrl(struct mtd_info *mtd, int data, unsigned int ctrl) 857static void gpmi_cmd_ctrl(struct mtd_info *mtd, int data, unsigned int ctrl)
858{ 858{
859 struct nand_chip *chip = mtd->priv; 859 struct nand_chip *chip = mtd_to_nand(mtd);
860 struct gpmi_nand_data *this = chip->priv; 860 struct gpmi_nand_data *this = chip->priv;
861 int ret; 861 int ret;
862 862
@@ -890,7 +890,7 @@ static void gpmi_cmd_ctrl(struct mtd_info *mtd, int data, unsigned int ctrl)
890 890
891static int gpmi_dev_ready(struct mtd_info *mtd) 891static int gpmi_dev_ready(struct mtd_info *mtd)
892{ 892{
893 struct nand_chip *chip = mtd->priv; 893 struct nand_chip *chip = mtd_to_nand(mtd);
894 struct gpmi_nand_data *this = chip->priv; 894 struct gpmi_nand_data *this = chip->priv;
895 895
896 return gpmi_is_ready(this, this->current_chip); 896 return gpmi_is_ready(this, this->current_chip);
@@ -898,7 +898,7 @@ static int gpmi_dev_ready(struct mtd_info *mtd)
898 898
899static void gpmi_select_chip(struct mtd_info *mtd, int chipnr) 899static void gpmi_select_chip(struct mtd_info *mtd, int chipnr)
900{ 900{
901 struct nand_chip *chip = mtd->priv; 901 struct nand_chip *chip = mtd_to_nand(mtd);
902 struct gpmi_nand_data *this = chip->priv; 902 struct gpmi_nand_data *this = chip->priv;
903 903
904 if ((this->current_chip < 0) && (chipnr >= 0)) 904 if ((this->current_chip < 0) && (chipnr >= 0))
@@ -911,7 +911,7 @@ static void gpmi_select_chip(struct mtd_info *mtd, int chipnr)
911 911
912static void gpmi_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) 912static void gpmi_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
913{ 913{
914 struct nand_chip *chip = mtd->priv; 914 struct nand_chip *chip = mtd_to_nand(mtd);
915 struct gpmi_nand_data *this = chip->priv; 915 struct gpmi_nand_data *this = chip->priv;
916 916
917 dev_dbg(this->dev, "len is %d\n", len); 917 dev_dbg(this->dev, "len is %d\n", len);
@@ -923,7 +923,7 @@ static void gpmi_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
923 923
924static void gpmi_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) 924static void gpmi_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
925{ 925{
926 struct nand_chip *chip = mtd->priv; 926 struct nand_chip *chip = mtd_to_nand(mtd);
927 struct gpmi_nand_data *this = chip->priv; 927 struct gpmi_nand_data *this = chip->priv;
928 928
929 dev_dbg(this->dev, "len is %d\n", len); 929 dev_dbg(this->dev, "len is %d\n", len);
@@ -935,7 +935,7 @@ static void gpmi_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
935 935
936static uint8_t gpmi_read_byte(struct mtd_info *mtd) 936static uint8_t gpmi_read_byte(struct mtd_info *mtd)
937{ 937{
938 struct nand_chip *chip = mtd->priv; 938 struct nand_chip *chip = mtd_to_nand(mtd);
939 struct gpmi_nand_data *this = chip->priv; 939 struct gpmi_nand_data *this = chip->priv;
940 uint8_t *buf = this->data_buffer_dma; 940 uint8_t *buf = this->data_buffer_dma;
941 941
@@ -1538,7 +1538,7 @@ static int gpmi_ecc_write_oob_raw(struct mtd_info *mtd, struct nand_chip *chip,
1538 1538
1539static int gpmi_block_markbad(struct mtd_info *mtd, loff_t ofs) 1539static int gpmi_block_markbad(struct mtd_info *mtd, loff_t ofs)
1540{ 1540{
1541 struct nand_chip *chip = mtd->priv; 1541 struct nand_chip *chip = mtd_to_nand(mtd);
1542 struct gpmi_nand_data *this = chip->priv; 1542 struct gpmi_nand_data *this = chip->priv;
1543 int ret = 0; 1543 int ret = 0;
1544 uint8_t *block_mark; 1544 uint8_t *block_mark;
@@ -1838,7 +1838,7 @@ static void gpmi_nand_exit(struct gpmi_nand_data *this)
1838static int gpmi_init_last(struct gpmi_nand_data *this) 1838static int gpmi_init_last(struct gpmi_nand_data *this)
1839{ 1839{
1840 struct mtd_info *mtd = &this->mtd; 1840 struct mtd_info *mtd = &this->mtd;
1841 struct nand_chip *chip = mtd->priv; 1841 struct nand_chip *chip = mtd_to_nand(mtd);
1842 struct nand_ecc_ctrl *ecc = &chip->ecc; 1842 struct nand_ecc_ctrl *ecc = &chip->ecc;
1843 struct bch_geometry *bch_geo = &this->bch_geometry; 1843 struct bch_geometry *bch_geo = &this->bch_geometry;
1844 int ret; 1844 int ret;
diff --git a/drivers/mtd/nand/hisi504_nand.c b/drivers/mtd/nand/hisi504_nand.c
index 0aad4acab9d6..6358d4ae7b75 100644
--- a/drivers/mtd/nand/hisi504_nand.c
+++ b/drivers/mtd/nand/hisi504_nand.c
@@ -190,7 +190,7 @@ static void wait_controller_finished(struct hinfc_host *host)
190static void hisi_nfc_dma_transfer(struct hinfc_host *host, int todev) 190static void hisi_nfc_dma_transfer(struct hinfc_host *host, int todev)
191{ 191{
192 struct mtd_info *mtd = &host->mtd; 192 struct mtd_info *mtd = &host->mtd;
193 struct nand_chip *chip = mtd->priv; 193 struct nand_chip *chip = mtd_to_nand(mtd);
194 unsigned long val; 194 unsigned long val;
195 int ret; 195 int ret;
196 196
@@ -357,7 +357,7 @@ static int hisi_nfc_send_cmd_reset(struct hinfc_host *host, int chipselect)
357 357
358static void hisi_nfc_select_chip(struct mtd_info *mtd, int chipselect) 358static void hisi_nfc_select_chip(struct mtd_info *mtd, int chipselect)
359{ 359{
360 struct nand_chip *chip = mtd->priv; 360 struct nand_chip *chip = mtd_to_nand(mtd);
361 struct hinfc_host *host = chip->priv; 361 struct hinfc_host *host = chip->priv;
362 362
363 if (chipselect < 0) 363 if (chipselect < 0)
@@ -368,7 +368,7 @@ static void hisi_nfc_select_chip(struct mtd_info *mtd, int chipselect)
368 368
369static uint8_t hisi_nfc_read_byte(struct mtd_info *mtd) 369static uint8_t hisi_nfc_read_byte(struct mtd_info *mtd)
370{ 370{
371 struct nand_chip *chip = mtd->priv; 371 struct nand_chip *chip = mtd_to_nand(mtd);
372 struct hinfc_host *host = chip->priv; 372 struct hinfc_host *host = chip->priv;
373 373
374 if (host->command == NAND_CMD_STATUS) 374 if (host->command == NAND_CMD_STATUS)
@@ -384,7 +384,7 @@ static uint8_t hisi_nfc_read_byte(struct mtd_info *mtd)
384 384
385static u16 hisi_nfc_read_word(struct mtd_info *mtd) 385static u16 hisi_nfc_read_word(struct mtd_info *mtd)
386{ 386{
387 struct nand_chip *chip = mtd->priv; 387 struct nand_chip *chip = mtd_to_nand(mtd);
388 struct hinfc_host *host = chip->priv; 388 struct hinfc_host *host = chip->priv;
389 389
390 host->offset += 2; 390 host->offset += 2;
@@ -394,7 +394,7 @@ static u16 hisi_nfc_read_word(struct mtd_info *mtd)
394static void 394static void
395hisi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) 395hisi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
396{ 396{
397 struct nand_chip *chip = mtd->priv; 397 struct nand_chip *chip = mtd_to_nand(mtd);
398 struct hinfc_host *host = chip->priv; 398 struct hinfc_host *host = chip->priv;
399 399
400 memcpy(host->buffer + host->offset, buf, len); 400 memcpy(host->buffer + host->offset, buf, len);
@@ -403,7 +403,7 @@ hisi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
403 403
404static void hisi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) 404static void hisi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
405{ 405{
406 struct nand_chip *chip = mtd->priv; 406 struct nand_chip *chip = mtd_to_nand(mtd);
407 struct hinfc_host *host = chip->priv; 407 struct hinfc_host *host = chip->priv;
408 408
409 memcpy(buf, host->buffer + host->offset, len); 409 memcpy(buf, host->buffer + host->offset, len);
@@ -412,7 +412,7 @@ static void hisi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
412 412
413static void set_addr(struct mtd_info *mtd, int column, int page_addr) 413static void set_addr(struct mtd_info *mtd, int column, int page_addr)
414{ 414{
415 struct nand_chip *chip = mtd->priv; 415 struct nand_chip *chip = mtd_to_nand(mtd);
416 struct hinfc_host *host = chip->priv; 416 struct hinfc_host *host = chip->priv;
417 unsigned int command = host->command; 417 unsigned int command = host->command;
418 418
@@ -448,7 +448,7 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr)
448static void hisi_nfc_cmdfunc(struct mtd_info *mtd, unsigned command, int column, 448static void hisi_nfc_cmdfunc(struct mtd_info *mtd, unsigned command, int column,
449 int page_addr) 449 int page_addr)
450{ 450{
451 struct nand_chip *chip = mtd->priv; 451 struct nand_chip *chip = mtd_to_nand(mtd);
452 struct hinfc_host *host = chip->priv; 452 struct hinfc_host *host = chip->priv;
453 int is_cache_invalid = 1; 453 int is_cache_invalid = 1;
454 unsigned int flag = 0; 454 unsigned int flag = 0;
diff --git a/drivers/mtd/nand/jz4740_nand.c b/drivers/mtd/nand/jz4740_nand.c
index 5a99a93ed025..5a06fba9bd1a 100644
--- a/drivers/mtd/nand/jz4740_nand.c
+++ b/drivers/mtd/nand/jz4740_nand.c
@@ -82,7 +82,7 @@ static inline struct jz_nand *mtd_to_jz_nand(struct mtd_info *mtd)
82static void jz_nand_select_chip(struct mtd_info *mtd, int chipnr) 82static void jz_nand_select_chip(struct mtd_info *mtd, int chipnr)
83{ 83{
84 struct jz_nand *nand = mtd_to_jz_nand(mtd); 84 struct jz_nand *nand = mtd_to_jz_nand(mtd);
85 struct nand_chip *chip = mtd->priv; 85 struct nand_chip *chip = mtd_to_nand(mtd);
86 uint32_t ctrl; 86 uint32_t ctrl;
87 int banknr; 87 int banknr;
88 88
@@ -104,7 +104,7 @@ static void jz_nand_select_chip(struct mtd_info *mtd, int chipnr)
104static void jz_nand_cmd_ctrl(struct mtd_info *mtd, int dat, unsigned int ctrl) 104static void jz_nand_cmd_ctrl(struct mtd_info *mtd, int dat, unsigned int ctrl)
105{ 105{
106 struct jz_nand *nand = mtd_to_jz_nand(mtd); 106 struct jz_nand *nand = mtd_to_jz_nand(mtd);
107 struct nand_chip *chip = mtd->priv; 107 struct nand_chip *chip = mtd_to_nand(mtd);
108 uint32_t reg; 108 uint32_t reg;
109 void __iomem *bank_base = nand->bank_base[nand->selected_bank]; 109 void __iomem *bank_base = nand->bank_base[nand->selected_bank];
110 110
diff --git a/drivers/mtd/nand/lpc32xx_mlc.c b/drivers/mtd/nand/lpc32xx_mlc.c
index 57c4b712cf1a..373885659fe0 100644
--- a/drivers/mtd/nand/lpc32xx_mlc.c
+++ b/drivers/mtd/nand/lpc32xx_mlc.c
@@ -275,7 +275,7 @@ static void lpc32xx_nand_setup(struct lpc32xx_nand_host *host)
275static void lpc32xx_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, 275static void lpc32xx_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
276 unsigned int ctrl) 276 unsigned int ctrl)
277{ 277{
278 struct nand_chip *nand_chip = mtd->priv; 278 struct nand_chip *nand_chip = mtd_to_nand(mtd);
279 struct lpc32xx_nand_host *host = nand_chip->priv; 279 struct lpc32xx_nand_host *host = nand_chip->priv;
280 280
281 if (cmd != NAND_CMD_NONE) { 281 if (cmd != NAND_CMD_NONE) {
@@ -291,7 +291,7 @@ static void lpc32xx_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
291 */ 291 */
292static int lpc32xx_nand_device_ready(struct mtd_info *mtd) 292static int lpc32xx_nand_device_ready(struct mtd_info *mtd)
293{ 293{
294 struct nand_chip *nand_chip = mtd->priv; 294 struct nand_chip *nand_chip = mtd_to_nand(mtd);
295 struct lpc32xx_nand_host *host = nand_chip->priv; 295 struct lpc32xx_nand_host *host = nand_chip->priv;
296 296
297 if ((readb(MLC_ISR(host->io_base)) & 297 if ((readb(MLC_ISR(host->io_base)) &
@@ -389,7 +389,7 @@ static void lpc32xx_dma_complete_func(void *completion)
389static int lpc32xx_xmit_dma(struct mtd_info *mtd, void *mem, int len, 389static int lpc32xx_xmit_dma(struct mtd_info *mtd, void *mem, int len,
390 enum dma_transfer_direction dir) 390 enum dma_transfer_direction dir)
391{ 391{
392 struct nand_chip *chip = mtd->priv; 392 struct nand_chip *chip = mtd_to_nand(mtd);
393 struct lpc32xx_nand_host *host = chip->priv; 393 struct lpc32xx_nand_host *host = chip->priv;
394 struct dma_async_tx_descriptor *desc; 394 struct dma_async_tx_descriptor *desc;
395 int flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT; 395 int flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
diff --git a/drivers/mtd/nand/lpc32xx_slc.c b/drivers/mtd/nand/lpc32xx_slc.c
index 277626e46379..fcd9facad05e 100644
--- a/drivers/mtd/nand/lpc32xx_slc.c
+++ b/drivers/mtd/nand/lpc32xx_slc.c
@@ -260,7 +260,7 @@ static void lpc32xx_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
260 unsigned int ctrl) 260 unsigned int ctrl)
261{ 261{
262 uint32_t tmp; 262 uint32_t tmp;
263 struct nand_chip *chip = mtd->priv; 263 struct nand_chip *chip = mtd_to_nand(mtd);
264 struct lpc32xx_nand_host *host = chip->priv; 264 struct lpc32xx_nand_host *host = chip->priv;
265 265
266 /* Does CE state need to be changed? */ 266 /* Does CE state need to be changed? */
@@ -284,7 +284,7 @@ static void lpc32xx_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
284 */ 284 */
285static int lpc32xx_nand_device_ready(struct mtd_info *mtd) 285static int lpc32xx_nand_device_ready(struct mtd_info *mtd)
286{ 286{
287 struct nand_chip *chip = mtd->priv; 287 struct nand_chip *chip = mtd_to_nand(mtd);
288 struct lpc32xx_nand_host *host = chip->priv; 288 struct lpc32xx_nand_host *host = chip->priv;
289 int rdy = 0; 289 int rdy = 0;
290 290
@@ -339,7 +339,7 @@ static int lpc32xx_nand_ecc_calculate(struct mtd_info *mtd,
339 */ 339 */
340static uint8_t lpc32xx_nand_read_byte(struct mtd_info *mtd) 340static uint8_t lpc32xx_nand_read_byte(struct mtd_info *mtd)
341{ 341{
342 struct nand_chip *chip = mtd->priv; 342 struct nand_chip *chip = mtd_to_nand(mtd);
343 struct lpc32xx_nand_host *host = chip->priv; 343 struct lpc32xx_nand_host *host = chip->priv;
344 344
345 return (uint8_t)readl(SLC_DATA(host->io_base)); 345 return (uint8_t)readl(SLC_DATA(host->io_base));
@@ -350,7 +350,7 @@ static uint8_t lpc32xx_nand_read_byte(struct mtd_info *mtd)
350 */ 350 */
351static void lpc32xx_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) 351static void lpc32xx_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
352{ 352{
353 struct nand_chip *chip = mtd->priv; 353 struct nand_chip *chip = mtd_to_nand(mtd);
354 struct lpc32xx_nand_host *host = chip->priv; 354 struct lpc32xx_nand_host *host = chip->priv;
355 355
356 /* Direct device read with no ECC */ 356 /* Direct device read with no ECC */
@@ -363,7 +363,7 @@ static void lpc32xx_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
363 */ 363 */
364static void lpc32xx_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) 364static void lpc32xx_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
365{ 365{
366 struct nand_chip *chip = mtd->priv; 366 struct nand_chip *chip = mtd_to_nand(mtd);
367 struct lpc32xx_nand_host *host = chip->priv; 367 struct lpc32xx_nand_host *host = chip->priv;
368 368
369 /* Direct device write with no ECC */ 369 /* Direct device write with no ECC */
@@ -428,7 +428,7 @@ static void lpc32xx_dma_complete_func(void *completion)
428static int lpc32xx_xmit_dma(struct mtd_info *mtd, dma_addr_t dma, 428static int lpc32xx_xmit_dma(struct mtd_info *mtd, dma_addr_t dma,
429 void *mem, int len, enum dma_transfer_direction dir) 429 void *mem, int len, enum dma_transfer_direction dir)
430{ 430{
431 struct nand_chip *chip = mtd->priv; 431 struct nand_chip *chip = mtd_to_nand(mtd);
432 struct lpc32xx_nand_host *host = chip->priv; 432 struct lpc32xx_nand_host *host = chip->priv;
433 struct dma_async_tx_descriptor *desc; 433 struct dma_async_tx_descriptor *desc;
434 int flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT; 434 int flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
@@ -488,7 +488,7 @@ out1:
488static int lpc32xx_xfer(struct mtd_info *mtd, uint8_t *buf, int eccsubpages, 488static int lpc32xx_xfer(struct mtd_info *mtd, uint8_t *buf, int eccsubpages,
489 int read) 489 int read)
490{ 490{
491 struct nand_chip *chip = mtd->priv; 491 struct nand_chip *chip = mtd_to_nand(mtd);
492 struct lpc32xx_nand_host *host = chip->priv; 492 struct lpc32xx_nand_host *host = chip->priv;
493 int i, status = 0; 493 int i, status = 0;
494 unsigned long timeout; 494 unsigned long timeout;
diff --git a/drivers/mtd/nand/mpc5121_nfc.c b/drivers/mtd/nand/mpc5121_nfc.c
index 0fdfc42f75f8..642c486ea3c2 100644
--- a/drivers/mtd/nand/mpc5121_nfc.c
+++ b/drivers/mtd/nand/mpc5121_nfc.c
@@ -135,7 +135,7 @@ static void mpc5121_nfc_done(struct mtd_info *mtd);
135/* Read NFC register */ 135/* Read NFC register */
136static inline u16 nfc_read(struct mtd_info *mtd, uint reg) 136static inline u16 nfc_read(struct mtd_info *mtd, uint reg)
137{ 137{
138 struct nand_chip *chip = mtd->priv; 138 struct nand_chip *chip = mtd_to_nand(mtd);
139 struct mpc5121_nfc_prv *prv = chip->priv; 139 struct mpc5121_nfc_prv *prv = chip->priv;
140 140
141 return in_be16(prv->regs + reg); 141 return in_be16(prv->regs + reg);
@@ -144,7 +144,7 @@ static inline u16 nfc_read(struct mtd_info *mtd, uint reg)
144/* Write NFC register */ 144/* Write NFC register */
145static inline void nfc_write(struct mtd_info *mtd, uint reg, u16 val) 145static inline void nfc_write(struct mtd_info *mtd, uint reg, u16 val)
146{ 146{
147 struct nand_chip *chip = mtd->priv; 147 struct nand_chip *chip = mtd_to_nand(mtd);
148 struct mpc5121_nfc_prv *prv = chip->priv; 148 struct mpc5121_nfc_prv *prv = chip->priv;
149 149
150 out_be16(prv->regs + reg, val); 150 out_be16(prv->regs + reg, val);
@@ -214,7 +214,7 @@ static inline void mpc5121_nfc_send_read_status(struct mtd_info *mtd)
214static irqreturn_t mpc5121_nfc_irq(int irq, void *data) 214static irqreturn_t mpc5121_nfc_irq(int irq, void *data)
215{ 215{
216 struct mtd_info *mtd = data; 216 struct mtd_info *mtd = data;
217 struct nand_chip *chip = mtd->priv; 217 struct nand_chip *chip = mtd_to_nand(mtd);
218 struct mpc5121_nfc_prv *prv = chip->priv; 218 struct mpc5121_nfc_prv *prv = chip->priv;
219 219
220 nfc_set(mtd, NFC_CONFIG1, NFC_INT_MASK); 220 nfc_set(mtd, NFC_CONFIG1, NFC_INT_MASK);
@@ -226,7 +226,7 @@ static irqreturn_t mpc5121_nfc_irq(int irq, void *data)
226/* Wait for operation complete */ 226/* Wait for operation complete */
227static void mpc5121_nfc_done(struct mtd_info *mtd) 227static void mpc5121_nfc_done(struct mtd_info *mtd)
228{ 228{
229 struct nand_chip *chip = mtd->priv; 229 struct nand_chip *chip = mtd_to_nand(mtd);
230 struct mpc5121_nfc_prv *prv = chip->priv; 230 struct mpc5121_nfc_prv *prv = chip->priv;
231 int rv; 231 int rv;
232 232
@@ -246,7 +246,7 @@ static void mpc5121_nfc_done(struct mtd_info *mtd)
246/* Do address cycle(s) */ 246/* Do address cycle(s) */
247static void mpc5121_nfc_addr_cycle(struct mtd_info *mtd, int column, int page) 247static void mpc5121_nfc_addr_cycle(struct mtd_info *mtd, int column, int page)
248{ 248{
249 struct nand_chip *chip = mtd->priv; 249 struct nand_chip *chip = mtd_to_nand(mtd);
250 u32 pagemask = chip->pagemask; 250 u32 pagemask = chip->pagemask;
251 251
252 if (column != -1) { 252 if (column != -1) {
@@ -281,7 +281,7 @@ static void mpc5121_nfc_select_chip(struct mtd_info *mtd, int chip)
281/* Init external chip select logic on ADS5121 board */ 281/* Init external chip select logic on ADS5121 board */
282static int ads5121_chipselect_init(struct mtd_info *mtd) 282static int ads5121_chipselect_init(struct mtd_info *mtd)
283{ 283{
284 struct nand_chip *chip = mtd->priv; 284 struct nand_chip *chip = mtd_to_nand(mtd);
285 struct mpc5121_nfc_prv *prv = chip->priv; 285 struct mpc5121_nfc_prv *prv = chip->priv;
286 struct device_node *dn; 286 struct device_node *dn;
287 287
@@ -303,7 +303,7 @@ static int ads5121_chipselect_init(struct mtd_info *mtd)
303/* Control chips select signal on ADS5121 board */ 303/* Control chips select signal on ADS5121 board */
304static void ads5121_select_chip(struct mtd_info *mtd, int chip) 304static void ads5121_select_chip(struct mtd_info *mtd, int chip)
305{ 305{
306 struct nand_chip *nand = mtd->priv; 306 struct nand_chip *nand = mtd_to_nand(mtd);
307 struct mpc5121_nfc_prv *prv = nand->priv; 307 struct mpc5121_nfc_prv *prv = nand->priv;
308 u8 v; 308 u8 v;
309 309
@@ -333,7 +333,7 @@ static int mpc5121_nfc_dev_ready(struct mtd_info *mtd)
333static void mpc5121_nfc_command(struct mtd_info *mtd, unsigned command, 333static void mpc5121_nfc_command(struct mtd_info *mtd, unsigned command,
334 int column, int page) 334 int column, int page)
335{ 335{
336 struct nand_chip *chip = mtd->priv; 336 struct nand_chip *chip = mtd_to_nand(mtd);
337 struct mpc5121_nfc_prv *prv = chip->priv; 337 struct mpc5121_nfc_prv *prv = chip->priv;
338 338
339 prv->column = (column >= 0) ? column : 0; 339 prv->column = (column >= 0) ? column : 0;
@@ -406,7 +406,7 @@ static void mpc5121_nfc_command(struct mtd_info *mtd, unsigned command,
406static void mpc5121_nfc_copy_spare(struct mtd_info *mtd, uint offset, 406static void mpc5121_nfc_copy_spare(struct mtd_info *mtd, uint offset,
407 u8 *buffer, uint size, int wr) 407 u8 *buffer, uint size, int wr)
408{ 408{
409 struct nand_chip *nand = mtd->priv; 409 struct nand_chip *nand = mtd_to_nand(mtd);
410 struct mpc5121_nfc_prv *prv = nand->priv; 410 struct mpc5121_nfc_prv *prv = nand->priv;
411 uint o, s, sbsize, blksize; 411 uint o, s, sbsize, blksize;
412 412
@@ -458,7 +458,7 @@ static void mpc5121_nfc_copy_spare(struct mtd_info *mtd, uint offset,
458static void mpc5121_nfc_buf_copy(struct mtd_info *mtd, u_char *buf, int len, 458static void mpc5121_nfc_buf_copy(struct mtd_info *mtd, u_char *buf, int len,
459 int wr) 459 int wr)
460{ 460{
461 struct nand_chip *chip = mtd->priv; 461 struct nand_chip *chip = mtd_to_nand(mtd);
462 struct mpc5121_nfc_prv *prv = chip->priv; 462 struct mpc5121_nfc_prv *prv = chip->priv;
463 uint c = prv->column; 463 uint c = prv->column;
464 uint l; 464 uint l;
@@ -536,7 +536,7 @@ static u16 mpc5121_nfc_read_word(struct mtd_info *mtd)
536 */ 536 */
537static int mpc5121_nfc_read_hw_config(struct mtd_info *mtd) 537static int mpc5121_nfc_read_hw_config(struct mtd_info *mtd)
538{ 538{
539 struct nand_chip *chip = mtd->priv; 539 struct nand_chip *chip = mtd_to_nand(mtd);
540 struct mpc5121_nfc_prv *prv = chip->priv; 540 struct mpc5121_nfc_prv *prv = chip->priv;
541 struct mpc512x_reset_module *rm; 541 struct mpc512x_reset_module *rm;
542 struct device_node *rmnode; 542 struct device_node *rmnode;
@@ -615,7 +615,7 @@ out:
615/* Free driver resources */ 615/* Free driver resources */
616static void mpc5121_nfc_free(struct device *dev, struct mtd_info *mtd) 616static void mpc5121_nfc_free(struct device *dev, struct mtd_info *mtd)
617{ 617{
618 struct nand_chip *chip = mtd->priv; 618 struct nand_chip *chip = mtd_to_nand(mtd);
619 struct mpc5121_nfc_prv *prv = chip->priv; 619 struct mpc5121_nfc_prv *prv = chip->priv;
620 620
621 if (prv->clk) 621 if (prv->clk)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index f507d361b1a6..b291258bfe7b 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -532,7 +532,7 @@ static void send_addr_v1_v2(struct mxc_nand_host *host, uint16_t addr, int islas
532 532
533static void send_page_v3(struct mtd_info *mtd, unsigned int ops) 533static void send_page_v3(struct mtd_info *mtd, unsigned int ops)
534{ 534{
535 struct nand_chip *nand_chip = mtd->priv; 535 struct nand_chip *nand_chip = mtd_to_nand(mtd);
536 struct mxc_nand_host *host = nand_chip->priv; 536 struct mxc_nand_host *host = nand_chip->priv;
537 uint32_t tmp; 537 uint32_t tmp;
538 538
@@ -548,7 +548,7 @@ static void send_page_v3(struct mtd_info *mtd, unsigned int ops)
548 548
549static void send_page_v2(struct mtd_info *mtd, unsigned int ops) 549static void send_page_v2(struct mtd_info *mtd, unsigned int ops)
550{ 550{
551 struct nand_chip *nand_chip = mtd->priv; 551 struct nand_chip *nand_chip = mtd_to_nand(mtd);
552 struct mxc_nand_host *host = nand_chip->priv; 552 struct mxc_nand_host *host = nand_chip->priv;
553 553
554 /* NANDFC buffer 0 is used for page read/write */ 554 /* NANDFC buffer 0 is used for page read/write */
@@ -562,7 +562,7 @@ static void send_page_v2(struct mtd_info *mtd, unsigned int ops)
562 562
563static void send_page_v1(struct mtd_info *mtd, unsigned int ops) 563static void send_page_v1(struct mtd_info *mtd, unsigned int ops)
564{ 564{
565 struct nand_chip *nand_chip = mtd->priv; 565 struct nand_chip *nand_chip = mtd_to_nand(mtd);
566 struct mxc_nand_host *host = nand_chip->priv; 566 struct mxc_nand_host *host = nand_chip->priv;
567 int bufs, i; 567 int bufs, i;
568 568
@@ -663,7 +663,7 @@ static void mxc_nand_enable_hwecc(struct mtd_info *mtd, int mode)
663static int mxc_nand_correct_data_v1(struct mtd_info *mtd, u_char *dat, 663static int mxc_nand_correct_data_v1(struct mtd_info *mtd, u_char *dat,
664 u_char *read_ecc, u_char *calc_ecc) 664 u_char *read_ecc, u_char *calc_ecc)
665{ 665{
666 struct nand_chip *nand_chip = mtd->priv; 666 struct nand_chip *nand_chip = mtd_to_nand(mtd);
667 struct mxc_nand_host *host = nand_chip->priv; 667 struct mxc_nand_host *host = nand_chip->priv;
668 668
669 /* 669 /*
@@ -684,7 +684,7 @@ static int mxc_nand_correct_data_v1(struct mtd_info *mtd, u_char *dat,
684static int mxc_nand_correct_data_v2_v3(struct mtd_info *mtd, u_char *dat, 684static int mxc_nand_correct_data_v2_v3(struct mtd_info *mtd, u_char *dat,
685 u_char *read_ecc, u_char *calc_ecc) 685 u_char *read_ecc, u_char *calc_ecc)
686{ 686{
687 struct nand_chip *nand_chip = mtd->priv; 687 struct nand_chip *nand_chip = mtd_to_nand(mtd);
688 struct mxc_nand_host *host = nand_chip->priv; 688 struct mxc_nand_host *host = nand_chip->priv;
689 u32 ecc_stat, err; 689 u32 ecc_stat, err;
690 int no_subpages = 1; 690 int no_subpages = 1;
@@ -722,7 +722,7 @@ static int mxc_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
722 722
723static u_char mxc_nand_read_byte(struct mtd_info *mtd) 723static u_char mxc_nand_read_byte(struct mtd_info *mtd)
724{ 724{
725 struct nand_chip *nand_chip = mtd->priv; 725 struct nand_chip *nand_chip = mtd_to_nand(mtd);
726 struct mxc_nand_host *host = nand_chip->priv; 726 struct mxc_nand_host *host = nand_chip->priv;
727 uint8_t ret; 727 uint8_t ret;
728 728
@@ -746,7 +746,7 @@ static u_char mxc_nand_read_byte(struct mtd_info *mtd)
746 746
747static uint16_t mxc_nand_read_word(struct mtd_info *mtd) 747static uint16_t mxc_nand_read_word(struct mtd_info *mtd)
748{ 748{
749 struct nand_chip *nand_chip = mtd->priv; 749 struct nand_chip *nand_chip = mtd_to_nand(mtd);
750 struct mxc_nand_host *host = nand_chip->priv; 750 struct mxc_nand_host *host = nand_chip->priv;
751 uint16_t ret; 751 uint16_t ret;
752 752
@@ -762,7 +762,7 @@ static uint16_t mxc_nand_read_word(struct mtd_info *mtd)
762static void mxc_nand_write_buf(struct mtd_info *mtd, 762static void mxc_nand_write_buf(struct mtd_info *mtd,
763 const u_char *buf, int len) 763 const u_char *buf, int len)
764{ 764{
765 struct nand_chip *nand_chip = mtd->priv; 765 struct nand_chip *nand_chip = mtd_to_nand(mtd);
766 struct mxc_nand_host *host = nand_chip->priv; 766 struct mxc_nand_host *host = nand_chip->priv;
767 u16 col = host->buf_start; 767 u16 col = host->buf_start;
768 int n = mtd->oobsize + mtd->writesize - col; 768 int n = mtd->oobsize + mtd->writesize - col;
@@ -780,7 +780,7 @@ static void mxc_nand_write_buf(struct mtd_info *mtd,
780 */ 780 */
781static void mxc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) 781static void mxc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
782{ 782{
783 struct nand_chip *nand_chip = mtd->priv; 783 struct nand_chip *nand_chip = mtd_to_nand(mtd);
784 struct mxc_nand_host *host = nand_chip->priv; 784 struct mxc_nand_host *host = nand_chip->priv;
785 u16 col = host->buf_start; 785 u16 col = host->buf_start;
786 int n = mtd->oobsize + mtd->writesize - col; 786 int n = mtd->oobsize + mtd->writesize - col;
@@ -796,7 +796,7 @@ static void mxc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
796 * deselect of the NAND chip */ 796 * deselect of the NAND chip */
797static void mxc_nand_select_chip_v1_v3(struct mtd_info *mtd, int chip) 797static void mxc_nand_select_chip_v1_v3(struct mtd_info *mtd, int chip)
798{ 798{
799 struct nand_chip *nand_chip = mtd->priv; 799 struct nand_chip *nand_chip = mtd_to_nand(mtd);
800 struct mxc_nand_host *host = nand_chip->priv; 800 struct mxc_nand_host *host = nand_chip->priv;
801 801
802 if (chip == -1) { 802 if (chip == -1) {
@@ -817,7 +817,7 @@ static void mxc_nand_select_chip_v1_v3(struct mtd_info *mtd, int chip)
817 817
818static void mxc_nand_select_chip_v2(struct mtd_info *mtd, int chip) 818static void mxc_nand_select_chip_v2(struct mtd_info *mtd, int chip)
819{ 819{
820 struct nand_chip *nand_chip = mtd->priv; 820 struct nand_chip *nand_chip = mtd_to_nand(mtd);
821 struct mxc_nand_host *host = nand_chip->priv; 821 struct mxc_nand_host *host = nand_chip->priv;
822 822
823 if (chip == -1) { 823 if (chip == -1) {
@@ -850,7 +850,7 @@ static void mxc_nand_select_chip_v2(struct mtd_info *mtd, int chip)
850 */ 850 */
851static void copy_spare(struct mtd_info *mtd, bool bfrom) 851static void copy_spare(struct mtd_info *mtd, bool bfrom)
852{ 852{
853 struct nand_chip *this = mtd->priv; 853 struct nand_chip *this = mtd_to_nand(mtd);
854 struct mxc_nand_host *host = this->priv; 854 struct mxc_nand_host *host = this->priv;
855 u16 i, oob_chunk_size; 855 u16 i, oob_chunk_size;
856 u16 num_chunks = mtd->writesize / 512; 856 u16 num_chunks = mtd->writesize / 512;
@@ -893,7 +893,7 @@ static void copy_spare(struct mtd_info *mtd, bool bfrom)
893 */ 893 */
894static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr) 894static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr)
895{ 895{
896 struct nand_chip *nand_chip = mtd->priv; 896 struct nand_chip *nand_chip = mtd_to_nand(mtd);
897 struct mxc_nand_host *host = nand_chip->priv; 897 struct mxc_nand_host *host = nand_chip->priv;
898 898
899 /* Write out column address, if necessary */ 899 /* Write out column address, if necessary */
@@ -979,7 +979,7 @@ static void ecc_8bit_layout_4k(struct nand_ecclayout *layout)
979 979
980static void preset_v1(struct mtd_info *mtd) 980static void preset_v1(struct mtd_info *mtd)
981{ 981{
982 struct nand_chip *nand_chip = mtd->priv; 982 struct nand_chip *nand_chip = mtd_to_nand(mtd);
983 struct mxc_nand_host *host = nand_chip->priv; 983 struct mxc_nand_host *host = nand_chip->priv;
984 uint16_t config1 = 0; 984 uint16_t config1 = 0;
985 985
@@ -1007,7 +1007,7 @@ static void preset_v1(struct mtd_info *mtd)
1007 1007
1008static void preset_v2(struct mtd_info *mtd) 1008static void preset_v2(struct mtd_info *mtd)
1009{ 1009{
1010 struct nand_chip *nand_chip = mtd->priv; 1010 struct nand_chip *nand_chip = mtd_to_nand(mtd);
1011 struct mxc_nand_host *host = nand_chip->priv; 1011 struct mxc_nand_host *host = nand_chip->priv;
1012 uint16_t config1 = 0; 1012 uint16_t config1 = 0;
1013 1013
@@ -1053,7 +1053,7 @@ static void preset_v2(struct mtd_info *mtd)
1053 1053
1054static void preset_v3(struct mtd_info *mtd) 1054static void preset_v3(struct mtd_info *mtd)
1055{ 1055{
1056 struct nand_chip *chip = mtd->priv; 1056 struct nand_chip *chip = mtd_to_nand(mtd);
1057 struct mxc_nand_host *host = chip->priv; 1057 struct mxc_nand_host *host = chip->priv;
1058 uint32_t config2, config3; 1058 uint32_t config2, config3;
1059 int i, addr_phases; 1059 int i, addr_phases;
@@ -1124,7 +1124,7 @@ static void preset_v3(struct mtd_info *mtd)
1124static void mxc_nand_command(struct mtd_info *mtd, unsigned command, 1124static void mxc_nand_command(struct mtd_info *mtd, unsigned command,
1125 int column, int page_addr) 1125 int column, int page_addr)
1126{ 1126{
1127 struct nand_chip *nand_chip = mtd->priv; 1127 struct nand_chip *nand_chip = mtd_to_nand(mtd);
1128 struct mxc_nand_host *host = nand_chip->priv; 1128 struct mxc_nand_host *host = nand_chip->priv;
1129 1129
1130 pr_debug("mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n", 1130 pr_debug("mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n",
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index 69658584061b..d8a23b052d50 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -48,7 +48,7 @@ static struct ndfc_controller ndfc_ctrl[NDFC_MAX_CS];
48static void ndfc_select_chip(struct mtd_info *mtd, int chip) 48static void ndfc_select_chip(struct mtd_info *mtd, int chip)
49{ 49{
50 uint32_t ccr; 50 uint32_t ccr;
51 struct nand_chip *nchip = mtd->priv; 51 struct nand_chip *nchip = mtd_to_nand(mtd);
52 struct ndfc_controller *ndfc = nchip->priv; 52 struct ndfc_controller *ndfc = nchip->priv;
53 53
54 ccr = in_be32(ndfc->ndfcbase + NDFC_CCR); 54 ccr = in_be32(ndfc->ndfcbase + NDFC_CCR);
@@ -62,7 +62,7 @@ static void ndfc_select_chip(struct mtd_info *mtd, int chip)
62 62
63static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) 63static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
64{ 64{
65 struct nand_chip *chip = mtd->priv; 65 struct nand_chip *chip = mtd_to_nand(mtd);
66 struct ndfc_controller *ndfc = chip->priv; 66 struct ndfc_controller *ndfc = chip->priv;
67 67
68 if (cmd == NAND_CMD_NONE) 68 if (cmd == NAND_CMD_NONE)
@@ -76,7 +76,7 @@ static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
76 76
77static int ndfc_ready(struct mtd_info *mtd) 77static int ndfc_ready(struct mtd_info *mtd)
78{ 78{
79 struct nand_chip *chip = mtd->priv; 79 struct nand_chip *chip = mtd_to_nand(mtd);
80 struct ndfc_controller *ndfc = chip->priv; 80 struct ndfc_controller *ndfc = chip->priv;
81 81
82 return in_be32(ndfc->ndfcbase + NDFC_STAT) & NDFC_STAT_IS_READY; 82 return in_be32(ndfc->ndfcbase + NDFC_STAT) & NDFC_STAT_IS_READY;
@@ -85,7 +85,7 @@ static int ndfc_ready(struct mtd_info *mtd)
85static void ndfc_enable_hwecc(struct mtd_info *mtd, int mode) 85static void ndfc_enable_hwecc(struct mtd_info *mtd, int mode)
86{ 86{
87 uint32_t ccr; 87 uint32_t ccr;
88 struct nand_chip *chip = mtd->priv; 88 struct nand_chip *chip = mtd_to_nand(mtd);
89 struct ndfc_controller *ndfc = chip->priv; 89 struct ndfc_controller *ndfc = chip->priv;
90 90
91 ccr = in_be32(ndfc->ndfcbase + NDFC_CCR); 91 ccr = in_be32(ndfc->ndfcbase + NDFC_CCR);
@@ -97,7 +97,7 @@ static void ndfc_enable_hwecc(struct mtd_info *mtd, int mode)
97static int ndfc_calculate_ecc(struct mtd_info *mtd, 97static int ndfc_calculate_ecc(struct mtd_info *mtd,
98 const u_char *dat, u_char *ecc_code) 98 const u_char *dat, u_char *ecc_code)
99{ 99{
100 struct nand_chip *chip = mtd->priv; 100 struct nand_chip *chip = mtd_to_nand(mtd);
101 struct ndfc_controller *ndfc = chip->priv; 101 struct ndfc_controller *ndfc = chip->priv;
102 uint32_t ecc; 102 uint32_t ecc;
103 uint8_t *p = (uint8_t *)&ecc; 103 uint8_t *p = (uint8_t *)&ecc;
@@ -121,7 +121,7 @@ static int ndfc_calculate_ecc(struct mtd_info *mtd,
121 */ 121 */
122static void ndfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) 122static void ndfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
123{ 123{
124 struct nand_chip *chip = mtd->priv; 124 struct nand_chip *chip = mtd_to_nand(mtd);
125 struct ndfc_controller *ndfc = chip->priv; 125 struct ndfc_controller *ndfc = chip->priv;
126 uint32_t *p = (uint32_t *) buf; 126 uint32_t *p = (uint32_t *) buf;
127 127
@@ -131,7 +131,7 @@ static void ndfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
131 131
132static void ndfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) 132static void ndfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)
133{ 133{
134 struct nand_chip *chip = mtd->priv; 134 struct nand_chip *chip = mtd_to_nand(mtd);
135 struct ndfc_controller *ndfc = chip->priv; 135 struct ndfc_controller *ndfc = chip->priv;
136 uint32_t *p = (uint32_t *) buf; 136 uint32_t *p = (uint32_t *) buf;
137 137
diff --git a/drivers/mtd/nand/nuc900_nand.c b/drivers/mtd/nand/nuc900_nand.c
index f0687f71fbd8..8148cd689678 100644
--- a/drivers/mtd/nand/nuc900_nand.c
+++ b/drivers/mtd/nand/nuc900_nand.c
@@ -136,7 +136,7 @@ static int nuc900_nand_devready(struct mtd_info *mtd)
136static void nuc900_nand_command_lp(struct mtd_info *mtd, unsigned int command, 136static void nuc900_nand_command_lp(struct mtd_info *mtd, unsigned int command,
137 int column, int page_addr) 137 int column, int page_addr)
138{ 138{
139 register struct nand_chip *chip = mtd->priv; 139 register struct nand_chip *chip = mtd_to_nand(mtd);
140 struct nuc900_nand *nand; 140 struct nuc900_nand *nand;
141 141
142 nand = container_of(mtd, struct nuc900_nand, mtd); 142 nand = container_of(mtd, struct nuc900_nand, mtd);
diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index e307576f300b..944a74e7a513 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -270,7 +270,7 @@ static void omap_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
270 */ 270 */
271static void omap_read_buf8(struct mtd_info *mtd, u_char *buf, int len) 271static void omap_read_buf8(struct mtd_info *mtd, u_char *buf, int len)
272{ 272{
273 struct nand_chip *nand = mtd->priv; 273 struct nand_chip *nand = mtd_to_nand(mtd);
274 274
275 ioread8_rep(nand->IO_ADDR_R, buf, len); 275 ioread8_rep(nand->IO_ADDR_R, buf, len);
276} 276}
@@ -306,7 +306,7 @@ static void omap_write_buf8(struct mtd_info *mtd, const u_char *buf, int len)
306 */ 306 */
307static void omap_read_buf16(struct mtd_info *mtd, u_char *buf, int len) 307static void omap_read_buf16(struct mtd_info *mtd, u_char *buf, int len)
308{ 308{
309 struct nand_chip *nand = mtd->priv; 309 struct nand_chip *nand = mtd_to_nand(mtd);
310 310
311 ioread16_rep(nand->IO_ADDR_R, buf, len / 2); 311 ioread16_rep(nand->IO_ADDR_R, buf, len / 2);
312} 312}
@@ -955,7 +955,7 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int mode)
955{ 955{
956 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, 956 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
957 mtd); 957 mtd);
958 struct nand_chip *chip = mtd->priv; 958 struct nand_chip *chip = mtd_to_nand(mtd);
959 unsigned int dev_width = (chip->options & NAND_BUSWIDTH_16) ? 1 : 0; 959 unsigned int dev_width = (chip->options & NAND_BUSWIDTH_16) ? 1 : 0;
960 u32 val; 960 u32 val;
961 961
@@ -1001,7 +1001,7 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int mode)
1001 */ 1001 */
1002static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip) 1002static int omap_wait(struct mtd_info *mtd, struct nand_chip *chip)
1003{ 1003{
1004 struct nand_chip *this = mtd->priv; 1004 struct nand_chip *this = mtd_to_nand(mtd);
1005 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, 1005 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
1006 mtd); 1006 mtd);
1007 unsigned long timeo = jiffies; 1007 unsigned long timeo = jiffies;
@@ -1061,7 +1061,7 @@ static void __maybe_unused omap_enable_hwecc_bch(struct mtd_info *mtd, int mode)
1061 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, 1061 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
1062 mtd); 1062 mtd);
1063 enum omap_ecc ecc_opt = info->ecc_opt; 1063 enum omap_ecc ecc_opt = info->ecc_opt;
1064 struct nand_chip *chip = mtd->priv; 1064 struct nand_chip *chip = mtd_to_nand(mtd);
1065 u32 val, wr_mode; 1065 u32 val, wr_mode;
1066 unsigned int ecc_size1, ecc_size0; 1066 unsigned int ecc_size1, ecc_size0;
1067 1067
@@ -2056,7 +2056,7 @@ return_error:
2056static int omap_nand_remove(struct platform_device *pdev) 2056static int omap_nand_remove(struct platform_device *pdev)
2057{ 2057{
2058 struct mtd_info *mtd = platform_get_drvdata(pdev); 2058 struct mtd_info *mtd = platform_get_drvdata(pdev);
2059 struct nand_chip *nand_chip = mtd->priv; 2059 struct nand_chip *nand_chip = mtd_to_nand(mtd);
2060 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info, 2060 struct omap_nand_info *info = container_of(mtd, struct omap_nand_info,
2061 mtd); 2061 mtd);
2062 if (nand_chip->ecc.priv) { 2062 if (nand_chip->ecc.priv) {
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index 5c214161244a..4ed4f676ee05 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -25,7 +25,7 @@
25 25
26static void orion_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) 26static void orion_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
27{ 27{
28 struct nand_chip *nc = mtd->priv; 28 struct nand_chip *nc = mtd_to_nand(mtd);
29 struct orion_nand_data *board = nc->priv; 29 struct orion_nand_data *board = nc->priv;
30 u32 offs; 30 u32 offs;
31 31
@@ -47,7 +47,7 @@ static void orion_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl
47 47
48static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) 48static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
49{ 49{
50 struct nand_chip *chip = mtd->priv; 50 struct nand_chip *chip = mtd_to_nand(mtd);
51 void __iomem *io_base = chip->IO_ADDR_R; 51 void __iomem *io_base = chip->IO_ADDR_R;
52 uint64_t *buf64; 52 uint64_t *buf64;
53 int i = 0; 53 int i = 0;
diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c
index 83cf021b9651..0ececac2020f 100644
--- a/drivers/mtd/nand/pasemi_nand.c
+++ b/drivers/mtd/nand/pasemi_nand.c
@@ -45,7 +45,7 @@ static const char driver_name[] = "pasemi-nand";
45 45
46static void pasemi_read_buf(struct mtd_info *mtd, u_char *buf, int len) 46static void pasemi_read_buf(struct mtd_info *mtd, u_char *buf, int len)
47{ 47{
48 struct nand_chip *chip = mtd->priv; 48 struct nand_chip *chip = mtd_to_nand(mtd);
49 49
50 while (len > 0x800) { 50 while (len > 0x800) {
51 memcpy_fromio(buf, chip->IO_ADDR_R, 0x800); 51 memcpy_fromio(buf, chip->IO_ADDR_R, 0x800);
@@ -57,7 +57,7 @@ static void pasemi_read_buf(struct mtd_info *mtd, u_char *buf, int len)
57 57
58static void pasemi_write_buf(struct mtd_info *mtd, const u_char *buf, int len) 58static void pasemi_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
59{ 59{
60 struct nand_chip *chip = mtd->priv; 60 struct nand_chip *chip = mtd_to_nand(mtd);
61 61
62 while (len > 0x800) { 62 while (len > 0x800) {
63 memcpy_toio(chip->IO_ADDR_R, buf, 0x800); 63 memcpy_toio(chip->IO_ADDR_R, buf, 0x800);
@@ -70,7 +70,7 @@ static void pasemi_write_buf(struct mtd_info *mtd, const u_char *buf, int len)
70static void pasemi_hwcontrol(struct mtd_info *mtd, int cmd, 70static void pasemi_hwcontrol(struct mtd_info *mtd, int cmd,
71 unsigned int ctrl) 71 unsigned int ctrl)
72{ 72{
73 struct nand_chip *chip = mtd->priv; 73 struct nand_chip *chip = mtd_to_nand(mtd);
74 74
75 if (cmd == NAND_CMD_NONE) 75 if (cmd == NAND_CMD_NONE)
76 return; 76 return;
@@ -192,7 +192,7 @@ static int pasemi_nand_remove(struct platform_device *ofdev)
192 if (!pasemi_nand_mtd) 192 if (!pasemi_nand_mtd)
193 return 0; 193 return 0;
194 194
195 chip = pasemi_nand_mtd->priv; 195 chip = mtd_to_nand(pasemi_nand_mtd);
196 196
197 /* Release resources, unregister device */ 197 /* Release resources, unregister device */
198 nand_release(pasemi_nand_mtd); 198 nand_release(pasemi_nand_mtd);
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index bdbc2c231ceb..dc39a9847bf5 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -1113,7 +1113,7 @@ static int prepare_set_command(struct pxa3xx_nand_info *info, int command,
1113static void nand_cmdfunc(struct mtd_info *mtd, unsigned command, 1113static void nand_cmdfunc(struct mtd_info *mtd, unsigned command,
1114 int column, int page_addr) 1114 int column, int page_addr)
1115{ 1115{
1116 struct nand_chip *chip = mtd->priv; 1116 struct nand_chip *chip = mtd_to_nand(mtd);
1117 struct pxa3xx_nand_host *host = chip->priv; 1117 struct pxa3xx_nand_host *host = chip->priv;
1118 struct pxa3xx_nand_info *info = host->info_data; 1118 struct pxa3xx_nand_info *info = host->info_data;
1119 int exec_cmd; 1119 int exec_cmd;
@@ -1162,7 +1162,7 @@ static void nand_cmdfunc_extended(struct mtd_info *mtd,
1162 const unsigned command, 1162 const unsigned command,
1163 int column, int page_addr) 1163 int column, int page_addr)
1164{ 1164{
1165 struct nand_chip *chip = mtd->priv; 1165 struct nand_chip *chip = mtd_to_nand(mtd);
1166 struct pxa3xx_nand_host *host = chip->priv; 1166 struct pxa3xx_nand_host *host = chip->priv;
1167 struct pxa3xx_nand_info *info = host->info_data; 1167 struct pxa3xx_nand_info *info = host->info_data;
1168 int exec_cmd, ext_cmd_type; 1168 int exec_cmd, ext_cmd_type;
@@ -1309,7 +1309,7 @@ static int pxa3xx_nand_read_page_hwecc(struct mtd_info *mtd,
1309 1309
1310static uint8_t pxa3xx_nand_read_byte(struct mtd_info *mtd) 1310static uint8_t pxa3xx_nand_read_byte(struct mtd_info *mtd)
1311{ 1311{
1312 struct nand_chip *chip = mtd->priv; 1312 struct nand_chip *chip = mtd_to_nand(mtd);
1313 struct pxa3xx_nand_host *host = chip->priv; 1313 struct pxa3xx_nand_host *host = chip->priv;
1314 struct pxa3xx_nand_info *info = host->info_data; 1314 struct pxa3xx_nand_info *info = host->info_data;
1315 char retval = 0xFF; 1315 char retval = 0xFF;
@@ -1323,7 +1323,7 @@ static uint8_t pxa3xx_nand_read_byte(struct mtd_info *mtd)
1323 1323
1324static u16 pxa3xx_nand_read_word(struct mtd_info *mtd) 1324static u16 pxa3xx_nand_read_word(struct mtd_info *mtd)
1325{ 1325{
1326 struct nand_chip *chip = mtd->priv; 1326 struct nand_chip *chip = mtd_to_nand(mtd);
1327 struct pxa3xx_nand_host *host = chip->priv; 1327 struct pxa3xx_nand_host *host = chip->priv;
1328 struct pxa3xx_nand_info *info = host->info_data; 1328 struct pxa3xx_nand_info *info = host->info_data;
1329 u16 retval = 0xFFFF; 1329 u16 retval = 0xFFFF;
@@ -1337,7 +1337,7 @@ static u16 pxa3xx_nand_read_word(struct mtd_info *mtd)
1337 1337
1338static void pxa3xx_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) 1338static void pxa3xx_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
1339{ 1339{
1340 struct nand_chip *chip = mtd->priv; 1340 struct nand_chip *chip = mtd_to_nand(mtd);
1341 struct pxa3xx_nand_host *host = chip->priv; 1341 struct pxa3xx_nand_host *host = chip->priv;
1342 struct pxa3xx_nand_info *info = host->info_data; 1342 struct pxa3xx_nand_info *info = host->info_data;
1343 int real_len = min_t(size_t, len, info->buf_count - info->buf_start); 1343 int real_len = min_t(size_t, len, info->buf_count - info->buf_start);
@@ -1349,7 +1349,7 @@ static void pxa3xx_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
1349static void pxa3xx_nand_write_buf(struct mtd_info *mtd, 1349static void pxa3xx_nand_write_buf(struct mtd_info *mtd,
1350 const uint8_t *buf, int len) 1350 const uint8_t *buf, int len)
1351{ 1351{
1352 struct nand_chip *chip = mtd->priv; 1352 struct nand_chip *chip = mtd_to_nand(mtd);
1353 struct pxa3xx_nand_host *host = chip->priv; 1353 struct pxa3xx_nand_host *host = chip->priv;
1354 struct pxa3xx_nand_info *info = host->info_data; 1354 struct pxa3xx_nand_info *info = host->info_data;
1355 int real_len = min_t(size_t, len, info->buf_count - info->buf_start); 1355 int real_len = min_t(size_t, len, info->buf_count - info->buf_start);
@@ -1365,7 +1365,7 @@ static void pxa3xx_nand_select_chip(struct mtd_info *mtd, int chip)
1365 1365
1366static int pxa3xx_nand_waitfunc(struct mtd_info *mtd, struct nand_chip *this) 1366static int pxa3xx_nand_waitfunc(struct mtd_info *mtd, struct nand_chip *this)
1367{ 1367{
1368 struct nand_chip *chip = mtd->priv; 1368 struct nand_chip *chip = mtd_to_nand(mtd);
1369 struct pxa3xx_nand_host *host = chip->priv; 1369 struct pxa3xx_nand_host *host = chip->priv;
1370 struct pxa3xx_nand_info *info = host->info_data; 1370 struct pxa3xx_nand_info *info = host->info_data;
1371 1371
@@ -1416,7 +1416,7 @@ static void pxa3xx_nand_config_tail(struct pxa3xx_nand_info *info)
1416{ 1416{
1417 struct pxa3xx_nand_host *host = info->host[info->cs]; 1417 struct pxa3xx_nand_host *host = info->host[info->cs];
1418 struct mtd_info *mtd = host->mtd; 1418 struct mtd_info *mtd = host->mtd;
1419 struct nand_chip *chip = mtd->priv; 1419 struct nand_chip *chip = mtd_to_nand(mtd);
1420 1420
1421 info->reg_ndcr |= (host->col_addr_cycles == 2) ? NDCR_RA_START : 0; 1421 info->reg_ndcr |= (host->col_addr_cycles == 2) ? NDCR_RA_START : 0;
1422 info->reg_ndcr |= (chip->page_shift == 6) ? NDCR_PG_PER_BLK : 0; 1422 info->reg_ndcr |= (chip->page_shift == 6) ? NDCR_PG_PER_BLK : 0;
@@ -1572,7 +1572,7 @@ static int pxa_ecc_init(struct pxa3xx_nand_info *info,
1572 1572
1573static int pxa3xx_nand_scan(struct mtd_info *mtd) 1573static int pxa3xx_nand_scan(struct mtd_info *mtd)
1574{ 1574{
1575 struct nand_chip *chip = mtd->priv; 1575 struct nand_chip *chip = mtd_to_nand(mtd);
1576 struct pxa3xx_nand_host *host = chip->priv; 1576 struct pxa3xx_nand_host *host = chip->priv;
1577 struct pxa3xx_nand_info *info = host->info_data; 1577 struct pxa3xx_nand_info *info = host->info_data;
1578 struct platform_device *pdev = info->pdev; 1578 struct platform_device *pdev = info->pdev;
diff --git a/drivers/mtd/nand/r852.c b/drivers/mtd/nand/r852.c
index be28cddec9cd..ca05b20c017f 100644
--- a/drivers/mtd/nand/r852.c
+++ b/drivers/mtd/nand/r852.c
@@ -64,7 +64,7 @@ static inline void r852_write_reg_dword(struct r852_device *dev,
64/* returns pointer to our private structure */ 64/* returns pointer to our private structure */
65static inline struct r852_device *r852_get_dev(struct mtd_info *mtd) 65static inline struct r852_device *r852_get_dev(struct mtd_info *mtd)
66{ 66{
67 struct nand_chip *chip = mtd->priv; 67 struct nand_chip *chip = mtd_to_nand(mtd);
68 return chip->priv; 68 return chip->priv;
69} 69}
70 70
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 05105cadd0db..e658b2988acf 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -382,7 +382,7 @@ static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip)
382{ 382{
383 struct s3c2410_nand_info *info; 383 struct s3c2410_nand_info *info;
384 struct s3c2410_nand_mtd *nmtd; 384 struct s3c2410_nand_mtd *nmtd;
385 struct nand_chip *this = mtd->priv; 385 struct nand_chip *this = mtd_to_nand(mtd);
386 unsigned long cur; 386 unsigned long cur;
387 387
388 nmtd = this->priv; 388 nmtd = this->priv;
@@ -634,7 +634,7 @@ static int s3c2440_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
634 634
635static void s3c2410_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len) 635static void s3c2410_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
636{ 636{
637 struct nand_chip *this = mtd->priv; 637 struct nand_chip *this = mtd_to_nand(mtd);
638 readsb(this->IO_ADDR_R, buf, len); 638 readsb(this->IO_ADDR_R, buf, len);
639} 639}
640 640
@@ -656,7 +656,7 @@ static void s3c2440_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
656static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf, 656static void s3c2410_nand_write_buf(struct mtd_info *mtd, const u_char *buf,
657 int len) 657 int len)
658{ 658{
659 struct nand_chip *this = mtd->priv; 659 struct nand_chip *this = mtd_to_nand(mtd);
660 writesb(this->IO_ADDR_W, buf, len); 660 writesb(this->IO_ADDR_W, buf, len);
661} 661}
662 662
diff --git a/drivers/mtd/nand/sharpsl.c b/drivers/mtd/nand/sharpsl.c
index 082b6009736d..84129e539930 100644
--- a/drivers/mtd/nand/sharpsl.c
+++ b/drivers/mtd/nand/sharpsl.c
@@ -66,7 +66,7 @@ static void sharpsl_nand_hwcontrol(struct mtd_info *mtd, int cmd,
66 unsigned int ctrl) 66 unsigned int ctrl)
67{ 67{
68 struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd); 68 struct sharpsl_nand *sharpsl = mtd_to_sharpsl(mtd);
69 struct nand_chip *chip = mtd->priv; 69 struct nand_chip *chip = mtd_to_nand(mtd);
70 70
71 if (ctrl & NAND_CTRL_CHANGE) { 71 if (ctrl & NAND_CTRL_CHANGE) {
72 unsigned char bits = ctrl & 0x07; 72 unsigned char bits = ctrl & 0x07;
diff --git a/drivers/mtd/nand/sm_common.c b/drivers/mtd/nand/sm_common.c
index e06b5e5d3287..c514740f9a83 100644
--- a/drivers/mtd/nand/sm_common.c
+++ b/drivers/mtd/nand/sm_common.c
@@ -102,7 +102,7 @@ static struct nand_flash_dev nand_xd_flash_ids[] = {
102 102
103int sm_register_device(struct mtd_info *mtd, int smartmedia) 103int sm_register_device(struct mtd_info *mtd, int smartmedia)
104{ 104{
105 struct nand_chip *chip = mtd->priv; 105 struct nand_chip *chip = mtd_to_nand(mtd);
106 int ret; 106 int ret;
107 107
108 chip->options |= NAND_SKIP_BBTSCAN; 108 chip->options |= NAND_SKIP_BBTSCAN;
diff --git a/drivers/mtd/nand/socrates_nand.c b/drivers/mtd/nand/socrates_nand.c
index bde40433b4d9..2dfb1e0d815a 100644
--- a/drivers/mtd/nand/socrates_nand.c
+++ b/drivers/mtd/nand/socrates_nand.c
@@ -45,7 +45,7 @@ static void socrates_nand_write_buf(struct mtd_info *mtd,
45 const uint8_t *buf, int len) 45 const uint8_t *buf, int len)
46{ 46{
47 int i; 47 int i;
48 struct nand_chip *this = mtd->priv; 48 struct nand_chip *this = mtd_to_nand(mtd);
49 struct socrates_nand_host *host = this->priv; 49 struct socrates_nand_host *host = this->priv;
50 50
51 for (i = 0; i < len; i++) { 51 for (i = 0; i < len; i++) {
@@ -64,7 +64,7 @@ static void socrates_nand_write_buf(struct mtd_info *mtd,
64static void socrates_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) 64static void socrates_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
65{ 65{
66 int i; 66 int i;
67 struct nand_chip *this = mtd->priv; 67 struct nand_chip *this = mtd_to_nand(mtd);
68 struct socrates_nand_host *host = this->priv; 68 struct socrates_nand_host *host = this->priv;
69 uint32_t val; 69 uint32_t val;
70 70
@@ -105,7 +105,7 @@ static uint16_t socrates_nand_read_word(struct mtd_info *mtd)
105static void socrates_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, 105static void socrates_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
106 unsigned int ctrl) 106 unsigned int ctrl)
107{ 107{
108 struct nand_chip *nand_chip = mtd->priv; 108 struct nand_chip *nand_chip = mtd_to_nand(mtd);
109 struct socrates_nand_host *host = nand_chip->priv; 109 struct socrates_nand_host *host = nand_chip->priv;
110 uint32_t val; 110 uint32_t val;
111 111
@@ -130,7 +130,7 @@ static void socrates_nand_cmd_ctrl(struct mtd_info *mtd, int cmd,
130 */ 130 */
131static int socrates_nand_device_ready(struct mtd_info *mtd) 131static int socrates_nand_device_ready(struct mtd_info *mtd)
132{ 132{
133 struct nand_chip *nand_chip = mtd->priv; 133 struct nand_chip *nand_chip = mtd_to_nand(mtd);
134 struct socrates_nand_host *host = nand_chip->priv; 134 struct socrates_nand_host *host = nand_chip->priv;
135 135
136 if (in_be32(host->io_base) & FPGA_NAND_BUSY) 136 if (in_be32(host->io_base) & FPGA_NAND_BUSY)
diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index 1bbcc0c2aab5..4ecd48601182 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -350,7 +350,7 @@ static int sunxi_nfc_rst(struct sunxi_nfc *nfc)
350 350
351static int sunxi_nfc_dev_ready(struct mtd_info *mtd) 351static int sunxi_nfc_dev_ready(struct mtd_info *mtd)
352{ 352{
353 struct nand_chip *nand = mtd->priv; 353 struct nand_chip *nand = mtd_to_nand(mtd);
354 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); 354 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand);
355 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller); 355 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller);
356 struct sunxi_nand_rb *rb; 356 struct sunxi_nand_rb *rb;
@@ -388,7 +388,7 @@ static int sunxi_nfc_dev_ready(struct mtd_info *mtd)
388 388
389static void sunxi_nfc_select_chip(struct mtd_info *mtd, int chip) 389static void sunxi_nfc_select_chip(struct mtd_info *mtd, int chip)
390{ 390{
391 struct nand_chip *nand = mtd->priv; 391 struct nand_chip *nand = mtd_to_nand(mtd);
392 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); 392 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand);
393 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller); 393 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller);
394 struct sunxi_nand_chip_sel *sel; 394 struct sunxi_nand_chip_sel *sel;
@@ -433,7 +433,7 @@ static void sunxi_nfc_select_chip(struct mtd_info *mtd, int chip)
433 433
434static void sunxi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) 434static void sunxi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
435{ 435{
436 struct nand_chip *nand = mtd->priv; 436 struct nand_chip *nand = mtd_to_nand(mtd);
437 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); 437 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand);
438 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller); 438 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller);
439 int ret; 439 int ret;
@@ -466,7 +466,7 @@ static void sunxi_nfc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
466static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf, 466static void sunxi_nfc_write_buf(struct mtd_info *mtd, const uint8_t *buf,
467 int len) 467 int len)
468{ 468{
469 struct nand_chip *nand = mtd->priv; 469 struct nand_chip *nand = mtd_to_nand(mtd);
470 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); 470 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand);
471 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller); 471 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller);
472 int ret; 472 int ret;
@@ -507,7 +507,7 @@ static uint8_t sunxi_nfc_read_byte(struct mtd_info *mtd)
507static void sunxi_nfc_cmd_ctrl(struct mtd_info *mtd, int dat, 507static void sunxi_nfc_cmd_ctrl(struct mtd_info *mtd, int dat,
508 unsigned int ctrl) 508 unsigned int ctrl)
509{ 509{
510 struct nand_chip *nand = mtd->priv; 510 struct nand_chip *nand = mtd_to_nand(mtd);
511 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); 511 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand);
512 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller); 512 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller);
513 int ret; 513 int ret;
@@ -541,7 +541,7 @@ static void sunxi_nfc_cmd_ctrl(struct mtd_info *mtd, int dat,
541 541
542static void sunxi_nfc_hw_ecc_enable(struct mtd_info *mtd) 542static void sunxi_nfc_hw_ecc_enable(struct mtd_info *mtd)
543{ 543{
544 struct nand_chip *nand = mtd->priv; 544 struct nand_chip *nand = mtd_to_nand(mtd);
545 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); 545 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller);
546 struct sunxi_nand_hw_ecc *data = nand->ecc.priv; 546 struct sunxi_nand_hw_ecc *data = nand->ecc.priv;
547 u32 ecc_ctl; 547 u32 ecc_ctl;
@@ -556,7 +556,7 @@ static void sunxi_nfc_hw_ecc_enable(struct mtd_info *mtd)
556 556
557static void sunxi_nfc_hw_ecc_disable(struct mtd_info *mtd) 557static void sunxi_nfc_hw_ecc_disable(struct mtd_info *mtd)
558{ 558{
559 struct nand_chip *nand = mtd->priv; 559 struct nand_chip *nand = mtd_to_nand(mtd);
560 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); 560 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller);
561 561
562 writel(readl(nfc->regs + NFC_REG_ECC_CTL) & ~NFC_ECC_EN, 562 writel(readl(nfc->regs + NFC_REG_ECC_CTL) & ~NFC_ECC_EN,
@@ -577,7 +577,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd,
577 int *cur_off, 577 int *cur_off,
578 unsigned int *max_bitflips) 578 unsigned int *max_bitflips)
579{ 579{
580 struct nand_chip *nand = mtd->priv; 580 struct nand_chip *nand = mtd_to_nand(mtd);
581 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); 581 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller);
582 struct nand_ecc_ctrl *ecc = &nand->ecc; 582 struct nand_ecc_ctrl *ecc = &nand->ecc;
583 u32 status; 583 u32 status;
@@ -638,7 +638,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct mtd_info *mtd,
638static void sunxi_nfc_hw_ecc_read_extra_oob(struct mtd_info *mtd, 638static void sunxi_nfc_hw_ecc_read_extra_oob(struct mtd_info *mtd,
639 u8 *oob, int *cur_off) 639 u8 *oob, int *cur_off)
640{ 640{
641 struct nand_chip *nand = mtd->priv; 641 struct nand_chip *nand = mtd_to_nand(mtd);
642 struct nand_ecc_ctrl *ecc = &nand->ecc; 642 struct nand_ecc_ctrl *ecc = &nand->ecc;
643 int offset = ((ecc->bytes + 4) * ecc->steps); 643 int offset = ((ecc->bytes + 4) * ecc->steps);
644 int len = mtd->oobsize - offset; 644 int len = mtd->oobsize - offset;
@@ -665,7 +665,7 @@ static int sunxi_nfc_hw_ecc_write_chunk(struct mtd_info *mtd,
665 const u8 *oob, int oob_off, 665 const u8 *oob, int oob_off,
666 int *cur_off) 666 int *cur_off)
667{ 667{
668 struct nand_chip *nand = mtd->priv; 668 struct nand_chip *nand = mtd_to_nand(mtd);
669 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller); 669 struct sunxi_nfc *nfc = to_sunxi_nfc(nand->controller);
670 struct nand_ecc_ctrl *ecc = &nand->ecc; 670 struct nand_ecc_ctrl *ecc = &nand->ecc;
671 int ret; 671 int ret;
@@ -702,7 +702,7 @@ static int sunxi_nfc_hw_ecc_write_chunk(struct mtd_info *mtd,
702static void sunxi_nfc_hw_ecc_write_extra_oob(struct mtd_info *mtd, 702static void sunxi_nfc_hw_ecc_write_extra_oob(struct mtd_info *mtd,
703 u8 *oob, int *cur_off) 703 u8 *oob, int *cur_off)
704{ 704{
705 struct nand_chip *nand = mtd->priv; 705 struct nand_chip *nand = mtd_to_nand(mtd);
706 struct nand_ecc_ctrl *ecc = &nand->ecc; 706 struct nand_ecc_ctrl *ecc = &nand->ecc;
707 int offset = ((ecc->bytes + 4) * ecc->steps); 707 int offset = ((ecc->bytes + 4) * ecc->steps);
708 int len = mtd->oobsize - offset; 708 int len = mtd->oobsize - offset;
@@ -1031,7 +1031,7 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd,
1031 struct device_node *np) 1031 struct device_node *np)
1032{ 1032{
1033 static const u8 strengths[] = { 16, 24, 28, 32, 40, 48, 56, 60, 64 }; 1033 static const u8 strengths[] = { 16, 24, 28, 32, 40, 48, 56, 60, 64 };
1034 struct nand_chip *nand = mtd->priv; 1034 struct nand_chip *nand = mtd_to_nand(mtd);
1035 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); 1035 struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand);
1036 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller); 1036 struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller);
1037 struct sunxi_nand_hw_ecc *data; 1037 struct sunxi_nand_hw_ecc *data;
@@ -1189,7 +1189,7 @@ static void sunxi_nand_ecc_cleanup(struct nand_ecc_ctrl *ecc)
1189static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc, 1189static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct nand_ecc_ctrl *ecc,
1190 struct device_node *np) 1190 struct device_node *np)
1191{ 1191{
1192 struct nand_chip *nand = mtd->priv; 1192 struct nand_chip *nand = mtd_to_nand(mtd);
1193 int ret; 1193 int ret;
1194 1194
1195 if (!ecc->size) { 1195 if (!ecc->size) {
diff --git a/drivers/mtd/nand/tmio_nand.c b/drivers/mtd/nand/tmio_nand.c
index befddf0776e4..6d0cbe90b1b2 100644
--- a/drivers/mtd/nand/tmio_nand.c
+++ b/drivers/mtd/nand/tmio_nand.c
@@ -128,7 +128,7 @@ static void tmio_nand_hwcontrol(struct mtd_info *mtd, int cmd,
128 unsigned int ctrl) 128 unsigned int ctrl)
129{ 129{
130 struct tmio_nand *tmio = mtd_to_tmio(mtd); 130 struct tmio_nand *tmio = mtd_to_tmio(mtd);
131 struct nand_chip *chip = mtd->priv; 131 struct nand_chip *chip = mtd_to_nand(mtd);
132 132
133 if (ctrl & NAND_CTRL_CHANGE) { 133 if (ctrl & NAND_CTRL_CHANGE) {
134 u8 mode; 134 u8 mode;
diff --git a/drivers/mtd/nand/txx9ndfmc.c b/drivers/mtd/nand/txx9ndfmc.c
index 8572519b8441..ff9afb1eb3ad 100644
--- a/drivers/mtd/nand/txx9ndfmc.c
+++ b/drivers/mtd/nand/txx9ndfmc.c
@@ -79,7 +79,7 @@ struct txx9ndfmc_drvdata {
79 79
80static struct platform_device *mtd_to_platdev(struct mtd_info *mtd) 80static struct platform_device *mtd_to_platdev(struct mtd_info *mtd)
81{ 81{
82 struct nand_chip *chip = mtd->priv; 82 struct nand_chip *chip = mtd_to_nand(mtd);
83 struct txx9ndfmc_priv *txx9_priv = chip->priv; 83 struct txx9ndfmc_priv *txx9_priv = chip->priv;
84 return txx9_priv->dev; 84 return txx9_priv->dev;
85} 85}
@@ -135,7 +135,7 @@ static void txx9ndfmc_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
135static void txx9ndfmc_cmd_ctrl(struct mtd_info *mtd, int cmd, 135static void txx9ndfmc_cmd_ctrl(struct mtd_info *mtd, int cmd,
136 unsigned int ctrl) 136 unsigned int ctrl)
137{ 137{
138 struct nand_chip *chip = mtd->priv; 138 struct nand_chip *chip = mtd_to_nand(mtd);
139 struct txx9ndfmc_priv *txx9_priv = chip->priv; 139 struct txx9ndfmc_priv *txx9_priv = chip->priv;
140 struct platform_device *dev = txx9_priv->dev; 140 struct platform_device *dev = txx9_priv->dev;
141 struct txx9ndfmc_platform_data *plat = dev_get_platdata(&dev->dev); 141 struct txx9ndfmc_platform_data *plat = dev_get_platdata(&dev->dev);
@@ -175,7 +175,7 @@ static int txx9ndfmc_calculate_ecc(struct mtd_info *mtd, const uint8_t *dat,
175 uint8_t *ecc_code) 175 uint8_t *ecc_code)
176{ 176{
177 struct platform_device *dev = mtd_to_platdev(mtd); 177 struct platform_device *dev = mtd_to_platdev(mtd);
178 struct nand_chip *chip = mtd->priv; 178 struct nand_chip *chip = mtd_to_nand(mtd);
179 int eccbytes; 179 int eccbytes;
180 u32 mcr = txx9ndfmc_read(dev, TXX9_NDFMCR); 180 u32 mcr = txx9ndfmc_read(dev, TXX9_NDFMCR);
181 181
@@ -195,7 +195,7 @@ static int txx9ndfmc_calculate_ecc(struct mtd_info *mtd, const uint8_t *dat,
195static int txx9ndfmc_correct_data(struct mtd_info *mtd, unsigned char *buf, 195static int txx9ndfmc_correct_data(struct mtd_info *mtd, unsigned char *buf,
196 unsigned char *read_ecc, unsigned char *calc_ecc) 196 unsigned char *read_ecc, unsigned char *calc_ecc)
197{ 197{
198 struct nand_chip *chip = mtd->priv; 198 struct nand_chip *chip = mtd_to_nand(mtd);
199 int eccsize; 199 int eccsize;
200 int corrected = 0; 200 int corrected = 0;
201 int stat; 201 int stat;
@@ -257,7 +257,7 @@ static void txx9ndfmc_initialize(struct platform_device *dev)
257 257
258static int txx9ndfmc_nand_scan(struct mtd_info *mtd) 258static int txx9ndfmc_nand_scan(struct mtd_info *mtd)
259{ 259{
260 struct nand_chip *chip = mtd->priv; 260 struct nand_chip *chip = mtd_to_nand(mtd);
261 int ret; 261 int ret;
262 262
263 ret = nand_scan_ident(mtd, 1, NULL); 263 ret = nand_scan_ident(mtd, 1, NULL);
@@ -391,7 +391,7 @@ static int __exit txx9ndfmc_remove(struct platform_device *dev)
391 391
392 if (!mtd) 392 if (!mtd)
393 continue; 393 continue;
394 chip = mtd->priv; 394 chip = mtd_to_nand(mtd);
395 txx9_priv = chip->priv; 395 txx9_priv = chip->priv;
396 396
397 nand_release(mtd); 397 nand_release(mtd);
diff --git a/drivers/mtd/nand/xway_nand.c b/drivers/mtd/nand/xway_nand.c
index 3b28db458ea0..0cf0ac07a8c2 100644
--- a/drivers/mtd/nand/xway_nand.c
+++ b/drivers/mtd/nand/xway_nand.c
@@ -89,7 +89,7 @@ static void xway_select_chip(struct mtd_info *mtd, int chip)
89 89
90static void xway_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl) 90static void xway_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
91{ 91{
92 struct nand_chip *this = mtd->priv; 92 struct nand_chip *this = mtd_to_nand(mtd);
93 unsigned long nandaddr = (unsigned long) this->IO_ADDR_W; 93 unsigned long nandaddr = (unsigned long) this->IO_ADDR_W;
94 unsigned long flags; 94 unsigned long flags;
95 95
@@ -118,7 +118,7 @@ static int xway_dev_ready(struct mtd_info *mtd)
118 118
119static unsigned char xway_read_byte(struct mtd_info *mtd) 119static unsigned char xway_read_byte(struct mtd_info *mtd)
120{ 120{
121 struct nand_chip *this = mtd->priv; 121 struct nand_chip *this = mtd_to_nand(mtd);
122 unsigned long nandaddr = (unsigned long) this->IO_ADDR_R; 122 unsigned long nandaddr = (unsigned long) this->IO_ADDR_R;
123 unsigned long flags; 123 unsigned long flags;
124 int ret; 124 int ret;