mtd: nand: Remove jz4740 driver
Subsystems (10)
PATCH 1/7 mtd: nand: Remove jz4740 driver
From: Marek Vasut <[email protected]>
This driver is not used by anyone, remove it.
--- drivers/mtd/nand/Makefile | 1 - drivers/mtd/nand/jz4740_nand.c | 258 ----------------------------------------- 2 files changed, 259 deletions(-) delete mode 100644 drivers/mtd/nand/jz4740_nand.c
drivers/mtd/nand/Makefile +0 -1
@@ -50,7 +50,6 @@ obj-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_nand.o obj-$(CONFIG_NAND_FSL_IFC) += fsl_ifc_nand.o obj-$(CONFIG_NAND_FSL_UPM) += fsl_upm.o obj-$(CONFIG_NAND_FSMC) += fsmc_nand.o -obj-$(CONFIG_NAND_JZ4740) += jz4740_nand.o obj-$(CONFIG_NAND_KB9202) += kb9202_nand.o obj-$(CONFIG_NAND_KIRKWOOD) += kirkwood_nand.o obj-$(CONFIG_NAND_KMETER1) += kmeter1_nand.o
drivers/mtd/nand/jz4740_nand.c deleted +0 -258
258 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 2/7 mtd: nand: Remove docg4 driver and palmtreo680 flashing tool
Commit ad4f54ea86b ("arm: Remove palmtreo680 board") removed the only user of the docg4 driver and the palmtreo680 image flashing tool. This patch removes them.
--- drivers/mtd/nand/Makefile | 2 - drivers/mtd/nand/docg4.c | 1030 -------------------------------------- drivers/mtd/nand/docg4_spl.c | 219 -------- include/linux/mtd/docg4.h | 132 ----- tools/palmtreo680/flash_u-boot.c | 177 ------- 5 files changed, 1560 deletions(-) delete mode 100644 drivers/mtd/nand/docg4.c delete mode 100644 drivers/mtd/nand/docg4_spl.c delete mode 100644 include/linux/mtd/docg4.h delete mode 100644 tools/palmtreo680/flash_u-boot.c
drivers/mtd/nand/Makefile +0 -2
@@ -13,7 +13,6 @@ endif obj-$(CONFIG_SPL_NAND_AM33XX_BCH) += am335x_spl_bch.o obj-$(CONFIG_SPL_NAND_DENALI) += denali_spl.o -obj-$(CONFIG_SPL_NAND_DOCG4) += docg4_spl.o obj-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o obj-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o obj-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o
@@ -67,7 +66,6 @@ obj-$(CONFIG_TEGRA_NAND) += tegra_nand.o obj-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o obj-$(CONFIG_NAND_OMAP_ELM) += omap_elm.o obj-$(CONFIG_NAND_PLAT) += nand_plat.o -obj-$(CONFIG_NAND_DOCG4) += docg4.o else # minimal SPL drivers
drivers/mtd/nand/docg4.c deleted +0 -1030
1,030 lines not on this page · raw message
drivers/mtd/nand/docg4_spl.c deleted +0 -219
219 lines not on this page · raw message
include/linux/mtd/docg4.h deleted +0 -132
132 lines not on this page · raw message
tools/palmtreo680/flash_u-boot.c deleted +0 -177
177 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 3/7 mtd: nand: Remove nand_info_t typedef
In reply to Scott WoodThis typedef serves no purpose other than causing confusion with struct nand_chip.
--- cmd/bootm.c | 30 +++---- cmd/jffs2.c | 6 +- cmd/nand.c | 161 ++++++++++++++++++----------------- common/env_nand.c | 6 +- common/fb_nand.c | 32 +++---- drivers/dfu/dfu_nand.c | 20 ++--- drivers/mtd/nand/am335x_spl_bch.c | 2 +- drivers/mtd/nand/atmel_nand.c | 2 +- drivers/mtd/nand/mxs_nand_spl.c | 2 +- drivers/mtd/nand/nand.c | 2 +- drivers/mtd/nand/nand_spl_simple.c | 2 +- drivers/mtd/nand/nand_util.c | 170 ++++++++++++++++++------------------- fs/jffs2/jffs2_nand_1pass.c | 24 +++--- fs/yaffs2/yaffs_uboot_glue.c | 2 +- include/nand.h | 39 ++++----- 15 files changed, 251 insertions(+), 249 deletions(-)
cmd/bootm.c +14 -16
@@ -372,8 +372,8 @@ next_bank: ;#endif #if defined(CONFIG_CMD_IMLS_NAND ) -static int nand_imls_legacyimage (nand_info_t *nand,int nand_dev,loff_t off, -size_t len) +static int nand_imls_legacyimage (struct mtd_info *mtd,int nand_dev, +loff_t off,size_t len) {void *imgdata;int ret;
@@ -386,8 +386,7 @@ static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev, loff_t off,return -ENOMEM ; } - ret =nand_read_skip_bad (nand, off, &len, - imgdata); + ret =nand_read_skip_bad (mtd, off, &len, imgdata);if (ret <0 && ret != -EUCLEAN ) {free (imgdata);return ret;
@@ -413,8 +412,8 @@ static int nand_imls_legacyimage(nand_info_t *nand, int nand_dev, loff_t off,return 0 ; } -static int nand_imls_fitimage (nand_info_t *nand,int nand_dev,loff_t off, -size_t len) +static int nand_imls_fitimage (struct mtd_info *mtd,int nand_dev,loff_t off, +size_t len) {void *imgdata;int ret;
@@ -427,8 +426,7 @@ static int nand_imls_fitimage(nand_info_t *nand, int nand_dev, loff_t off,return -ENOMEM ; } - ret =nand_read_skip_bad (nand, off, &len, - imgdata); + ret =nand_read_skip_bad (mtd, off, &len, imgdata);if (ret <0 && ret != -EUCLEAN ) {free (imgdata);return ret;
@@ -449,7 +447,7 @@ static int nand_imls_fitimage(nand_info_t *nand, int nand_dev, loff_t off,static int do_imls_nand (void ) { -nand_info_t *nand; +struct mtd_info *mtd;int nand_dev = nand_curr_device;size_t len;loff_t off;
@@ -463,20 +461,20 @@ static int do_imls_nand(void)printf ("\n" );for (nand_dev =0 ; nand_dev <CONFIG_SYS_MAX_NAND_DEVICE ; nand_dev++) { - nand = &nand_info[nand_dev]; -if (!nand->name || !nand->size) + mtd = &nand_info[nand_dev]; +if (!mtd->name || !mtd->size)continue ; -for (off =0 ; off < nand->size; off += nand->erasesize) { +for (off =0 ; off < mtd->size; off += mtd->erasesize) {const image_header_t *header;int ret; -if (nand_block_isbad (nand, off)) +if (nand_block_isbad (mtd, off))continue ; len =sizeof (buffer); - ret =nand_read (nand, off, &len, (u8 *)buffer); + ret =nand_read (mtd, off, &len, (u8 *)buffer);if (ret <0 && ret != -EUCLEAN ) {printf ("NAND read error %d@offset %08llX\n" , ret, off);
@@ -489,13 +487,13 @@ static int do_imls_nand(void) header = (const image_header_t *)buffer; len =image_get_image_size (header); -nand_imls_legacyimage (nand, nand_dev, off, len); +nand_imls_legacyimage (mtd, nand_dev, off, len);break ;#endif #if defined(CONFIG_FIT )case IMAGE_FORMAT_FIT : len =fit_get_size (buffer); -nand_imls_fitimage (nand, nand_dev, off, len); +nand_imls_fitimage (mtd, nand_dev, off, len);break ;#endif }
cmd/jffs2.c +3 -3
@@ -242,11 +242,11 @@ static int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dstatic inline u32 get_part_sector_size_nand (struct mtdids *id) {#if defined(CONFIG_JFFS2_NAND ) && defined(CONFIG_CMD_NAND ) -nand_info_t *nand; +struct mtd_info *mtd; - nand = &nand_info[id->num]; + mtd = &nand_info[id->num]; -return nand->erasesize; +return mtd->erasesize;#else BUG ();return 0 ;
cmd/nand.c +81 -80
429 lines not on this page · raw message
common/env_nand.c +3 -3
@@ -276,7 +276,7 @@ static int readenv(size_t offset, u_char *buf)#endif /* #if defined(CONFIG_SPL_BUILD) */ #ifdef CONFIG_ENV_OFFSET_OOB -int get_nand_env_oob (nand_info_t *nand,unsigned long *result) +int get_nand_env_oob (struct mtd_info *mtd,unsigned long *result) {struct mtd_oob_ops ops;uint32_t oob_buf[ENV_OFFSET_SIZE /sizeof (uint32_t )];
@@ -288,14 +288,14 @@ int get_nand_env_oob(nand_info_t *nand, unsigned long *result) ops.ooblen =ENV_OFFSET_SIZE ; ops.oobbuf = (void *)oob_buf; - ret = nand->read_oob (nand,ENV_OFFSET_SIZE , &ops); + ret = mtd->read_oob (mtd,ENV_OFFSET_SIZE , &ops);if (ret) {printf ("error reading OOB block 0\n" );return ret; }if (oob_buf[0 ] ==ENV_OOB_MARKER ) { - *result = oob_buf[1 ] * nand->erasesize; + *result = oob_buf[1 ] * mtd->erasesize; }else if (oob_buf[0 ] ==ENV_OOB_MARKER_OLD ) { *result = oob_buf[1 ]; }else {
common/fb_nand.c +16 -16
@@ -19,7 +19,7 @@static char *response_str;struct fb_nand_sparse { -nand_info_t *nand; +struct mtd_info *nand;struct part_info *part; };
@@ -34,7 +34,7 @@ __weak int board_fastboot_write_partition_setup(char *name) }static int fb_nand_lookup (const char *partname,char *response, -nand_info_t **nand, +struct mtd_info **nand,struct part_info **part) {struct mtd_device *dev;
@@ -62,12 +62,12 @@ static int fb_nand_lookup(const char *partname, char *response,return -EINVAL ; } - *nand = &nand_info[dev->id->num]; + *mtd = &nand_info[dev->id->num];return 0 ; } -static int _fb_nand_erase (nand_info_t *nand,struct part_info *part) +static int _fb_nand_erase (struct mtd_info *mtd,struct part_info *part) {nand_erase_options_t opts;int ret;
@@ -80,7 +80,7 @@ static int _fb_nand_erase(nand_info_t *nand, struct part_info *part)printf ("Erasing blocks 0x%llx to 0x%llx\n" , part->offset, part->offset + part->size); - ret =nand_erase_opts (nand, &opts); + ret =nand_erase_opts (mtd, &opts);if (ret)return ret;
@@ -90,7 +90,7 @@ static int _fb_nand_erase(nand_info_t *nand, struct part_info *part)return 0 ; } -static int _fb_nand_write (nand_info_t *nand,struct part_info *part, +static int _fb_nand_write (struct mtd_info *mtd,struct part_info *part,void *buffer,unsigned int offset,unsigned int length,size_t *written) {
@@ -100,7 +100,7 @@ static int _fb_nand_write(nand_info_t *nand, struct part_info *part, flags |=WITH_DROP_FFS ;#endif -return nand_write_skip_bad (nand, offset, &length, written, +return nand_write_skip_bad (mtd, offset, &length, written, part->size - (offset - part->offset), buffer, flags); }
@@ -131,13 +131,13 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id, char *response) {struct part_info *part; -nand_info_t *nand =NULL ; +struct mtd_info *mtd =NULL ;int ret;/* initialize the response buffer */ response_str = response; - ret =fb_nand_lookup (partname, response, &nand, &part); + ret =fb_nand_lookup (partname, response, &mtd, &part);if (ret) {error ("invalid NAND device" );fastboot_fail (response_str,"invalid NAND device" );
@@ -152,10 +152,10 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id,struct fb_nand_sparse sparse_priv;sparse_storage_t sparse; - sparse_priv.nand = nand; + sparse_priv.nand = mtd; sparse_priv.part = part; - sparse.block_sz = nand->writesize; + sparse.block_sz = mtd->writesize; sparse.start = part->offset / sparse.block_sz; sparse.size = part->size / sparse.block_sz; sparse.name = part->name;
@@ -167,7 +167,7 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id,printf ("Flashing raw image at offset 0x%llx\n" , part->offset); - ret =_fb_nand_write (nand, part, download_buffer, part->offset, + ret =_fb_nand_write (mtd, part, download_buffer, part->offset, download_bytes,NULL ); printf("........ wrote %u bytes to '%s'\n",
@@ -185,13 +185,13 @@ void fb_nand_flash_write(const char *partname, unsigned int session_id,void fb_nand_erase (const char *partname,char *response) {struct part_info *part; -nand_info_t *nand =NULL ; +struct mtd_info *mtd =NULL ;int ret;/* initialize the response buffer */ response_str = response; - ret =fb_nand_lookup (partname, response, &nand, &part); + ret =fb_nand_lookup (partname, response, &mtd, &part);if (ret) {error ("invalid NAND device" );fastboot_fail (response_str,"invalid NAND device" );
@@ -202,9 +202,9 @@ void fb_nand_erase(const char *partname, char *response)if (ret)return ; - ret =_fb_nand_erase (nand, part); + ret =_fb_nand_erase (mtd, part);if (ret) { -error ("failed erasing from device %s" , nand->name); +error ("failed erasing from device %s" , mtd->name);fastboot_fail (response_str,"failed erasing from device" );return ; }
drivers/dfu/dfu_nand.c +10 -10
@@ -25,7 +25,7 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu,loff_t start, lim;size_t count, actual;int ret; -nand_info_t *nand; +struct mtd_info *mtd;/* if buf == NULL return total size of the area */ if (buf ==NULL ) {
@@ -44,11 +44,11 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu,return -1 ; } - nand = &nand_info[nand_curr_device]; + mtd = &nand_info[nand_curr_device];if (op ==DFU_OP_READ ) { - ret =nand_read_skip_bad (nand, start, &count, &actual, - lim, buf); + ret =nand_read_skip_bad (mtd, start, &count, &actual, + lim, buf); }else {nand_erase_options_t opts;
@@ -59,12 +59,12 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu, opts.quiet =1 ; opts.lim = lim;/* first erase */ - ret =nand_erase_opts (nand, &opts); + ret =nand_erase_opts (mtd, &opts);if (ret)return ret;/* then write */ - ret =nand_write_skip_bad (nand, start, &count, &actual, - lim, buf,WITH_WR_VERIFY ); + ret =nand_write_skip_bad (mtd, start, &count, &actual, + lim, buf,WITH_WR_VERIFY ); }if (ret !=0 ) {
@@ -142,7 +142,7 @@ static int dfu_flush_medium_nand(struct dfu_entity *dfu)/* in case of ubi partition, erase rest of the partition */ if (dfu->data.nand.ubi) { -nand_info_t *nand; +struct mtd_info *mtd;nand_erase_options_t opts; if (nand_curr_device < 0 ||
@@ -152,14 +152,14 @@ static int dfu_flush_medium_nand(struct dfu_entity *dfu)return -1 ; } - nand = &nand_info[nand_curr_device]; + mtd = &nand_info[nand_curr_device];memset (&opts,0 ,sizeof (opts)); opts.offset = dfu->data.nand.start + dfu->offset + dfu->bad_skip; opts.length = dfu->data.nand.start + dfu->data.nand.size - opts.offset; - ret =nand_erase_opts (nand, &opts); + ret =nand_erase_opts (mtd, &opts);if (ret !=0 )printf ("Failure erase: %d\n" , ret); }
drivers/mtd/nand/am335x_spl_bch.c +1 -1
@@ -16,7 +16,7 @@#include <linux/mtd/nand_ecc.h> static int nand_ecc_pos[] =CONFIG_SYS_NAND_ECCPOS ; -nand_info_t nand_info[1 ]; +struct mtd_info nand_info[1 ];static struct nand_chip nand_chip;#define ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \
drivers/mtd/nand/atmel_nand.c +1 -1
@@ -1238,7 +1238,7 @@ static int at91_nand_ready(struct mtd_info *mtd)#ifdef CONFIG_SPL_BUILD /* The following code is for SPL */ -static nand_info_t mtd; +static struct mtd_info mtd;static struct nand_chip nand_chip;static int nand_command (int block,int page,uint32_t offs,u8 cmd)
drivers/mtd/nand/mxs_nand_spl.c +1 -1
@@ -8,7 +8,7 @@#include <nand.h> #include <malloc.h> -static nand_info_t mtd; +static struct mtd_info mtd;static struct nand_chip nand_chip; static void mxs_nand_command(struct mtd_info *mtd, unsigned int command,
drivers/mtd/nand/nand.c +1 -1
@@ -19,7 +19,7 @@ DECLARE_GLOBAL_DATA_PTR;int nand_curr_device =-1 ; -nand_info_t nand_info[CONFIG_SYS_MAX_NAND_DEVICE ]; +struct mtd_info nand_info[CONFIG_SYS_MAX_NAND_DEVICE ];#ifndef CONFIG_SYS_NAND_SELF_INIT static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE ];
drivers/mtd/nand/nand_spl_simple.c +1 -1
@@ -11,7 +11,7 @@#include <linux/mtd/nand_ecc.h> static int nand_ecc_pos[] =CONFIG_SYS_NAND_ECCPOS ; -static nand_info_t mtd; +static struct mtd_info mtd;static struct nand_chip nand_chip;#define ECCSTEPS (CONFIG_SYS_NAND_PAGE_SIZE / \
drivers/mtd/nand/nand_util.c +85 -85
466 lines not on this page · raw message
fs/jffs2/jffs2_nand_1pass.c +13 -11
@@ -23,7 +23,7 @@ # define DEBUGF(fmt,args...)#endif -static nand_info_t *nand; +static struct mtd_info *mtd;/* Compression names */ static char *compr_names[] = {
@@ -304,7 +304,7 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 ino, char *dest, len =sizeof (struct jffs2_raw_inode );if (dest) len += jNode->csize; -nand_read (nand, jNode->offset, &len, inode); +nand_read (mtd, jNode->offset, &len, inode);/* ignore data behind latest known EOF */ if (inode->offset > totalSize)continue ;
@@ -450,7 +450,7 @@ dump_inode(struct b_lists *pL, struct b_dirent *d, struct b_inode *i)if (!d || !i)return -1 ; len = d->nsize; -nand_read (nand, d->offset +sizeof (struct jffs2_raw_dirent ), +nand_read (mtd, d->offset +sizeof (struct jffs2_raw_dirent ), &len, &fname); fname[d->nsize] ='\0' ;
@@ -592,7 +592,9 @@ jffs2_1pass_resolve_inode(struct b_lists * pL, u32 ino)for (jNode = (struct b_inode *)pL->frag.listHead; jNode; jNode = jNode->next) {if (jNode->ino == jDirFoundIno) {size_t len = jNode->csize; -nand_read (nand, jNode->offset +sizeof (struct jffs2_raw_inode ), &len, &tmp); +nand_read (mtd, + jNode->offset +sizeof (struct jffs2_raw_inode ), + &len, &tmp); tmp[jNode->csize] ='\0' ;break ; }
@@ -760,14 +762,14 @@ dump_dirents(struct b_lists *pL)#endif static int -jffs2_fill_scan_buf (nand_info_t *nand,unsigned char *buf, +jffs2_fill_scan_buf (struct mtd_info *mtd,unsigned char *buf,unsigned ofs,unsigned len) {int ret;unsigned olen; olen = len; - ret =nand_read (nand, ofs, &olen, buf); + ret =nand_read (mtd, ofs, &olen, buf);if (ret) {printf ("nand_read(0x%x bytes from 0x%x) returned %d\n" , len, ofs, ret);return ret;
@@ -794,7 +796,7 @@ jffs2_1pass_build_lists(struct part_info * part)u32 counterN =0 ;struct mtdids *id = part->dev->id; - nand = nand_info + id->num; + mtd = nand_info + id->num;/* if we are building a list we need to refresh the cache. */ jffs_init_1pass_list (part);
@@ -802,7 +804,7 @@ jffs2_1pass_build_lists(struct part_info * part) pL->partOffset = part->offset;puts ("Scanning JFFS2 FS: " ); - sectorsize = nand->erasesize; + sectorsize = mtd->erasesize; nr_blocks = part->size / sectorsize; buf =malloc (sectorsize);if (!buf)
@@ -813,10 +815,10 @@ jffs2_1pass_build_lists(struct part_info * part) offset = part->offset + i * sectorsize; -if (nand_block_isbad (nand, offset)) +if (nand_block_isbad (mtd, offset))continue ; -if (jffs2_fill_scan_buf (nand, buf, offset,EMPTY_SCAN_SIZE )) +if (jffs2_fill_scan_buf (mtd, buf, offset,EMPTY_SCAN_SIZE ))return 0 ; ofs =0 ;
@@ -826,7 +828,7 @@ jffs2_1pass_build_lists(struct part_info * part)if (ofs ==EMPTY_SCAN_SIZE )continue ; -if (jffs2_fill_scan_buf (nand, buf +EMPTY_SCAN_SIZE , offset +EMPTY_SCAN_SIZE , sectorsize -EMPTY_SCAN_SIZE )) +if (jffs2_fill_scan_buf (mtd, buf +EMPTY_SCAN_SIZE , offset +EMPTY_SCAN_SIZE , sectorsize -EMPTY_SCAN_SIZE ))return 0 ; offset += ofs;
fs/yaffs2/yaffs_uboot_glue.c +1 -1
@@ -141,7 +141,7 @@ static const char *yaffs_error_str(void) } } -extern nand_info_t nand_info[]; +extern struct mtd_info nand_info[];void cmd_yaffs_tracemask (unsigned set,unsigned mask) {
include/nand.h +20 -19
@@ -40,27 +40,27 @@ int nand_register(int devnum);extern int board_nand_init (struct nand_chip *nand);#endif -typedef struct mtd_info nand_info_t ; -extern int nand_curr_device; -extern nand_info_t nand_info[]; +extern struct mtd_info nand_info[]; -static inline int nand_read (nand_info_t *info,loff_t ofs,size_t *len,u_char *buf) +static inline int nand_read (struct mtd_info *info,loff_t ofs,size_t *len, +u_char *buf) {return mtd_read (info, ofs, *len, (size_t *)len, buf); } -static inline int nand_write (nand_info_t *info,loff_t ofs,size_t *len,u_char *buf) +static inline int nand_write (struct mtd_info *info,loff_t ofs,size_t *len, +u_char *buf) {return mtd_write (info, ofs, *len, (size_t *)len, buf); } -static inline int nand_block_isbad (nand_info_t *info,loff_t ofs) +static inline int nand_block_isbad (struct mtd_info *info,loff_t ofs) {return mtd_block_isbad (info, ofs); } -static inline int nand_erase (nand_info_t *info,loff_t off,size_t size) +static inline int nand_erase (struct mtd_info *info,loff_t off,size_t size) {struct erase_info instr;
@@ -96,27 +96,28 @@ struct nand_erase_options {typedef struct nand_erase_options nand_erase_options_t ; -int nand_read_skip_bad (nand_info_t *nand,loff_t offset,size_t *length, +int nand_read_skip_bad (struct mtd_info *mtd,loff_t offset,size_t *length,size_t *actual,loff_t lim,u_char *buffer);#define WITH_DROP_FFS (1 << 0)/* drop trailing all-0xff pages */ #define WITH_WR_VERIFY (1 << 1)/* verify data was written correctly */ -int nand_write_skip_bad (nand_info_t *nand,loff_t offset,size_t *length, +int nand_write_skip_bad (struct mtd_info *mtd,loff_t offset,size_t *length,size_t *actual,loff_t lim,u_char *buffer,int flags); -int nand_erase_opts (nand_info_t *meminfo,const nand_erase_options_t *opts); -int nand_torture (nand_info_t *nand,loff_t offset); -int nand_verify_page_oob (nand_info_t *nand,struct mtd_oob_ops *ops, -loff_t ofs); -int nand_verify (nand_info_t *nand,loff_t ofs,size_t len,u_char *buf); +int nand_erase_opts (struct mtd_info *mtd, +const nand_erase_options_t *opts); +int nand_torture (struct mtd_info *mtd,loff_t offset); +int nand_verify_page_oob (struct mtd_info *mtd,struct mtd_oob_ops *ops, +loff_t ofs); +int nand_verify (struct mtd_info *mtd,loff_t ofs,size_t len,u_char *buf);#define NAND_LOCK_STATUS_TIGHT 0x01#define NAND_LOCK_STATUS_UNLOCK 0x04 -int nand_lock (nand_info_t *meminfo,int tight); -int nand_unlock (nand_info_t *meminfo,loff_t start,size_t length, -int allexcept); -int nand_get_lock_status (nand_info_t *meminfo,loff_t offset); +int nand_lock (struct mtd_info *mtd,int tight); +int nand_unlock (struct mtd_info *mtd,loff_t start,size_t length, +int allexcept); +int nand_get_lock_status (struct mtd_info *mtd,loff_t offset);int nand_spl_load_image (uint32_t offs,unsigned int size,void *dst);void nand_deselect (void );
@@ -135,6 +136,6 @@ __attribute__((noreturn)) void nand_boot(void);#define ENV_OOB_MARKER_OLD 0x30564e45/*"ENV0" in little-endian -- offset is stored as byte number */ #define ENV_OFFSET_SIZE 8 -int get_nand_env_oob (nand_info_t *nand,unsigned long *result); +int get_nand_env_oob (struct mtd_info *mtd,unsigned long *result);#endif int spl_nand_erase_one (int block,int page);
Signature · 1 line
2.5.0
PATCH 4/7 nand: Embed mtd_info in struct nand_chip
In reply to Scott Woodnand_info[] is now an array of pointers, with the actual mtd_info instance embedded in struct nand_chip.
This is in preparation for syncing the NAND code with Linux 4.6, which makes the same change to struct nand_chip. It's in a separate commit due to the large amount of changes required to accommodate the change to nand_info[].
--- board/BuR/common/common.c | 2 +- board/atmel/at91sam9261ek/at91sam9261ek.c | 2 +- board/atmel/at91sam9263ek/at91sam9263ek.c | 2 +- board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c | 2 +- board/atmel/at91sam9n12ek/at91sam9n12ek.c | 2 +- board/atmel/at91sam9rlek/at91sam9rlek.c | 2 +- board/atmel/at91sam9x5ek/at91sam9x5ek.c | 2 +- board/atmel/sama5d3xek/sama5d3xek.c | 2 +- board/atmel/sama5d4_xplained/sama5d4_xplained.c | 2 +- board/atmel/sama5d4ek/sama5d4ek.c | 2 +- board/ronetix/pm9261/pm9261.c | 2 +- board/ronetix/pm9263/pm9263.c | 2 +- cmd/bootm.c | 2 +- cmd/jffs2.c | 4 +- cmd/nand.c | 42 ++++++------ common/env_nand.c | 18 +++--- common/fb_nand.c | 2 +- common/splash_source.c | 4 +- doc/README.nand | 15 ++--- drivers/dfu/dfu_nand.c | 8 +-- drivers/mtd/nand/am335x_spl_bch.c | 54 ++++++++-------- drivers/mtd/nand/arasan_nfc.c | 4 +- drivers/mtd/nand/atmel_nand.c | 77 +++++++++++----------- drivers/mtd/nand/denali.c | 4 +- drivers/mtd/nand/fsl_elbc_nand.c | 5 +- drivers/mtd/nand/fsl_ifc_nand.c | 5 +- drivers/mtd/nand/fsmc_nand.c | 10 ++- drivers/mtd/nand/lpc32xx_nand_mlc.c | 10 ++- drivers/mtd/nand/mpc5121_nfc.c | 3 +- drivers/mtd/nand/mxc_nand.c | 2 +- drivers/mtd/nand/mxs_nand_spl.c | 33 +++++----- drivers/mtd/nand/nand.c | 27 +++++--- drivers/mtd/nand/nand_spl_simple.c | 85 +++++++++++++------------ drivers/mtd/nand/omap_gpmc.c | 4 +- drivers/mtd/nand/pxa3xx_nand.c | 10 +-- drivers/mtd/nand/tegra_nand.c | 4 +- drivers/mtd/nand/vf610_nfc.c | 5 +- drivers/net/fm/fm.c | 2 +- drivers/net/phy/cortina.c | 4 +- fs/jffs2/jffs2_1pass.c | 2 +- fs/jffs2/jffs2_nand_1pass.c | 2 +- fs/yaffs2/yaffs_uboot_glue.c | 8 +-- include/linux/mtd/nand.h | 1 + include/nand.h | 6 +- 44 files changed, 247 insertions(+), 239 deletions(-)
board/BuR/common/common.c +1 -1
@@ -259,7 +259,7 @@ static int load_devicetree(void) }#ifdef CONFIG_NAND dtbsize =0x20000 ; - rc =nand_read_skip_bad (&nand_info[0 ],0x40000 , (size_t *)&dtbsize, + rc =nand_read_skip_bad (nand_info[0 ],0x40000 , (size_t *)&dtbsize,NULL ,0x20000 , (u_char *)dtbaddr);#else char *dtbname =getenv ("dtb" );
board/atmel/at91sam9261ek/at91sam9261ek.c +1 -1
@@ -212,7 +212,7 @@ void lcd_show_board_info(void) dram_size += gd->bd->bi_dram[i].size; nand_size =0 ;for (i =0 ; i <CONFIG_SYS_MAX_NAND_DEVICE ; i++) - nand_size += nand_info[i].size; + nand_size += nand_info[i]->size;lcd_printf (" %ld MB SDRAM, %ld MB NAND\n" , dram_size >>20 , nand_size >>20 );
board/atmel/at91sam9263ek/at91sam9263ek.c +1 -1
@@ -191,7 +191,7 @@ void lcd_show_board_info(void) dram_size += gd->bd->bi_dram[i].size; nand_size =0 ;for (i =0 ; i <CONFIG_SYS_MAX_NAND_DEVICE ; i++) - nand_size += nand_info[i].size; + nand_size += nand_info[i]->size;#ifndef CONFIG_SYS_NO_FLASH flash_size =0 ;for (i =0 ; i <CONFIG_SYS_MAX_FLASH_BANKS ; i++)
board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c +1 -1
@@ -272,7 +272,7 @@ void lcd_show_board_info(void) dram_size += gd->bd->bi_dram[i].size; nand_size =0 ;for (i =0 ; i <CONFIG_SYS_MAX_NAND_DEVICE ; i++) - nand_size += nand_info[i].size; + nand_size += nand_info[i]->size;lcd_printf (" %ld MB SDRAM, %ld MB NAND\n" , dram_size >>20 , nand_size >>20 );
board/atmel/at91sam9n12ek/at91sam9n12ek.c +1 -1
@@ -124,7 +124,7 @@ void lcd_show_board_info(void) dram_size += gd->bd->bi_dram[i].size; nand_size =0 ;for (i =0 ; i <CONFIG_SYS_MAX_NAND_DEVICE ; i++) - nand_size += nand_info[i].size; + nand_size += nand_info[i]->size;lcd_printf (" %ld MB SDRAM, %ld MB NAND\n" , dram_size >>20 , nand_size >>20 );
board/atmel/at91sam9rlek/at91sam9rlek.c +1 -1
@@ -151,7 +151,7 @@ void lcd_show_board_info(void) dram_size += gd->bd->bi_dram[i].size; nand_size =0 ;for (i =0 ; i <CONFIG_SYS_MAX_NAND_DEVICE ; i++) - nand_size += nand_info[i].size; + nand_size += nand_info[i]->size;lcd_printf (" %ld MB SDRAM, %ld MB NAND\n" , dram_size >>20 , nand_size >>20 );
board/atmel/at91sam9x5ek/at91sam9x5ek.c +1 -1
@@ -196,7 +196,7 @@ void lcd_show_board_info(void) dram_size += gd->bd->bi_dram[i].size; nand_size =0 ;for (i =0 ; i <CONFIG_SYS_MAX_NAND_DEVICE ; i++) - nand_size += nand_info[i].size; + nand_size += nand_info[i]->size;lcd_printf (" %ld MB SDRAM, %ld MB NAND\n" , dram_size >>20 , nand_size >>20 );
board/atmel/sama5d3xek/sama5d3xek.c +1 -1
@@ -207,7 +207,7 @@ void lcd_show_board_info(void) nand_size =0 ;#ifdef CONFIG_NAND_ATMEL for (i =0 ; i <CONFIG_SYS_MAX_NAND_DEVICE ; i++) - nand_size += nand_info[i].size; + nand_size += nand_info[i]->size;#endif lcd_printf ("%ld MB SDRAM, %lld MB NAND\n" , dram_size >>20 , nand_size >>20 );
board/atmel/sama5d4_xplained/sama5d4_xplained.c +1 -1
@@ -191,7 +191,7 @@ void lcd_show_board_info(void) nand_size =0 ;#ifdef CONFIG_NAND_ATMEL for (i =0 ; i <CONFIG_SYS_MAX_NAND_DEVICE ; i++) - nand_size += nand_info[i].size; + nand_size += nand_info[i]->size;#endif lcd_printf ("%ld MB SDRAM, %ld MB NAND\n" , dram_size >>20 , nand_size >>20 );
board/atmel/sama5d4ek/sama5d4ek.c +1 -1
@@ -187,7 +187,7 @@ void lcd_show_board_info(void) nand_size =0 ;#ifdef CONFIG_NAND_ATMEL for (i =0 ; i <CONFIG_SYS_MAX_NAND_DEVICE ; i++) - nand_size += nand_info[i].size; + nand_size += nand_info[i]->size;#endif lcd_printf ("%ld MB SDRAM, %ld MB NAND\n" , dram_size >>20 , nand_size >>20 );
board/ronetix/pm9261/pm9261.c +1 -1
@@ -194,7 +194,7 @@ void lcd_show_board_info(void) nand_size =0 ;for (i =0 ; i <CONFIG_SYS_MAX_NAND_DEVICE ; i++) - nand_size += nand_info[i].size; + nand_size += nand_info[i]->size; flash_size =0 ;for (i =0 ; i <CONFIG_SYS_MAX_FLASH_BANKS ; i++)
board/ronetix/pm9263/pm9263.c +1 -1
@@ -293,7 +293,7 @@ void lcd_show_board_info(void) nand_size =0 ;for (i =0 ; i <CONFIG_SYS_MAX_NAND_DEVICE ; i++) - nand_size += nand_info[i].size; + nand_size += nand_info[i]->size; flash_size =0 ;for (i =0 ; i <CONFIG_SYS_MAX_FLASH_BANKS ; i++)
cmd/bootm.c +1 -1
@@ -461,7 +461,7 @@ static int do_imls_nand(void)printf ("\n" );for (nand_dev =0 ; nand_dev <CONFIG_SYS_MAX_NAND_DEVICE ; nand_dev++) { - mtd = &nand_info[nand_dev]; + mtd = nand_info[nand_dev];if (!mtd->name || !mtd->size)continue ;
cmd/jffs2.c +2 -2
@@ -167,7 +167,7 @@ static int mtd_device_validate(u8 type, u8 num, u32 *size) }else if (type ==MTD_DEV_TYPE_NAND ) {#if defined(CONFIG_JFFS2_NAND ) && defined(CONFIG_CMD_NAND )if (num <CONFIG_SYS_MAX_NAND_DEVICE ) { - *size = nand_info[num].size; + *size = nand_info[num]->size;return 0 ; }
@@ -244,7 +244,7 @@ static inline u32 get_part_sector_size_nand(struct mtdids *id)#if defined(CONFIG_JFFS2_NAND ) && defined(CONFIG_CMD_NAND )struct mtd_info *mtd; - mtd = &nand_info[id->num]; + mtd = nand_info[id->num];return mtd->erasesize;#else
cmd/nand.c +21 -21
160 lines not on this page · raw message
common/env_nand.c +9 -9
@@ -132,15 +132,15 @@ static int writeenv(size_t offset, u_char *buf)size_t blocksize, len;u_char *char_ptr; - blocksize = nand_info[0 ].erasesize; + blocksize = nand_info[0 ]->erasesize; len =min (blocksize, (size_t )CONFIG_ENV_SIZE );while (amount_saved <CONFIG_ENV_SIZE && offset < end) { -if (nand_block_isbad (&nand_info[0 ], offset)) { +if (nand_block_isbad (nand_info[0 ], offset)) { offset += blocksize; }else { char_ptr = &buf[amount_saved]; -if (nand_write (&nand_info[0 ], offset, &len, char_ptr)) +if (nand_write (nand_info[0 ], offset, &len, char_ptr))return 1 ; offset += blocksize;
@@ -164,7 +164,7 @@ static int erase_and_write_env(const struct env_location *location,int ret =0 ;printf ("Erasing %s...\n" , location->name); -if (nand_erase_opts (&nand_info[0 ], &location->erase_opts)) +if (nand_erase_opts (nand_info[0 ], &location->erase_opts))return 1 ;printf ("Writing to %s... " , location->name);
@@ -247,20 +247,20 @@ static int readenv(size_t offset, u_char *buf)size_t blocksize, len;u_char *char_ptr; - blocksize = nand_info[0 ].erasesize; + blocksize = nand_info[0 ]->erasesize;if (!blocksize)return 1 ; len =min (blocksize, (size_t )CONFIG_ENV_SIZE );while (amount_loaded <CONFIG_ENV_SIZE && offset < end) { -if (nand_block_isbad (&nand_info[0 ], offset)) { +if (nand_block_isbad (nand_info[0 ], offset)) { offset += blocksize; }else { char_ptr = &buf[amount_loaded]; -if (nand_read_skip_bad (&nand_info[0 ], offset, +if (nand_read_skip_bad (nand_info[0 ], offset, &len,NULL , - nand_info[0 ].size, char_ptr)) + nand_info[0 ]->size, char_ptr))return 1 ; offset += blocksize;
@@ -387,7 +387,7 @@ void env_relocate_spec(void)ALLOC_CACHE_ALIGN_BUFFER (char, buf,CONFIG_ENV_SIZE );#if defined(CONFIG_ENV_OFFSET_OOB ) - ret =get_nand_env_oob (&nand_info[0 ], &nand_env_oob_offset); + ret =get_nand_env_oob (nand_info[0 ], &nand_env_oob_offset);/* * If unable to read environment offset from NAND OOB then fall through * to the normal environment reading code below
common/fb_nand.c +1 -1
@@ -62,7 +62,7 @@ static int fb_nand_lookup(const char *partname, char *response,return -EINVAL ; } - *mtd = &nand_info[dev->id->num]; + *mtd = nand_info[dev->id->num];return 0 ; }
common/splash_source.c +2 -2
@@ -45,9 +45,9 @@ static int splash_sf_read_raw(u32 bmp_load_addr, int offset, size_t read_size)#ifdef CONFIG_CMD_NAND static int splash_nand_read_raw (u32 bmp_load_addr,int offset,size_t read_size) { -return nand_read_skip_bad (&nand_info[nand_curr_device], offset, +return nand_read_skip_bad (nand_info[nand_curr_device], offset, &read_size,NULL , - nand_info[nand_curr_device].size, + nand_info[nand_curr_device]->size, (u_char *)bmp_load_addr); }#else
doc/README.nand +6 -9
@@ -136,15 +136,8 @@ Configuration Options: Example of new init to be added to the end of an existing driver init: - /* - * devnum is the device number to be used in nand commands - * and in mtd->name. Must be less than - * CONFIG_SYS_NAND_MAX_DEVICE. - */ - mtd = &nand_info[devnum]; - /* chip is struct nand_chip, and is now provided by the driver. */ - mtd->priv = &chip; + mtd = &chip.mtd; /* * Fill in appropriate values if this driver uses these fields,
@@ -165,7 +158,11 @@ Configuration Options: if (nand_scan_tail(mtd)) error out - if (nand_register(devnum)) + /* + * devnum is the device number to be used in nand commands + * and in mtd->name. Must be less than CONFIG_SYS_NAND_MAX_DEVICE. + */ + if (nand_register(devnum, mtd)) error out In addition to providing more flexibility to the driver, it reduces
drivers/dfu/dfu_nand.c +4 -4
@@ -39,12 +39,12 @@ static int nand_block_op(enum dfu_op op, struct dfu_entity *dfu,if (nand_curr_device <0 || nand_curr_device >=CONFIG_SYS_MAX_NAND_DEVICE || - !nand_info[nand_curr_device].name) { + !nand_info[nand_curr_device]->name) {printf ("%s: invalid nand device\n" , __func__);return -1 ; } - mtd = &nand_info[nand_curr_device]; + mtd = nand_info[nand_curr_device];if (op ==DFU_OP_READ ) { ret = nand_read_skip_bad(mtd, start, &count, &actual,
@@ -147,12 +147,12 @@ static int dfu_flush_medium_nand(struct dfu_entity *dfu)if (nand_curr_device <0 || nand_curr_device >=CONFIG_SYS_MAX_NAND_DEVICE || - !nand_info[nand_curr_device].name) { + !nand_info[nand_curr_device]->name) {printf ("%s: invalid nand device\n" , __func__);return -1 ; } - mtd = &nand_info[nand_curr_device]; + mtd = nand_info[nand_curr_device];memset (&opts,0 ,sizeof (opts)); opts.offset = dfu->data.nand.start + dfu->offset +
drivers/mtd/nand/am335x_spl_bch.c +27 -27
150 lines not on this page · raw message
drivers/mtd/nand/arasan_nfc.c +2 -2
@@ -1101,7 +1101,7 @@ static int arasan_nand_init(struct nand_chip *nand_chip, int devnum) } nand->nand_base = arasan_nand_base; - mtd = &nand_info[0 ]; + mtd = &nand_chip->mtd; nand_chip->priv = nand; mtd->priv = nand_chip;
@@ -1134,7 +1134,7 @@ static int arasan_nand_init(struct nand_chip *nand_chip, int devnum) goto fail; } -if (nand_register (devnum)) { +if (nand_register (devnum, mtd)) {printf ("Nand Register Fail\n" ); goto fail; }
drivers/mtd/nand/atmel_nand.c +39 -38
194 lines not on this page · raw message
drivers/mtd/nand/denali.c +2 -2
@@ -1263,7 +1263,7 @@ static int denali_init(struct denali_nand_info *denali) goto fail; } - ret =nand_register (0 ); + ret =nand_register (0 , denali->mtd); fail:return ret;
@@ -1282,7 +1282,7 @@ static int __board_nand_init(void)* for instantiating struct nand_chip, while drivers/mtd/nand/nand.c * still provides a "struct mtd_info nand_info" instance. */ - denali->mtd = &nand_info[0 ]; + denali->mtd = &denali->nand.mtd;/* * In the future, these base addresses should be taken from
drivers/mtd/nand/fsl_elbc_nand.c +3 -2
@@ -656,7 +656,7 @@ static void fsl_elbc_ctrl_init(void)static int fsl_elbc_chip_init (int devnum,u8 *addr) { -struct mtd_info *mtd = &nand_info[devnum]; +struct mtd_info *mtd;struct nand_chip *nand;struct fsl_elbc_mtd *priv;uint32_t br =0 , or =0 ;
@@ -697,6 +697,7 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr) } nand = &priv->chip; + mtd = &nand->mtd; mtd->priv = nand; elbc_ctrl->chips[priv->bank] = priv;
@@ -787,7 +788,7 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr)if (ret)return ret; - ret =nand_register (devnum); + ret =nand_register (devnum, mtd);if (ret)return ret;
drivers/mtd/nand/fsl_ifc_nand.c +3 -2
@@ -880,7 +880,7 @@ static int fsl_ifc_sram_init(uint32_t ver)static int fsl_ifc_chip_init (int devnum,u8 *addr) { -struct mtd_info *mtd = &nand_info[devnum]; +struct mtd_info *mtd;struct nand_chip *nand;struct fsl_ifc_mtd *priv;struct nand_ecclayout *layout;
@@ -925,6 +925,7 @@ static int fsl_ifc_chip_init(int devnum, u8 *addr) } nand = &priv->chip; + mtd = &nand->mtd; mtd->priv = nand; ifc_ctrl->chips[priv->bank] = priv;
@@ -1044,7 +1045,7 @@ static int fsl_ifc_chip_init(int devnum, u8 *addr)if (ret)return ret; - ret =nand_register (devnum); + ret =nand_register (devnum, mtd);if (ret)return ret;return 0 ;
drivers/mtd/nand/fsmc_nand.c +4 -6
@@ -409,7 +409,7 @@ int fsmc_nand_switch_ecc(uint32_t eccstrength)* Nomadik SoC is currently supporting this fsmc_nand_switch_ecc() * function, as it doesn't need to switch to a different ECC layout. */ - mtd = &nand_info[nand_curr_device]; + mtd = nand_info[nand_curr_device]; nand = mtd->priv;/* Setup the ecc configurations again */
@@ -443,7 +443,6 @@ int fsmc_nand_init(struct nand_chip *nand) {static int chip_nr;struct mtd_info *mtd; -int i;u32 peripid2 =readl (&fsmc_regs_p->peripid2); fsmc_version = (peripid2 >> FSMC_REVISION_SHFT) &
@@ -480,7 +479,7 @@ int fsmc_nand_init(struct nand_chip *nand) (void __iomem *)CONFIG_SYS_NAND_BASE ; nand->badblockbits =7 ; - mtd = &nand_info[chip_nr++]; + mtd = &nand->mtd; mtd->priv = nand;switch (fsmc_version) {
@@ -514,9 +513,8 @@ int fsmc_nand_init(struct nand_chip *nand)if (nand_scan_tail (mtd))return -ENXIO ; -for (i =0 ; i <CONFIG_SYS_MAX_NAND_DEVICE ; i++) -if (nand_register (i)) -return -ENXIO ; +if (nand_register (chip_nr++, mtd)) +return -ENXIO ;return 0 ; }
drivers/mtd/nand/lpc32xx_nand_mlc.c +4 -6
@@ -539,13 +539,11 @@ static struct nand_chip lpc32xx_chip;void board_nand_init (void ) { -/* we have only one device anyway */ -struct mtd_info *mtd = &nand_info[0 ]; -/* chip is struct nand_chip, and is now provided by the driver. */ - mtd->priv = &lpc32xx_chip; -/* to store return status in case we need to print it */ +struct mtd_info *mtd = &lpc32xx_chip.mtd;int ret; + mtd->priv = &lpc32xx_chip; +/* Set all BOARDSPECIFIC (actually core-specific) fields */ lpc32xx_chip.IO_ADDR_R = &lpc32xx_nand_mlc_registers->buff;
@@ -597,7 +595,7 @@ void board_nand_init(void) }/* chip is good, register it */ - ret =nand_register (0 ); + ret =nand_register (0 , mtd);if (ret)error ("nand_register returned %i" , ret); }
drivers/mtd/nand/mpc5121_nfc.c +1 -2
@@ -549,7 +549,6 @@ int board_nand_init(struct nand_chip *chip)int resettime =0 ;int retval =0 ;int rev; -static int chip_nr =0 ;/* * Check SoC revision. This driver supports only NFC
@@ -568,7 +567,7 @@ int board_nand_init(struct nand_chip *chip)return -ENOMEM ; } - mtd = &nand_info[chip_nr++]; + mtd = &chip->mtd; mtd->priv = chip; chip->priv = prv;
drivers/mtd/nand/mxc_nand.c +1 -1
@@ -1164,7 +1164,7 @@ int board_nand_init(struct nand_chip *this)#endif /* structures must be linked */ - mtd = &host->mtd; + mtd = &this->mtd; mtd->priv = this; host->nand = this;
drivers/mtd/nand/mxs_nand_spl.c +17 -16
@@ -8,7 +8,7 @@#include <nand.h> #include <malloc.h> -static struct mtd_info mtd; +static struct mtd_info *mtd;static struct nand_chip nand_chip; static void mxs_nand_command(struct mtd_info *mtd, unsigned int command,
@@ -147,14 +147,15 @@ static int mxs_nand_init(void)/* init mxs nand driver */ board_nand_init (&nand_chip); - mtd.priv = &nand_chip; + mtd = &nand_chip.mtd; + mtd->priv = &nand_chip;/* set mtd functions */ nand_chip.cmdfunc = mxs_nand_command; nand_chip.numchips =1 ;/* identify flash device */ puts ("NAND : " ); -if (mxs_flash_ident (&mtd)) { +if (mxs_flash_ident (mtd)) {printf ("Failed to identify\n" );return -1 ; }
@@ -162,12 +163,12 @@ static int mxs_nand_init(void)/* allocate and initialize buffers */ nand_chip.buffers =memalign (ARCH_DMA_MINALIGN ,sizeof (*nand_chip.buffers)); - nand_chip.oob_poi = nand_chip.buffers->databuf + mtd.writesize; + nand_chip.oob_poi = nand_chip.buffers->databuf + mtd->writesize;/* setup flash layout (does not scan as we override that) */ - mtd.size = nand_chip.chipsize; - nand_chip.scan_bbt (&mtd); + mtd->size = nand_chip.chipsize; + nand_chip.scan_bbt (mtd); -printf ("%llu MiB\n" , (mtd.size / (1024 *1024 ))); +printf ("%llu MiB\n" , (mtd->size / (1024 *1024 )));return 0 ; }
@@ -180,20 +181,20 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *buf)if (mxs_nand_init ())return -ENODEV ; - chip = mtd.priv; + chip = mtd->priv; page = offs >> chip->page_shift; - nand_page_per_block = mtd.erasesize / mtd.writesize; + nand_page_per_block = mtd->erasesize / mtd->writesize;debug ("%s offset:0x%08x len:%d page:%d\n" , __func__, offs, size, page); - size =roundup (size, mtd.writesize); + size =roundup (size, mtd->writesize);while (sz < size) { -if (mxs_read_page_ecc (&mtd, buf, page) <0 ) +if (mxs_read_page_ecc (mtd, buf, page) <0 )return -1 ; - sz += mtd.writesize; - offs += mtd.writesize; + sz += mtd->writesize; + offs += mtd->writesize; page++; - buf += mtd.writesize; + buf += mtd->writesize;/* * Check if we have crossed a block boundary, and if so
@@ -204,10 +205,10 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *buf)* Yes, new block. See if this block is good. If not, * loop until we find a good block. */ -while (is_badblock (&mtd, offs,1 )) { +while (is_badblock (mtd, offs,1 )) { page = page + nand_page_per_block;/* Check i we've reached the end of flash. */ -if (page >= mtd.size >> chip->page_shift) +if (page >= mtd->size >> chip->page_shift)return -ENOMEM ; } }
drivers/mtd/nand/nand.c +19 -8
@@ -19,7 +19,7 @@ DECLARE_GLOBAL_DATA_PTR;int nand_curr_device =-1 ; -struct mtd_info nand_info[CONFIG_SYS_MAX_NAND_DEVICE ]; +struct mtd_info *nand_info[CONFIG_SYS_MAX_NAND_DEVICE ];#ifndef CONFIG_SYS_NAND_SELF_INIT static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE ];
@@ -30,15 +30,25 @@ static char dev_name[CONFIG_SYS_MAX_NAND_DEVICE][8];static unsigned long total_nand_size;/* in kiB */ -/* Register an initialized NAND mtd device with the U-Boot NAND command. */ -int nand_register (int devnum) +int nand_mtd_to_devnum (struct mtd_info *mtd) { -struct mtd_info *mtd; +int i; +for (i =0 ; i <ARRAY_SIZE (nand_info); i++) { +if (mtd && nand_info[i] == mtd) +return i; + } + +return -ENODEV ; +} + +/* Register an initialized NAND mtd device with the U-Boot NAND command. */ +int nand_register (int devnum,struct mtd_info *mtd) +{if (devnum >=CONFIG_SYS_MAX_NAND_DEVICE )return -EINVAL ; - mtd = &nand_info[devnum]; + nand_info[devnum] = mtd;sprintf (dev_name[devnum],"nand%d" , devnum); mtd->name = dev_name[devnum];
@@ -62,8 +72,8 @@ int nand_register(int devnum)#ifndef CONFIG_SYS_NAND_SELF_INIT static void nand_init_chip (int i) { -struct mtd_info *mtd = &nand_info[i];struct nand_chip *nand = &nand_chip[i]; +struct mtd_info *mtd = &nand->mtd;ulong base_addr = base_address[i];int maxchips =CONFIG_SYS_NAND_MAX_CHIPS ;
@@ -79,7 +89,7 @@ static void nand_init_chip(int i)if (nand_scan (mtd, maxchips))return ; - nand_register(i); + nand_register(i, mtd); }#endif
@@ -100,6 +110,7 @@ void nand_init(void)/* * Select the chip in the board/cpu specific driver */ -board_nand_select_device (nand_info[nand_curr_device].priv, nand_curr_device); +board_nand_select_device (nand_info[nand_curr_device]->priv, + nand_curr_device);#endif }
drivers/mtd/nand/nand_spl_simple.c +43 -42
210 lines not on this page · raw message
drivers/mtd/nand/omap_gpmc.c +2 -2
@@ -898,12 +898,12 @@ int __maybe_unused omap_nand_switch_ecc(uint32_t hardware, uint32_t eccstrength)if (nand_curr_device <0 || nand_curr_device >=CONFIG_SYS_MAX_NAND_DEVICE || - !nand_info[nand_curr_device].name) { + !nand_info[nand_curr_device]->name) {printf ("nand: error: no NAND devices found\n" );return -ENODEV ; } - mtd = &nand_info[nand_curr_device]; + mtd = nand_info[nand_curr_device]; nand = mtd->priv; nand->options |=NAND_OWN_BUFFERS ; nand->options &= ~NAND_SUBPAGE_READ ;
drivers/mtd/nand/pxa3xx_nand.c +5 -5
@@ -1477,9 +1477,9 @@ static int alloc_nand_resource(struct pxa3xx_nand_info *info) info->variant =pxa3xx_nand_get_variant ();for (cs =0 ; cs < pdata->num_cs; cs++) { - mtd = &nand_info[cs]; chip = (struct nand_chip *) ((u8 *)&info[1 ] +sizeof (*host) * cs); + mtd = &chip->mtd; host = (struct pxa3xx_nand_host *)chip; info->host[cs] = host; host->mtd = mtd;
@@ -1573,8 +1573,10 @@ static int pxa3xx_nand_probe(struct pxa3xx_nand_info *info)continue ; } -if (!ret) - probe_success =1 ; +if (nand_register (cs, mtd)) +continue ; + + probe_success =1 ; }if (!probe_success)
@@ -1601,6 +1603,4 @@ void board_nand_init(void) ret =pxa3xx_nand_probe (info);if (ret)return ; - -nand_register (0 ); }
drivers/mtd/nand/tegra_nand.c +2 -2
@@ -976,7 +976,7 @@ int tegra_nand_init(struct nand_chip *nand, int devnum)dm_gpio_set_value (&config->wp_gpio,1 ); - our_mtd = &nand_info[devnum]; + our_mtd = &nand->mtd; our_mtd->priv = nand; ret =nand_scan_ident (our_mtd,CONFIG_SYS_NAND_MAX_CHIPS ,NULL );if (ret)
@@ -989,7 +989,7 @@ int tegra_nand_init(struct nand_chip *nand, int devnum)if (ret)return ret; - ret =nand_register (devnum); + ret =nand_register (devnum, our_mtd);if (ret)return ret;
drivers/mtd/nand/vf610_nfc.c +3 -2
@@ -630,7 +630,7 @@ struct vf610_nfc_config {static int vf610_nfc_nand_init (int devnum,void __iomem *addr) { -struct mtd_info *mtd = &nand_info[devnum]; +struct mtd_info *mtd;struct nand_chip *chip;struct vf610_nfc *nfc;int err =0 ;
@@ -653,6 +653,7 @@ static int vf610_nfc_nand_init(int devnum, void __iomem *addr) chip = &nfc->chip; nfc->regs = addr; + mtd = &chip->mtd; mtd->priv = chip; chip->priv = nfc;
@@ -753,7 +754,7 @@ static int vf610_nfc_nand_init(int devnum, void __iomem *addr)if (err)return err; - err =nand_register (devnum); + err =nand_register (devnum, mtd);if (err)return err;
drivers/net/fm/fm.c +1 -1
@@ -360,7 +360,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)size_t fw_length =CONFIG_SYS_QE_FMAN_FW_LENGTH ;void *addr =malloc (CONFIG_SYS_QE_FMAN_FW_LENGTH ); - rc =nand_read (&nand_info[0 ], (loff_t )CONFIG_SYS_FMAN_FW_ADDR , + rc =nand_read (nand_info[0 ], (loff_t )CONFIG_SYS_FMAN_FW_ADDR , &fw_length, (u_char *)addr);if (rc == -EUCLEAN ) { printf("NAND read of FMAN firmware at offset 0x%x failed %d\n",
drivers/net/phy/cortina.c +2 -2
@@ -139,8 +139,8 @@ void cs4340_upload_firmware(struct phy_device *phydev)size_t fw_length =CONFIG_CORTINA_FW_LENGTH ; addr =malloc (CONFIG_CORTINA_FW_LENGTH ); - ret =nand_read (&nand_info[0 ], (loff_t )CONFIG_CORTINA_FW_ADDR , - &fw_length, (u_char *)addr); + ret =nand_read (nand_info[0 ], (loff_t )CONFIG_CORTINA_FW_ADDR , + &fw_length, (u_char *)addr);if (ret == -EUCLEAN ) {printf ("NAND read of Cortina firmware at 0x%x failed %d\n" ,CONFIG_CORTINA_FW_ADDR , ret);
fs/jffs2/jffs2_1pass.c +1 -1
@@ -195,7 +195,7 @@ static int read_nand_cached(u32 off, u32 size, u_char *buf) } retlen =NAND_CACHE_SIZE ; -if (nand_read (&nand_info[id->num], nand_cache_off, +if (nand_read (nand_info[id->num], nand_cache_off, &retlen, nand_cache) !=0 || retlen !=NAND_CACHE_SIZE ) { printf("read_nand_cached: error reading nand off %#x size %d bytes\n",
fs/jffs2/jffs2_nand_1pass.c +1 -1
@@ -796,7 +796,7 @@ jffs2_1pass_build_lists(struct part_info * part)u32 counterN =0 ;struct mtdids *id = part->dev->id; - mtd = nand_info + id->num; + mtd = nand_info[id->num];/* if we are building a list we need to refresh the cache. */ jffs_init_1pass_list (part);
fs/yaffs2/yaffs_uboot_glue.c +2 -6
@@ -141,8 +141,6 @@ static const char *yaffs_error_str(void) } } -extern struct mtd_info nand_info[]; -void cmd_yaffs_tracemask (unsigned set,unsigned mask) {if (set)
@@ -171,7 +169,7 @@ void cmd_yaffs_devconfig(char *_mp, int flash_dev, dev =calloc (1 ,sizeof (*dev)); mp =strdup (_mp); - mtd = &nand_info[flash_dev]; + mtd = nand_info[flash_dev];if (!dev || !mp) {/* Alloc error */
@@ -260,9 +258,7 @@ void cmd_yaffs_dev_ls(void) dev =yaffs_next_dev ();if (!dev)return ; - flash_dev = - ((unsigned ) dev->driver_context - (unsigned ) nand_info)/ -sizeof (nand_info[0 ]); + flash_dev =nand_mtd_to_devnum (dev->driver_context); printf("%-10s %5d 0x%05x 0x%05x %s", dev->param.name, flash_dev, dev->param.start_block, dev->param.end_block,
include/linux/mtd/nand.h +1 -0
@@ -659,6 +659,7 @@ struct nand_buffers {*/ struct nand_chip { +struct mtd_info mtd;void __iomem *IO_ADDR_R;void __iomem *IO_ADDR_W;
include/nand.h +4 -2
@@ -33,15 +33,17 @@ extern void nand_init(void);#include <linux/mtd/mtd.h> #include <linux/mtd/nand.h> +int nand_mtd_to_devnum (struct mtd_info *mtd); +#ifdef CONFIG_SYS_NAND_SELF_INIT void board_nand_init (void ); -int nand_register (int devnum); +int nand_register (int devnum,struct mtd_info *mtd);#else extern int board_nand_init (struct nand_chip *nand);#endif extern int nand_curr_device; -extern struct mtd_info nand_info[]; +extern struct mtd_info *nand_info[];static inline int nand_read (struct mtd_info *info,loff_t ofs,size_t *len,u_char *buf)
Signature · 1 line
2.5.0
PATCH 5/7 mtd: nand: Add+use mtd_to/from_nand and nand_get/set_controller_data
In reply to Scott WoodThese functions are part of the Linux 4.6 sync. They are being added before the main sync patch in order to make it easier to address the issue across all NAND drivers (many/most of which do not closely track their Linux counterparts) separately from other merge issues.
--- board/esd/common/esd405ep_nand.c | 2 +- board/freescale/m5329evb/nand.c | 2 +- board/freescale/m5373evb/nand.c | 2 +- board/socrates/nand.c | 6 ++-- board/xes/common/actl_nand.c | 2 +- cmd/nand.c | 4 +-- drivers/mtd/nand/am335x_spl_bch.c | 6 ++-- drivers/mtd/nand/arasan_nfc.c | 19 +++++----- drivers/mtd/nand/atmel_nand.c | 55 ++++++++++++++-------------- drivers/mtd/nand/davinci_nand.c | 8 ++--- drivers/mtd/nand/denali.c | 4 +-- drivers/mtd/nand/fsl_elbc_nand.c | 33 +++++++++-------- drivers/mtd/nand/fsl_ifc_nand.c | 43 +++++++++++----------- drivers/mtd/nand/fsl_upm.c | 22 ++++++------ drivers/mtd/nand/fsmc_nand.c | 7 ++-- drivers/mtd/nand/kb9202_nand.c | 2 +- drivers/mtd/nand/kirkwood_nand.c | 2 +- drivers/mtd/nand/lpc32xx_nand_mlc.c | 2 -- drivers/mtd/nand/lpc32xx_nand_slc.c | 2 +- drivers/mtd/nand/mpc5121_nfc.c | 27 +++++++------- drivers/mtd/nand/mxc_nand.c | 51 +++++++++++++------------- drivers/mtd/nand/mxs_nand.c | 46 ++++++++++++------------ drivers/mtd/nand/mxs_nand_spl.c | 11 +++--- drivers/mtd/nand/nand.c | 5 ++- drivers/mtd/nand/nand_base.c | 72 ++++++++++++++++++------------------- drivers/mtd/nand/nand_bbt.c | 32 ++++++++--------- drivers/mtd/nand/nand_bch.c | 4 +-- drivers/mtd/nand/nand_plat.c | 4 +-- drivers/mtd/nand/nand_spl_simple.c | 11 +++--- drivers/mtd/nand/nand_util.c | 8 ++--- drivers/mtd/nand/ndfc.c | 14 ++++---- drivers/mtd/nand/omap_gpmc.c | 40 ++++++++++----------- drivers/mtd/nand/pxa3xx_nand.c | 34 ++++++++++-------- drivers/mtd/nand/s3c2410_nand.c | 4 +-- drivers/mtd/nand/tegra_nand.c | 29 ++++++++------- drivers/mtd/nand/vf610_nfc.c | 8 ++--- fs/yaffs2/yaffs_uboot_glue.c | 2 +- include/linux/mtd/nand.h | 20 +++++++++++ 38 files changed, 328 insertions(+), 317 deletions(-)
board/esd/common/esd405ep_nand.c +1 -1
@@ -16,7 +16,7 @@*/ static void esd405ep_nand_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);if (ctrl &NAND_CTRL_CHANGE ) {if ( ctrl &NAND_CLE )out_be32 ((void *)GPIO0_OR ,in_be32 ((void *)GPIO0_OR ) |CONFIG_SYS_NAND_CLE );
board/freescale/m5329evb/nand.c +1 -1
@@ -24,7 +24,7 @@ DECLARE_GLOBAL_DATA_PTR;static void nand_hwcontrol (struct mtd_info *mtdinfo,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);volatile u16 *nCE = (u16 *)CONFIG_SYS_LATCH_ADDR ;if (ctrl &NAND_CTRL_CHANGE ) {
board/freescale/m5373evb/nand.c +1 -1
@@ -24,7 +24,7 @@ DECLARE_GLOBAL_DATA_PTR;static void nand_hwcontrol (struct mtd_info *mtdinfo,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);volatile u16 *nCE = (u16 *)CONFIG_SYS_LATCH_ADDR ;if (ctrl &NAND_CTRL_CHANGE ) {
board/socrates/nand.c +3 -3
@@ -48,7 +48,7 @@ static void sc_nand_write_byte(struct mtd_info *mtd, u_char byte)static void sc_nand_write_buf (struct mtd_info *mtd,const u_char *buf,int len) {int i; -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);for (i =0 ; i < len; i++) { out_be32(this->IO_ADDR_W,
@@ -88,7 +88,7 @@ static u16 sc_nand_read_word(struct mtd_info *mtd)static void sc_nand_read_buf (struct mtd_info *mtd,u_char *buf,int len) {int i; -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int val; val = (state &FPGA_NAND_ENABLE ) |FPGA_NAND_CMD_READ ;
@@ -105,7 +105,7 @@ static void sc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)*/ static int sc_nand_device_ready (struct mtd_info *mtdinfo) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);if (in_be32 (this->IO_ADDR_W) &FPGA_NAND_BUSY )return 0 ;/* busy */
board/xes/common/actl_nand.c +1 -1
@@ -16,7 +16,7 @@*/ static void nand_addr_hwcontrol (struct mtd_info *mtd,int cmd,uint ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);ulong IO_ADDR_W ;if (ctrl &NAND_CTRL_CHANGE ) {
cmd/nand.c +2 -2
@@ -159,7 +159,7 @@ static void do_nand_status(struct mtd_info *mtd)ulong off;int last_status =-1 ; -struct nand_chip *nand_chip = mtd->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd);/* check the WP bit */ nand_chip->cmdfunc (mtd,NAND_CMD_STATUS ,-1 ,-1 ); printf("device is %swrite protected\n",
@@ -285,7 +285,7 @@ usage:static void nand_print_and_set_info (int idx) {struct mtd_info *mtd = nand_info[idx]; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);printf ("Device %d: " , idx);if (chip->numchips >1 )
drivers/mtd/nand/am335x_spl_bch.c +3 -3
@@ -30,7 +30,7 @@ static struct nand_chip nand_chip;static int nand_command (int block,int page,uint32_t offs,u8 cmd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int page_addr = page + block *CONFIG_SYS_NAND_PAGE_COUNT ;void (*hwctrl)(struct mtd_info *mtd,int cmd,unsigned int ctrl) = this->cmd_ctrl;
@@ -100,7 +100,7 @@ static int nand_command(int block, int page, uint32_t offs,static int nand_is_bad_block (int block) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);nand_command (block,0 ,CONFIG_SYS_NAND_BAD_BLOCK_POS ,NAND_CMD_READOOB );
@@ -121,7 +121,7 @@ static int nand_is_bad_block(int block)static int nand_read_page (int block,int page,void *dst) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u_char ecc_calc[ECCTOTAL ];u_char ecc_code[ECCTOTAL ];u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];
drivers/mtd/nand/arasan_nfc.c +9 -10
@@ -230,7 +230,7 @@ static void arasan_nand_enable_ecc(void)static u8 arasan_nand_get_addrcycle (struct mtd_info *mtd) {u8 addrcycles; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);switch (curr_cmd->addr_cycles) {case NAND_ADDR_CYCL_NONE :
@@ -264,7 +264,7 @@ static u8 arasan_nand_get_addrcycle(struct mtd_info *mtd)static int arasan_nand_read_page (struct mtd_info *mtd,u8 *buf,u32 size) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);u32 reg_val, i, pktsize, pktnum;u32 *bufptr = (u32 *)buf;u32 timeout;
@@ -441,7 +441,7 @@ static int arasan_nand_write_page_hwecc(struct mtd_info *mtd,u32 size = mtd->writesize;u32 rdcount =0 ;u8 column_addr_cycles; -struct arasan_nand_info *nand = chip->priv; +struct arasan_nand_info *nand =nand_get_controller_data (chip);if (chip->ecc_step_ds >=ARASAN_NAND_PKTSIZE_1K ) pktsize =ARASAN_NAND_PKTSIZE_1K ;
@@ -944,7 +944,7 @@ static void arasan_nand_read_buf(struct mtd_info *mtd, u8 *buf, int size)static u8 arasan_nand_read_byte (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);u32 size;u8 val;struct nand_onfi_params *p;
@@ -976,8 +976,8 @@ static void arasan_nand_cmd_function(struct mtd_info *mtd, unsigned int command, int column, int page_addr) {u32 i, ret =0 ; -struct nand_chip *chip = mtd->priv; -struct arasan_nand_info *nand = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct arasan_nand_info *nand =nand_get_controller_data (chip); curr_cmd =NULL ; writel(ARASAN_NAND_INT_STS_XFR_CMPLT_MASK,
@@ -1033,7 +1033,7 @@ static int arasan_nand_ecc_init(struct mtd_info *mtd) {int found =-1 ;u32 regval, eccpos_start, i; -struct nand_chip *nand_chip = mtd->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); nand_chip->ecc.mode =NAND_ECC_HW ; nand_chip->ecc.hwctl =NULL ;
@@ -1101,9 +1101,8 @@ static int arasan_nand_init(struct nand_chip *nand_chip, int devnum) } nand->nand_base = arasan_nand_base; - mtd = &nand_chip->mtd; - nand_chip->priv = nand; - mtd->priv = nand_chip; + mtd =nand_to_mtd (nand_chip); +nand_set_controller_data (nand_chip, nand);/* Set the driver entry points for MTD */ nand_chip->cmdfunc = arasan_nand_cmd_function;
drivers/mtd/nand/atmel_nand.c +27 -28
176 lines not on this page · raw message
drivers/mtd/nand/davinci_nand.c +4 -4
@@ -54,7 +54,7 @@*/ static void nand_davinci_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);const u32 *nand = chip->IO_ADDR_R;/* Make sure that buf is 32 bit aligned */
@@ -99,7 +99,7 @@ static void nand_davinci_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)static void nand_davinci_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);const u32 *nand = chip->IO_ADDR_W;/* Make sure that buf is 32 bit aligned */
@@ -144,7 +144,7 @@ static void nand_davinci_write_buf(struct mtd_info *mtd, const uint8_t *buf,static void nand_davinci_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u_int32_t IO_ADDR_W = (u_int32_t )this->IO_ADDR_W;if (ctrl &NAND_CTRL_CHANGE ) {
@@ -223,7 +223,7 @@ static int nand_davinci_calculate_ecc(struct mtd_info *mtd, const u_char *dat,static int nand_davinci_correct_data (struct mtd_info *mtd,u_char *dat,u_char *read_ecc,u_char *calc_ecc) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u_int32_t ecc_nand = read_ecc[0 ] | (read_ecc[1 ] <<8 ) | (read_ecc[2 ] <<16 ); u_int32_t ecc_calc = calc_ecc[0] | (calc_ecc[1] << 8) |
drivers/mtd/nand/denali.c +2 -2
@@ -48,7 +48,8 @@ static int onfi_timing_mode = NAND_DEFAULT_TIMINGS;* this macro allows us to convert from an MTD structure to our own * device context (denali) structure. */ -#define mtd_to_denali (m) container_of(m->priv, struct denali_nand_info, nand) +#define mtd_to_denali (m) \ + container_of(mtd_to_nand(m), struct denali_nand_info, nand)/* * These constants are defined by the driver to enable common driver
@@ -1179,7 +1180,6 @@ static int denali_init(struct denali_nand_info *denali) denali->mtd->name ="denali-nand" ; denali->mtd->owner =THIS_MODULE ; - denali->mtd->priv = &denali->nand;/* register the driver with the NAND core subsystem */ denali->nand.select_chip = denali_select_chip;
drivers/mtd/nand/fsl_elbc_nand.c +16 -17
@@ -154,8 +154,8 @@ static struct nand_bbt_descr bbt_mirror_descr = {*/ static void set_addr (struct mtd_info *mtd,int column,int page_addr,int oob) { -struct nand_chip *chip = mtd->priv; -struct fsl_elbc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;fsl_lbc_t *lbc = ctrl->regs;int buf_num;
@@ -194,8 +194,8 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob)*/ static int fsl_elbc_run_command (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; -struct fsl_elbc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;fsl_lbc_t *lbc = ctrl->regs;u32 timeo = (CONFIG_SYS_HZ *10 ) /1000 ;
@@ -246,7 +246,7 @@ static int fsl_elbc_run_command(struct mtd_info *mtd)static void fsl_elbc_do_read (struct nand_chip *chip,int oob) { -struct fsl_elbc_mtd *priv = chip->priv; +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;fsl_lbc_t *lbc = ctrl->regs;
@@ -279,8 +279,8 @@ static void fsl_elbc_do_read(struct nand_chip *chip, int oob)static void fsl_elbc_cmdfunc (struct mtd_info *mtd,unsigned int command,int column,int page_addr) { -struct nand_chip *chip = mtd->priv; -struct fsl_elbc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;fsl_lbc_t *lbc = ctrl->regs;
@@ -489,8 +489,8 @@ static void fsl_elbc_select_chip(struct mtd_info *mtd, int chip)*/ static void fsl_elbc_write_buf (struct mtd_info *mtd,const u8 *buf,int len) { -struct nand_chip *chip = mtd->priv; -struct fsl_elbc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;unsigned int bufsize = mtd->writesize + mtd->oobsize;
@@ -526,8 +526,8 @@ static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)*/ static u8 fsl_elbc_read_byte (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; -struct fsl_elbc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;/* If there are still bytes in the FCM, then use the next byte. */
@@ -543,8 +543,8 @@ static u8 fsl_elbc_read_byte(struct mtd_info *mtd)*/ static void fsl_elbc_read_buf (struct mtd_info *mtd,u8 *buf,int len) { -struct nand_chip *chip = mtd->priv; -struct fsl_elbc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;int avail;
@@ -566,7 +566,7 @@ static void fsl_elbc_read_buf(struct mtd_info *mtd, u8 *buf, int len)*/ static int fsl_elbc_wait (struct mtd_info *mtd,struct nand_chip *chip) { -struct fsl_elbc_mtd *priv = chip->priv; +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;fsl_lbc_t *lbc = ctrl->regs;
@@ -697,8 +697,7 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr) } nand = &priv->chip; - mtd = &nand->mtd; - mtd->priv = nand; + mtd =nand_to_mtd (nand); elbc_ctrl->chips[priv->bank] = priv;
@@ -720,7 +719,7 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr) nand->bbt_options =NAND_BBT_USE_FLASH ; nand->controller = &elbc_ctrl->controller; - nand->priv = priv; +nand_set_controller_data (nand, priv); nand->ecc.read_page = fsl_elbc_read_page; nand->ecc.write_page = fsl_elbc_write_page;
drivers/mtd/nand/fsl_ifc_nand.c +21 -22
121 lines not on this page · raw message
drivers/mtd/nand/fsl_upm.c +11 -11
@@ -64,8 +64,8 @@ static void fun_wait(struct fsl_upm_nand *fun)#if CONFIG_SYS_NAND_MAX_CHIPS >1 static void fun_select_chip (struct mtd_info *mtd,int chip_nr) { -struct nand_chip *chip = mtd->priv; -struct fsl_upm_nand *fun = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_upm_nand *fun =nand_get_controller_data (chip);if (chip_nr >=0 ) { fun->chip_nr = chip_nr;
@@ -79,8 +79,8 @@ static void fun_select_chip(struct mtd_info *mtd, int chip_nr)static void fun_cmd_ctrl (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *chip = mtd->priv; -struct fsl_upm_nand *fun = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_upm_nand *fun =nand_get_controller_data (chip);void __iomem *io_addr;u32 mar;
@@ -123,7 +123,7 @@ static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)static u8 upm_nand_read_byte (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);return in_8 (chip->IO_ADDR_R); }
@@ -131,8 +131,8 @@ static u8 upm_nand_read_byte(struct mtd_info *mtd)static void upm_nand_write_buf (struct mtd_info *mtd,const u_char *buf,int len) {int i; -struct nand_chip *chip = mtd->priv; -struct fsl_upm_nand *fun = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_upm_nand *fun =nand_get_controller_data (chip);for (i =0 ; i < len; i++) {out_8 (chip->IO_ADDR_W, buf[i]);
@@ -147,7 +147,7 @@ static void upm_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)static void upm_nand_read_buf (struct mtd_info *mtd,u_char *buf,int len) {int i; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);for (i =0 ; i < len; i++) buf[i] =in_8 (chip->IO_ADDR_R);
@@ -155,8 +155,8 @@ static void upm_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)static int nand_dev_ready (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; -struct fsl_upm_nand *fun = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_upm_nand *fun =nand_get_controller_data (chip);return fun->dev_ready (fun->chip_nr); }
@@ -168,7 +168,7 @@ int fsl_upm_nand_init(struct nand_chip *chip, struct fsl_upm_nand *fun) fun->last_ctrl =NAND_CLE ; - chip->priv = fun; +nand_set_controller_data (chip, fun); chip->chip_delay = fun->chip_delay; chip->ecc.mode =NAND_ECC_SOFT ; chip->cmd_ctrl = fun_cmd_ctrl;
drivers/mtd/nand/fsmc_nand.c +3 -4
@@ -165,7 +165,7 @@ static int count_written_bits(uint8_t *buff, int size, int max_bits)static void fsmc_nand_hwcontrol (struct mtd_info *mtd,int cmd,uint ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);ulong IO_ADDR_W ;if (ctrl &NAND_CTRL_CHANGE ) {
@@ -410,7 +410,7 @@ int fsmc_nand_switch_ecc(uint32_t eccstrength)* function, as it doesn't need to switch to a different ECC layout. */ mtd = nand_info[nand_curr_device]; - nand = mtd->priv; + nand =mtd_to_nand (mtd);/* Setup the ecc configurations again */ if (eccstrength ==1 ) {
@@ -479,8 +479,7 @@ int fsmc_nand_init(struct nand_chip *nand) (void __iomem *)CONFIG_SYS_NAND_BASE ; nand->badblockbits =7 ; - mtd = &nand->mtd; - mtd->priv = nand; + mtd =nand_to_mtd (nand);switch (fsmc_version) {case FSMC_VER8 :
drivers/mtd/nand/kb9202_nand.c +1 -1
@@ -35,7 +35,7 @@*/ static void kb9202_nand_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);if (ctrl &NAND_CTRL_CHANGE ) {ulong IO_ADDR_W = (ulong ) this->IO_ADDR_W;
drivers/mtd/nand/kirkwood_nand.c +1 -1
@@ -33,7 +33,7 @@ static u32 nand_mpp_backup[9] = { 0 };static void kw_nand_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *nc = mtd->priv; +struct nand_chip *nc =mtd_to_nand (mtd);u32 offs;if (cmd ==NAND_CMD_NONE )
drivers/mtd/nand/lpc32xx_nand_mlc.c +0 -2
@@ -542,8 +542,6 @@ void board_nand_init(void)struct mtd_info *mtd = &lpc32xx_chip.mtd;int ret; - mtd->priv = &lpc32xx_chip; -/* Set all BOARDSPECIFIC (actually core-specific) fields */ lpc32xx_chip.IO_ADDR_R = &lpc32xx_nand_mlc_registers->buff;
drivers/mtd/nand/lpc32xx_nand_slc.c +1 -1
@@ -291,7 +291,7 @@ static void lpc32xx_nand_dma_configure(struct nand_chip *chip,static void lpc32xx_nand_xfer (struct mtd_info *mtd,const u8 *buf,int len,int read) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);u32 config;int ret;
drivers/mtd/nand/mpc5121_nfc.c +13 -14
@@ -117,8 +117,8 @@ static void mpc5121_nfc_done(struct mtd_info *mtd);/* Read NFC register */ static inline u16 nfc_read (struct mtd_info *mtd,uint reg) { -struct nand_chip *chip = mtd->priv; -struct mpc5121_nfc_prv *prv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct mpc5121_nfc_prv *prv =nand_get_controller_data (chip);return in_be16 (prv->regs + reg); }
@@ -126,8 +126,8 @@ static inline u16 nfc_read(struct mtd_info *mtd, uint reg)/* Write NFC register */ static inline void nfc_write (struct mtd_info *mtd,uint reg,u16 val) { -struct nand_chip *chip = mtd->priv; -struct mpc5121_nfc_prv *prv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct mpc5121_nfc_prv *prv =nand_get_controller_data (chip);out_be16 (prv->regs + reg, val); }
@@ -211,7 +211,7 @@ static void mpc5121_nfc_done(struct mtd_info *mtd)/* Do address cycle(s) */ static void mpc5121_nfc_addr_cycle (struct mtd_info *mtd,int column,int page) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);u32 pagemask = chip->pagemask;if (column !=-1 ) {
@@ -283,8 +283,8 @@ static int mpc5121_nfc_dev_ready(struct mtd_info *mtd)static void mpc5121_nfc_command (struct mtd_info *mtd,unsigned command,int column,int page) { -struct nand_chip *chip = mtd->priv; -struct mpc5121_nfc_prv *prv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct mpc5121_nfc_prv *prv =nand_get_controller_data (chip); prv->column = (column >=0 ) ? column :0 ; prv->spareonly =0 ;
@@ -357,8 +357,8 @@ static void mpc5121_nfc_command(struct mtd_info *mtd, unsigned command,static void mpc5121_nfc_copy_spare (struct mtd_info *mtd,uint offset,u8 * buffer,uint size,int wr) { -struct nand_chip *nand = mtd->priv; -struct mpc5121_nfc_prv *prv = nand->priv; +struct nand_chip *nand =mtd_to_nand (mtd); +struct mpc5121_nfc_prv *prv =nand_get_controller_data (nand);uint o, s, sbsize, blksize;/*
@@ -410,8 +410,8 @@ static void mpc5121_nfc_copy_spare(struct mtd_info *mtd, uint offset,static void mpc5121_nfc_buf_copy (struct mtd_info *mtd,u_char * buf,int len,int wr) { -struct nand_chip *chip = mtd->priv; -struct mpc5121_nfc_prv *prv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct mpc5121_nfc_prv *prv =nand_get_controller_data (chip);uint c = prv->column;uint l;
@@ -489,7 +489,7 @@ static u16 mpc5121_nfc_read_word(struct mtd_info *mtd)static int mpc5121_nfc_read_hw_config (struct mtd_info *mtd) {immap_t *im = (immap_t *)CONFIG_SYS_IMMR ; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);uint rcw_pagesize =0 ;uint rcw_sparesize =0 ;uint rcw_width;
@@ -568,8 +568,7 @@ int board_nand_init(struct nand_chip *chip) } mtd = &chip->mtd; - mtd->priv = chip; - chip->priv = prv; +nand_set_controller_data (chip, prv);/* Read NFC configuration from Reset Config Word */ retval =mpc5121_nfc_read_hw_config (mtd);
drivers/mtd/nand/mxc_nand.c +25 -26
152 lines not on this page · raw message
drivers/mtd/nand/mxs_nand.c +23 -23
130 lines not on this page · raw message
drivers/mtd/nand/mxs_nand_spl.c +5 -6
@@ -14,7 +14,7 @@ static struct nand_chip nand_chip;static void mxs_nand_command (struct mtd_info *mtd,unsigned int command,int column,int page_addr) { - registerstruct nand_chip *chip = mtd->priv; + registerstruct nand_chip *chip =mtd_to_nand (mtd);u32 timeo, time_start;/* write out the command to the device */
@@ -51,7 +51,7 @@ static void mxs_nand_command(struct mtd_info *mtd, unsigned int command,static int mxs_flash_ident (struct mtd_info *mtd) { - registerstruct nand_chip *chip = mtd->priv; + registerstruct nand_chip *chip =mtd_to_nand (mtd);int i;u8 mfg_id, dev_id;u8 id_data[8 ];
@@ -111,7 +111,7 @@ static int mxs_flash_ident(struct mtd_info *mtd)static int mxs_read_page_ecc (struct mtd_info *mtd,void *buf,unsigned int page) { - registerstruct nand_chip *chip = mtd->priv; + registerstruct nand_chip *chip =mtd_to_nand (mtd);int ret; chip->cmdfunc (mtd,NAND_CMD_READ0 ,0x0 , page);
@@ -125,7 +125,7 @@ static int mxs_read_page_ecc(struct mtd_info *mtd, void *buf, unsigned int page)static int is_badblock (struct mtd_info *mtd,loff_t offs,int allowbbt) { - registerstruct nand_chip *chip = mtd->priv; + registerstruct nand_chip *chip =mtd_to_nand (mtd);unsigned int block = offs >> chip->phys_erase_shift;unsigned int page = offs >> chip->page_shift;
@@ -148,7 +148,6 @@ static int mxs_nand_init(void)/* init mxs nand driver */ board_nand_init (&nand_chip); mtd = &nand_chip.mtd; - mtd->priv = &nand_chip;/* set mtd functions */ nand_chip.cmdfunc = mxs_nand_command; nand_chip.numchips =1 ;
@@ -181,7 +180,7 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *buf)if (mxs_nand_init ())return -ENODEV ; - chip = mtd->priv; + chip =mtd_to_nand (mtd); page = offs >> chip->page_shift; nand_page_per_block = mtd->erasesize / mtd->writesize;
drivers/mtd/nand/nand.c +2 -3
@@ -73,14 +73,13 @@ int nand_register(int devnum, struct mtd_info *mtd)static void nand_init_chip (int i) {struct nand_chip *nand = &nand_chip[i]; -struct mtd_info *mtd = &nand->mtd; +struct mtd_info *mtd =nand_to_mtd (nand);ulong base_addr = base_address[i];int maxchips =CONFIG_SYS_NAND_MAX_CHIPS ;if (maxchips <1 ) maxchips =1 ; - mtd->priv = nand; nand->IO_ADDR_R = nand->IO_ADDR_W = (void __iomem *)base_addr;if (board_nand_init (nand))
@@ -110,7 +109,7 @@ void nand_init(void)/* * Select the chip in the board/cpu specific driver */ -board_nand_select_device (nand_info[nand_curr_device]->priv, +board_nand_select_device (mtd_to_nand (nand_info[nand_curr_device]), nand_curr_device);#endif }
drivers/mtd/nand/nand_base.c +36 -36
288 lines not on this page · raw message
drivers/mtd/nand/nand_bbt.c +16 -16
@@ -173,7 +173,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, struct nand_bbt_descr *td, int offs) { int res, ret = 0, i, j, act = 0; -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);size_t retlen, len, totlen;loff_t from;int bits = td->options &NAND_BBT_NRBITS_MSK ;
@@ -264,7 +264,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,*/ static int read_abs_bbt (struct mtd_info *mtd,uint8_t *buf,struct nand_bbt_descr *td,int chip) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int res =0 , i;if (td->options &NAND_BBT_PERCHIP ) {
@@ -389,7 +389,7 @@ static u32 bbt_get_ver_offs(struct mtd_info *mtd, struct nand_bbt_descr *td)static void read_abs_bbts (struct mtd_info *mtd,uint8_t *buf,struct nand_bbt_descr *td,struct nand_bbt_descr *md) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);/* Read the primary version, if available */ if (td->options &NAND_BBT_VERSION ) {
@@ -455,7 +455,7 @@ static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,static int create_bbt (struct mtd_info *mtd,uint8_t *buf,struct nand_bbt_descr *bd,int chip) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int i, numblocks, numpages;int startblock;loff_t from;
@@ -524,7 +524,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,*/ static int search_bbt (struct mtd_info *mtd,uint8_t *buf,struct nand_bbt_descr *td) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int i, chips;int startblock, block, dir;int scanlen = mtd->writesize + mtd->oobsize;
@@ -619,7 +619,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, struct nand_bbt_descr *md, int chipsel) { - struct nand_chip *this = mtd->priv; + struct nand_chip *this = mtd_to_nand(mtd);struct erase_info einfo;int i, res, chip =0 ;int bits, startblock, dir, page, offs, numblocks, sft, sftmsk;
@@ -820,7 +820,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,*/ static inline int nand_memory_bbt (struct mtd_info *mtd,struct nand_bbt_descr *bd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);return create_bbt (mtd, this->buffers->databuf, bd,-1 ); }
@@ -839,7 +839,7 @@ static inline int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bstatic int check_create (struct mtd_info *mtd,uint8_t *buf,struct nand_bbt_descr *bd) {int i, chips, writeops, create, chipsel, res, res2; -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);struct nand_bbt_descr *td = this->bbt_td;struct nand_bbt_descr *md = this->bbt_md;struct nand_bbt_descr *rd, *rd2;
@@ -963,7 +963,7 @@ static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc*/ static void mark_bbt_region (struct mtd_info *mtd,struct nand_bbt_descr *td) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int i, j, chips, block, nrblocks, update;uint8_t oldval;
@@ -1023,7 +1023,7 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td)*/ static void verify_bbt_descr (struct mtd_info *mtd,struct nand_bbt_descr *bd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u32 pattern_len;u32 bits;u32 table_size;
@@ -1075,7 +1075,7 @@ static void verify_bbt_descr(struct mtd_info *mtd, struct nand_bbt_descr *bd)*/ int nand_scan_bbt (struct mtd_info *mtd,struct nand_bbt_descr *bd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int len, res =0 ;uint8_t *buf;struct nand_bbt_descr *td = this->bbt_td;
@@ -1143,7 +1143,7 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)*/ static int nand_update_bbt (struct mtd_info *mtd,loff_t offs) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int len, res =0 ;int chip, chipsel;uint8_t *buf;
@@ -1277,7 +1277,7 @@ static int nand_create_badblock_pattern(struct nand_chip *this)*/ int nand_default_bbt (struct mtd_info *mtd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int ret;/* Is a flash based bad block table requested? */
@@ -1313,7 +1313,7 @@ int nand_default_bbt(struct mtd_info *mtd)*/ int nand_isreserved_bbt (struct mtd_info *mtd,loff_t offs) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int block; block = (int )(offs >> this->bbt_erase_shift);
@@ -1328,7 +1328,7 @@ int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs)*/ int nand_isbad_bbt (struct mtd_info *mtd,loff_t offs,int allowbbt) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int block, res; block = (int )(offs >> this->bbt_erase_shift);
@@ -1355,7 +1355,7 @@ int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt)*/ int nand_markbad_bbt (struct mtd_info *mtd,loff_t offs) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int block, ret =0 ; block = (int )(offs >> this->bbt_erase_shift);
drivers/mtd/nand/nand_bch.c +2 -2
@@ -41,7 +41,7 @@ struct nand_bch_control {int nand_bch_calculate_ecc (struct mtd_info *mtd,const unsigned char *buf,unsigned char *code) { -const struct nand_chip *chip = mtd->priv; +const struct nand_chip *chip =mtd_to_nand (mtd);struct nand_bch_control *nbc = chip->ecc.priv;unsigned int i;
@@ -67,7 +67,7 @@ int nand_bch_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf,int nand_bch_correct_data (struct mtd_info *mtd,unsigned char *buf,unsigned char *read_ecc,unsigned char *calc_ecc) { -const struct nand_chip *chip = mtd->priv; +const struct nand_chip *chip =mtd_to_nand (mtd);struct nand_bch_control *nbc = chip->ecc.priv;unsigned int *errloc = nbc->errloc;int i, count;
drivers/mtd/nand/nand_plat.c +2 -2
@@ -25,7 +25,7 @@static void plat_cmd_ctrl (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);if (cmd ==NAND_CMD_NONE )return ;
@@ -39,7 +39,7 @@ static void plat_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)#ifdef NAND_PLAT_DEV_READY static int plat_dev_ready (struct mtd_info *mtd) { -return NAND_PLAT_DEV_READY ((struct nand_chip *)mtd->priv); +return NAND_PLAT_DEV_READY ((struct nand_chip *)mtd_to_nand (mtd)); }#else # define plat_dev_ready NULL
drivers/mtd/nand/nand_spl_simple.c +5 -6
@@ -26,7 +26,7 @@ static struct nand_chip nand_chip;static int nand_command (int block,int page,uint32_t offs,u8 cmd) { -struct nand_chip *this = mtd->priv (); +struct nand_chip *this =mtd_to_nand (mtd);int page_addr = page + block *CONFIG_SYS_NAND_PAGE_COUNT ;while (!this->dev_ready (mtd))
@@ -63,7 +63,7 @@ static int nand_command(int block, int page, uint32_t offs,static int nand_command (int block,int page,uint32_t offs,u8 cmd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int page_addr = page + block *CONFIG_SYS_NAND_PAGE_COUNT ;void (*hwctrl)(struct mtd_info *mtd,int cmd,unsigned int ctrl) = this->cmd_ctrl;
@@ -114,7 +114,7 @@ static int nand_command(int block, int page, uint32_t offs,static int nand_is_bad_block (int block) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u_char bb_data[2 ]; nand_command(block, 0, CONFIG_SYS_NAND_BAD_BLOCK_POS,
@@ -139,7 +139,7 @@ static int nand_is_bad_block(int block)#if defined(CONFIG_SYS_NAND_HW_ECC_OOBFIRST )static int nand_read_page (int block,int page,uchar *dst) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u_char ecc_calc[ECCTOTAL ];u_char ecc_code[ECCTOTAL ];u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];
@@ -170,7 +170,7 @@ static int nand_read_page(int block, int page, uchar *dst)#else static int nand_read_page (int block,int page,void *dst) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u_char ecc_calc[ECCTOTAL ];u_char ecc_code[ECCTOTAL ];u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];
@@ -250,7 +250,6 @@ void nand_init(void)* Init board specific nand support */ mtd = &nand_chip.mtd; - mtd->priv = &nand_chip; nand_chip.IO_ADDR_R = nand_chip.IO_ADDR_W = (void __iomem *)CONFIG_SYS_NAND_BASE ;board_nand_init (&nand_chip);
drivers/mtd/nand/nand_util.c +4 -4
@@ -59,7 +59,7 @@ int nand_erase_opts(struct mtd_info *mtd,int percent_complete =-1 ;const char *mtd_device = mtd->name;struct mtd_oob_ops oob_opts; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);if ((opts->offset & (mtd->erasesize -1 )) !=0 ) {printf ("Attempt to erase non block-aligned data\n" );
@@ -217,7 +217,7 @@ int nand_lock(struct mtd_info *mtd, int tight) {int ret =0 ;int status; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);/* select the NAND device */ chip->select_chip (mtd,0 );
@@ -267,7 +267,7 @@ int nand_get_lock_status(struct mtd_info *mtd, loff_t offset)int ret =0 ;int chipnr;int page; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);/* select the NAND device */ chipnr = (int )(offset >> chip->chip_shift);
@@ -314,7 +314,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t start, size_t length,int chipnr;int status;int page; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);debug ("nand_unlock%s: start: %08llx, length: %zd!\n" , allexcept ?" (allexcept)" :"" , start, length);
drivers/mtd/nand/ndfc.c +7 -7
@@ -37,7 +37,7 @@ static int ndfc_cs[NDFC_MAX_BANKS];static void ndfc_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);ulong base = (ulong ) this->IO_ADDR_W &0xffffff00 ;if (cmd ==NAND_CMD_NONE )
@@ -51,7 +51,7 @@ static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)static int ndfc_dev_ready (struct mtd_info *mtdinfo) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);ulong base = (ulong ) this->IO_ADDR_W &0xffffff00 ;return (in_be32 ((u32 *)(base +NDFC_STAT )) &NDFC_STAT_IS_READY );
@@ -59,7 +59,7 @@ static int ndfc_dev_ready(struct mtd_info *mtdinfo)static void ndfc_enable_hwecc (struct mtd_info *mtdinfo,int mode) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);ulong base = (ulong ) this->IO_ADDR_W &0xffffff00 ;u32 ccr;
@@ -71,7 +71,7 @@ static void ndfc_enable_hwecc(struct mtd_info *mtdinfo, int mode)static int ndfc_calculate_ecc (struct mtd_info *mtdinfo,const u_char *dat,u_char *ecc_code) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);ulong base = (ulong ) this->IO_ADDR_W &0xffffff00 ;u32 ecc;u8 *p = (u8 *)&ecc;
@@ -96,7 +96,7 @@ static int ndfc_calculate_ecc(struct mtd_info *mtdinfo,*/ static void ndfc_read_buf (struct mtd_info *mtdinfo,uint8_t *buf,int len) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);ulong base = (ulong ) this->IO_ADDR_W &0xffffff00 ;uint32_t *p = (uint32_t *) buf;
@@ -110,7 +110,7 @@ static void ndfc_read_buf(struct mtd_info *mtdinfo, uint8_t *buf, int len)*/ static void ndfc_write_buf (struct mtd_info *mtdinfo,const uint8_t *buf,int len) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);ulong base = (ulong ) this->IO_ADDR_W &0xffffff00 ;uint32_t *p = (uint32_t *) buf;
@@ -124,7 +124,7 @@ static void ndfc_write_buf(struct mtd_info *mtdinfo, const uint8_t *buf, int lenstatic uint8_t ndfc_read_byte (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);#ifdef CONFIG_SYS_NAND_BUSWIDTH_16BIT return (uint8_t )readw (chip->IO_ADDR_R);
drivers/mtd/nand/omap_gpmc.c +20 -20
@@ -58,8 +58,8 @@ static struct omap_nand_info omap_nand_info[GPMC_MAX_CS];static void omap_nand_hwcontrol (struct mtd_info *mtd,int32_t cmd,uint32_t ctrl) { - registerstruct nand_chip *this = mtd->priv; -struct omap_nand_info *info = this->priv; + registerstruct nand_chip *this =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (this);int cs = info->cs;/*
@@ -85,8 +85,8 @@ static void omap_nand_hwcontrol(struct mtd_info *mtd, int32_t cmd,/* Check wait pin as dev ready indicator */ static int omap_dev_ready (struct mtd_info *mtd) { - registerstruct nand_chip *this = mtd->priv; -struct omap_nand_info *info = this->priv; + registerstruct nand_chip *this =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (this);return gpmc_cfg->status & (1 << (8 + info->ws)); }
@@ -177,8 +177,8 @@ static int __maybe_unused omap_correct_data(struct mtd_info *mtd, uint8_t *dat,__maybe_unused static void omap_enable_hwecc (struct mtd_info *mtd,int32_t mode) { -struct nand_chip *nand = mtd->priv; -struct omap_nand_info *info = nand->priv; +struct nand_chip *nand =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (nand);unsigned int dev_width = (nand->options &NAND_BUSWIDTH_16 ) ?1 :0 ;unsigned int ecc_algo =0 ;unsigned int bch_type =0 ;
@@ -262,8 +262,8 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int32_t mode)static int omap_calculate_ecc (struct mtd_info *mtd,const uint8_t *dat,uint8_t *ecc_code) { -struct nand_chip *chip = mtd->priv; -struct omap_nand_info *info = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (chip);uint32_t *ptr, val =0 ;int8_t i =0 , j;
@@ -392,7 +392,7 @@ static int __read_prefetch_aligned(struct nand_chip *chip, uint32_t *buf, int le {int ret;uint32_t cnt; -struct omap_nand_info *info = chip->priv; +struct omap_nand_info *info =nand_get_controller_data (chip); ret =omap_prefetch_enable (PREFETCH_FIFOTHRESHOLD_MAX , len,0 , info->cs);if (ret <0 )
@@ -417,7 +417,7 @@ static int __read_prefetch_aligned(struct nand_chip *chip, uint32_t *buf, int lestatic inline void omap_nand_read (struct mtd_info *mtd,uint8_t *buf,int len) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);if (chip->options &NAND_BUSWIDTH_16 )nand_read_buf16 (mtd, buf, len);
@@ -429,7 +429,7 @@ static void omap_nand_read_prefetch(struct mtd_info *mtd, uint8_t *buf, int len) {int ret;uint32_t head, tail; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);/* * If the destination buffer is unaligned, start with reading
@@ -491,8 +491,8 @@ static void omap_reverse_list(u8 *list, unsigned int length)static int omap_correct_data_bch (struct mtd_info *mtd,uint8_t *dat,uint8_t *read_ecc,uint8_t *calc_ecc) { -struct nand_chip *chip = mtd->priv; -struct omap_nand_info *info = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (chip);struct nand_ecc_ctrl *ecc = &chip->ecc;uint32_t error_count =0 , error_max;uint32_t error_loc[ELM_MAX_ERROR_COUNT ];
@@ -652,8 +652,8 @@ static int omap_correct_data_bch_sw(struct mtd_info *mtd, u_char *data,int i, count;/* cannot correct more than 8 errors */ unsigned int errloc[8 ]; -struct nand_chip *chip = mtd->priv; -struct omap_nand_info *info = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (chip); count =decode_bch (info->control,NULL ,512 , read_ecc, calc_ecc,NULL , errloc);
@@ -691,8 +691,8 @@ static int omap_correct_data_bch_sw(struct mtd_info *mtd, u_char *data,*/ static void __maybe_unused omap_free_bch (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; -struct omap_nand_info *info = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (chip);if (info->control) {free_bch (info->control);
@@ -710,7 +710,7 @@ static void __maybe_unused omap_free_bch(struct mtd_info *mtd)*/ static int omap_select_ecc_scheme (struct nand_chip *nand,enum omap_ecc ecc_scheme,unsigned int pagesize,unsigned int oobsize) { -struct omap_nand_info *info = nand->priv; +struct omap_nand_info *info =nand_get_controller_data (nand);struct nand_ecclayout *ecclayout = &omap_ecclayout;int eccsteps = pagesize /SECTOR_BYTES ;int i;
@@ -904,7 +904,7 @@ int __maybe_unused omap_nand_switch_ecc(uint32_t hardware, uint32_t eccstrength) } mtd = nand_info[nand_curr_device]; - nand = mtd->priv; + nand =mtd_to_nand (mtd); nand->options |=NAND_OWN_BUFFERS ; nand->options &= ~NAND_SUBPAGE_READ ;/* Setup the ecc configurations again */
@@ -994,7 +994,7 @@ int board_nand_init(struct nand_chip *nand) omap_nand_info[cs].control =NULL ; omap_nand_info[cs].cs = cs; omap_nand_info[cs].ws = wscfg[cs]; - nand->priv = &omap_nand_info[cs]; +nand_set_controller_data (nand, &omap_nand_info[cs]); nand->cmd_ctrl = omap_nand_hwcontrol; nand->options |=NAND_NO_PADDING |NAND_CACHEPRG ; nand->chip_delay =100 ;
drivers/mtd/nand/pxa3xx_nand.c +20 -14
@@ -900,7 +900,8 @@ static int prepare_set_command(struct pxa3xx_nand_info *info, int command,static void nand_cmdfunc (struct mtd_info *mtd,unsigned command,int column,int page_addr) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;int exec_cmd;
@@ -960,7 +961,8 @@ static void nand_cmdfunc_extended(struct mtd_info *mtd,const unsigned command, int column, int page_addr) { - struct pxa3xx_nand_host *host = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;int exec_cmd, ext_cmd_type;
@@ -1091,7 +1093,7 @@ static int pxa3xx_nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { - struct pxa3xx_nand_host *host = mtd->priv; + struct pxa3xx_nand_host *host = nand_get_controller_data(chip);struct pxa3xx_nand_info *info = host->info_data; chip->read_buf (mtd, buf, mtd->writesize);
@@ -1117,7 +1119,8 @@ static int pxa3xx_nand_read_page_hwecc(struct mtd_info *mtd,static uint8_t pxa3xx_nand_read_byte (struct mtd_info *mtd) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;char retval =0xFF ;
@@ -1130,7 +1133,8 @@ static uint8_t pxa3xx_nand_read_byte(struct mtd_info *mtd)static u16 pxa3xx_nand_read_word (struct mtd_info *mtd) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;u16 retval =0xFFFF ;
@@ -1143,7 +1147,8 @@ static u16 pxa3xx_nand_read_word(struct mtd_info *mtd)static void pxa3xx_nand_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;int real_len =min_t (size_t, len, info->buf_count - info->buf_start);
@@ -1154,7 +1159,8 @@ static void pxa3xx_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)static void pxa3xx_nand_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;int real_len =min_t (size_t, len, info->buf_count - info->buf_start);
@@ -1169,7 +1175,8 @@ static void pxa3xx_nand_select_chip(struct mtd_info *mtd, int chip)static int pxa3xx_nand_waitfunc (struct mtd_info *mtd,struct nand_chip *this) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;if (info->need_wait) {
@@ -1210,7 +1217,7 @@ static int pxa3xx_nand_config_flash(struct pxa3xx_nand_info *info) {struct pxa3xx_nand_host *host = info->host[info->cs];struct mtd_info *mtd = host->mtd; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); info->reg_ndcr |= (host->col_addr_cycles ==2 ) ?NDCR_RA_START :0 ; info->reg_ndcr |= (chip->page_shift ==6 ) ?NDCR_PG_PER_BLK :0 ;
@@ -1262,7 +1269,7 @@ static int pxa3xx_nand_sensing(struct pxa3xx_nand_host *host)int ret; mtd = info->host[info->cs]->mtd; - chip = mtd->priv; + chip =mtd_to_nand (mtd);/* configure default flash values */ info->reg_ndcr =0x0 ;/* enable all interrupts */
@@ -1354,10 +1361,10 @@ static int pxa_ecc_init(struct pxa3xx_nand_info *info,static int pxa3xx_nand_scan (struct mtd_info *mtd) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;struct pxa3xx_nand_platform_data *pdata = info->pdata; -struct nand_chip *chip = mtd->priv;int ret;uint16_t ecc_strength, ecc_step;
@@ -1479,14 +1486,13 @@ static int alloc_nand_resource(struct pxa3xx_nand_info *info)for (cs =0 ; cs < pdata->num_cs; cs++) { chip = (struct nand_chip *) ((u8 *)&info[1 ] +sizeof (*host) * cs); - mtd = &chip->mtd; + mtd =nand_to_mtd (chip); host = (struct pxa3xx_nand_host *)chip; info->host[cs] = host; host->mtd = mtd; host->cs = cs; host->info_data = info; host->read_id_bytes =4 ; - mtd->priv = host; mtd->owner =THIS_MODULE ; chip->ecc.read_page = pxa3xx_nand_read_page_hwecc;
drivers/mtd/nand/s3c2410_nand.c +2 -2
@@ -31,7 +31,7 @@static void nand_read_buf (struct mtd_info *mtd,u_char *buf,int len) {int i; -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);for (i =0 ; i < len; i++) buf[i] =readb (this->IO_ADDR_R);
@@ -40,7 +40,7 @@ static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)static void s3c24x0_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);struct s3c24x0_nand *nand =s3c24x0_get_base_nand ();debug ("hwcontrol(): 0x%02x 0x%02x\n" , cmd, ctrl);
drivers/mtd/nand/tegra_nand.c +14 -15
@@ -143,10 +143,10 @@ static int nand_waitfor_cmd_completion(struct nand_ctlr *reg)*/ static uint8_t read_byte (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);struct nand_drv *info; - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip);writel (CMD_GO |CMD_PIO |CMD_RX |CMD_CE0 |CMD_A_VALID , &info->reg->command);
@@ -169,8 +169,8 @@ static void read_buf(struct mtd_info *mtd, uint8_t *buf, int len) {int i, s;unsigned int reg; -struct nand_chip *chip = mtd->priv; -struct nand_drv *info = (struct nand_drv *)chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct nand_drv *info = (struct nand_drv *)nand_get_controller_data (chip);for (i =0 ; i < len; i +=4 ) { s = (len - i) >4 ?4 : len - i;
@@ -194,11 +194,11 @@ static void read_buf(struct mtd_info *mtd, uint8_t *buf, int len)*/ static int nand_dev_ready (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);int reg_val;struct nand_drv *info; - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip); reg_val =readl (&info->reg->status);if (reg_val &STATUS_RBSY0 )
@@ -245,10 +245,10 @@ static void nand_clear_interrupt_status(struct nand_ctlr *reg)static void nand_command (struct mtd_info *mtd,unsigned int command,int column,int page_addr) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);struct nand_drv *info; - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip);/* * Write out the command to the device.
@@ -512,7 +512,7 @@ static int nand_rw_page(struct mtd_info *mtd, struct nand_chip *chip,return -EINVAL ; } - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip); config = &info->config;if (set_bus_width_page_size (config, ®_val))return -EINVAL ;
@@ -662,7 +662,7 @@ static int nand_write_page_hwecc(struct mtd_info *mtd,int page;struct nand_drv *info; - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip); page = (readl (&info->reg->addr_reg1) >>16 ) | (readl (&info->reg->addr_reg2) <<16 );
@@ -702,7 +702,7 @@ static int nand_write_page_raw(struct mtd_info *mtd,int page;struct nand_drv *info; - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip); page = (readl (&info->reg->addr_reg1) >>16 ) | (readl (&info->reg->addr_reg2) <<16 );
@@ -734,7 +734,7 @@ static int nand_rw_oob(struct mtd_info *mtd, struct nand_chip *chip,if (((int )chip->oob_poi) &0x03 )return -EINVAL ; - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip);if (set_bus_width_page_size (&info->config, ®_val))return -EINVAL ;
@@ -963,7 +963,7 @@ int tegra_nand_init(struct nand_chip *nand, int devnum) nand->ecc.strength =1 ; nand->select_chip = nand_select_chip; nand->dev_ready = nand_dev_ready; - nand->priv = &nand_ctrl; +nand_set_controller_data (nand, &nand_ctrl);/* Disable subpage writes as we do not provide ecc->hwctl */ nand->options |=NAND_NO_SUBPAGE_WRITE ;
@@ -976,8 +976,7 @@ int tegra_nand_init(struct nand_chip *nand, int devnum)dm_gpio_set_value (&config->wp_gpio,1 ); - our_mtd = &nand->mtd; - our_mtd->priv = nand; + our_mtd =nand_to_mtd (nand); ret =nand_scan_ident (our_mtd,CONFIG_SYS_NAND_MAX_CHIPS ,NULL );if (ret)return ret;
drivers/mtd/nand/vf610_nfc.c +3 -5
@@ -155,8 +155,7 @@ struct vf610_nfc {enum vf610_nfc_alt_buf alt_buf; }; -#define mtd_to_nfc (_mtd) \ - (struct vf610_nfc *)((struct nand_chip *)_mtd->priv)->priv +#define mtd_to_nfc (_mtd) nand_get_controller_data(mtd_to_nand(_mtd))#if defined(CONFIG_SYS_NAND_VF610_NFC_45_ECC_BYTES )#define ECC_HW_MODE ECC_45_BYTE
@@ -653,9 +652,8 @@ static int vf610_nfc_nand_init(int devnum, void __iomem *addr) chip = &nfc->chip; nfc->regs = addr; - mtd = &chip->mtd; - mtd->priv = chip; - chip->priv = nfc; + mtd =nand_to_mtd (chip); +nand_set_controller_data (chip, nfc);if (cfg.width ==16 ) chip->options |=NAND_BUSWIDTH_16 ;
fs/yaffs2/yaffs_uboot_glue.c +1 -1
@@ -190,7 +190,7 @@ void cmd_yaffs_devconfig(char *_mp, int flash_dev, goto err; } - chip = mtd->priv; + chip =mtd_to_nand (mtd);/* Check for any conflicts */ yaffs_dev_rewind ();
include/linux/mtd/nand.h +20 -0
@@ -740,6 +740,26 @@ struct nand_chip {void *priv; }; +static inline struct nand_chip *mtd_to_nand (struct mtd_info *mtd) +{ + return container_of(mtd, struct nand_chip, mtd); +} + +static inline struct mtd_info *nand_to_mtd (struct nand_chip *chip) +{ +return &chip->mtd; +} + +static inline void *nand_get_controller_data (struct nand_chip *chip) +{ +return chip->priv; +} + +static inline void nand_set_controller_data (struct nand_chip *chip,void *priv) +{ + chip->priv = priv; +} +/* * NAND Flash Manufacturer ID Codes */
Signature · 1 line
2.5.0
PATCH 5/7 mtd: nand: Add+use mtd_to/from_nand and nand_get/set_controller_data
Quoted 4 lines · On Mon, 30 May 2016 13:57:56 -0500 Scott Wood <[email protected]> wrote:
These functions are part of the Linux 4.6 sync. They are being added before the main sync patch in order to make it easier to address the issue across all NAND drivers (many/most of which do not closely track their Linux counterparts) separately from other merge issues.
Some drivers are still directly accessing chip->mtd. Here is a patch fixing those places [1] (not tested).
[1] http://code.bulix.org/inu69a-100476
Quoted 2,561 lines
Signed-off-by Scott Wood <[email protected]>--- board/esd/common/esd405ep_nand.c | 2 +- board/freescale/m5329evb/nand.c | 2 +- board/freescale/m5373evb/nand.c | 2 +- board/socrates/nand.c | 6 ++-- board/xes/common/actl_nand.c | 2 +- cmd/nand.c | 4 +-- drivers/mtd/nand/am335x_spl_bch.c | 6 ++-- drivers/mtd/nand/arasan_nfc.c | 19 +++++----- drivers/mtd/nand/atmel_nand.c | 55 ++++++++++++++-------------- drivers/mtd/nand/davinci_nand.c | 8 ++--- drivers/mtd/nand/denali.c | 4 +-- drivers/mtd/nand/fsl_elbc_nand.c | 33 +++++++++-------- drivers/mtd/nand/fsl_ifc_nand.c | 43 +++++++++++----------- drivers/mtd/nand/fsl_upm.c | 22 ++++++------ drivers/mtd/nand/fsmc_nand.c | 7 ++-- drivers/mtd/nand/kb9202_nand.c | 2 +- drivers/mtd/nand/kirkwood_nand.c | 2 +- drivers/mtd/nand/lpc32xx_nand_mlc.c | 2 -- drivers/mtd/nand/lpc32xx_nand_slc.c | 2 +- drivers/mtd/nand/mpc5121_nfc.c | 27 +++++++------- drivers/mtd/nand/mxc_nand.c | 51 +++++++++++++------------- drivers/mtd/nand/mxs_nand.c | 46 ++++++++++++------------ drivers/mtd/nand/mxs_nand_spl.c | 11 +++--- drivers/mtd/nand/nand.c | 5 ++- drivers/mtd/nand/nand_base.c | 72 ++++++++++++++++++------------------- drivers/mtd/nand/nand_bbt.c | 32 ++++++++--------- drivers/mtd/nand/nand_bch.c | 4 +-- drivers/mtd/nand/nand_plat.c | 4 +-- drivers/mtd/nand/nand_spl_simple.c | 11 +++--- drivers/mtd/nand/nand_util.c | 8 ++--- drivers/mtd/nand/ndfc.c | 14 ++++---- drivers/mtd/nand/omap_gpmc.c | 40 ++++++++++----------- drivers/mtd/nand/pxa3xx_nand.c | 34 ++++++++++-------- drivers/mtd/nand/s3c2410_nand.c | 4 +-- drivers/mtd/nand/tegra_nand.c | 29 ++++++++------- drivers/mtd/nand/vf610_nfc.c | 8 ++--- fs/yaffs2/yaffs_uboot_glue.c | 2 +- include/linux/mtd/nand.h | 20 +++++++++++ 38 files changed, 328 insertions(+), 317 deletions(-)board/esd/common/esd405ep_nand.c +1
-1@@ -16,7 +16,7 @@*/ static void esd405ep_nand_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);if (ctrl &NAND_CTRL_CHANGE ) {if ( ctrl &NAND_CLE )out_be32 ((void *)GPIO0_OR ,in_be32 ((void *)GPIO0_OR ) |CONFIG_SYS_NAND_CLE );board/freescale/m5329evb/nand.c +1
-1@@ -24,7 +24,7 @@ DECLARE_GLOBAL_DATA_PTR;static void nand_hwcontrol (struct mtd_info *mtdinfo,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);volatile u16 *nCE = (u16 *)CONFIG_SYS_LATCH_ADDR ;if (ctrl &NAND_CTRL_CHANGE ) {board/freescale/m5373evb/nand.c +1
-1@@ -24,7 +24,7 @@ DECLARE_GLOBAL_DATA_PTR;static void nand_hwcontrol (struct mtd_info *mtdinfo,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);volatile u16 *nCE = (u16 *)CONFIG_SYS_LATCH_ADDR ;if (ctrl &NAND_CTRL_CHANGE ) {board/socrates/nand.c +3
-3@@ -48,7 +48,7 @@ static void sc_nand_write_byte(struct mtd_info *mtd, u_char byte)static void sc_nand_write_buf (struct mtd_info *mtd,const u_char *buf,int len) {int i; -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);for (i =0 ; i < len; i++) { out_be32(this->IO_ADDR_W,@@ -88,7 +88,7 @@ static u16 sc_nand_read_word(struct mtd_info *mtd)static void sc_nand_read_buf (struct mtd_info *mtd,u_char *buf,int len) {int i; -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int val; val = (state &FPGA_NAND_ENABLE ) |FPGA_NAND_CMD_READ ;@@ -105,7 +105,7 @@ static void sc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)*/ static int sc_nand_device_ready (struct mtd_info *mtdinfo) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);if (in_be32 (this->IO_ADDR_W) &FPGA_NAND_BUSY )return 0 ;/* busy */ board/xes/common/actl_nand.c +1
-1@@ -16,7 +16,7 @@*/ static void nand_addr_hwcontrol (struct mtd_info *mtd,int cmd,uint ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);ulong IO_ADDR_W ;if (ctrl &NAND_CTRL_CHANGE ) {cmd/nand.c +2
-2@@ -159,7 +159,7 @@ static void do_nand_status(struct mtd_info *mtd)ulong off;int last_status =-1 ; -struct nand_chip *nand_chip = mtd->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd);/* check the WP bit */ nand_chip->cmdfunc (mtd,NAND_CMD_STATUS ,-1 ,-1 ); printf("device is %swrite protected\n",@@ -285,7 +285,7 @@ usage:static void nand_print_and_set_info (int idx) {struct mtd_info *mtd = nand_info[idx]; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);printf ("Device %d: " , idx);if (chip->numchips >1 )drivers/mtd/nand/am335x_spl_bch.c +3
-3@@ -30,7 +30,7 @@ static struct nand_chip nand_chip;static int nand_command (int block,int page,uint32_t offs,u8 cmd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int page_addr = page + block *CONFIG_SYS_NAND_PAGE_COUNT ;void (*hwctrl)(struct mtd_info *mtd,int cmd,unsigned int ctrl) = this->cmd_ctrl;@@ -100,7 +100,7 @@ static int nand_command(int block, int page, uint32_t offs,static int nand_is_bad_block (int block) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);nand_command (block,0 ,CONFIG_SYS_NAND_BAD_BLOCK_POS ,NAND_CMD_READOOB );@@ -121,7 +121,7 @@ static int nand_is_bad_block(int block)static int nand_read_page (int block,int page,void *dst) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u_char ecc_calc[ECCTOTAL ];u_char ecc_code[ECCTOTAL ];u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];drivers/mtd/nand/arasan_nfc.c +9
-10@@ -230,7 +230,7 @@ static void arasan_nand_enable_ecc(void)static u8 arasan_nand_get_addrcycle (struct mtd_info *mtd) {u8 addrcycles; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);switch (curr_cmd->addr_cycles) {case NAND_ADDR_CYCL_NONE :@@ -264,7 +264,7 @@ static u8 arasan_nand_get_addrcycle(struct mtd_info *mtd)static int arasan_nand_read_page (struct mtd_info *mtd,u8 *buf,u32 size) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);u32 reg_val, i, pktsize, pktnum;u32 *bufptr = (u32 *)buf;u32 timeout;@@ -441,7 +441,7 @@ static int arasan_nand_write_page_hwecc(struct mtd_info *mtd,u32 size = mtd->writesize;u32 rdcount =0 ;u8 column_addr_cycles; -struct arasan_nand_info *nand = chip->priv; +struct arasan_nand_info *nand =nand_get_controller_data (chip);if (chip->ecc_step_ds >=ARASAN_NAND_PKTSIZE_1K ) pktsize =ARASAN_NAND_PKTSIZE_1K ;@@ -944,7 +944,7 @@ static void arasan_nand_read_buf(struct mtd_info *mtd, u8 *buf, int size)static u8 arasan_nand_read_byte (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);u32 size;u8 val;struct nand_onfi_params *p;@@ -976,8 +976,8 @@ static void arasan_nand_cmd_function(struct mtd_info *mtd, unsigned int command, int column, int page_addr) {u32 i, ret =0 ; -struct nand_chip *chip = mtd->priv; -struct arasan_nand_info *nand = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct arasan_nand_info *nand =nand_get_controller_data (chip); curr_cmd =NULL ; writel(ARASAN_NAND_INT_STS_XFR_CMPLT_MASK,@@ -1033,7 +1033,7 @@ static int arasan_nand_ecc_init(struct mtd_info *mtd) {int found =-1 ;u32 regval, eccpos_start, i; -struct nand_chip *nand_chip = mtd->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); nand_chip->ecc.mode =NAND_ECC_HW ; nand_chip->ecc.hwctl =NULL ;@@ -1101,9 +1101,8 @@ static int arasan_nand_init(struct nand_chip *nand_chip, int devnum) } nand->nand_base = arasan_nand_base; - mtd = &nand_chip->mtd; - nand_chip->priv = nand; - mtd->priv = nand_chip; + mtd =nand_to_mtd (nand_chip); +nand_set_controller_data (nand_chip, nand);/* Set the driver entry points for MTD */ nand_chip->cmdfunc = arasan_nand_cmd_function;drivers/mtd/nand/atmel_nand.c +27
-28@@ -160,8 +160,8 @@ static int pmecc_data_alloc(struct atmel_nand_host *host)static void pmecc_gen_syndrome (struct mtd_info *mtd,int sector) { -struct nand_chip *nand_chip = mtd->priv; -struct atmel_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct atmel_nand_host *host =nand_get_controller_data (nand_chip);int i;uint32_t value;@@ -177,8 +177,8 @@ static void pmecc_gen_syndrome(struct mtd_info *mtd, int sector)static void pmecc_substitute (struct mtd_info *mtd) { -struct nand_chip *nand_chip = mtd->priv; -struct atmel_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct atmel_nand_host *host =nand_get_controller_data (nand_chip);int16_t __iomem *alpha_to = host->pmecc_alpha_to;int16_t __iomem *index_of = host->pmecc_index_of;int16_t *partial_syn = host->pmecc_partial_syn;@@ -227,8 +227,8 @@ static void pmecc_substitute(struct mtd_info *mtd)*/ static void pmecc_get_sigma (struct mtd_info *mtd) { -struct nand_chip *nand_chip = mtd->priv; -struct atmel_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct atmel_nand_host *host =nand_get_controller_data (nand_chip);int16_t *lmu = host->pmecc_lmu;int16_t *si = host->pmecc_si;@@ -383,8 +383,8 @@ static void pmecc_get_sigma(struct mtd_info *mtd)static int pmecc_err_location (struct mtd_info *mtd) { -struct nand_chip *nand_chip = mtd->priv; -struct atmel_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct atmel_nand_host *host =nand_get_controller_data (nand_chip);const int cap = host->pmecc_corr_cap;const int num =2 * cap +1 ;int sector_size = host->pmecc_sector_size;@@ -437,8 +437,8 @@ static int pmecc_err_location(struct mtd_info *mtd)static void pmecc_correct_data (struct mtd_info *mtd,uint8_t *buf,uint8_t *ecc,int sector_num,int extra_bytes,int err_nbr) { -struct nand_chip *nand_chip = mtd->priv; -struct atmel_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct atmel_nand_host *host =nand_get_controller_data (nand_chip);int i =0 ;int byte_pos, bit_pos, sector_size, pos;uint32_t tmp;@@ -483,8 +483,8 @@ static void pmecc_correct_data(struct mtd_info *mtd, uint8_t *buf, uint8_t *ecc,static int pmecc_correction (struct mtd_info *mtd,u32 pmecc_stat,uint8_t *buf,u8 *ecc) { -struct nand_chip *nand_chip = mtd->priv; -struct atmel_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct atmel_nand_host *host =nand_get_controller_data (nand_chip);int i, err_nbr, eccbytes;uint8_t *buf_pos;@@ -529,7 +529,7 @@ normal_check:static int atmel_nand_pmecc_read_page (struct mtd_info *mtd,struct nand_chip *chip,uint8_t *buf,int oob_required,int page) { -struct atmel_nand_host *host = chip->priv; +struct atmel_nand_host *host =nand_get_controller_data (chip);int eccsize = chip->ecc.size;uint8_t *oob = chip->oob_poi;uint32_t *eccpos = chip->ecc.layout->eccpos;@@ -571,7 +571,7 @@ static int atmel_nand_pmecc_write_page(struct mtd_info *mtd, struct nand_chip *chip, const uint8_t *buf, int oob_required) { - struct atmel_nand_host *host = chip->priv; + struct atmel_nand_host *host = nand_get_controller_data(chip);uint32_t *eccpos = chip->ecc.layout->eccpos;int i, j;int timeout =PMECC_MAX_TIMEOUT_US ;@@ -615,8 +615,8 @@ out:static void atmel_pmecc_core_init (struct mtd_info *mtd) { -struct nand_chip *nand_chip = mtd->priv; -struct atmel_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct atmel_nand_host *host =nand_get_controller_data (nand_chip);uint32_t val =0 ;struct nand_ecclayout *ecc_layout;@@ -808,7 +808,8 @@ static int atmel_pmecc_nand_init_params(struct nand_chip *nand,struct atmel_nand_host *host;int cap, sector_size; - host = nand->priv = &pmecc_host; + host = &pmecc_host; +nand_set_controller_data (nand, host); nand->ecc.mode =NAND_ECC_HW ; nand->ecc.calculate =NULL ;@@ -1080,7 +1081,7 @@ static int atmel_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip,static int atmel_nand_correct (struct mtd_info *mtd,u_char *dat,u_char *read_ecc,u_char *isnull) { -struct nand_chip *nand_chip = mtd->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd);unsigned int ecc_status;unsigned int ecc_word, ecc_bit;@@ -1207,7 +1208,7 @@ int atmel_hwecc_nand_init_param(struct nand_chip *nand, struct mtd_info *mtd)static void at91_nand_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);if (ctrl &NAND_CTRL_CHANGE ) {ulong IO_ADDR_W = (ulong ) this->IO_ADDR_W;@@ -1243,7 +1244,7 @@ static struct nand_chip nand_chip;static int nand_command (int block,int page,uint32_t offs,u8 cmd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int page_addr = page + block *CONFIG_SYS_NAND_PAGE_COUNT ;void (*hwctrl)(struct mtd_info *mtd,int cmd,unsigned int ctrl) = this->cmd_ctrl;@@ -1281,7 +1282,7 @@ static int nand_command(int block, int page, uint32_t offs, u8 cmd)static int nand_is_bad_block (int block) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);nand_command (block,0 ,CONFIG_SYS_NAND_BAD_BLOCK_POS ,NAND_CMD_READOOB );@@ -1304,7 +1305,7 @@ static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;static int nand_read_page (int block,int page,void *dst) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u_char ecc_calc[ECCTOTAL ];u_char ecc_code[ECCTOTAL ];u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];@@ -1337,7 +1338,7 @@ static int nand_read_page(int block, int page, void *dst)int spl_nand_erase_one (int block,int page) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);void (*hwctrl)(struct mtd_info *mtd,int cmd,unsigned int ctrl) = this->cmd_ctrl;int page_addr;@@ -1368,7 +1369,7 @@ int spl_nand_erase_one(int block, int page)#else static int nand_read_page (int block,int page,void *dst) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);nand_command (block, page,0 ,NAND_CMD_READ0 );atmel_nand_pmecc_read_page (mtd, this, dst,0 , page);@@ -1407,7 +1408,7 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)int at91_nand_wait_ready (struct mtd_info *mtd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);udelay (this->chip_delay);@@ -1450,7 +1451,6 @@ void nand_init(void) mtd = &nand_chip.mtd; mtd->writesize =CONFIG_SYS_NAND_PAGE_SIZE ; mtd->oobsize =CONFIG_SYS_NAND_OOBSIZE ; - mtd->priv = &nand_chip; nand_chip.IO_ADDR_R = (void __iomem *)CONFIG_SYS_NAND_BASE ; nand_chip.IO_ADDR_W = (void __iomem *)CONFIG_SYS_NAND_BASE ;board_nand_init (&nand_chip);@@ -1484,9 +1484,8 @@ int atmel_nand_chip_init(int devnum, ulong base_addr) {int ret;struct nand_chip *nand = &nand_chip[devnum]; -struct mtd_info *mtd = &nand->mtd; +struct mtd_info *mtd =nand_to_mtd (nand); - mtd->priv = nand; nand->IO_ADDR_R = nand->IO_ADDR_W = (void __iomem *)base_addr;#ifdef CONFIG_NAND_ECC_BCH drivers/mtd/nand/davinci_nand.c +4
-4@@ -54,7 +54,7 @@*/ static void nand_davinci_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);const u32 *nand = chip->IO_ADDR_R;/* Make sure that buf is 32 bit aligned */ @@ -99,7 +99,7 @@ static void nand_davinci_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)static void nand_davinci_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);const u32 *nand = chip->IO_ADDR_W;/* Make sure that buf is 32 bit aligned */ @@ -144,7 +144,7 @@ static void nand_davinci_write_buf(struct mtd_info *mtd, const uint8_t *buf,static void nand_davinci_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u_int32_t IO_ADDR_W = (u_int32_t )this->IO_ADDR_W;if (ctrl &NAND_CTRL_CHANGE ) {@@ -223,7 +223,7 @@ static int nand_davinci_calculate_ecc(struct mtd_info *mtd, const u_char *dat,static int nand_davinci_correct_data (struct mtd_info *mtd,u_char *dat,u_char *read_ecc,u_char *calc_ecc) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u_int32_t ecc_nand = read_ecc[0 ] | (read_ecc[1 ] <<8 ) | (read_ecc[2 ] <<16 ); u_int32_t ecc_calc = calc_ecc[0] | (calc_ecc[1] << 8) |drivers/mtd/nand/denali.c +2
-2@@ -48,7 +48,8 @@ static int onfi_timing_mode = NAND_DEFAULT_TIMINGS;* this macro allows us to convert from an MTD structure to our own * device context (denali) structure. */ -#define mtd_to_denali (m) container_of(m->priv, struct denali_nand_info, nand) +#define mtd_to_denali (m) \ + container_of(mtd_to_nand(m), struct denali_nand_info, nand)/* * These constants are defined by the driver to enable common driver @@ -1179,7 +1180,6 @@ static int denali_init(struct denali_nand_info *denali) denali->mtd->name ="denali-nand" ; denali->mtd->owner =THIS_MODULE ; - denali->mtd->priv = &denali->nand;/* register the driver with the NAND core subsystem */ denali->nand.select_chip = denali_select_chip;drivers/mtd/nand/fsl_elbc_nand.c +16
-17@@ -154,8 +154,8 @@ static struct nand_bbt_descr bbt_mirror_descr = {*/ static void set_addr (struct mtd_info *mtd,int column,int page_addr,int oob) { -struct nand_chip *chip = mtd->priv; -struct fsl_elbc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;fsl_lbc_t *lbc = ctrl->regs;int buf_num;@@ -194,8 +194,8 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob)*/ static int fsl_elbc_run_command (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; -struct fsl_elbc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;fsl_lbc_t *lbc = ctrl->regs;u32 timeo = (CONFIG_SYS_HZ *10 ) /1000 ;@@ -246,7 +246,7 @@ static int fsl_elbc_run_command(struct mtd_info *mtd)static void fsl_elbc_do_read (struct nand_chip *chip,int oob) { -struct fsl_elbc_mtd *priv = chip->priv; +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;fsl_lbc_t *lbc = ctrl->regs;@@ -279,8 +279,8 @@ static void fsl_elbc_do_read(struct nand_chip *chip, int oob)static void fsl_elbc_cmdfunc (struct mtd_info *mtd,unsigned int command,int column,int page_addr) { -struct nand_chip *chip = mtd->priv; -struct fsl_elbc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;fsl_lbc_t *lbc = ctrl->regs;@@ -489,8 +489,8 @@ static void fsl_elbc_select_chip(struct mtd_info *mtd, int chip)*/ static void fsl_elbc_write_buf (struct mtd_info *mtd,const u8 *buf,int len) { -struct nand_chip *chip = mtd->priv; -struct fsl_elbc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;unsigned int bufsize = mtd->writesize + mtd->oobsize;@@ -526,8 +526,8 @@ static void fsl_elbc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)*/ static u8 fsl_elbc_read_byte (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; -struct fsl_elbc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;/* If there are still bytes in the FCM, then use the next byte. */ @@ -543,8 +543,8 @@ static u8 fsl_elbc_read_byte(struct mtd_info *mtd)*/ static void fsl_elbc_read_buf (struct mtd_info *mtd,u8 *buf,int len) { -struct nand_chip *chip = mtd->priv; -struct fsl_elbc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;int avail;@@ -566,7 +566,7 @@ static void fsl_elbc_read_buf(struct mtd_info *mtd, u8 *buf, int len)*/ static int fsl_elbc_wait (struct mtd_info *mtd,struct nand_chip *chip) { -struct fsl_elbc_mtd *priv = chip->priv; +struct fsl_elbc_mtd *priv =nand_get_controller_data (chip);struct fsl_elbc_ctrl *ctrl = priv->ctrl;fsl_lbc_t *lbc = ctrl->regs;@@ -697,8 +697,7 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr) } nand = &priv->chip; - mtd = &nand->mtd; - mtd->priv = nand; + mtd =nand_to_mtd (nand); elbc_ctrl->chips[priv->bank] = priv;@@ -720,7 +719,7 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr) nand->bbt_options =NAND_BBT_USE_FLASH ; nand->controller = &elbc_ctrl->controller; - nand->priv = priv; +nand_set_controller_data (nand, priv); nand->ecc.read_page = fsl_elbc_read_page; nand->ecc.write_page = fsl_elbc_write_page;drivers/mtd/nand/fsl_ifc_nand.c +21
-22@@ -222,8 +222,8 @@ static struct nand_bbt_descr bbt_mirror_descr = {*/ static void set_addr (struct mtd_info *mtd,int column,int page_addr,int oob) { -struct nand_chip *chip = mtd->priv; -struct fsl_ifc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);struct fsl_ifc_ctrl *ctrl = priv->ctrl;struct fsl_ifc_runtime *ifc = ctrl->regs.rregs;int buf_num;@@ -247,8 +247,8 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob)static int is_blank (struct mtd_info *mtd,struct fsl_ifc_ctrl *ctrl,unsigned int bufnum) { -struct nand_chip *chip = mtd->priv; -struct fsl_ifc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);u8 __iomem *addr = priv->vbase + bufnum * (mtd->writesize *2 );u32 __iomem *main = (u32 *)addr;u8 __iomem *oob = addr + mtd->writesize;@@ -286,8 +286,8 @@ static int check_read_ecc(struct mtd_info *mtd, struct fsl_ifc_ctrl *ctrl,*/ static int fsl_ifc_run_command (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; -struct fsl_ifc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);struct fsl_ifc_ctrl *ctrl = priv->ctrl;struct fsl_ifc_runtime *ifc = ctrl->regs.rregs;u32 timeo = (CONFIG_SYS_HZ *10 ) /1000 ;@@ -367,7 +367,7 @@ static void fsl_ifc_do_read(struct nand_chip *chip,int oob, struct mtd_info *mtd) { - struct fsl_ifc_mtd *priv = chip->priv; + struct fsl_ifc_mtd *priv = nand_get_controller_data(chip);struct fsl_ifc_ctrl *ctrl = priv->ctrl;struct fsl_ifc_runtime *ifc = ctrl->regs.rregs;@@ -404,8 +404,8 @@ static void fsl_ifc_do_read(struct nand_chip *chip,static void fsl_ifc_cmdfunc (struct mtd_info *mtd,unsigned int command,int column,int page_addr) { -struct nand_chip *chip = mtd->priv; -struct fsl_ifc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);struct fsl_ifc_ctrl *ctrl = priv->ctrl;struct fsl_ifc_runtime *ifc = ctrl->regs.rregs;@@ -607,8 +607,8 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command,*/ static void fsl_ifc_write_buf (struct mtd_info *mtd,const u8 *buf,int len) { -struct nand_chip *chip = mtd->priv; -struct fsl_ifc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);struct fsl_ifc_ctrl *ctrl = priv->ctrl;unsigned int bufsize = mtd->writesize + mtd->oobsize;@@ -635,8 +635,8 @@ static void fsl_ifc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)*/ static u8 fsl_ifc_read_byte (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; -struct fsl_ifc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);struct fsl_ifc_ctrl *ctrl = priv->ctrl;unsigned int offset;@@ -659,8 +659,8 @@ static u8 fsl_ifc_read_byte(struct mtd_info *mtd)*/ static uint8_t fsl_ifc_read_byte16 (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; -struct fsl_ifc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);struct fsl_ifc_ctrl *ctrl = priv->ctrl;uint16_t data;@@ -683,8 +683,8 @@ static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd)*/ static void fsl_ifc_read_buf (struct mtd_info *mtd,u8 *buf,int len) { -struct nand_chip *chip = mtd->priv; -struct fsl_ifc_mtd *priv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);struct fsl_ifc_ctrl *ctrl = priv->ctrl;int avail;@@ -706,7 +706,7 @@ static void fsl_ifc_read_buf(struct mtd_info *mtd, u8 *buf, int len)*/ static int fsl_ifc_wait (struct mtd_info *mtd,struct nand_chip *chip) { -struct fsl_ifc_mtd *priv = chip->priv; +struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);struct fsl_ifc_ctrl *ctrl = priv->ctrl;struct fsl_ifc_runtime *ifc = ctrl->regs.rregs;u32 nand_fsr;@@ -739,7 +739,7 @@ static int fsl_ifc_wait(struct mtd_info *mtd, struct nand_chip *chip)static int fsl_ifc_read_page (struct mtd_info *mtd,struct nand_chip *chip,uint8_t *buf,int oob_required,int page) { -struct fsl_ifc_mtd *priv = chip->priv; +struct fsl_ifc_mtd *priv =nand_get_controller_data (chip);struct fsl_ifc_ctrl *ctrl = priv->ctrl;fsl_ifc_read_buf (mtd, buf, mtd->writesize);@@ -925,8 +925,7 @@ static int fsl_ifc_chip_init(int devnum, u8 *addr) } nand = &priv->chip; - mtd = &nand->mtd; - mtd->priv = nand; + mtd =nand_to_mtd (nand); ifc_ctrl->chips[priv->bank] = priv;@@ -955,7 +954,7 @@ static int fsl_ifc_chip_init(int devnum, u8 *addr) } nand->controller = &ifc_ctrl->controller; - nand->priv = priv; +nand_set_controller_data (nand, priv); nand->ecc.read_page = fsl_ifc_read_page; nand->ecc.write_page = fsl_ifc_write_page;drivers/mtd/nand/fsl_upm.c +11
-11@@ -64,8 +64,8 @@ static void fun_wait(struct fsl_upm_nand *fun)#if CONFIG_SYS_NAND_MAX_CHIPS >1 static void fun_select_chip (struct mtd_info *mtd,int chip_nr) { -struct nand_chip *chip = mtd->priv; -struct fsl_upm_nand *fun = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_upm_nand *fun =nand_get_controller_data (chip);if (chip_nr >=0 ) { fun->chip_nr = chip_nr;@@ -79,8 +79,8 @@ static void fun_select_chip(struct mtd_info *mtd, int chip_nr)static void fun_cmd_ctrl (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *chip = mtd->priv; -struct fsl_upm_nand *fun = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_upm_nand *fun =nand_get_controller_data (chip);void __iomem *io_addr;u32 mar;@@ -123,7 +123,7 @@ static void fun_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)static u8 upm_nand_read_byte (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);return in_8 (chip->IO_ADDR_R); }@@ -131,8 +131,8 @@ static u8 upm_nand_read_byte(struct mtd_info *mtd)static void upm_nand_write_buf (struct mtd_info *mtd,const u_char *buf,int len) {int i; -struct nand_chip *chip = mtd->priv; -struct fsl_upm_nand *fun = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_upm_nand *fun =nand_get_controller_data (chip);for (i =0 ; i < len; i++) {out_8 (chip->IO_ADDR_W, buf[i]);@@ -147,7 +147,7 @@ static void upm_nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len)static void upm_nand_read_buf (struct mtd_info *mtd,u_char *buf,int len) {int i; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);for (i =0 ; i < len; i++) buf[i] =in_8 (chip->IO_ADDR_R);@@ -155,8 +155,8 @@ static void upm_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)static int nand_dev_ready (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; -struct fsl_upm_nand *fun = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct fsl_upm_nand *fun =nand_get_controller_data (chip);return fun->dev_ready (fun->chip_nr); }@@ -168,7 +168,7 @@ int fsl_upm_nand_init(struct nand_chip *chip, struct fsl_upm_nand *fun) fun->last_ctrl =NAND_CLE ; - chip->priv = fun; +nand_set_controller_data (chip, fun); chip->chip_delay = fun->chip_delay; chip->ecc.mode =NAND_ECC_SOFT ; chip->cmd_ctrl = fun_cmd_ctrl;drivers/mtd/nand/fsmc_nand.c +3
-4@@ -165,7 +165,7 @@ static int count_written_bits(uint8_t *buff, int size, int max_bits)static void fsmc_nand_hwcontrol (struct mtd_info *mtd,int cmd,uint ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);ulong IO_ADDR_W ;if (ctrl &NAND_CTRL_CHANGE ) {@@ -410,7 +410,7 @@ int fsmc_nand_switch_ecc(uint32_t eccstrength)* function, as it doesn't need to switch to a different ECC layout. */ mtd = nand_info[nand_curr_device]; - nand = mtd->priv; + nand =mtd_to_nand (mtd);/* Setup the ecc configurations again */ if (eccstrength ==1 ) {@@ -479,8 +479,7 @@ int fsmc_nand_init(struct nand_chip *nand) (void __iomem *)CONFIG_SYS_NAND_BASE ; nand->badblockbits =7 ; - mtd = &nand->mtd; - mtd->priv = nand; + mtd =nand_to_mtd (nand);switch (fsmc_version) {case FSMC_VER8 :drivers/mtd/nand/kb9202_nand.c +1
-1@@ -35,7 +35,7 @@*/ static void kb9202_nand_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);if (ctrl &NAND_CTRL_CHANGE ) {ulong IO_ADDR_W = (ulong ) this->IO_ADDR_W;drivers/mtd/nand/kirkwood_nand.c +1
-1@@ -33,7 +33,7 @@ static u32 nand_mpp_backup[9] = { 0 };static void kw_nand_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *nc = mtd->priv; +struct nand_chip *nc =mtd_to_nand (mtd);u32 offs;if (cmd ==NAND_CMD_NONE )drivers/mtd/nand/lpc32xx_nand_mlc.c +0
-2@@ -542,8 +542,6 @@ void board_nand_init(void)struct mtd_info *mtd = &lpc32xx_chip.mtd;int ret; - mtd->priv = &lpc32xx_chip; -/* Set all BOARDSPECIFIC (actually core-specific) fields */ lpc32xx_chip.IO_ADDR_R = &lpc32xx_nand_mlc_registers->buff;drivers/mtd/nand/lpc32xx_nand_slc.c +1
-1@@ -291,7 +291,7 @@ static void lpc32xx_nand_dma_configure(struct nand_chip *chip,static void lpc32xx_nand_xfer (struct mtd_info *mtd,const u8 *buf,int len,int read) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);u32 config;int ret;drivers/mtd/nand/mpc5121_nfc.c +13
-14@@ -117,8 +117,8 @@ static void mpc5121_nfc_done(struct mtd_info *mtd);/* Read NFC register */ static inline u16 nfc_read (struct mtd_info *mtd,uint reg) { -struct nand_chip *chip = mtd->priv; -struct mpc5121_nfc_prv *prv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct mpc5121_nfc_prv *prv =nand_get_controller_data (chip);return in_be16 (prv->regs + reg); }@@ -126,8 +126,8 @@ static inline u16 nfc_read(struct mtd_info *mtd, uint reg)/* Write NFC register */ static inline void nfc_write (struct mtd_info *mtd,uint reg,u16 val) { -struct nand_chip *chip = mtd->priv; -struct mpc5121_nfc_prv *prv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct mpc5121_nfc_prv *prv =nand_get_controller_data (chip);out_be16 (prv->regs + reg, val); }@@ -211,7 +211,7 @@ static void mpc5121_nfc_done(struct mtd_info *mtd)/* Do address cycle(s) */ static void mpc5121_nfc_addr_cycle (struct mtd_info *mtd,int column,int page) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);u32 pagemask = chip->pagemask;if (column !=-1 ) {@@ -283,8 +283,8 @@ static int mpc5121_nfc_dev_ready(struct mtd_info *mtd)static void mpc5121_nfc_command (struct mtd_info *mtd,unsigned command,int column,int page) { -struct nand_chip *chip = mtd->priv; -struct mpc5121_nfc_prv *prv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct mpc5121_nfc_prv *prv =nand_get_controller_data (chip); prv->column = (column >=0 ) ? column :0 ; prv->spareonly =0 ;@@ -357,8 +357,8 @@ static void mpc5121_nfc_command(struct mtd_info *mtd, unsigned command,static void mpc5121_nfc_copy_spare (struct mtd_info *mtd,uint offset,u8 * buffer,uint size,int wr) { -struct nand_chip *nand = mtd->priv; -struct mpc5121_nfc_prv *prv = nand->priv; +struct nand_chip *nand =mtd_to_nand (mtd); +struct mpc5121_nfc_prv *prv =nand_get_controller_data (nand);uint o, s, sbsize, blksize;/* @@ -410,8 +410,8 @@ static void mpc5121_nfc_copy_spare(struct mtd_info *mtd, uint offset,static void mpc5121_nfc_buf_copy (struct mtd_info *mtd,u_char * buf,int len,int wr) { -struct nand_chip *chip = mtd->priv; -struct mpc5121_nfc_prv *prv = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct mpc5121_nfc_prv *prv =nand_get_controller_data (chip);uint c = prv->column;uint l;@@ -489,7 +489,7 @@ static u16 mpc5121_nfc_read_word(struct mtd_info *mtd)static int mpc5121_nfc_read_hw_config (struct mtd_info *mtd) {immap_t *im = (immap_t *)CONFIG_SYS_IMMR ; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);uint rcw_pagesize =0 ;uint rcw_sparesize =0 ;uint rcw_width;@@ -568,8 +568,7 @@ int board_nand_init(struct nand_chip *chip) } mtd = &chip->mtd; - mtd->priv = chip; - chip->priv = prv; +nand_set_controller_data (chip, prv);/* Read NFC configuration from Reset Config Word */ retval =mpc5121_nfc_read_hw_config (mtd);drivers/mtd/nand/mxc_nand.c +25
-26@@ -351,8 +351,8 @@ static int mxc_nand_dev_ready(struct mtd_info *mtd)static void _mxc_nand_enable_hwecc (struct mtd_info *mtd,int on) { -struct nand_chip *nand_chip = mtd->priv; -struct mxc_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mxc_nand_host *host =nand_get_controller_data (nand_chip);#if defined(MXC_NFC_V1 ) || defined(MXC_NFC_V2_1 )uint16_t tmp =readnfc (&host->regs->config1);@@ -386,7 +386,7 @@ static int mxc_nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip, int page) { -struct mxc_nand_host *host = chip->priv; +struct mxc_nand_host *host =nand_get_controller_data (chip);uint8_t *buf = chip->oob_poi;int length = mtd->oobsize;int eccpitch = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;@@ -441,7 +441,7 @@ static int mxc_nand_read_page_raw_syndrome(struct mtd_info *mtd, int oob_required, int page) { -struct mxc_nand_host *host = chip->priv; +struct mxc_nand_host *host =nand_get_controller_data (chip);int eccsize = chip->ecc.size;int eccbytes = chip->ecc.bytes;int eccpitch = eccbytes + chip->ecc.prepad + chip->ecc.postpad;@@ -486,7 +486,7 @@ static int mxc_nand_read_page_syndrome(struct mtd_info *mtd, int oob_required, int page) { -struct mxc_nand_host *host = chip->priv; +struct mxc_nand_host *host =nand_get_controller_data (chip);int n, eccsize = chip->ecc.size;int eccbytes = chip->ecc.bytes;int eccpitch = eccbytes + chip->ecc.prepad + chip->ecc.postpad;@@ -550,7 +550,7 @@ static int mxc_nand_read_page_syndrome(struct mtd_info *mtd,static int mxc_nand_write_oob_syndrome (struct mtd_info *mtd,struct nand_chip *chip,int page) { -struct mxc_nand_host *host = chip->priv; +struct mxc_nand_host *host =nand_get_controller_data (chip);int eccpitch = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;int length = mtd->oobsize;int i, len, status, steps = chip->ecc.steps;@@ -578,7 +578,7 @@ static int mxc_nand_write_page_raw_syndrome(struct mtd_info *mtd, const uint8_t *buf, int oob_required) { -struct mxc_nand_host *host = chip->priv; +struct mxc_nand_host *host =nand_get_controller_data (chip);int eccsize = chip->ecc.size;int eccbytes = chip->ecc.bytes;int eccpitch = eccbytes + chip->ecc.prepad + chip->ecc.postpad;@@ -618,7 +618,7 @@ static int mxc_nand_write_page_syndrome(struct mtd_info *mtd, const uint8_t *buf, int oob_required) { -struct mxc_nand_host *host = chip->priv; +struct mxc_nand_host *host =nand_get_controller_data (chip);int i, n, eccsize = chip->ecc.size;int eccbytes = chip->ecc.bytes;int eccpitch = eccbytes + chip->ecc.prepad + chip->ecc.postpad;@@ -661,8 +661,8 @@ static int mxc_nand_write_page_syndrome(struct mtd_info *mtd,static int mxc_nand_correct_data (struct mtd_info *mtd,u_char *dat,u_char *read_ecc,u_char *calc_ecc) { -struct nand_chip *nand_chip = mtd->priv; -struct mxc_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mxc_nand_host *host =nand_get_controller_data (nand_chip);uint32_t ecc_status =readl (&host->regs->ecc_status_result);int subpages = mtd->writesize / nand_chip->subpagesize; int pg2blk_shift = nand_chip->phys_erase_shift -@@ -700,8 +700,8 @@ static int mxc_nand_correct_data(struct mtd_info *mtd, u_char *dat,static int mxc_nand_correct_data (struct mtd_info *mtd,u_char *dat,u_char *read_ecc,u_char *calc_ecc) { -struct nand_chip *nand_chip = mtd->priv; -struct mxc_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mxc_nand_host *host =nand_get_controller_data (nand_chip);/* * 1-Bit errors are automatically corrected in HW. No need for @@ -729,8 +729,8 @@ static int mxc_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,static u_char mxc_nand_read_byte (struct mtd_info *mtd) { -struct nand_chip *nand_chip = mtd->priv; -struct mxc_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mxc_nand_host *host =nand_get_controller_data (nand_chip);uint8_t ret =0 ;uint16_t col; uint16_t __iomem *main_buf =@@ -769,8 +769,8 @@ static u_char mxc_nand_read_byte(struct mtd_info *mtd)static uint16_t mxc_nand_read_word (struct mtd_info *mtd) { -struct nand_chip *nand_chip = mtd->priv; -struct mxc_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mxc_nand_host *host =nand_get_controller_data (nand_chip);uint16_t col, ret;uint16_t __iomem *p;@@ -821,8 +821,8 @@ static uint16_t mxc_nand_read_word(struct mtd_info *mtd)static void mxc_nand_write_buf (struct mtd_info *mtd,const u_char *buf,int len) { -struct nand_chip *nand_chip = mtd->priv; -struct mxc_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mxc_nand_host *host =nand_get_controller_data (nand_chip);int n, col, i =0 ; MTDDEBUG(MTD_DEBUG_LEVEL3,@@ -895,8 +895,8 @@ static void mxc_nand_write_buf(struct mtd_info *mtd,*/ static void mxc_nand_read_buf (struct mtd_info *mtd,u_char *buf,int len) { -struct nand_chip *nand_chip = mtd->priv; -struct mxc_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mxc_nand_host *host =nand_get_controller_data (nand_chip);int n, col, i =0 ; MTDDEBUG(MTD_DEBUG_LEVEL3,@@ -955,8 +955,8 @@ static void mxc_nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)*/ static void mxc_nand_select_chip (struct mtd_info *mtd,int chip) { -struct nand_chip *nand_chip = mtd->priv; -struct mxc_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mxc_nand_host *host =nand_get_controller_data (nand_chip);switch (chip) {case -1 :@@ -982,8 +982,8 @@ static void mxc_nand_select_chip(struct mtd_info *mtd, int chip)void mxc_nand_command (struct mtd_info *mtd,unsigned command,int column,int page_addr) { -struct nand_chip *nand_chip = mtd->priv; -struct mxc_nand_host *host = nand_chip->priv; +struct nand_chip *nand_chip =mtd_to_nand (mtd); +struct mxc_nand_host *host =nand_get_controller_data (nand_chip); MTDDEBUG(MTD_DEBUG_LEVEL3, "mxc_nand_command (cmd = 0x%x, col = 0x%x, page = 0x%x)\n",@@ -1165,13 +1165,12 @@ int board_nand_init(struct nand_chip *this)/* structures must be linked */ mtd = &this->mtd; - mtd->priv = this; host->nand = this;/* 5 us command delay time */ this->chip_delay =5 ; - this->priv = host; +nand_set_controller_data (this, host); this->dev_ready = mxc_nand_dev_ready; this->cmdfunc = mxc_nand_command; this->select_chip = mxc_nand_select_chip;drivers/mtd/nand/mxs_nand.c +23
-23@@ -264,8 +264,8 @@ static int mxs_nand_wait_for_bch_complete(void)*/ static void mxs_nand_cmd_ctrl (struct mtd_info *mtd,int data,unsigned int ctrl) { -struct nand_chip *nand = mtd->priv; -struct mxs_nand_info *nand_info = nand->priv; +struct nand_chip *nand =mtd_to_nand (mtd); +struct mxs_nand_info *nand_info =nand_get_controller_data (nand);struct mxs_dma_desc *d;uint32_t channel =MXS_DMA_CHANNEL_AHB_APBH_GPMI0 + nand_info->cur_chip;int ret;@@ -343,8 +343,8 @@ static void mxs_nand_cmd_ctrl(struct mtd_info *mtd, int data, unsigned int ctrl)*/ static int mxs_nand_device_ready (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; -struct mxs_nand_info *nand_info = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct mxs_nand_info *nand_info =nand_get_controller_data (chip);struct mxs_gpmi_regs *gpmi_regs = (struct mxs_gpmi_regs *)MXS_GPMI_BASE ;uint32_t tmp;@@ -360,8 +360,8 @@ static int mxs_nand_device_ready(struct mtd_info *mtd)*/ static void mxs_nand_select_chip (struct mtd_info *mtd,int chip) { -struct nand_chip *nand = mtd->priv; -struct mxs_nand_info *nand_info = nand->priv; +struct nand_chip *nand =mtd_to_nand (mtd); +struct mxs_nand_info *nand_info =nand_get_controller_data (nand); nand_info->cur_chip = chip; }@@ -410,8 +410,8 @@ static void mxs_nand_swap_block_mark(struct mtd_info *mtd,*/ static void mxs_nand_read_buf (struct mtd_info *mtd,uint8_t *buf,int length) { -struct nand_chip *nand = mtd->priv; -struct mxs_nand_info *nand_info = nand->priv; +struct nand_chip *nand =mtd_to_nand (mtd); +struct mxs_nand_info *nand_info =nand_get_controller_data (nand);struct mxs_dma_desc *d;uint32_t channel =MXS_DMA_CHANNEL_AHB_APBH_GPMI0 + nand_info->cur_chip;int ret;@@ -494,8 +494,8 @@ rtn:static void mxs_nand_write_buf (struct mtd_info *mtd,const uint8_t *buf,int length) { -struct nand_chip *nand = mtd->priv; -struct mxs_nand_info *nand_info = nand->priv; +struct nand_chip *nand =mtd_to_nand (mtd); +struct mxs_nand_info *nand_info =nand_get_controller_data (nand);struct mxs_dma_desc *d;uint32_t channel =MXS_DMA_CHANNEL_AHB_APBH_GPMI0 + nand_info->cur_chip;int ret;@@ -559,7 +559,7 @@ static int mxs_nand_ecc_read_page(struct mtd_info *mtd, struct nand_chip *nand, uint8_t *buf, int oob_required, int page) { - struct mxs_nand_info *nand_info = nand->priv; + struct mxs_nand_info *nand_info = nand_get_controller_data(nand);struct mxs_dma_desc *d;uint32_t channel =MXS_DMA_CHANNEL_AHB_APBH_GPMI0 + nand_info->cur_chip;uint32_t corrected =0 , failed =0 ;@@ -709,7 +709,7 @@ static int mxs_nand_ecc_write_page(struct mtd_info *mtd, struct nand_chip *nand, const uint8_t *buf, int oob_required) { - struct mxs_nand_info *nand_info = nand->priv; + struct mxs_nand_info *nand_info = nand_get_controller_data(nand);struct mxs_dma_desc *d;uint32_t channel =MXS_DMA_CHANNEL_AHB_APBH_GPMI0 + nand_info->cur_chip;int ret;@@ -775,8 +775,8 @@ rtn:static int mxs_nand_hook_read_oob (struct mtd_info *mtd,loff_t from,struct mtd_oob_ops *ops) { -struct nand_chip *chip = mtd->priv; -struct mxs_nand_info *nand_info = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct mxs_nand_info *nand_info =nand_get_controller_data (chip);int ret;if (ops->mode ==MTD_OPS_RAW )@@ -800,8 +800,8 @@ static int mxs_nand_hook_read_oob(struct mtd_info *mtd, loff_t from,static int mxs_nand_hook_write_oob (struct mtd_info *mtd,loff_t to,struct mtd_oob_ops *ops) { -struct nand_chip *chip = mtd->priv; -struct mxs_nand_info *nand_info = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct mxs_nand_info *nand_info =nand_get_controller_data (chip);int ret;if (ops->mode ==MTD_OPS_RAW )@@ -824,8 +824,8 @@ static int mxs_nand_hook_write_oob(struct mtd_info *mtd, loff_t to,*/ static int mxs_nand_hook_block_markbad (struct mtd_info *mtd,loff_t ofs) { -struct nand_chip *chip = mtd->priv; -struct mxs_nand_info *nand_info = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct mxs_nand_info *nand_info =nand_get_controller_data (chip);int ret; nand_info->marking_block_bad =1 ;@@ -884,7 +884,7 @@ static int mxs_nand_hook_block_markbad(struct mtd_info *mtd, loff_t ofs)static int mxs_nand_ecc_read_oob (struct mtd_info *mtd,struct nand_chip *nand,int page) { -struct mxs_nand_info *nand_info = nand->priv; +struct mxs_nand_info *nand_info =nand_get_controller_data (nand);/* * First, fill in the OOB buffer. If we're doing a raw read, we need to @@ -919,7 +919,7 @@ static int mxs_nand_ecc_read_oob(struct mtd_info *mtd, struct nand_chip *nand,static int mxs_nand_ecc_write_oob (struct mtd_info *mtd,struct nand_chip *nand,int page) { -struct mxs_nand_info *nand_info = nand->priv; +struct mxs_nand_info *nand_info =nand_get_controller_data (nand);uint8_t block_mark =0 ;/* @@ -982,8 +982,8 @@ static int mxs_nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)*/ static int mxs_nand_scan_bbt (struct mtd_info *mtd) { -struct nand_chip *nand = mtd->priv; -struct mxs_nand_info *nand_info = nand->priv; +struct nand_chip *nand =mtd_to_nand (mtd); +struct mxs_nand_info *nand_info =nand_get_controller_data (nand);struct mxs_bch_regs *bch_regs = (struct mxs_bch_regs *)MXS_BCH_BASE ;uint32_t tmp;@@ -1175,7 +1175,7 @@ int board_nand_init(struct nand_chip *nand)memset (&fake_ecc_layout,0 ,sizeof (fake_ecc_layout)); - nand->priv = nand_info; +nand_set_controller_data (nand, nand_info); nand->options |=NAND_NO_SUBPAGE_WRITE ; nand->cmd_ctrl = mxs_nand_cmd_ctrl;drivers/mtd/nand/mxs_nand_spl.c +5
-6@@ -14,7 +14,7 @@ static struct nand_chip nand_chip;static void mxs_nand_command (struct mtd_info *mtd,unsigned int command,int column,int page_addr) { - registerstruct nand_chip *chip = mtd->priv; + registerstruct nand_chip *chip =mtd_to_nand (mtd);u32 timeo, time_start;/* write out the command to the device */ @@ -51,7 +51,7 @@ static void mxs_nand_command(struct mtd_info *mtd, unsigned int command,static int mxs_flash_ident (struct mtd_info *mtd) { - registerstruct nand_chip *chip = mtd->priv; + registerstruct nand_chip *chip =mtd_to_nand (mtd);int i;u8 mfg_id, dev_id;u8 id_data[8 ];@@ -111,7 +111,7 @@ static int mxs_flash_ident(struct mtd_info *mtd)static int mxs_read_page_ecc (struct mtd_info *mtd,void *buf,unsigned int page) { - registerstruct nand_chip *chip = mtd->priv; + registerstruct nand_chip *chip =mtd_to_nand (mtd);int ret; chip->cmdfunc (mtd,NAND_CMD_READ0 ,0x0 , page);@@ -125,7 +125,7 @@ static int mxs_read_page_ecc(struct mtd_info *mtd, void *buf, unsigned int page)static int is_badblock (struct mtd_info *mtd,loff_t offs,int allowbbt) { - registerstruct nand_chip *chip = mtd->priv; + registerstruct nand_chip *chip =mtd_to_nand (mtd);unsigned int block = offs >> chip->phys_erase_shift;unsigned int page = offs >> chip->page_shift;@@ -148,7 +148,6 @@ static int mxs_nand_init(void)/* init mxs nand driver */ board_nand_init (&nand_chip); mtd = &nand_chip.mtd; - mtd->priv = &nand_chip;/* set mtd functions */ nand_chip.cmdfunc = mxs_nand_command; nand_chip.numchips =1 ;@@ -181,7 +180,7 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *buf)if (mxs_nand_init ())return -ENODEV ; - chip = mtd->priv; + chip =mtd_to_nand (mtd); page = offs >> chip->page_shift; nand_page_per_block = mtd->erasesize / mtd->writesize;drivers/mtd/nand/nand.c +2
-3@@ -73,14 +73,13 @@ int nand_register(int devnum, struct mtd_info *mtd)static void nand_init_chip (int i) {struct nand_chip *nand = &nand_chip[i]; -struct mtd_info *mtd = &nand->mtd; +struct mtd_info *mtd =nand_to_mtd (nand);ulong base_addr = base_address[i];int maxchips =CONFIG_SYS_NAND_MAX_CHIPS ;if (maxchips <1 ) maxchips =1 ; - mtd->priv = nand; nand->IO_ADDR_R = nand->IO_ADDR_W = (void __iomem *)base_addr;if (board_nand_init (nand))@@ -110,7 +109,7 @@ void nand_init(void)/* * Select the chip in the board/cpu specific driver */ -board_nand_select_device (nand_info[nand_curr_device]->priv, +board_nand_select_device (mtd_to_nand (nand_info[nand_curr_device]), nand_curr_device);#endif }drivers/mtd/nand/nand_base.c +36
-36@@ -105,7 +105,7 @@ DEFINE_LED_TRIGGER(nand_led_trigger);static int check_offs_len (struct mtd_info *mtd,loff_t ofs,uint64_t len) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);int ret =0 ;/* Start address must align on block boundary */ @@ -131,7 +131,7 @@ static int check_offs_len(struct mtd_info *mtd,*/ static void nand_release_device (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);/* De-select the NAND device */ chip->select_chip (mtd,-1 );@@ -145,7 +145,7 @@ static void nand_release_device(struct mtd_info *mtd)*/ uint8_t nand_read_byte (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);return readb (chip->IO_ADDR_R); }@@ -158,7 +158,7 @@ uint8_t nand_read_byte(struct mtd_info *mtd)*/ static uint8_t nand_read_byte16 (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);return (uint8_t )cpu_to_le16 (readw (chip->IO_ADDR_R)); }@@ -170,7 +170,7 @@ static uint8_t nand_read_byte16(struct mtd_info *mtd)*/ static u16 nand_read_word (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);return readw (chip->IO_ADDR_R); }@@ -183,7 +183,7 @@ static u16 nand_read_word(struct mtd_info *mtd)*/ static void nand_select_chip (struct mtd_info *mtd,int chipnr) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);switch (chipnr) {case -1 :@@ -206,7 +206,7 @@ static void nand_select_chip(struct mtd_info *mtd, int chipnr)*/ static void nand_write_byte (struct mtd_info *mtd,uint8_t byte) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); chip->write_buf (mtd, &byte,1 ); }@@ -220,7 +220,7 @@ static void nand_write_byte(struct mtd_info *mtd, uint8_t byte)*/ static void nand_write_byte16 (struct mtd_info *mtd,uint8_t byte) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);uint16_t word = byte;/* @@ -287,7 +287,7 @@ static void iowrite16_rep(void *addr, void *buf, int len)*/ void nand_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);iowrite8_rep (chip->IO_ADDR_W, buf, len); }@@ -302,7 +302,7 @@ void nand_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len)*/ void nand_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);ioread8_rep (chip->IO_ADDR_R, buf, len); }@@ -317,7 +317,7 @@ void nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)*/ void nand_write_buf16 (struct mtd_info *mtd,const uint8_t *buf,int len) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);u16 *p = (u16 *) buf;iowrite16_rep (chip->IO_ADDR_W, p, len >>1 );@@ -333,7 +333,7 @@ void nand_write_buf16(struct mtd_info *mtd, const uint8_t *buf, int len)*/ void nand_read_buf16 (struct mtd_info *mtd,uint8_t *buf,int len) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);u16 *p = (u16 *) buf;ioread16_rep (chip->IO_ADDR_R, p, len >>1 );@@ -350,7 +350,7 @@ void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len)static int nand_block_bad (struct mtd_info *mtd,loff_t ofs,int getchip) {int page, chipnr, res =0 , i =0 ; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);u16 bad;if (chip->bbt_options &NAND_BBT_SCANLASTPAGE )@@ -410,7 +410,7 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)*/ static int nand_default_block_markbad (struct mtd_info *mtd,loff_t ofs) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);struct mtd_oob_ops ops;uint8_t buf[2 ] = {0 ,0 };int ret =0 , res, i =0 ;@@ -460,7 +460,7 @@ static int nand_default_block_markbad(struct mtd_info *mtd, loff_t ofs)*/ static int nand_block_markbad_lowlevel (struct mtd_info *mtd,loff_t ofs) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);int res, ret =0 ;if (!(chip->bbt_options &NAND_BBT_NO_OOB_BBM )) {@@ -501,7 +501,7 @@ static int nand_block_markbad_lowlevel(struct mtd_info *mtd, loff_t ofs)*/ static int nand_check_wp (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);/* Broken xD cards report WP despite being writable */ if (chip->options &NAND_BROKEN_XD )@@ -521,7 +521,7 @@ static int nand_check_wp(struct mtd_info *mtd)*/ static int nand_block_isreserved (struct mtd_info *mtd,loff_t ofs) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);if (!chip->bbt)return 0 ;@@ -542,7 +542,7 @@ static int nand_block_isreserved(struct mtd_info *mtd, loff_t ofs)static int nand_block_checkbad (struct mtd_info *mtd,loff_t ofs,int getchip,int allowbbt) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);if (!(chip->options &NAND_SKIP_BBTSCAN ) && !(chip->options &NAND_BBT_SCANNED )) {@@ -560,7 +560,7 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip,/* Wait for the ready pin, after a command. The timeout is caught later. */ void nand_wait_ready (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);u32 timeo = (CONFIG_SYS_HZ *20 ) /1000 ;u32 time_start;@@ -583,7 +583,7 @@ EXPORT_SYMBOL_GPL(nand_wait_ready);*/ static void nand_wait_status_ready (struct mtd_info *mtd,unsigned long timeo) { - registerstruct nand_chip *chip = mtd->priv; + registerstruct nand_chip *chip =mtd_to_nand (mtd);u32 time_start; timeo = (CONFIG_SYS_HZ * timeo) /1000 ;@@ -608,7 +608,7 @@ static void nand_wait_status_ready(struct mtd_info *mtd, unsigned long timeo)static void nand_command (struct mtd_info *mtd,unsigned int command,int column,int page_addr) { - registerstruct nand_chip *chip = mtd->priv; + registerstruct nand_chip *chip =mtd_to_nand (mtd);int ctrl =NAND_CTRL_CLE |NAND_CTRL_CHANGE ;/* Write out the command to the device */ @@ -711,7 +711,7 @@ static void nand_command(struct mtd_info *mtd, unsigned int command,static void nand_command_lp (struct mtd_info *mtd,unsigned int command,int column,int page_addr) { - registerstruct nand_chip *chip = mtd->priv; + registerstruct nand_chip *chip =mtd_to_nand (mtd);/* Emulate NAND_CMD_READOOB */ if (command ==NAND_CMD_READOOB ) {@@ -835,7 +835,7 @@ static void panic_nand_get_device(struct nand_chip *chip,static int nand_get_device (struct mtd_info *mtd,int new_state) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); chip->state = new_state;return 0 ; }@@ -1332,7 +1332,7 @@ static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,*/ static int nand_setup_read_retry (struct mtd_info *mtd,int retry_mode) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);pr_debug ("setting READ RETRY mode %d\n" , retry_mode);@@ -1357,7 +1357,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) {int chipnr, page, realpage, col, bytes, aligned, oob_required; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);int ret =0 ;uint32_t readlen = ops->len;uint32_t oobreadlen = ops->ooblen;@@ -1700,7 +1700,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) {int page, realpage, chipnr; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);struct mtd_ecc_stats stats;int readlen = ops->ooblen;int len;@@ -2139,7 +2139,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,static uint8_t *nand_fill_oob (struct mtd_info *mtd,uint8_t *oob,size_t len,struct mtd_oob_ops *ops) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);/* * Initialise to all 0xFF, to avoid the possibility of left over OOB @@ -2199,7 +2199,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) {int chipnr, realpage, page, blockmask, column; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);uint32_t writelen = ops->len;uint32_t oobwritelen = ops->ooblen;@@ -2328,7 +2328,7 @@ err_out:static int panic_nand_write (struct mtd_info *mtd,loff_t to,size_t len,size_t *retlen,const uint8_t *buf) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);struct mtd_oob_ops ops;int ret;@@ -2388,7 +2388,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) {int chipnr, page, status, len; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);pr_debug ("%s: to = 0x%08x, len = %i\n" , __func__, (unsigned int )to, (int )ops->ooblen);@@ -2513,7 +2513,7 @@ out:*/ static int single_erase (struct mtd_info *mtd,int page) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);/* Send commands to erase a block */ chip->cmdfunc (mtd,NAND_CMD_ERASE1 ,-1 , page); chip->cmdfunc (mtd,NAND_CMD_ERASE2 ,-1 ,-1 );@@ -2545,7 +2545,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr, int allowbbt) {int page, status, pages_per_block, ret, chipnr; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);loff_t len; pr_debug("%s: start = 0x%012llx, len = %llu\n",@@ -2908,7 +2908,7 @@ ext_out:static int nand_setup_read_retry_micron (struct mtd_info *mtd,int retry_mode) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);uint8_t feature[ONFI_SUBFEATURE_PARAM_LEN ] = {retry_mode}; return chip->onfi_set_features(mtd, chip, ONFI_FEATURE_ADDR_READ_RETRY,@@ -3616,7 +3616,7 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, struct nand_flash_dev *table) {int i, nand_maf_id, nand_dev_id; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);struct nand_flash_dev *type;/* Set the default functions */ @@ -3680,7 +3680,7 @@ EXPORT_SYMBOL(nand_scan_ident);*/ static bool nand_ecc_strength_good (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);struct nand_ecc_ctrl *ecc = &chip->ecc;int corr, ds_corr;@@ -3709,7 +3709,7 @@ static bool nand_ecc_strength_good(struct mtd_info *mtd)int nand_scan_tail (struct mtd_info *mtd) {int i; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);struct nand_ecc_ctrl *ecc = &chip->ecc;struct nand_buffers *nbuf;drivers/mtd/nand/nand_bbt.c +16
-16@@ -173,7 +173,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num, struct nand_bbt_descr *td, int offs) { int res, ret = 0, i, j, act = 0; -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);size_t retlen, len, totlen;loff_t from;int bits = td->options &NAND_BBT_NRBITS_MSK ;@@ -264,7 +264,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,*/ static int read_abs_bbt (struct mtd_info *mtd,uint8_t *buf,struct nand_bbt_descr *td,int chip) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int res =0 , i;if (td->options &NAND_BBT_PERCHIP ) {@@ -389,7 +389,7 @@ static u32 bbt_get_ver_offs(struct mtd_info *mtd, struct nand_bbt_descr *td)static void read_abs_bbts (struct mtd_info *mtd,uint8_t *buf,struct nand_bbt_descr *td,struct nand_bbt_descr *md) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);/* Read the primary version, if available */ if (td->options &NAND_BBT_VERSION ) {@@ -455,7 +455,7 @@ static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd,static int create_bbt (struct mtd_info *mtd,uint8_t *buf,struct nand_bbt_descr *bd,int chip) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int i, numblocks, numpages;int startblock;loff_t from;@@ -524,7 +524,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,*/ static int search_bbt (struct mtd_info *mtd,uint8_t *buf,struct nand_bbt_descr *td) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int i, chips;int startblock, block, dir;int scanlen = mtd->writesize + mtd->oobsize;@@ -619,7 +619,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *td, struct nand_bbt_descr *md, int chipsel) { - struct nand_chip *this = mtd->priv; + struct nand_chip *this = mtd_to_nand(mtd);struct erase_info einfo;int i, res, chip =0 ;int bits, startblock, dir, page, offs, numblocks, sft, sftmsk;@@ -820,7 +820,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,*/ static inline int nand_memory_bbt (struct mtd_info *mtd,struct nand_bbt_descr *bd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);return create_bbt (mtd, this->buffers->databuf, bd,-1 ); }@@ -839,7 +839,7 @@ static inline int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bstatic int check_create (struct mtd_info *mtd,uint8_t *buf,struct nand_bbt_descr *bd) {int i, chips, writeops, create, chipsel, res, res2; -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);struct nand_bbt_descr *td = this->bbt_td;struct nand_bbt_descr *md = this->bbt_md;struct nand_bbt_descr *rd, *rd2;@@ -963,7 +963,7 @@ static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc*/ static void mark_bbt_region (struct mtd_info *mtd,struct nand_bbt_descr *td) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int i, j, chips, block, nrblocks, update;uint8_t oldval;@@ -1023,7 +1023,7 @@ static void mark_bbt_region(struct mtd_info *mtd, struct nand_bbt_descr *td)*/ static void verify_bbt_descr (struct mtd_info *mtd,struct nand_bbt_descr *bd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u32 pattern_len;u32 bits;u32 table_size;@@ -1075,7 +1075,7 @@ static void verify_bbt_descr(struct mtd_info *mtd, struct nand_bbt_descr *bd)*/ int nand_scan_bbt (struct mtd_info *mtd,struct nand_bbt_descr *bd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int len, res =0 ;uint8_t *buf;struct nand_bbt_descr *td = this->bbt_td;@@ -1143,7 +1143,7 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)*/ static int nand_update_bbt (struct mtd_info *mtd,loff_t offs) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int len, res =0 ;int chip, chipsel;uint8_t *buf;@@ -1277,7 +1277,7 @@ static int nand_create_badblock_pattern(struct nand_chip *this)*/ int nand_default_bbt (struct mtd_info *mtd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int ret;/* Is a flash based bad block table requested? */ @@ -1313,7 +1313,7 @@ int nand_default_bbt(struct mtd_info *mtd)*/ int nand_isreserved_bbt (struct mtd_info *mtd,loff_t offs) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int block; block = (int )(offs >> this->bbt_erase_shift);@@ -1328,7 +1328,7 @@ int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs)*/ int nand_isbad_bbt (struct mtd_info *mtd,loff_t offs,int allowbbt) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int block, res; block = (int )(offs >> this->bbt_erase_shift);@@ -1355,7 +1355,7 @@ int nand_isbad_bbt(struct mtd_info *mtd, loff_t offs, int allowbbt)*/ int nand_markbad_bbt (struct mtd_info *mtd,loff_t offs) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int block, ret =0 ; block = (int )(offs >> this->bbt_erase_shift);drivers/mtd/nand/nand_bch.c +2
-2@@ -41,7 +41,7 @@ struct nand_bch_control {int nand_bch_calculate_ecc (struct mtd_info *mtd,const unsigned char *buf,unsigned char *code) { -const struct nand_chip *chip = mtd->priv; +const struct nand_chip *chip =mtd_to_nand (mtd);struct nand_bch_control *nbc = chip->ecc.priv;unsigned int i;@@ -67,7 +67,7 @@ int nand_bch_calculate_ecc(struct mtd_info *mtd, const unsigned char *buf,int nand_bch_correct_data (struct mtd_info *mtd,unsigned char *buf,unsigned char *read_ecc,unsigned char *calc_ecc) { -const struct nand_chip *chip = mtd->priv; +const struct nand_chip *chip =mtd_to_nand (mtd);struct nand_bch_control *nbc = chip->ecc.priv;unsigned int *errloc = nbc->errloc;int i, count;drivers/mtd/nand/nand_plat.c +2
-2@@ -25,7 +25,7 @@static void plat_cmd_ctrl (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);if (cmd ==NAND_CMD_NONE )return ;@@ -39,7 +39,7 @@ static void plat_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)#ifdef NAND_PLAT_DEV_READY static int plat_dev_ready (struct mtd_info *mtd) { -return NAND_PLAT_DEV_READY ((struct nand_chip *)mtd->priv); +return NAND_PLAT_DEV_READY ((struct nand_chip *)mtd_to_nand (mtd)); }#else # define plat_dev_ready NULLdrivers/mtd/nand/nand_spl_simple.c +5
-6@@ -26,7 +26,7 @@ static struct nand_chip nand_chip;static int nand_command (int block,int page,uint32_t offs,u8 cmd) { -struct nand_chip *this = mtd->priv (); +struct nand_chip *this =mtd_to_nand (mtd);int page_addr = page + block *CONFIG_SYS_NAND_PAGE_COUNT ;while (!this->dev_ready (mtd))@@ -63,7 +63,7 @@ static int nand_command(int block, int page, uint32_t offs,static int nand_command (int block,int page,uint32_t offs,u8 cmd) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);int page_addr = page + block *CONFIG_SYS_NAND_PAGE_COUNT ;void (*hwctrl)(struct mtd_info *mtd,int cmd,unsigned int ctrl) = this->cmd_ctrl;@@ -114,7 +114,7 @@ static int nand_command(int block, int page, uint32_t offs,static int nand_is_bad_block (int block) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u_char bb_data[2 ]; nand_command(block, 0, CONFIG_SYS_NAND_BAD_BLOCK_POS,@@ -139,7 +139,7 @@ static int nand_is_bad_block(int block)#if defined(CONFIG_SYS_NAND_HW_ECC_OOBFIRST )static int nand_read_page (int block,int page,uchar *dst) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u_char ecc_calc[ECCTOTAL ];u_char ecc_code[ECCTOTAL ];u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];@@ -170,7 +170,7 @@ static int nand_read_page(int block, int page, uchar *dst)#else static int nand_read_page (int block,int page,void *dst) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);u_char ecc_calc[ECCTOTAL ];u_char ecc_code[ECCTOTAL ];u_char oob_data[CONFIG_SYS_NAND_OOBSIZE ];@@ -250,7 +250,6 @@ void nand_init(void)* Init board specific nand support */ mtd = &nand_chip.mtd; - mtd->priv = &nand_chip; nand_chip.IO_ADDR_R = nand_chip.IO_ADDR_W = (void __iomem *)CONFIG_SYS_NAND_BASE ;board_nand_init (&nand_chip);drivers/mtd/nand/nand_util.c +4
-4@@ -59,7 +59,7 @@ int nand_erase_opts(struct mtd_info *mtd,int percent_complete =-1 ;const char *mtd_device = mtd->name;struct mtd_oob_ops oob_opts; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);if ((opts->offset & (mtd->erasesize -1 )) !=0 ) {printf ("Attempt to erase non block-aligned data\n" );@@ -217,7 +217,7 @@ int nand_lock(struct mtd_info *mtd, int tight) {int ret =0 ;int status; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);/* select the NAND device */ chip->select_chip (mtd,0 );@@ -267,7 +267,7 @@ int nand_get_lock_status(struct mtd_info *mtd, loff_t offset)int ret =0 ;int chipnr;int page; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);/* select the NAND device */ chipnr = (int )(offset >> chip->chip_shift);@@ -314,7 +314,7 @@ int nand_unlock(struct mtd_info *mtd, loff_t start, size_t length,int chipnr;int status;int page; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);debug ("nand_unlock%s: start: %08llx, length: %zd!\n" , allexcept ?" (allexcept)" :"" , start, length);drivers/mtd/nand/ndfc.c +7
-7@@ -37,7 +37,7 @@ static int ndfc_cs[NDFC_MAX_BANKS];static void ndfc_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);ulong base = (ulong ) this->IO_ADDR_W &0xffffff00 ;if (cmd ==NAND_CMD_NONE )@@ -51,7 +51,7 @@ static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)static int ndfc_dev_ready (struct mtd_info *mtdinfo) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);ulong base = (ulong ) this->IO_ADDR_W &0xffffff00 ;return (in_be32 ((u32 *)(base +NDFC_STAT )) &NDFC_STAT_IS_READY );@@ -59,7 +59,7 @@ static int ndfc_dev_ready(struct mtd_info *mtdinfo)static void ndfc_enable_hwecc (struct mtd_info *mtdinfo,int mode) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);ulong base = (ulong ) this->IO_ADDR_W &0xffffff00 ;u32 ccr;@@ -71,7 +71,7 @@ static void ndfc_enable_hwecc(struct mtd_info *mtdinfo, int mode)static int ndfc_calculate_ecc (struct mtd_info *mtdinfo,const u_char *dat,u_char *ecc_code) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);ulong base = (ulong ) this->IO_ADDR_W &0xffffff00 ;u32 ecc;u8 *p = (u8 *)&ecc;@@ -96,7 +96,7 @@ static int ndfc_calculate_ecc(struct mtd_info *mtdinfo,*/ static void ndfc_read_buf (struct mtd_info *mtdinfo,uint8_t *buf,int len) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);ulong base = (ulong ) this->IO_ADDR_W &0xffffff00 ;uint32_t *p = (uint32_t *) buf;@@ -110,7 +110,7 @@ static void ndfc_read_buf(struct mtd_info *mtdinfo, uint8_t *buf, int len)*/ static void ndfc_write_buf (struct mtd_info *mtdinfo,const uint8_t *buf,int len) { -struct nand_chip *this = mtdinfo->priv; +struct nand_chip *this =mtd_to_nand (mtdinfo);ulong base = (ulong ) this->IO_ADDR_W &0xffffff00 ;uint32_t *p = (uint32_t *) buf;@@ -124,7 +124,7 @@ static void ndfc_write_buf(struct mtd_info *mtdinfo, const uint8_t *buf, int lenstatic uint8_t ndfc_read_byte (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);#ifdef CONFIG_SYS_NAND_BUSWIDTH_16BIT return (uint8_t )readw (chip->IO_ADDR_R);drivers/mtd/nand/omap_gpmc.c +20
-20@@ -58,8 +58,8 @@ static struct omap_nand_info omap_nand_info[GPMC_MAX_CS];static void omap_nand_hwcontrol (struct mtd_info *mtd,int32_t cmd,uint32_t ctrl) { - registerstruct nand_chip *this = mtd->priv; -struct omap_nand_info *info = this->priv; + registerstruct nand_chip *this =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (this);int cs = info->cs;/* @@ -85,8 +85,8 @@ static void omap_nand_hwcontrol(struct mtd_info *mtd, int32_t cmd,/* Check wait pin as dev ready indicator */ static int omap_dev_ready (struct mtd_info *mtd) { - registerstruct nand_chip *this = mtd->priv; -struct omap_nand_info *info = this->priv; + registerstruct nand_chip *this =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (this);return gpmc_cfg->status & (1 << (8 + info->ws)); }@@ -177,8 +177,8 @@ static int __maybe_unused omap_correct_data(struct mtd_info *mtd, uint8_t *dat,__maybe_unused static void omap_enable_hwecc (struct mtd_info *mtd,int32_t mode) { -struct nand_chip *nand = mtd->priv; -struct omap_nand_info *info = nand->priv; +struct nand_chip *nand =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (nand);unsigned int dev_width = (nand->options &NAND_BUSWIDTH_16 ) ?1 :0 ;unsigned int ecc_algo =0 ;unsigned int bch_type =0 ;@@ -262,8 +262,8 @@ static void omap_enable_hwecc(struct mtd_info *mtd, int32_t mode)static int omap_calculate_ecc (struct mtd_info *mtd,const uint8_t *dat,uint8_t *ecc_code) { -struct nand_chip *chip = mtd->priv; -struct omap_nand_info *info = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (chip);uint32_t *ptr, val =0 ;int8_t i =0 , j;@@ -392,7 +392,7 @@ static int __read_prefetch_aligned(struct nand_chip *chip, uint32_t *buf, int le {int ret;uint32_t cnt; -struct omap_nand_info *info = chip->priv; +struct omap_nand_info *info =nand_get_controller_data (chip); ret =omap_prefetch_enable (PREFETCH_FIFOTHRESHOLD_MAX , len,0 , info->cs);if (ret <0 )@@ -417,7 +417,7 @@ static int __read_prefetch_aligned(struct nand_chip *chip, uint32_t *buf, int lestatic inline void omap_nand_read (struct mtd_info *mtd,uint8_t *buf,int len) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);if (chip->options &NAND_BUSWIDTH_16 )nand_read_buf16 (mtd, buf, len);@@ -429,7 +429,7 @@ static void omap_nand_read_prefetch(struct mtd_info *mtd, uint8_t *buf, int len) {int ret;uint32_t head, tail; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);/* * If the destination buffer is unaligned, start with reading @@ -491,8 +491,8 @@ static void omap_reverse_list(u8 *list, unsigned int length)static int omap_correct_data_bch (struct mtd_info *mtd,uint8_t *dat,uint8_t *read_ecc,uint8_t *calc_ecc) { -struct nand_chip *chip = mtd->priv; -struct omap_nand_info *info = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (chip);struct nand_ecc_ctrl *ecc = &chip->ecc;uint32_t error_count =0 , error_max;uint32_t error_loc[ELM_MAX_ERROR_COUNT ];@@ -652,8 +652,8 @@ static int omap_correct_data_bch_sw(struct mtd_info *mtd, u_char *data,int i, count;/* cannot correct more than 8 errors */ unsigned int errloc[8 ]; -struct nand_chip *chip = mtd->priv; -struct omap_nand_info *info = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (chip); count =decode_bch (info->control,NULL ,512 , read_ecc, calc_ecc,NULL , errloc);@@ -691,8 +691,8 @@ static int omap_correct_data_bch_sw(struct mtd_info *mtd, u_char *data,*/ static void __maybe_unused omap_free_bch (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; -struct omap_nand_info *info = chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct omap_nand_info *info =nand_get_controller_data (chip);if (info->control) {free_bch (info->control);@@ -710,7 +710,7 @@ static void __maybe_unused omap_free_bch(struct mtd_info *mtd)*/ static int omap_select_ecc_scheme (struct nand_chip *nand,enum omap_ecc ecc_scheme,unsigned int pagesize,unsigned int oobsize) { -struct omap_nand_info *info = nand->priv; +struct omap_nand_info *info =nand_get_controller_data (nand);struct nand_ecclayout *ecclayout = &omap_ecclayout;int eccsteps = pagesize /SECTOR_BYTES ;int i;@@ -904,7 +904,7 @@ int __maybe_unused omap_nand_switch_ecc(uint32_t hardware, uint32_t eccstrength) } mtd = nand_info[nand_curr_device]; - nand = mtd->priv; + nand =mtd_to_nand (mtd); nand->options |=NAND_OWN_BUFFERS ; nand->options &= ~NAND_SUBPAGE_READ ;/* Setup the ecc configurations again */ @@ -994,7 +994,7 @@ int board_nand_init(struct nand_chip *nand) omap_nand_info[cs].control =NULL ; omap_nand_info[cs].cs = cs; omap_nand_info[cs].ws = wscfg[cs]; - nand->priv = &omap_nand_info[cs]; +nand_set_controller_data (nand, &omap_nand_info[cs]); nand->cmd_ctrl = omap_nand_hwcontrol; nand->options |=NAND_NO_PADDING |NAND_CACHEPRG ; nand->chip_delay =100 ;drivers/mtd/nand/pxa3xx_nand.c +20
-14@@ -900,7 +900,8 @@ static int prepare_set_command(struct pxa3xx_nand_info *info, int command,static void nand_cmdfunc (struct mtd_info *mtd,unsigned command,int column,int page_addr) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;int exec_cmd;@@ -960,7 +961,8 @@ static void nand_cmdfunc_extended(struct mtd_info *mtd,const unsigned command, int column, int page_addr) { - struct pxa3xx_nand_host *host = mtd->priv; + struct nand_chip *chip = mtd_to_nand(mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;int exec_cmd, ext_cmd_type;@@ -1091,7 +1093,7 @@ static int pxa3xx_nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { - struct pxa3xx_nand_host *host = mtd->priv; + struct pxa3xx_nand_host *host = nand_get_controller_data(chip);struct pxa3xx_nand_info *info = host->info_data; chip->read_buf (mtd, buf, mtd->writesize);@@ -1117,7 +1119,8 @@ static int pxa3xx_nand_read_page_hwecc(struct mtd_info *mtd,static uint8_t pxa3xx_nand_read_byte (struct mtd_info *mtd) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;char retval =0xFF ;@@ -1130,7 +1133,8 @@ static uint8_t pxa3xx_nand_read_byte(struct mtd_info *mtd)static u16 pxa3xx_nand_read_word (struct mtd_info *mtd) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;u16 retval =0xFFFF ;@@ -1143,7 +1147,8 @@ static u16 pxa3xx_nand_read_word(struct mtd_info *mtd)static void pxa3xx_nand_read_buf (struct mtd_info *mtd,uint8_t *buf,int len) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;int real_len =min_t (size_t, len, info->buf_count - info->buf_start);@@ -1154,7 +1159,8 @@ static void pxa3xx_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)static void pxa3xx_nand_write_buf (struct mtd_info *mtd,const uint8_t *buf,int len) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;int real_len =min_t (size_t, len, info->buf_count - info->buf_start);@@ -1169,7 +1175,8 @@ static void pxa3xx_nand_select_chip(struct mtd_info *mtd, int chip)static int pxa3xx_nand_waitfunc (struct mtd_info *mtd,struct nand_chip *this) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;if (info->need_wait) {@@ -1210,7 +1217,7 @@ static int pxa3xx_nand_config_flash(struct pxa3xx_nand_info *info) {struct pxa3xx_nand_host *host = info->host[info->cs];struct mtd_info *mtd = host->mtd; -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); info->reg_ndcr |= (host->col_addr_cycles ==2 ) ?NDCR_RA_START :0 ; info->reg_ndcr |= (chip->page_shift ==6 ) ?NDCR_PG_PER_BLK :0 ;@@ -1262,7 +1269,7 @@ static int pxa3xx_nand_sensing(struct pxa3xx_nand_host *host)int ret; mtd = info->host[info->cs]->mtd; - chip = mtd->priv; + chip =mtd_to_nand (mtd);/* configure default flash values */ info->reg_ndcr =0x0 ;/* enable all interrupts */ @@ -1354,10 +1361,10 @@ static int pxa_ecc_init(struct pxa3xx_nand_info *info,static int pxa3xx_nand_scan (struct mtd_info *mtd) { -struct pxa3xx_nand_host *host = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct pxa3xx_nand_host *host =nand_get_controller_data (chip);struct pxa3xx_nand_info *info = host->info_data;struct pxa3xx_nand_platform_data *pdata = info->pdata; -struct nand_chip *chip = mtd->priv;int ret;uint16_t ecc_strength, ecc_step;@@ -1479,14 +1486,13 @@ static int alloc_nand_resource(struct pxa3xx_nand_info *info)for (cs =0 ; cs < pdata->num_cs; cs++) { chip = (struct nand_chip *) ((u8 *)&info[1 ] +sizeof (*host) * cs); - mtd = &chip->mtd; + mtd =nand_to_mtd (chip); host = (struct pxa3xx_nand_host *)chip; info->host[cs] = host; host->mtd = mtd; host->cs = cs; host->info_data = info; host->read_id_bytes =4 ; - mtd->priv = host; mtd->owner =THIS_MODULE ; chip->ecc.read_page = pxa3xx_nand_read_page_hwecc;drivers/mtd/nand/s3c2410_nand.c +2
-2@@ -31,7 +31,7 @@static void nand_read_buf (struct mtd_info *mtd,u_char *buf,int len) {int i; -struct nand_chip *this = mtd->priv; +struct nand_chip *this =mtd_to_nand (mtd);for (i =0 ; i < len; i++) buf[i] =readb (this->IO_ADDR_R);@@ -40,7 +40,7 @@ static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)static void s3c24x0_hwcontrol (struct mtd_info *mtd,int cmd,unsigned int ctrl) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);struct s3c24x0_nand *nand =s3c24x0_get_base_nand ();debug ("hwcontrol(): 0x%02x 0x%02x\n" , cmd, ctrl);drivers/mtd/nand/tegra_nand.c +14
-15@@ -143,10 +143,10 @@ static int nand_waitfor_cmd_completion(struct nand_ctlr *reg)*/ static uint8_t read_byte (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);struct nand_drv *info; - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip);writel (CMD_GO |CMD_PIO |CMD_RX |CMD_CE0 |CMD_A_VALID , &info->reg->command);@@ -169,8 +169,8 @@ static void read_buf(struct mtd_info *mtd, uint8_t *buf, int len) {int i, s;unsigned int reg; -struct nand_chip *chip = mtd->priv; -struct nand_drv *info = (struct nand_drv *)chip->priv; +struct nand_chip *chip =mtd_to_nand (mtd); +struct nand_drv *info = (struct nand_drv *)nand_get_controller_data (chip);for (i =0 ; i < len; i +=4 ) { s = (len - i) >4 ?4 : len - i;@@ -194,11 +194,11 @@ static void read_buf(struct mtd_info *mtd, uint8_t *buf, int len)*/ static int nand_dev_ready (struct mtd_info *mtd) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);int reg_val;struct nand_drv *info; - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip); reg_val =readl (&info->reg->status);if (reg_val &STATUS_RBSY0 )@@ -245,10 +245,10 @@ static void nand_clear_interrupt_status(struct nand_ctlr *reg)static void nand_command (struct mtd_info *mtd,unsigned int command,int column,int page_addr) { -struct nand_chip *chip = mtd->priv; +struct nand_chip *chip =mtd_to_nand (mtd);struct nand_drv *info; - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip);/* * Write out the command to the device. @@ -512,7 +512,7 @@ static int nand_rw_page(struct mtd_info *mtd, struct nand_chip *chip,return -EINVAL ; } - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip); config = &info->config;if (set_bus_width_page_size (config, ®_val))return -EINVAL ;@@ -662,7 +662,7 @@ static int nand_write_page_hwecc(struct mtd_info *mtd,int page;struct nand_drv *info; - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip); page = (readl (&info->reg->addr_reg1) >>16 ) | (readl (&info->reg->addr_reg2) <<16 );@@ -702,7 +702,7 @@ static int nand_write_page_raw(struct mtd_info *mtd,int page;struct nand_drv *info; - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip); page = (readl (&info->reg->addr_reg1) >>16 ) | (readl (&info->reg->addr_reg2) <<16 );@@ -734,7 +734,7 @@ static int nand_rw_oob(struct mtd_info *mtd, struct nand_chip *chip,if (((int )chip->oob_poi) &0x03 )return -EINVAL ; - info = (struct nand_drv *)chip->priv; + info = (struct nand_drv *)nand_get_controller_data (chip);if (set_bus_width_page_size (&info->config, ®_val))return -EINVAL ;@@ -963,7 +963,7 @@ int tegra_nand_init(struct nand_chip *nand, int devnum) nand->ecc.strength =1 ; nand->select_chip = nand_select_chip; nand->dev_ready = nand_dev_ready; - nand->priv = &nand_ctrl; +nand_set_controller_data (nand, &nand_ctrl);/* Disable subpage writes as we do not provide ecc->hwctl */ nand->options |=NAND_NO_SUBPAGE_WRITE ;@@ -976,8 +976,7 @@ int tegra_nand_init(struct nand_chip *nand, int devnum)dm_gpio_set_value (&config->wp_gpio,1 ); - our_mtd = &nand->mtd; - our_mtd->priv = nand; + our_mtd =nand_to_mtd (nand); ret =nand_scan_ident (our_mtd,CONFIG_SYS_NAND_MAX_CHIPS ,NULL );if (ret)return ret;drivers/mtd/nand/vf610_nfc.c +3
-5@@ -155,8 +155,7 @@ struct vf610_nfc {enum vf610_nfc_alt_buf alt_buf; }; -#define mtd_to_nfc (_mtd) \ - (struct vf610_nfc *)((struct nand_chip *)_mtd->priv)->priv +#define mtd_to_nfc (_mtd) nand_get_controller_data(mtd_to_nand(_mtd))#if defined(CONFIG_SYS_NAND_VF610_NFC_45_ECC_BYTES )#define ECC_HW_MODE ECC_45_BYTE@@ -653,9 +652,8 @@ static int vf610_nfc_nand_init(int devnum, void __iomem *addr) chip = &nfc->chip; nfc->regs = addr; - mtd = &chip->mtd; - mtd->priv = chip; - chip->priv = nfc; + mtd =nand_to_mtd (chip); +nand_set_controller_data (chip, nfc);if (cfg.width ==16 ) chip->options |=NAND_BUSWIDTH_16 ;fs/yaffs2/yaffs_uboot_glue.c +1
-1@@ -190,7 +190,7 @@ void cmd_yaffs_devconfig(char *_mp, int flash_dev, goto err; } - chip = mtd->priv; + chip =mtd_to_nand (mtd);/* Check for any conflicts */ yaffs_dev_rewind ();include/linux/mtd/nand.h +20
-0@@ -740,6 +740,26 @@ struct nand_chip {void *priv; }; +static inline struct nand_chip *mtd_to_nand (struct mtd_info *mtd) +{ + return container_of(mtd, struct nand_chip, mtd); +} + +static inline struct mtd_info *nand_to_mtd (struct nand_chip *chip) +{ +return &chip->mtd; +} + +static inline void *nand_get_controller_data (struct nand_chip *chip) +{ +return chip->priv; +} + +static inline void nand_set_controller_data (struct nand_chip *chip,void *priv) +{ + chip->priv = priv; +} +/* * NAND Flash Manufacturer ID Codes */
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 5/7 mtd: nand: Add+use mtd_to/from_nand and nand_get/set_controller_data
Quoted 8 lines · Boris Brezillon
Quoted 4 lines · On Mon, 30 May 2016 13:57:56 -0500 Scott Wood <[email protected]> wrote:
These functions are part of the Linux 4.6 sync. They are being added before the main sync patch in order to make it easier to address the issue across all NAND drivers (many/most of which do not closely track their Linux counterparts) separately from other merge issues.
Quoted 4 lines
Some drivers are still directly accessing
chip->mtd. Here is a patch fixing those places [1] (not tested).
Could you send this as a proper patch?
Though some of the changes seem to be removing SPL mtd pointers rather than converting chip->mtd. I don't care much whether those pointers are retained but it's not "directly accessing chip->mtd".
-Scott
PATCH 5/7 mtd: nand: Add+use mtd_to/from_nand and nand_get/set_controller_data
Hi Scott,
Quoted 9 lines · On Thu, 09 Jun 2016 21:07:00 -0500 Scott Wood <[email protected]> wrote:
Quoted 8 lines · Boris Brezillon
Quoted 4 lines · On Mon, 30 May 2016 13:57:56 -0500 Scott Wood <[email protected]> wrote:
These functions are part of the Linux 4.6 sync. They are being added before the main sync patch in order to make it easier to address the issue across all NAND drivers (many/most of which do not closely track their Linux counterparts) separately from other merge issues.
Quoted 6 lines
Quoted 4 lines
Some drivers are still directly accessing
chip->mtd. Here is a patch fixing those places [1] (not tested).Could you send this as a proper patch?
Sure, see below. You can squash the changes into you patch (hence the !fixup prefix).
Quoted 4 lines
Though some of the changes seem to be removing SPL mtd pointers rather than converting
chip->mtd. I don't care much whether those pointers are retained but it's not "directly accessingchip->mtd".
Yes, I dropped all the unnecessary changes.
Regards,
Boris
Quoted 3 lines
-Scott
--->8---
PATCH 5/7 mtd: nand: Add+use mtd_to/from_nand and nand_get/set_controller_data
Quoted 17 lines · On Wed, 15 Jun 2016 09:59:15 +0200 Boris Brezillon…
Hi Scott,
Quoted 12 lines · On Thu, 09 Jun 2016 21:07:00 -0500 Scott Wood <[email protected]> wrote:
Quoted 11 lines · Boris Brezillon
Quoted 4 lines · On Mon, 30 May 2016 13:57:56 -0500 Scott Wood <[email protected]> wrote:
These functions are part of the Linux 4.6 sync. They are being added before the main sync patch in order to make it easier to address the issue across all NAND drivers (many/most of which do not closely track their Linux counterparts) separately from other merge issues.
Some drivers are still directly accessing
chip->mtd. Here is a patch fixing those places [1] (not tested).
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Could you send this as a proper patch?
Sure, see below. You can squash the changes into you patch (hence the !fixup prefix).
Oops, sorry this version was buggy: mtd_to_nand() was called instead of nand_to_mtd() in a few places. Here is an updated one.
--->8---
PATCH 5/7 mtd: nand: Add+use mtd_to/from_nand and nand_get/set_controller_data
Quoted 32 lines · Boris Brezillon
Quoted 19 lines · On Wed, 15 Jun 2016 09:59:15 +0200 Boris Brezillon…
Hi Scott,
Quoted 14 lines · On Thu, 09 Jun 2016 21:07:00 -0500 Scott Wood <[email protected]> wrote:
Quoted 13 lines · Boris Brezillon
Quoted 6 lines · On Mon, 30 May 2016 13:57:56 -0500 Scott Wood <[email protected]> wrote:
These functions are part of the Linux 4.6 sync. They are being added
before the main sync patch in order to make it easier to address the issue across all NAND drivers (many/most of which do not closely track
their Linux counterparts) separately from other merge issues.Some drivers are still directly accessing
chip->mtd. Here is a patch fixing those places [1] (not tested).Quoted 6 lines
Quoted 3 lines
Quoted 1 line
[1] http://code.bulix.org/inu69a-100476????;
Could you send this as a proper patch?
Sure, see below. You can squash the changes into you patch (hence the !fixup prefix).
Oops, sorry this version was buggy:
mtd_to_nand()was called instead ofnand_to_mtd()in a few places. Here is an updated one.
Quoted 6 lines
--->8---
From9c885ff8b3d96f29dfa5ef9850c4519a88a7912dMon Sep 17 00:00:00 2001
From: Boris Brezillon <[email protected]>
Date: Wed, 15 Jun 2016 09:48:48 +0200
Subject: [PATCH] fixup! mtd: nand: Add+use mtd_to/from_nand and
nand_get/set_controller_data
It's too late to amend the commit. I need a standalone patch with signoff, etc.
-Scott
PATCH 5/7 mtd: nand: Add+use mtd_to/from_nand and nand_get/set_controller_data
Quoted 40 lines · On Wed, 15 Jun 2016 12:39:50 -0500 Scott Wood <[email protected]> wrote:
Quoted 32 lines · Boris Brezillon
Quoted 19 lines · On Wed, 15 Jun 2016 09:59:15 +0200 Boris Brezillon…
Hi Scott,
Quoted 14 lines · On Thu, 09 Jun 2016 21:07:00 -0500 Scott Wood <[email protected]> wrote:
Quoted 13 lines · Boris Brezillon
Quoted 6 lines · On Mon, 30 May 2016 13:57:56 -0500 Scott Wood <[email protected]> wrote:
These functions are part of the Linux 4.6 sync. They are being added
before the main sync patch in order to make it easier to address the issue across all NAND drivers (many/most of which do not closely track
their Linux counterparts) separately from other merge issues.Some drivers are still directly accessing
chip->mtd. Here is a patch fixing those places [1] (not tested).Quoted 6 lines
Quoted 3 lines
Quoted 1 line
[1] http://code.bulix.org/inu69a-100476????;
Could you send this as a proper patch?
Sure, see below. You can squash the changes into you patch (hence the !fixup prefix).
Oops, sorry this version was buggy:
mtd_to_nand()was called instead ofnand_to_mtd()in a few places. Here is an updated one.Quoted 6 lines
--->8---
From9c885ff8b3d96f29dfa5ef9850c4519a88a7912dMon Sep 17 00:00:00 2001
From: Boris Brezillon <[email protected]>
Date: Wed, 15 Jun 2016 09:48:48 +0200
Subject: [PATCH] fixup! mtd: nand: Add+use mtd_to/from_nand and
nand_get/set_controller_data
Quoted 2 lines
It's too late to amend the commit. I need a standalone patch with signoff, etc.
Ok, I'll send a standalone patch. BTW, I didn't see any answer mentioning that you had applied the series to your tree, hence this fixup patch.
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 6/7 mtd: nand: Add page argument to write_page() etc.
In reply to Scott WoodThis change is part of the Linux 4.6 sync. It is being done before the main sync patch in order to make it easier to address the issue across all NAND drivers (many/most of which do not closely track their Linux counterparts) separately from other merge issues.
--- drivers/mtd/nand/arasan_nfc.c | 3 ++- drivers/mtd/nand/atmel_nand.c | 2 +- drivers/mtd/nand/davinci_nand.c | 11 +++++++---- drivers/mtd/nand/denali.c | 6 ++++-- drivers/mtd/nand/fsl_elbc_nand.c | 5 +++-- drivers/mtd/nand/fsl_ifc_nand.c | 2 +- drivers/mtd/nand/lpc32xx_nand_mlc.c | 6 ++++-- drivers/mtd/nand/lpc32xx_nand_slc.c | 3 ++- drivers/mtd/nand/mxc_nand.c | 4 ++-- drivers/mtd/nand/mxs_nand.c | 2 +- drivers/mtd/nand/nand_base.c | 31 +++++++++++++++++++++---------- drivers/mtd/nand/pxa3xx_nand.c | 3 ++- drivers/mtd/nand/tegra_nand.c | 21 ++++----------------- drivers/mtd/nand/vf610_nfc.c | 2 +- include/linux/mtd/nand.h | 6 +++--- 15 files changed, 58 insertions(+), 49 deletions(-)
drivers/mtd/nand/arasan_nfc.c +2 -1
@@ -433,7 +433,8 @@ static void arasan_nand_fill_tx(const u8 *buf, int len) }static int arasan_nand_write_page_hwecc (struct mtd_info *mtd, -struct nand_chip *chip,const u8 *buf,int oob_required) +struct nand_chip *chip,const u8 *buf,int oob_required, +int page) {u32 reg_val, i, pktsize, pktnum;const u32 *bufptr = (const u32 *)buf;
drivers/mtd/nand/atmel_nand.c +1 -1
@@ -569,7 +569,7 @@ static int atmel_nand_pmecc_read_page(struct mtd_info *mtd,static int atmel_nand_pmecc_write_page (struct mtd_info *mtd,struct nand_chip *chip,const uint8_t *buf, -int oob_required) +int oob_required,int page) {struct atmel_nand_host *host =nand_get_controller_data (chip);uint32_t *eccpos = chip->ecc.layout->eccpos;
drivers/mtd/nand/davinci_nand.c +7 -4
@@ -380,10 +380,13 @@ static int nand_davinci_write_page(struct mtd_info *mtd, struct nand_chip *chip, chip->cmdfunc (mtd,NAND_CMD_SEQIN ,0x00 , page); -if (unlikely (raw)) - status = chip->ecc.write_page_raw (mtd, chip, buf, oob_required); -else - status = chip->ecc.write_page (mtd, chip, buf, oob_required); +if (unlikely (raw)) { + status = chip->ecc.write_page_raw (mtd, chip, buf, + oob_required, page); + }else { + status = chip->ecc.write_page (mtd, chip, buf, + oob_required, page); + }if (status <0 ) { ret = status;
drivers/mtd/nand/denali.c +4 -2
@@ -866,7 +866,8 @@ static int write_page(struct mtd_info *mtd, struct nand_chip *chip,* by write_page above. */ static int denali_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required) +const uint8_t *buf,int oob_required, +int page) {struct denali_nand_info *denali =mtd_to_denali (mtd);
@@ -890,7 +891,8 @@ static int denali_write_page(struct mtd_info *mtd, struct nand_chip *chip,* write_page() function above. */ static int denali_write_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required) +const uint8_t *buf,int oob_required, +int page) {struct denali_nand_info *denali =mtd_to_denali (mtd);
drivers/mtd/nand/fsl_elbc_nand.c +3 -2
@@ -611,7 +611,8 @@ static int fsl_elbc_read_page(struct mtd_info *mtd, struct nand_chip *chip,* waitfunc. */ static int fsl_elbc_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required) +const uint8_t *buf,int oob_required, +int page) {fsl_elbc_write_buf (mtd, buf, mtd->writesize);fsl_elbc_write_buf (mtd, chip->oob_poi, mtd->oobsize);
@@ -626,7 +627,7 @@ static struct fsl_elbc_ctrl *elbc_ctrl;*/ static int fsl_elbc_write_subpage (struct mtd_info *mtd,struct nand_chip *chip,uint32_t offset,uint32_t data_len, -const uint8_t *buf,int oob_required) +const uint8_t *buf,int oob_required,int page) {fsl_elbc_write_buf (mtd, buf, mtd->writesize);fsl_elbc_write_buf (mtd, chip->oob_poi, mtd->oobsize);
drivers/mtd/nand/fsl_ifc_nand.c +1 -1
@@ -755,7 +755,7 @@ static int fsl_ifc_read_page(struct mtd_info *mtd, struct nand_chip *chip,* waitfunc. */ static int fsl_ifc_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required) +const uint8_t *buf,int oob_required,int page) {fsl_ifc_write_buf (mtd, buf, mtd->writesize);fsl_ifc_write_buf (mtd, chip->oob_poi, mtd->oobsize);
drivers/mtd/nand/lpc32xx_nand_mlc.c +4 -2
@@ -378,7 +378,8 @@ static int lpc32xx_read_oob(struct mtd_info *mtd, struct nand_chip *chip,*/ static int lpc32xx_write_page_hwecc (struct mtd_info *mtd, -struct nand_chip *chip,const uint8_t *buf,int oob_required) +struct nand_chip *chip,const uint8_t *buf,int oob_required, +int page) {unsigned int i, status, timeout;struct lpc32xx_oob *oob = (struct lpc32xx_oob *)chip->oob_poi;
@@ -435,7 +436,8 @@ static int lpc32xx_write_page_hwecc(struct mtd_info *mtd,*/ static int lpc32xx_write_page_raw (struct mtd_info *mtd, -struct nand_chip *chip,const uint8_t *buf,int oob_required) +struct nand_chip *chip,const uint8_t *buf,int oob_required, +int page) {unsigned int i;struct lpc32xx_oob *oob = (struct lpc32xx_oob *)chip->oob_poi;
drivers/mtd/nand/lpc32xx_nand_slc.c +2 -1
@@ -486,7 +486,8 @@ static int lpc32xx_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,/* Reuse the logic from "nand_write_page_hwecc()" */ static int lpc32xx_write_page_hwecc (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required) +const uint8_t *buf,int oob_required, +int page) {int i;uint8_t *ecc_calc = chip->buffers->ecccalc;
drivers/mtd/nand/mxc_nand.c +2 -2
@@ -576,7 +576,7 @@ static int mxc_nand_write_oob_syndrome(struct mtd_info *mtd,static int mxc_nand_write_page_raw_syndrome (struct mtd_info *mtd,struct nand_chip *chip,const uint8_t *buf, -int oob_required) +int oob_required,int page) {struct mxc_nand_host *host =nand_get_controller_data (chip);int eccsize = chip->ecc.size;
@@ -616,7 +616,7 @@ static int mxc_nand_write_page_raw_syndrome(struct mtd_info *mtd,static int mxc_nand_write_page_syndrome (struct mtd_info *mtd,struct nand_chip *chip,const uint8_t *buf, -int oob_required) +int oob_required,int page) {struct mxc_nand_host *host =nand_get_controller_data (chip);int i, n, eccsize = chip->ecc.size;
drivers/mtd/nand/mxs_nand.c +1 -1
@@ -707,7 +707,7 @@ rtn:*/ static int mxs_nand_ecc_write_page (struct mtd_info *mtd,struct nand_chip *nand,const uint8_t *buf, -int oob_required) +int oob_required,int page) {struct mxs_nand_info *nand_info =nand_get_controller_data (nand);struct mxs_dma_desc *d;
drivers/mtd/nand/nand_base.c +21 -10
@@ -1840,11 +1840,13 @@ out:* @chip: nand chip info structure * @buf: data buffer * @oob_required: must write chip->oob_poi to OOB +* @page: page number to write * * Not for syndrome calculating ECC controllers, which use a special oob layout. */ static int nand_write_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required) +const uint8_t *buf,int oob_required, +int page) { chip->write_buf (mtd, buf, mtd->writesize);if (oob_required)
@@ -1864,7 +1866,8 @@ static int nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,*/ static int nand_write_page_raw_syndrome (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required) +const uint8_t *buf,int oob_required, +int page) {int eccsize = chip->ecc.size;int eccbytes = chip->ecc.bytes;
@@ -1901,9 +1904,11 @@ static int nand_write_page_raw_syndrome(struct mtd_info *mtd,* @chip: nand chip info structure * @buf: data buffer * @oob_required: must write chip->oob_poi to OOB +* @page: page number to write */ static int nand_write_page_swecc (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required) +const uint8_t *buf,int oob_required, +int page) {int i, eccsize = chip->ecc.size;int eccbytes = chip->ecc.bytes;
@@ -1919,7 +1924,7 @@ static int nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,for (i =0 ; i < chip->ecc.total; i++) chip->oob_poi[eccpos[i]] = ecc_calc[i]; -return chip->ecc.write_page_raw (mtd, chip, buf,1 ); +return chip->ecc.write_page_raw (mtd, chip, buf,1 , page); }/**
@@ -1928,9 +1933,11 @@ static int nand_write_page_swecc(struct mtd_info *mtd, struct nand_chip *chip,* @chip: nand chip info structure * @buf: data buffer * @oob_required: must write chip->oob_poi to OOB +* @page: page number to write */ static int nand_write_page_hwecc (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required) +const uint8_t *buf,int oob_required, +int page) {int i, eccsize = chip->ecc.size;int eccbytes = chip->ecc.bytes;
@@ -1962,11 +1969,12 @@ static int nand_write_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,* @data_len: data length * @buf: data buffer * @oob_required: must write chip->oob_poi to OOB +* @page: page number to write */ static int nand_write_subpage_hwecc (struct mtd_info *mtd,struct nand_chip *chip,uint32_t offset,uint32_t data_len,const uint8_t *buf, -int oob_required) +int oob_required,int page) {uint8_t *oob_buf = chip->oob_poi;uint8_t *ecc_calc = chip->buffers->ecccalc;
@@ -2027,7 +2035,8 @@ static int nand_write_subpage_hwecc(struct mtd_info *mtd,*/ static int nand_write_page_syndrome (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required) +const uint8_t *buf,int oob_required, +int page) {int i, eccsize = chip->ecc.size;int eccbytes = chip->ecc.bytes;
@@ -2091,12 +2100,13 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,if (unlikely (raw)) status = chip->ecc.write_page_raw (mtd, chip, buf, - oob_required); + oob_required, page);else if (subpage) status = chip->ecc.write_subpage (mtd, chip, offset, data_len, - buf, oob_required); + buf, oob_required, page);else - status = chip->ecc.write_page (mtd, chip, buf, oob_required); + status = chip->ecc.write_page (mtd, chip, buf, oob_required, + page);if (status <0 )return status;
@@ -2135,6 +2145,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,* @oob: oob data buffer * @len: oob data write length * @ops: oob ops structure +* @page: page number to write */ static uint8_t *nand_fill_oob (struct mtd_info *mtd,uint8_t *oob,size_t len,struct mtd_oob_ops *ops)
drivers/mtd/nand/pxa3xx_nand.c +2 -1
@@ -1081,7 +1081,8 @@ static void nand_cmdfunc_extended(struct mtd_info *mtd, }static int pxa3xx_nand_write_page_hwecc (struct mtd_info *mtd, -struct nand_chip *chip,const uint8_t *buf,int oob_required) +struct nand_chip *chip,const uint8_t *buf,int oob_required, +int page) { chip->write_buf (mtd, buf, mtd->writesize); chip->write_buf (mtd, chip->oob_poi, mtd->oobsize);
drivers/mtd/nand/tegra_nand.c +4 -17
@@ -657,16 +657,9 @@ static int nand_read_page_hwecc(struct mtd_info *mtd,* @param buf data buffer */ static int nand_write_page_hwecc (struct mtd_info *mtd, -struct nand_chip *chip,const uint8_t *buf,int oob_required) +struct nand_chip *chip,const uint8_t *buf,int oob_required, +int page) { -int page; -struct nand_drv *info; - - info = (struct nand_drv *)nand_get_controller_data (chip); - - page = (readl (&info->reg->addr_reg1) >>16 ) | - (readl (&info->reg->addr_reg2) <<16 ); -nand_rw_page (mtd, chip, (uint8_t *)buf, page,1 ,1 );return 0 ; }
@@ -697,15 +690,9 @@ static int nand_read_page_raw(struct mtd_info *mtd,* @param buf data buffer */ static int nand_write_page_raw (struct mtd_info *mtd, -struct nand_chip *chip,const uint8_t *buf,int oob_required) +struct nand_chip *chip,const uint8_t *buf, +int oob_required,int page) { -int page; -struct nand_drv *info; - - info = (struct nand_drv *)nand_get_controller_data (chip); - page = (readl (&info->reg->addr_reg1) >>16 ) | - (readl (&info->reg->addr_reg2) <<16 ); -nand_rw_page (mtd, chip, (uint8_t *)buf, page,0 ,1 );return 0 ; }
drivers/mtd/nand/vf610_nfc.c +1 -1
@@ -607,7 +607,7 @@ static int vf610_nfc_read_page(struct mtd_info *mtd, struct nand_chip *chip,* ECC will be calculated automatically */ static int vf610_nfc_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required) +const uint8_t *buf,int oob_required,int page) {struct vf610_nfc *nfc =mtd_to_nfc (mtd);
include/linux/mtd/nand.h +3 -3
@@ -519,16 +519,16 @@ struct nand_ecc_ctrl {int (*read_page_raw)(struct mtd_info *mtd,struct nand_chip *chip,uint8_t *buf,int oob_required,int page);int (*write_page_raw)(struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required); +const uint8_t *buf,int oob_required,int page);int (*read_page)(struct mtd_info *mtd,struct nand_chip *chip,uint8_t *buf,int oob_required,int page);int (*read_subpage)(struct mtd_info *mtd,struct nand_chip *chip,uint32_t offs,uint32_t len,uint8_t *buf,int page);int (*write_subpage)(struct mtd_info *mtd,struct nand_chip *chip,uint32_t offset,uint32_t data_len, -const uint8_t *data_buf,int oob_required); +const uint8_t *data_buf,int oob_required,int page);int (*write_page)(struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required); +const uint8_t *buf,int oob_required,int page);int (*write_oob_raw)(struct mtd_info *mtd,struct nand_chip *chip,int page); int (*read_oob_raw)(struct mtd_info *mtd, struct nand_chip *chip,
Signature · 1 line
2.5.0
PATCH 7/7 mtd: nand: Sync with Linux v4.6
In reply to Scott WoodUpdates the NAND code to match Linux v4.6. The previous sync was from Linux v4.1 in commit d3963721d93fafa.
Note that none of the individual NAND drivers tracked Linux closely enough to be synced themselves, other than manually applying a few cross-tree changes.
--- drivers/mtd/nand/atmel_nand.c | 6 +- drivers/mtd/nand/davinci_nand.c | 6 +- drivers/mtd/nand/denali.c | 39 +++-- drivers/mtd/nand/denali.h | 1 - drivers/mtd/nand/denali_spl.c | 2 +- drivers/mtd/nand/mpc5121_nfc.c | 1 - drivers/mtd/nand/mxc_nand.c | 5 +- drivers/mtd/nand/mxc_nand_spl.c | 2 +- drivers/mtd/nand/mxs_nand.c | 2 +- drivers/mtd/nand/nand_base.c | 329 ++++++++++++++++++++++++++++------------ drivers/mtd/nand/nand_bbt.c | 30 ++-- drivers/mtd/nand/nand_bch.c | 29 ++-- drivers/mtd/nand/nand_ids.c | 10 +- drivers/mtd/nand/ndfc.c | 2 +- drivers/mtd/nand/omap_gpmc.c | 2 +- drivers/mtd/nand/s3c2410_nand.c | 2 +- drivers/mtd/nand/vf610_nfc.c | 1 - include/linux/mtd/mtd.h | 5 + include/linux/mtd/nand.h | 65 +++++--- include/linux/mtd/nand_bch.h | 10 +- 20 files changed, 347 insertions(+), 202 deletions(-)
drivers/mtd/nand/atmel_nand.c +3 -3
@@ -513,7 +513,7 @@ normal_check:if (err_nbr ==-1 ) {dev_err (host->dev,"PMECC: Too many errors\n" ); mtd->ecc_stats.failed++; -return -EIO ; +return -EBADMSG ; }else {pmecc_correct_data (mtd, buf_pos, ecc, i, host->pmecc_bytes_per_sector, err_nbr);
@@ -562,7 +562,7 @@ static int atmel_nand_pmecc_read_page(struct mtd_info *mtd, stat =pmecc_readl (host->pmecc, isr);if (stat !=0 )if (pmecc_correction (mtd, stat, buf, &oob[eccpos[0 ]]) !=0 ) -return -EIO ; +return -EBADMSG ;return 0 ; }
@@ -1112,7 +1112,7 @@ static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,* We can't correct so many errors */ dev_warn (host->dev,"atmel_nand : multiple errors detected." " Unable to correct.\n" ); -return -EIO ; +return -EBADMSG ; }/* if there's a single bit error : we can correct it */
drivers/mtd/nand/davinci_nand.c +3 -3
@@ -243,7 +243,7 @@ static int nand_davinci_correct_data(struct mtd_info *mtd, u_char *dat, "%d\n", find_byte, find_bit);return 1 ; }else { -return -1 ; +return -EBADMSG ; } }else if (!(diff & (diff -1 ))) {/* Single bit ECC error in the ECC itself,
@@ -254,7 +254,7 @@ static int nand_davinci_correct_data(struct mtd_info *mtd, u_char *dat, }else {/* Uncorrectable error */ MTDDEBUG (MTD_DEBUG_LEVEL0 ,"ECC UNCORRECTED_ERROR 1\n" ); -return -1 ; +return -EBADMSG ; } }return 0 ;
@@ -701,7 +701,7 @@ static int nand_davinci_4bit_correct_data(struct mtd_info *mtd, uint8_t *dat,return 0 ; }else if (iserror ==ECC_STATE_TOO_MANY_ERRS ) { val =__raw_readl (&davinci_emif_regs->nanderrval1); -return -1 ; +return -EBADMSG ; } numerrors = ((__raw_readl(&davinci_emif_regs->nandfsr) >> 16)
drivers/mtd/nand/denali.c +17 -22
@@ -48,8 +48,10 @@ static int onfi_timing_mode = NAND_DEFAULT_TIMINGS;* this macro allows us to convert from an MTD structure to our own * device context (denali) structure. */ -#define mtd_to_denali (m) \ - container_of(mtd_to_nand(m), struct denali_nand_info, nand) +static inline struct denali_nand_info *mtd_to_denali (struct mtd_info *mtd) +{ + return container_of(mtd_to_nand(mtd), struct denali_nand_info, nand); +}/* * These constants are defined by the driver to enable common driver
@@ -866,8 +868,7 @@ static int write_page(struct mtd_info *mtd, struct nand_chip *chip,* by write_page above. */ static int denali_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required, -int page) +const uint8_t *buf,int oob_required,int page) {struct denali_nand_info *denali =mtd_to_denali (mtd);
@@ -891,8 +892,8 @@ static int denali_write_page(struct mtd_info *mtd, struct nand_chip *chip,* write_page() function above. */ static int denali_write_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required, -int page) +const uint8_t *buf,int oob_required, +int page) {struct denali_nand_info *denali =mtd_to_denali (mtd);
@@ -991,7 +992,7 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,debug (" ECC error cause by erased block\n" );/* false alarm, return the 0xFF */ }else { -return -EIO ; +return -EBADMSG ; } }memcpy (buf, denali->buf.dma_buf, mtd->writesize);
@@ -1176,12 +1177,13 @@ static struct nand_ecclayout nand_oob;static int denali_init (struct denali_nand_info *denali) { +struct mtd_info *mtd =nand_to_mtd (&denali->nand);int ret;denali_hw_init (denali); - denali->mtd->name ="denali-nand" ; - denali->mtd->owner =THIS_MODULE ; + mtd->name ="denali-nand" ; + mtd->owner =THIS_MODULE ;/* register the driver with the NAND core subsystem */ denali->nand.select_chip = denali_select_chip;
@@ -1195,7 +1197,7 @@ static int denali_init(struct denali_nand_info *denali)* this is the first stage in a two step process to register * with the nand subsystem */ -if (nand_scan_ident (denali->mtd, denali->max_banks,NULL )) { +if (nand_scan_ident (mtd, denali->max_banks,NULL )) { ret = -ENXIO ; goto fail; }
@@ -1241,13 +1243,13 @@ static int denali_init(struct denali_nand_info *denali) nand_oob.eccbytes = denali->nand.ecc.bytes; denali->nand.ecc.layout = &nand_oob; -writel (denali->mtd->erasesize / denali->mtd->writesize, +writel (mtd->erasesize / mtd->writesize, denali->flash_reg +PAGES_PER_BLOCK );writel (denali->nand.options &NAND_BUSWIDTH_16 ?1 :0 , denali->flash_reg +DEVICE_WIDTH ); -writel (denali->mtd->writesize, +writel (mtd->writesize, denali->flash_reg +DEVICE_MAIN_AREA_SIZE ); -writel (denali->mtd->oobsize, +writel (mtd->oobsize, denali->flash_reg +DEVICE_SPARE_AREA_SIZE );if (readl (denali->flash_reg +DEVICES_CONNECTED ) ==0 )writel (1 , denali->flash_reg +DEVICES_CONNECTED );
@@ -1260,12 +1262,12 @@ static int denali_init(struct denali_nand_info *denali) denali->nand.ecc.read_oob = denali_read_oob; denali->nand.ecc.write_oob = denali_write_oob; -if (nand_scan_tail (denali->mtd)) { +if (nand_scan_tail (mtd)) { ret = -ENXIO ; goto fail; } - ret =nand_register (0 , denali->mtd); + ret =nand_register (0 , mtd); fail:return ret;
@@ -1280,13 +1282,6 @@ static int __board_nand_init(void)return -ENOMEM ;/* -* If CONFIG_SYS_NAND_SELF_INIT is defined, each driver is responsible -* for instantiating struct nand_chip, while drivers/mtd/nand/nand.c -* still provides a "struct mtd_info nand_info" instance. -*/ - denali->mtd = &denali->nand.mtd; - -/* * In the future, these base addresses should be taken from * Device Tree or platform data. */
drivers/mtd/nand/denali.h +0 -1
@@ -436,7 +436,6 @@ struct nand_buf {#define DT 3struct denali_nand_info { -struct mtd_info *mtd;struct nand_chip nand;int flash_bank;/* currently selected chip */ int status;
drivers/mtd/nand/denali_spl.c +1 -1
@@ -41,7 +41,7 @@ static int wait_for_irq(uint32_t irq_mask)if (intr_status &INTR_STATUS__ECC_UNCOR_ERR ) {debug ("Uncorrected ECC detected\n" ); -return -EIO ; +return -EBADMSG ; }if (intr_status & irq_mask)
drivers/mtd/nand/mpc5121_nfc.c +0 -1
@@ -100,7 +100,6 @@#define NFC_WPC_UNLOCK (1 << 2)struct mpc5121_nfc_prv { -struct mtd_info mtd;struct nand_chip chip;int irq;void __iomem *regs;
drivers/mtd/nand/mxc_nand.c +2 -3
@@ -19,7 +19,6 @@#define DRIVER_NAME "mxc_nand"struct mxc_nand_host { -struct mtd_info mtd;struct nand_chip *nand;struct mxc_nand_regs __iomem *regs;
@@ -681,7 +680,7 @@ static int mxc_nand_correct_data(struct mtd_info *mtd, u_char *dat, mtd->writesize / nand_chip->subpagesize - subpages); } -return -1 ; +return -EBADMSG ; } ecc_status >>=4 ; subpages--;
@@ -713,7 +712,7 @@ static int mxc_nand_correct_data(struct mtd_info *mtd, u_char *dat,if (((ecc_status &0x3 ) ==2 ) || ((ecc_status >>2 ) ==2 )) {MTDDEBUG (MTD_DEBUG_LEVEL0 ,"MXC_NAND: HWECC uncorrectable 2-bit ECC error\n" ); -return -1 ; +return -EBADMSG ; }return 0 ;
drivers/mtd/nand/mxc_nand_spl.c +1 -1
@@ -232,7 +232,7 @@ static int nfc_read_page(unsigned int page_address, unsigned char *buf)nfc_nand_read_page (page_address);if (nfc_nand_check_ecc ()) -return -1 ; +return -EBADMSG ; src = (u32 *)&nfc->main_area[0 ][0 ]; dst = (u32 *)buf;
drivers/mtd/nand/mxs_nand.c +1 -1
@@ -961,7 +961,7 @@ static int mxs_nand_ecc_write_oob(struct mtd_info *mtd, struct nand_chip *nand,* Thus, this function is only called when we want *all* blocks to look good, * so it *always* return success. */ -static int mxs_nand_block_bad (struct mtd_info *mtd,loff_t ofs,int getchip) +static int mxs_nand_block_bad (struct mtd_info *mtd,loff_t ofs) {return 0 ; }
drivers/mtd/nand/nand_base.c +228 -101
581 lines not on this page · raw message
drivers/mtd/nand/nand_bbt.c +15 -15
@@ -1,6 +1,4 @@/* -* drivers/mtd/nand_bbt.c -* * Overview: * Bad block table support for the NAND driver *
@@ -65,7 +63,6 @@#include <linux/mtd/mtd.h> #include <linux/mtd/bbm.h> #include <linux/mtd/nand.h> -#include <linux/mtd/nand_ecc.h> #include <linux/bitops.h> #include <linux/string.h>
@@ -718,7 +715,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,/* Must we save the block contents? */ if (td->options &NAND_BBT_SAVECONTENT ) {/* Make it block aligned */ - to &= ~((loff_t)((1 << this->bbt_erase_shift) -1 )); + to &= ~(((loff_t )1 << this->bbt_erase_shift) -1 ); len =1 << this->bbt_erase_shift; res =mtd_read (mtd, to, len, &retlen, buf);if (res <0 ) {
@@ -1073,15 +1070,15 @@ static void verify_bbt_descr(struct mtd_info *mtd, struct nand_bbt_descr *bd)* The bad block table memory is allocated here. It must be freed by calling * the nand_free_bbt function. */ -int nand_scan_bbt (struct mtd_info *mtd,struct nand_bbt_descr *bd) +static int nand_scan_bbt (struct mtd_info *mtd,struct nand_bbt_descr *bd) {struct nand_chip *this =mtd_to_nand (mtd); -int len, res =0 ; +int len, res;uint8_t *buf;struct nand_bbt_descr *td = this->bbt_td;struct nand_bbt_descr *md = this->bbt_md; - len = mtd->size >> (this->bbt_erase_shift +2 ); + len = (mtd->size >> (this->bbt_erase_shift +2 )) ? :1 ;/* * Allocate memory (2bit per block) and clear the memory bad block * table.
@@ -1097,10 +1094,9 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)if (!td) {if ((res =nand_memory_bbt (mtd, bd))) {pr_err ("nand_bbt: can't scan flash and build the RAM-based BBT\n" ); -kfree (this->bbt); - this->bbt =NULL ; + goto err; } -return res; +return 0 ; }verify_bbt_descr (mtd, td);verify_bbt_descr (mtd, md);
@@ -1110,9 +1106,8 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) len += (len >> this->page_shift) * mtd->oobsize; buf =vmalloc (len);if (!buf) { -kfree (this->bbt); - this->bbt =NULL ; -return -ENOMEM ; + res = -ENOMEM ; + goto err; }/* Is the bbt at a given page? */
@@ -1124,6 +1119,8 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) } res =check_create (mtd, buf, bd); +if (res) + goto err;/* Prevent the bbt regions from erasing / writing */ mark_bbt_region (mtd, td);
@@ -1131,6 +1128,11 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)mark_bbt_region (mtd, md);vfree (buf); +return 0 ; + +err: +kfree (this->bbt); + this->bbt =NULL ;return res; }
@@ -1369,5 +1371,3 @@ int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs)return ret; } - -EXPORT_SYMBOL (nand_scan_bbt);
drivers/mtd/nand/nand_bch.c +18 -11
@@ -86,7 +86,7 @@ int nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, } }else if (count <0 ) {printk (KERN_ERR "ecc unrecoverable error\n" ); - count =-1 ; + count = -EBADMSG ; }return count; }
@@ -94,9 +94,6 @@ int nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf,/** * nand_bch_init - [NAND Interface] Initialize NAND BCH error correction * @mtd: MTD block structure -* @eccsize: ecc block size in bytes -* @eccbytes: ecc length in bytes -* @ecclayout: output default layout * * Returns: * a pointer to a new NAND BCH control structure, or NULL upon failure
@@ -110,14 +107,21 @@ int nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf,* @eccsize = 512 (thus, m=13 is the smallest integer such that 2^m-1 > 512*8) * @eccbytes = 7 (7 bytes are required to store m*t = 13*4 = 52 bits) */ -struct nand_bch_control * -nand_bch_init (struct mtd_info *mtd,unsigned int eccsize,unsigned int eccbytes, -struct nand_ecclayout **ecclayout) +struct nand_bch_control *nand_bch_init (struct mtd_info *mtd) { +struct nand_chip *nand =mtd_to_nand (mtd);unsigned int m, t, eccsteps, i; -struct nand_ecclayout *layout; +struct nand_ecclayout *layout = nand->ecc.layout;struct nand_bch_control *nbc =NULL ;unsigned char *erased_page; +unsigned int eccsize = nand->ecc.size; +unsigned int eccbytes = nand->ecc.bytes; +unsigned int eccstrength = nand->ecc.strength; + +if (!eccbytes && eccstrength) { + eccbytes =DIV_ROUND_UP (eccstrength *fls (8 * eccsize),8 ); + nand->ecc.bytes = eccbytes; + }if (!eccsize || !eccbytes) {printk (KERN_WARNING "ecc parameters not supplied\n" );
@@ -145,7 +149,7 @@ nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes, eccsteps = mtd->writesize/eccsize;/* if no ecc placement scheme was provided, build one */ -if (!*ecclayout) { +if (!layout) {/* handle large page devices only */ if (mtd->oobsize <64 ) {
@@ -171,7 +175,7 @@ nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes, layout->oobfree[0 ].offset =2 ; layout->oobfree[0 ].length = mtd->oobsize-2 -layout->eccbytes; - *ecclayout = layout; + nand->ecc.layout = layout; }/* sanity checks */
@@ -179,7 +183,7 @@ nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes,printk (KERN_WARNING "eccsize %u is too large\n" , eccsize); goto fail; } -if ((*ecclayout)->eccbytes != (eccsteps*eccbytes)) { +if (layout->eccbytes != (eccsteps*eccbytes)) {printk (KERN_WARNING "invalid ecc layout\n" ); goto fail; }
@@ -203,6 +207,9 @@ nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes,for (i =0 ; i < eccbytes; i++) nbc->eccmask[i] ^=0xff ; +if (!eccstrength) + nand->ecc.strength = (eccbytes *8 ) /fls (8 * eccsize); +return nbc; fail:nand_bch_free (nbc);
drivers/mtd/nand/nand_ids.c +6 -4
@@ -1,6 +1,4 @@/* -* drivers/mtd/nandids.c -* * Copyright (C) 2002 Thomas Gleixner (tglx at linutronix.de) * * This program is free software; you can redistribute it and/or modify
@@ -41,6 +39,10 @@ struct nand_flash_dev nand_flash_ids[] = {* listed by full ID. We list them first so that we can easily identify * the most specific match. */ + {"TC58NVG0S3E 1G 3.3V 8-bit" , + { .id = {0x98, 0xd1, 0x90, 0x15, 0x76, 0x14, 0x01, 0x00} }, +SZ_2K ,SZ_128 ,SZ_128K ,0 ,8 ,64 ,NAND_ECC_INFO (1 ,SZ_512 ), + 2 }, {"TC58NVG2S0F 4G 3.3V 8-bit", { .id = {0x98, 0xdc, 0x90, 0x26, 0x76, 0x15, 0x01, 0x08} }, SZ_4K, SZ_512, SZ_256K, 0, 8, 224, NAND_ECC_INFO(4, SZ_512) },
@@ -58,8 +60,8 @@ struct nand_flash_dev nand_flash_ids[] = { SZ_16K, SZ_8K, SZ_4M, 0, 6, 1280, NAND_ECC_INFO(40, SZ_1K) }, {"H27UCG8T2ATR-BC 64G 3.3V 8-bit" , { .id = {0xad, 0xde, 0x94, 0xda, 0x74, 0xc4} }, -SZ_8K ,SZ_8K ,SZ_2M ,0 ,6 ,640 ,NAND_ECC_INFO (40 ,SZ_1K ), - 4 }, +SZ_8K ,SZ_8K ,SZ_2M ,NAND_NEED_SCRAMBLING ,6 ,640 , + NAND_ECC_INFO(40, SZ_1K), 4 },LEGACY_ID_NAND ("NAND 4MiB 5V 8-bit" ,0x6B ,4 ,SZ_8K ,SP_OPTIONS ), LEGACY_ID_NAND("NAND 4MiB 3,3V 8-bit", 0xE3, 4, SZ_8K, SP_OPTIONS),
drivers/mtd/nand/ndfc.c +1 -1
@@ -1,6 +1,6 @@/* * Overview: -* Platform independend driver for NDFC (NanD Flash Controller) +* Platform independent driver for NDFC (NanD Flash Controller) * integrated into IBM/AMCC PPC4xx cores * * (C) Copyright 2006-2009
drivers/mtd/nand/omap_gpmc.c +1 -1
@@ -163,7 +163,7 @@ static int __maybe_unused omap_correct_data(struct mtd_info *mtd, uint8_t *dat,return 0 ;printf ("Error: Bad compare! failed\n" );/* detected 2 bit error */ -return -1 ; +return -EBADMSG ; } }return 0 ;
drivers/mtd/nand/s3c2410_nand.c +1 -1
@@ -104,7 +104,7 @@ static int s3c24x0_nand_correct_data(struct mtd_info *mtd, u_char *dat,return 0 ;printf ("s3c24x0_nand_correct_data: not implemented\n" ); - return -1; + return -EBADMSG; }#endif
drivers/mtd/nand/vf610_nfc.c +0 -1
@@ -146,7 +146,6 @@ enum vf610_nfc_alt_buf { };struct vf610_nfc { -struct mtd_info *mtd;struct nand_chip chip;void __iomem *regs;uint buf_offset;
include/linux/mtd/mtd.h +5 -0
@@ -278,6 +278,11 @@ struct mtd_info {int usecount; }; +static inline int mtd_oobavail (struct mtd_info *mtd,struct mtd_oob_ops *ops) +{ +return ops->mode ==MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize; +} +int mtd_erase (struct mtd_info *mtd,struct erase_info *instr);#ifndef __UBOOT__ int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
include/linux/mtd/nand.h +41 -24
172 lines not on this page · raw message
include/linux/mtd/nand_bch.h +3 -7
@@ -32,9 +32,7 @@ int nand_bch_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc,/* * Initialize BCH encoder/decoder */ -struct nand_bch_control * -nand_bch_init (struct mtd_info *mtd,unsigned int eccsize, -unsigned int eccbytes,struct nand_ecclayout **ecclayout); +struct nand_bch_control *nand_bch_init (struct mtd_info *mtd);/* * Release BCH encoder/decoder resources */
@@ -55,12 +53,10 @@ static inline int nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, unsigned char *read_ecc, unsigned char *calc_ecc) { - return -1; + return -ENOTSUPP; } -static inline struct nand_bch_control * -nand_bch_init (struct mtd_info *mtd,unsigned int eccsize, -unsigned int eccbytes,struct nand_ecclayout **ecclayout) +static inline struct nand_bch_control *nand_bch_init (struct mtd_info *mtd) {return NULL ; }
Signature · 1 line
2.5.0
PATCH 7/7 mtd: nand: Sync with Linux v4.6
Hello Scott,
Am 30.05.2016 um 20:57 schrieb Scott Wood:
Quoted 22 lines
Updates the NAND code to match Linux v4.6. The previous sync was from Linux v4.1 in commit
d3963721d93fafa.Note that none of the individual NAND drivers tracked Linux closely enough to be synced themselves, other than manually applying a few cross-tree changes.
Signed-off-by Scott Wood <[email protected]>--- drivers/mtd/nand/atmel_nand.c | 6 +- drivers/mtd/nand/davinci_nand.c | 6 +- drivers/mtd/nand/denali.c | 39 +++-- drivers/mtd/nand/denali.h | 1 - drivers/mtd/nand/denali_spl.c | 2 +- drivers/mtd/nand/mpc5121_nfc.c | 1 - drivers/mtd/nand/mxc_nand.c | 5 +- drivers/mtd/nand/mxc_nand_spl.c | 2 +- drivers/mtd/nand/mxs_nand.c | 2 +- drivers/mtd/nand/nand_base.c | 329 ++++++++++++++++++++++++++++------------ drivers/mtd/nand/nand_bbt.c | 30 ++-- drivers/mtd/nand/nand_bch.c | 29 ++-- drivers/mtd/nand/nand_ids.c | 10 +-
Quoted 8 lines
drivers/mtd/nand/ndfc.c | 2 +- drivers/mtd/nand/omap_gpmc.c | 2 +- drivers/mtd/nand/s3c2410_nand.c | 2 +- drivers/mtd/nand/vf610_nfc.c | 1 - include/linux/mtd/mtd.h | 5 + include/linux/mtd/nand.h | 65 +++++--- include/linux/mtd/nand_bch.h | 10 +- 20 files changed, 347 insertions(+), 202 deletions(-)
Thanks for your work!
I tested this series on the imx6 based aristainetos board incl. some basic UBI/UBIFS tests with tbot[1] without errors:
http://xeidos.ddns.net/tests/test_db_auslesen.php#41
beside some checkpatchwarnings:
(you must press on the "[+] control" link, block does not yet unblock
automagically ...)
http://xeidos.ddns.net/tbot/id_41/html_log.html#96
http://xeidos.ddns.net/tbot/id_41/html_log.html#116
http://xeidos.ddns.net/tbot/id_41/html_log.html#136
I currently disable failing tbot on checkpatch warnings/errors, as I think this warnings are from linux... or?
UBI Testcases (with first testing on nand) start at:
http://xeidos.ddns.net/tbot/id_41/html_log.html#212
So you can add my
to your series.
More tbot nand testcases appreciated ;-)
I am rebasing my patchseries for the siemens boards (am335x and at91 based boards) to current mainline and your patchset and test them on this boards, and send the results soon.
bye,
Heiko
[1] tbot
https://github.com/hsdenx/tbot/commits/master
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH 7/7 mtd: nand: Sync with Linux v4.6
Quoted 49 lines · Heiko Schocher
Hello Scott,
Am 30.05.2016 um 20:57 schrieb Scott Wood:
Quoted 23 lines
Updates the NAND code to match Linux v4.6. The previous sync was from Linux v4.1 in commit
d3963721d93fafa.Note that none of the individual NAND drivers tracked Linux closely enough to be synced themselves, other than manually applying a few cross-tree changes.
Signed-off-by Scott Wood <[email protected]>--- drivers/mtd/nand/atmel_nand.c | 6 +- drivers/mtd/nand/davinci_nand.c | 6 +- drivers/mtd/nand/denali.c | 39 +++-- drivers/mtd/nand/denali.h | 1 - drivers/mtd/nand/denali_spl.c | 2 +- drivers/mtd/nand/mpc5121_nfc.c | 1 - drivers/mtd/nand/mxc_nand.c | 5 +- drivers/mtd/nand/mxc_nand_spl.c | 2 +- drivers/mtd/nand/mxs_nand.c | 2 +- drivers/mtd/nand/nand_base.c | 329 ++++++++++++++++++++++++++++------ ------ drivers/mtd/nand/nand_bbt.c | 30 ++-- drivers/mtd/nand/nand_bch.c | 29 ++-- drivers/mtd/nand/nand_ids.c | 10 +-Quoted 8 lines
drivers/mtd/nand/ndfc.c | 2 +- drivers/mtd/nand/omap_gpmc.c | 2 +- drivers/mtd/nand/s3c2410_nand.c | 2 +- drivers/mtd/nand/vf610_nfc.c | 1 - include/linux/mtd/mtd.h | 5 + include/linux/mtd/nand.h | 65 +++++--- include/linux/mtd/nand_bch.h | 10 +- 20 files changed, 347 insertions(+), 202 deletions(-)Thanks for your work!
I tested this series on the imx6 based aristainetos board incl. some basic UBI/UBIFS tests with tbot[1] without errors:
http://xeidos.ddns.net/tests/test_db_auslesen.php#41
beside some checkpatchwarnings:
(you must press on the "[+] control" link, block does not yet unblock
automagically ...)
http://xeidos.ddns.net/tbot/id_41/html_log.html#96
http://xeidos.ddns.net/tbot/id_41/html_log.html#116
http://xeidos.ddns.net/tbot/id_41/html_log.html#136
Quoted 2 lines
I currently disable failing tbot on checkpatch warnings/errors, as I think this warnings are from linux... or?
The warnings are from (mostly minor) style problems in the existing U-Boot code, that weren't fixed when a (largely automatically generated with Coccinelle) patch did some search and replace.
-Scott
PATCH 7/7 mtd: nand: Sync with Linux v4.6
In reply to Scott WoodHi Scott,
Quoted 6 lines · On Mon, 30 May 2016 13:57:58 -0500 Scott Wood <[email protected]> wrote:
Updates the NAND code to match Linux v4.6. The previous sync was from Linux v4.1 in commit
d3963721d93fafa.Note that none of the individual NAND drivers tracked Linux closely enough to be synced themselves, other than manually applying a few cross-tree changes.
Nice work!
I'll port my sunxi NAND controller driver on top of these changes and test it.
Thanks a lot.
Boris
Quoted 1,426 lines
Signed-off-by Scott Wood <[email protected]>--- drivers/mtd/nand/atmel_nand.c | 6 +- drivers/mtd/nand/davinci_nand.c | 6 +- drivers/mtd/nand/denali.c | 39 +++-- drivers/mtd/nand/denali.h | 1 - drivers/mtd/nand/denali_spl.c | 2 +- drivers/mtd/nand/mpc5121_nfc.c | 1 - drivers/mtd/nand/mxc_nand.c | 5 +- drivers/mtd/nand/mxc_nand_spl.c | 2 +- drivers/mtd/nand/mxs_nand.c | 2 +- drivers/mtd/nand/nand_base.c | 329 ++++++++++++++++++++++++++++------------ drivers/mtd/nand/nand_bbt.c | 30 ++-- drivers/mtd/nand/nand_bch.c | 29 ++-- drivers/mtd/nand/nand_ids.c | 10 +- drivers/mtd/nand/ndfc.c | 2 +- drivers/mtd/nand/omap_gpmc.c | 2 +- drivers/mtd/nand/s3c2410_nand.c | 2 +- drivers/mtd/nand/vf610_nfc.c | 1 - include/linux/mtd/mtd.h | 5 + include/linux/mtd/nand.h | 65 +++++--- include/linux/mtd/nand_bch.h | 10 +- 20 files changed, 347 insertions(+), 202 deletions(-)drivers/mtd/nand/atmel_nand.c +3
-3@@ -513,7 +513,7 @@ normal_check:if (err_nbr ==-1 ) {dev_err (host->dev,"PMECC: Too many errors\n" ); mtd->ecc_stats.failed++; -return -EIO ; +return -EBADMSG ; }else {pmecc_correct_data (mtd, buf_pos, ecc, i, host->pmecc_bytes_per_sector, err_nbr);@@ -562,7 +562,7 @@ static int atmel_nand_pmecc_read_page(struct mtd_info *mtd, stat =pmecc_readl (host->pmecc, isr);if (stat !=0 )if (pmecc_correction (mtd, stat, buf, &oob[eccpos[0 ]]) !=0 ) -return -EIO ; +return -EBADMSG ;return 0 ; }@@ -1112,7 +1112,7 @@ static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,* We can't correct so many errors */ dev_warn (host->dev,"atmel_nand : multiple errors detected." " Unable to correct.\n" ); -return -EIO ; +return -EBADMSG ; }/* if there's a single bit error : we can correct it */ drivers/mtd/nand/davinci_nand.c +3
-3@@ -243,7 +243,7 @@ static int nand_davinci_correct_data(struct mtd_info *mtd, u_char *dat, "%d\n", find_byte, find_bit);return 1 ; }else { -return -1 ; +return -EBADMSG ; } }else if (!(diff & (diff -1 ))) {/* Single bit ECC error in the ECC itself, @@ -254,7 +254,7 @@ static int nand_davinci_correct_data(struct mtd_info *mtd, u_char *dat, }else {/* Uncorrectable error */ MTDDEBUG (MTD_DEBUG_LEVEL0 ,"ECC UNCORRECTED_ERROR 1\n" ); -return -1 ; +return -EBADMSG ; } }return 0 ;@@ -701,7 +701,7 @@ static int nand_davinci_4bit_correct_data(struct mtd_info *mtd, uint8_t *dat,return 0 ; }else if (iserror ==ECC_STATE_TOO_MANY_ERRS ) { val =__raw_readl (&davinci_emif_regs->nanderrval1); -return -1 ; +return -EBADMSG ; } numerrors = ((__raw_readl(&davinci_emif_regs->nandfsr) >> 16)drivers/mtd/nand/denali.c +17
-22@@ -48,8 +48,10 @@ static int onfi_timing_mode = NAND_DEFAULT_TIMINGS;* this macro allows us to convert from an MTD structure to our own * device context (denali) structure. */ -#define mtd_to_denali (m) \ - container_of(mtd_to_nand(m), struct denali_nand_info, nand) +static inline struct denali_nand_info *mtd_to_denali (struct mtd_info *mtd) +{ + return container_of(mtd_to_nand(mtd), struct denali_nand_info, nand); +}/* * These constants are defined by the driver to enable common driver @@ -866,8 +868,7 @@ static int write_page(struct mtd_info *mtd, struct nand_chip *chip,* by write_page above. */ static int denali_write_page (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required, -int page) +const uint8_t *buf,int oob_required,int page) {struct denali_nand_info *denali =mtd_to_denali (mtd);@@ -891,8 +892,8 @@ static int denali_write_page(struct mtd_info *mtd, struct nand_chip *chip,* write_page() function above. */ static int denali_write_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required, -int page) +const uint8_t *buf,int oob_required, +int page) {struct denali_nand_info *denali =mtd_to_denali (mtd);@@ -991,7 +992,7 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,debug (" ECC error cause by erased block\n" );/* false alarm, return the 0xFF */ }else { -return -EIO ; +return -EBADMSG ; } }memcpy (buf, denali->buf.dma_buf, mtd->writesize);@@ -1176,12 +1177,13 @@ static struct nand_ecclayout nand_oob;static int denali_init (struct denali_nand_info *denali) { +struct mtd_info *mtd =nand_to_mtd (&denali->nand);int ret;denali_hw_init (denali); - denali->mtd->name ="denali-nand" ; - denali->mtd->owner =THIS_MODULE ; + mtd->name ="denali-nand" ; + mtd->owner =THIS_MODULE ;/* register the driver with the NAND core subsystem */ denali->nand.select_chip = denali_select_chip;@@ -1195,7 +1197,7 @@ static int denali_init(struct denali_nand_info *denali)* this is the first stage in a two step process to register * with the nand subsystem */ -if (nand_scan_ident (denali->mtd, denali->max_banks,NULL )) { +if (nand_scan_ident (mtd, denali->max_banks,NULL )) { ret = -ENXIO ; goto fail; }@@ -1241,13 +1243,13 @@ static int denali_init(struct denali_nand_info *denali) nand_oob.eccbytes = denali->nand.ecc.bytes; denali->nand.ecc.layout = &nand_oob; -writel (denali->mtd->erasesize / denali->mtd->writesize, +writel (mtd->erasesize / mtd->writesize, denali->flash_reg +PAGES_PER_BLOCK );writel (denali->nand.options &NAND_BUSWIDTH_16 ?1 :0 , denali->flash_reg +DEVICE_WIDTH ); -writel (denali->mtd->writesize, +writel (mtd->writesize, denali->flash_reg +DEVICE_MAIN_AREA_SIZE ); -writel (denali->mtd->oobsize, +writel (mtd->oobsize, denali->flash_reg +DEVICE_SPARE_AREA_SIZE );if (readl (denali->flash_reg +DEVICES_CONNECTED ) ==0 )writel (1 , denali->flash_reg +DEVICES_CONNECTED );@@ -1260,12 +1262,12 @@ static int denali_init(struct denali_nand_info *denali) denali->nand.ecc.read_oob = denali_read_oob; denali->nand.ecc.write_oob = denali_write_oob; -if (nand_scan_tail (denali->mtd)) { +if (nand_scan_tail (mtd)) { ret = -ENXIO ; goto fail; } - ret =nand_register (0 , denali->mtd); + ret =nand_register (0 , mtd); fail:return ret;@@ -1280,13 +1282,6 @@ static int __board_nand_init(void)return -ENOMEM ;/* -* If CONFIG_SYS_NAND_SELF_INIT is defined, each driver is responsible -* for instantiating struct nand_chip, while drivers/mtd/nand/nand.c -* still provides a "struct mtd_info nand_info" instance. -*/ - denali->mtd = &denali->nand.mtd; - -/* * In the future, these base addresses should be taken from * Device Tree or platform data. */ drivers/mtd/nand/denali.h +0
-1@@ -436,7 +436,6 @@ struct nand_buf {#define DT 3struct denali_nand_info { -struct mtd_info *mtd;struct nand_chip nand;int flash_bank;/* currently selected chip */ int status;drivers/mtd/nand/denali_spl.c +1
-1@@ -41,7 +41,7 @@ static int wait_for_irq(uint32_t irq_mask)if (intr_status &INTR_STATUS__ECC_UNCOR_ERR ) {debug ("Uncorrected ECC detected\n" ); -return -EIO ; +return -EBADMSG ; }if (intr_status & irq_mask)drivers/mtd/nand/mpc5121_nfc.c +0
-1@@ -100,7 +100,6 @@#define NFC_WPC_UNLOCK (1 << 2)struct mpc5121_nfc_prv { -struct mtd_info mtd;struct nand_chip chip;int irq;void __iomem *regs;drivers/mtd/nand/mxc_nand.c +2
-3@@ -19,7 +19,6 @@#define DRIVER_NAME "mxc_nand"struct mxc_nand_host { -struct mtd_info mtd;struct nand_chip *nand;struct mxc_nand_regs __iomem *regs;@@ -681,7 +680,7 @@ static int mxc_nand_correct_data(struct mtd_info *mtd, u_char *dat, mtd->writesize / nand_chip->subpagesize - subpages); } -return -1 ; +return -EBADMSG ; } ecc_status >>=4 ; subpages--;@@ -713,7 +712,7 @@ static int mxc_nand_correct_data(struct mtd_info *mtd, u_char *dat,if (((ecc_status &0x3 ) ==2 ) || ((ecc_status >>2 ) ==2 )) {MTDDEBUG (MTD_DEBUG_LEVEL0 ,"MXC_NAND: HWECC uncorrectable 2-bit ECC error\n" ); -return -1 ; +return -EBADMSG ; }return 0 ;drivers/mtd/nand/mxc_nand_spl.c +1
-1@@ -232,7 +232,7 @@ static int nfc_read_page(unsigned int page_address, unsigned char *buf)nfc_nand_read_page (page_address);if (nfc_nand_check_ecc ()) -return -1 ; +return -EBADMSG ; src = (u32 *)&nfc->main_area[0 ][0 ]; dst = (u32 *)buf;drivers/mtd/nand/mxs_nand.c +1
-1@@ -961,7 +961,7 @@ static int mxs_nand_ecc_write_oob(struct mtd_info *mtd, struct nand_chip *nand,* Thus, this function is only called when we want *all* blocks to look good, * so it *always* return success. */ -static int mxs_nand_block_bad (struct mtd_info *mtd,loff_t ofs,int getchip) +static int mxs_nand_block_bad (struct mtd_info *mtd,loff_t ofs) {return 0 ; }drivers/mtd/nand/nand_base.c +228
-101@@ -1,6 +1,4 @@/* -* drivers/mtd/nand.c -* * Overview: * This is the generic MTD driver for NAND flash devices. It should be * capable of working with almost all NAND chips currently available. @@ -45,8 +43,6 @@#include <asm/io.h> #include <asm/errno.h> -static bool is_module_text_address (unsigned long addr) {return 0 ;} -/* Define default oob placement schemes for large and small page devices */ static struct nand_ecclayout nand_oob_8 = { .eccbytes =3 ,@@ -343,13 +339,12 @@ void nand_read_buf16(struct mtd_info *mtd, uint8_t *buf, int len)* nand_block_bad - [DEFAULT] Read bad block marker from the chip * @mtd: MTD device structure * @ofs: offset from device start -* @getchip: 0, if the chip is already selected * * Check, if the block is bad. */ -static int nand_block_bad (struct mtd_info *mtd,loff_t ofs,int getchip) +static int nand_block_bad (struct mtd_info *mtd,loff_t ofs) { -int page, chipnr, res =0 , i =0 ; +int page, res =0 , i =0 ;struct nand_chip *chip =mtd_to_nand (mtd);u16 bad;@@ -358,15 +353,6 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) page = (int )(ofs >> chip->page_shift) & chip->pagemask; -if (getchip) { - chipnr = (int )(ofs >> chip->chip_shift); - -nand_get_device (mtd,FL_READING ); - -/* Select the NAND device */ - chip->select_chip (mtd, chipnr); - } - do { if (chip->options & NAND_BUSWIDTH_16) { chip->cmdfunc(mtd, NAND_CMD_READOOB,@@ -391,11 +377,6 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) i++; }while (!res && i <2 && (chip->bbt_options &NAND_BBT_SCAN2NDPAGE )); -if (getchip) { - chip->select_chip (mtd,-1 ); -nand_release_device (mtd); - } -return res; }@@ -533,14 +514,12 @@ static int nand_block_isreserved(struct mtd_info *mtd, loff_t ofs)* nand_block_checkbad - [GENERIC] Check if a block is marked bad * @mtd: MTD device structure * @ofs: offset from device start -* @getchip: 0, if the chip is already selected * @allowbbt: 1, if its allowed to access the bbt area * * Check, if the block is bad. Either by reading the bad block table or * calling of the scan function. */ -static int nand_block_checkbad (struct mtd_info *mtd,loff_t ofs,int getchip, -int allowbbt) +static int nand_block_checkbad (struct mtd_info *mtd,loff_t ofs,int allowbbt) {struct nand_chip *chip =mtd_to_nand (mtd);@@ -551,17 +530,22 @@ static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip, }if (!chip->bbt) -return chip->block_bad (mtd, ofs, getchip); +return chip->block_bad (mtd, ofs);/* Return info from the table */ return nand_isbad_bbt (mtd, ofs, allowbbt); } -/* Wait for the ready pin, after a command. The timeout is caught later. */ +/** +* nand_wait_ready - [GENERIC] Wait for the ready pin after commands. +* @mtd: MTD device structure +* +* Wait for the ready pin after a command, and warn if a timeout occurs. +*/ void nand_wait_ready (struct mtd_info *mtd) {struct nand_chip *chip =mtd_to_nand (mtd); -u32 timeo = (CONFIG_SYS_HZ *20 ) /1000 ; +u32 timeo = (CONFIG_SYS_HZ *400 ) /1000 ;u32 time_start; time_start =get_timer (0 );@@ -571,6 +555,9 @@ void nand_wait_ready(struct mtd_info *mtd)if (chip->dev_ready (mtd))break ; } + +if (!chip->dev_ready (mtd)) +pr_warn ("timeout while waiting for chip to become ready\n" ); }EXPORT_SYMBOL_GPL (nand_wait_ready);@@ -871,15 +858,13 @@ static void panic_nand_wait(struct mtd_info *mtd, struct nand_chip *chip,* @mtd: MTD device structure * @chip: NAND chip structure * -* Wait for command done. This applies to erase and program only. Erase can -* take up to 400ms and program up to 20ms according to general NAND and -* SmartMedia specs. +* Wait for command done. This applies to erase and program only. */ static int nand_wait (struct mtd_info *mtd,struct nand_chip *chip) { -int status, state = chip->state; -unsigned long timeo = (state ==FL_ERASING ?400 :20 ); +int status; +unsigned long timeo =400 ;led_trigger_event (nand_led_trigger,LED_FULL );@@ -912,6 +897,135 @@ static int nand_wait(struct mtd_info *mtd, struct nand_chip *chip)return status; } +#define BITS_PER_BYTE 8 + +/** +* nand_check_erased_buf - check if a buffer contains (almost) only 0xff data +* @buf: buffer to test +* @len: buffer length +* @bitflips_threshold: maximum number of bitflips +* +* Check if a buffer contains only 0xff, which means the underlying region +* has been erased and is ready to be programmed. +* The bitflips_threshold specify the maximum number of bitflips before +* considering the region is not erased. +* Note: The logic of this function has been extracted from the memweight +* implementation, except that nand_check_erased_buf function exit before +* testing the whole buffer if the number of bitflips exceed the +* bitflips_threshold value. +* +* Returns a positive number of bitflips less than or equal to +* bitflips_threshold, or -ERROR_CODE for bitflips in excess of the +* threshold. +*/ +static int nand_check_erased_buf (void *buf,int len,int bitflips_threshold) +{ +const unsigned char *bitmap = buf; +int bitflips =0 ; +int weight; + +for (; len && ((uintptr_t )bitmap) %sizeof (long ); + len--, bitmap++) { + weight =hweight8 (*bitmap); + bitflips +=BITS_PER_BYTE - weight; +if (unlikely (bitflips > bitflips_threshold)) +return -EBADMSG ; + } + +for (; len >=4 ; len -=4 , bitmap +=4 ) { + weight =hweight32 (*((u32 *)bitmap)); + bitflips +=32 - weight; +if (unlikely (bitflips > bitflips_threshold)) +return -EBADMSG ; + } + +for (; len >0 ; len--, bitmap++) { + weight =hweight8 (*bitmap); + bitflips +=BITS_PER_BYTE - weight; +if (unlikely (bitflips > bitflips_threshold)) +return -EBADMSG ; + } + +return bitflips; +} + +/** +* nand_check_erased_ecc_chunk - check if an ECC chunk contains (almost) only +* 0xff data +* @data: data buffer to test +* @datalen: data length +* @ecc: ECC buffer +* @ecclen: ECC length +* @extraoob: extra OOB buffer +* @extraooblen: extra OOB length +* @bitflips_threshold: maximum number of bitflips +* +* Check if a data buffer and its associated ECC and OOB data contains only +* 0xff pattern, which means the underlying region has been erased and is +* ready to be programmed. +* The bitflips_threshold specify the maximum number of bitflips before +* considering the region as not erased. +* +* Note: +* 1/ ECC algorithms are working on pre-defined block sizes which are usually +* different from the NAND page size. When fixing bitflips, ECC engines will +* report the number of errors per chunk, and the NAND core infrastructure +* expect you to return the maximum number of bitflips for the whole page. +* This is why you should always use this function on a single chunk and +* not on the whole page. After checking each chunk you should update your +* max_bitflips value accordingly. +* 2/ When checking for bitflips in erased pages you should not only check +* the payload data but also their associated ECC data, because a user might +* have programmed almost all bits to 1 but a few. In this case, we +* shouldn't consider the chunk as erased, and checking ECC bytes prevent +* this case. +* 3/ The extraoob argument is optional, and should be used if some of your OOB +* data are protected by the ECC engine. +* It could also be used if you support subpages and want to attach some +* extra OOB data to an ECC chunk. +* +* Returns a positive number of bitflips less than or equal to +* bitflips_threshold, or -ERROR_CODE for bitflips in excess of the +* threshold. In case of success, the passed buffers are filled with 0xff. +*/ +int nand_check_erased_ecc_chunk (void *data,int datalen, +void *ecc,int ecclen, +void *extraoob,int extraooblen, +int bitflips_threshold) +{ +int data_bitflips =0 , ecc_bitflips =0 , extraoob_bitflips =0 ; + + data_bitflips =nand_check_erased_buf (data, datalen, + bitflips_threshold); +if (data_bitflips <0 ) +return data_bitflips; + + bitflips_threshold -= data_bitflips; + + ecc_bitflips =nand_check_erased_buf (ecc, ecclen, bitflips_threshold); +if (ecc_bitflips <0 ) +return ecc_bitflips; + + bitflips_threshold -= ecc_bitflips; + + extraoob_bitflips =nand_check_erased_buf (extraoob, extraooblen, + bitflips_threshold); +if (extraoob_bitflips <0 ) +return extraoob_bitflips; + +if (data_bitflips) +memset (data,0xff , datalen); + +if (ecc_bitflips) +memset (ecc,0xff , ecclen); + +if (extraoob_bitflips) +memset (extraoob,0xff , extraooblen); + +return data_bitflips + ecc_bitflips + extraoob_bitflips; +} +EXPORT_SYMBOL (nand_check_erased_ecc_chunk); +/** * nand_read_page_raw - [INTERN] read raw page data without ecc * @mtd: mtd info structure @@ -1103,6 +1217,16 @@ static int nand_read_subpage(struct mtd_info *mtd, struct nand_chip *chip, stat = chip->ecc.correct (mtd, p, &chip->buffers->ecccode[i], &chip->buffers->ecccalc[i]); +if (stat == -EBADMSG && + (chip->ecc.options &NAND_ECC_GENERIC_ERASED_CHECK )) { +/* check for empty pages with bitflips */ + stat =nand_check_erased_ecc_chunk (p, chip->ecc.size, + &chip->buffers->ecccode[i], + chip->ecc.bytes, +NULL ,0 , + chip->ecc.strength); + } +if (stat <0 ) { mtd->ecc_stats.failed++; }else {@@ -1152,6 +1276,15 @@ static int nand_read_page_hwecc(struct mtd_info *mtd, struct nand_chip *chip,int stat; stat = chip->ecc.correct (mtd, p, &ecc_code[i], &ecc_calc[i]); +if (stat == -EBADMSG && + (chip->ecc.options &NAND_ECC_GENERIC_ERASED_CHECK )) { +/* check for empty pages with bitflips */ + stat =nand_check_erased_ecc_chunk (p, eccsize, + &ecc_code[i], eccbytes, +NULL ,0 , + chip->ecc.strength); + } +if (stat <0 ) { mtd->ecc_stats.failed++; }else {@@ -1204,6 +1337,15 @@ static int nand_read_page_hwecc_oob_first(struct mtd_info *mtd, chip->ecc.calculate (mtd, p, &ecc_calc[i]); stat = chip->ecc.correct (mtd, p, &ecc_code[i],NULL ); +if (stat == -EBADMSG && + (chip->ecc.options &NAND_ECC_GENERIC_ERASED_CHECK )) { +/* check for empty pages with bitflips */ + stat =nand_check_erased_ecc_chunk (p, eccsize, + &ecc_code[i], eccbytes, +NULL ,0 , + chip->ecc.strength); + } +if (stat <0 ) { mtd->ecc_stats.failed++; }else {@@ -1231,6 +1373,7 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip,int i, eccsize = chip->ecc.size;int eccbytes = chip->ecc.bytes;int eccsteps = chip->ecc.steps; +int eccpadbytes = eccbytes + chip->ecc.prepad + chip->ecc.postpad;uint8_t *p = buf;uint8_t *oob = chip->oob_poi;unsigned int max_bitflips =0 ;@@ -1250,19 +1393,29 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip, chip->read_buf (mtd, oob, eccbytes); stat = chip->ecc.correct (mtd, p, oob,NULL ); -if (stat <0 ) { - mtd->ecc_stats.failed++; - }else { - mtd->ecc_stats.corrected += stat; - max_bitflips = max_t(unsigned int, max_bitflips, stat); - } - oob += eccbytes;if (chip->ecc.postpad) { chip->read_buf (mtd, oob, chip->ecc.postpad); oob += chip->ecc.postpad; } + +if (stat == -EBADMSG && + (chip->ecc.options &NAND_ECC_GENERIC_ERASED_CHECK )) { +/* check for empty pages with bitflips */ + stat =nand_check_erased_ecc_chunk (p, chip->ecc.size, + oob - eccpadbytes, + eccpadbytes, +NULL ,0 , + chip->ecc.strength); + } + +if (stat <0 ) { + mtd->ecc_stats.failed++; + }else { + mtd->ecc_stats.corrected += stat; + max_bitflips = max_t(unsigned int, max_bitflips, stat); + } }/* Calculate remaining oob bytes */ @@ -1361,8 +1514,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,int ret =0 ;uint32_t readlen = ops->len;uint32_t oobreadlen = ops->ooblen; -uint32_t max_oobsize = ops->mode ==MTD_OPS_AUTO_OOB ? - mtd->oobavail : mtd->oobsize; +uint32_t max_oobsize =mtd_oobavail (mtd, ops);uint8_t *bufpoi, *oob, *buf;int use_bufpoi;@@ -1712,10 +1864,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, stats = mtd->ecc_stats; -if (ops->mode ==MTD_OPS_AUTO_OOB ) - len = chip->ecc.layout->oobavail; -else - len = mtd->oobsize; + len =mtd_oobavail (mtd, ops);if (unlikely (ops->ooboffs >= len)) { pr_debug("%s: attempt to start read outside oob\n",@@ -1845,8 +1994,7 @@ out:* Not for syndrome calculating ECC controllers, which use a special oob layout. */ static int nand_write_page_raw (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required, -int page) +const uint8_t *buf,int oob_required,int page) { chip->write_buf (mtd, buf, mtd->writesize);if (oob_required)@@ -1861,6 +2009,7 @@ static int nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,* @chip: nand chip info structure * @buf: data buffer * @oob_required: must write chip->oob_poi to OOB +* @page: page number to write * * We need a special oob layout and handling even when ECC isn't checked. */ @@ -1907,8 +2056,8 @@ static int nand_write_page_raw_syndrome(struct mtd_info *mtd,* @page: page number to write */ static int nand_write_page_swecc (struct mtd_info *mtd,struct nand_chip *chip, -const uint8_t *buf,int oob_required, -int page) +const uint8_t *buf,int oob_required, +int page) {int i, eccsize = chip->ecc.size;int eccbytes = chip->ecc.bytes;@@ -2029,6 +2178,7 @@ static int nand_write_subpage_hwecc(struct mtd_info *mtd,* @chip: nand chip info structure * @buf: data buffer * @oob_required: must write chip->oob_poi to OOB +* @page: page number to write * * The hw generator calculates the error syndrome automatically. Therefore we * need a special oob layout and handling. @@ -2103,7 +2253,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, oob_required, page); else if (subpage) status = chip->ecc.write_subpage (mtd, chip, offset, data_len, - buf, oob_required, page); + buf, oob_required, page); else status = chip->ecc.write_page (mtd, chip, buf, oob_required, page);@@ -2145,7 +2295,6 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,* @oob: oob data buffer * @len: oob data write length * @ops: oob ops structure -* @page: page number to write */ static uint8_t *nand_fill_oob (struct mtd_info *mtd,uint8_t *oob,size_t len,struct mtd_oob_ops *ops)@@ -2214,8 +2363,7 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,uint32_t writelen = ops->len;uint32_t oobwritelen = ops->ooblen; -uint32_t oobmaxlen = ops->mode ==MTD_OPS_AUTO_OOB ? - mtd->oobavail : mtd->oobsize; +uint32_t oobmaxlen =mtd_oobavail (mtd, ops);uint8_t *oob = ops->oobbuf;uint8_t *buf = ops->datbuf;@@ -2404,10 +2552,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,pr_debug ("%s: to = 0x%08x, len = %i\n" , __func__, (unsigned int )to, (int )ops->ooblen); -if (ops->mode ==MTD_OPS_AUTO_OOB ) - len = chip->ecc.layout->oobavail; -else - len = mtd->oobsize; + len =mtd_oobavail (mtd, ops);/* Do not allow write past end of page */ if ((ops->ooboffs + ops->ooblen) > len) {@@ -2597,7 +2742,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,/* Check if we have a bad block, we do not erase bad blocks! */ if (!instr->scrub &&nand_block_checkbad (mtd, ((loff_t ) page) << - chip->page_shift,0 , allowbbt)) { + chip->page_shift, allowbbt)) {pr_warn ("%s: attempt to erase a bad block at page 0x%08x\n" , __func__, page); instr->state =MTD_ERASE_FAILED ;@@ -2684,7 +2829,20 @@ static void nand_sync(struct mtd_info *mtd)*/ static int nand_block_isbad (struct mtd_info *mtd,loff_t offs) { -return nand_block_checkbad (mtd, offs,1 ,0 ); +struct nand_chip *chip =mtd_to_nand (mtd); +int chipnr = (int )(offs >> chip->chip_shift); +int ret; + +/* Select the NAND device */ +nand_get_device (mtd,FL_READING ); + chip->select_chip (mtd, chipnr); + + ret =nand_block_checkbad (mtd, offs,0 ); + + chip->select_chip (mtd,-1 ); +nand_release_device (mtd); + +return ret; }/** @@ -2756,9 +2914,6 @@ static int nand_onfi_get_features(struct mtd_info *mtd, struct nand_chip *chip,return -EINVAL ;#endif -/* clear the sub feature parameters */ -memset (subfeature_param,0 ,ONFI_SUBFEATURE_PARAM_LEN ); - chip->cmdfunc (mtd,NAND_CMD_GET_FEATURES , addr,-1 );for (i =0 ; i <ONFI_SUBFEATURE_PARAM_LEN ; ++i) *subfeature_param++ = chip->read_byte (mtd);@@ -3491,7 +3646,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,if (find_full_id_nand (mtd, chip, type, id_data, &busw)) goto ident_done; }else if (*dev_id == type->dev_id) { -break ; +break ; } }@@ -3514,10 +3669,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, chip->chipsize = (uint64_t )type->chipsize <<20 ; -if (!type->pagesize && chip->init_size) { -/* Set the pagesize, oobsize, erasesize by the driver */ - busw = chip->init_size (mtd, chip, id_data); - }else if (!type->pagesize) { +if (!type->pagesize) {/* Decode parameters from extended ID */ nand_decode_ext_id (mtd, chip, id_data, &busw); }else {@@ -3621,7 +3773,6 @@ ident_done:* This is the first phase of the normal nand_scan() function. It reads the * flash ID and sets up MTD fields accordingly. * -* The mtd->owner field must be set to the module of the caller. */ int nand_scan_ident (struct mtd_info *mtd,int maxchips,struct nand_flash_dev *table)@@ -3797,7 +3948,7 @@ int nand_scan_tail(struct mtd_info *mtd) ecc->write_oob = nand_write_oob_std;if (!ecc->read_subpage) ecc->read_subpage = nand_read_subpage; -if (!ecc->write_subpage) +if (!ecc->write_subpage && ecc->hwctl && ecc->calculate) ecc->write_subpage = nand_write_subpage_hwecc;case NAND_ECC_HW_SYNDROME :@@ -3875,10 +4026,8 @@ int nand_scan_tail(struct mtd_info *mtd) }/* See nand_bch_init() for details. */ - ecc->bytes =DIV_ROUND_UP ( - ecc->strength *fls (8 * ecc->size),8 ); - ecc->priv =nand_bch_init (mtd, ecc->size, ecc->bytes, - &ecc->layout); + ecc->bytes =0 ; + ecc->priv =nand_bch_init (mtd);if (!ecc->priv) {pr_warn ("BCH ECC initialization failed!\n" );BUG ();@@ -3913,11 +4062,11 @@ int nand_scan_tail(struct mtd_info *mtd)* The number of bytes available for a client to place data into * the out of band area. */ - ecc->layout->oobavail =0 ; -for (i =0 ; ecc->layout->oobfree[i].length - && i <ARRAY_SIZE (ecc->layout->oobfree); i++) - ecc->layout->oobavail += ecc->layout->oobfree[i].length; - mtd->oobavail = ecc->layout->oobavail; + mtd->oobavail =0 ; +if (ecc->layout) { +for (i =0 ; ecc->layout->oobfree[i].length; i++) + mtd->oobavail += ecc->layout->oobfree[i].length; + }/* ECC sanity check: warn if it's too weak */ if (!nand_ecc_strength_good (mtd))@@ -4002,18 +4151,6 @@ int nand_scan_tail(struct mtd_info *mtd) }EXPORT_SYMBOL (nand_scan_tail); -/* -* is_module_text_address() isn't exported, and it's mostly a pointless -* test if this is a module _anyway_ -- they'd have to try _really_ hard -* to call us from in-kernel code if the core NAND support is modular. -*/ -#ifdef MODULE -#define caller_is_module () (1) -#else -#define caller_is_module () \ - is_module_text_address((unsigned long)__builtin_return_address(0)) -#endif -/** * nand_scan - [NAND Interface] Scan for the NAND device * @mtd: MTD device structure @@ -4021,19 +4158,12 @@ EXPORT_SYMBOL(nand_scan_tail);* * This fills out all the uninitialized function pointers with the defaults. * The flash ID is read and the mtd/chip structures are filled with the -* appropriate values. The mtd->owner field must be set to the module of the -* caller. +* appropriate values. */ int nand_scan (struct mtd_info *mtd,int maxchips) {int ret; -/* Many callers got this wrong, so check for it for a while... */ -if (!mtd->owner &&caller_is_module ()) { -pr_crit ("%s called with NULL mtd->owner!\n" , __func__); -BUG (); - } - ret =nand_scan_ident (mtd, maxchips,NULL );if (!ret) ret =nand_scan_tail (mtd);@@ -4041,9 +4171,6 @@ int nand_scan(struct mtd_info *mtd, int maxchips) }EXPORT_SYMBOL (nand_scan); -module_init (nand_base_init); -module_exit (nand_base_exit); -MODULE_LICENSE ("GPL" );MODULE_AUTHOR ("Steven J. Hill <[email protected]>" );MODULE_AUTHOR ("Thomas Gleixner <[email protected]>" );drivers/mtd/nand/nand_bbt.c +15
-15@@ -1,6 +1,4 @@/* -* drivers/mtd/nand_bbt.c -* * Overview: * Bad block table support for the NAND driver * @@ -65,7 +63,6 @@#include <linux/mtd/mtd.h> #include <linux/mtd/bbm.h> #include <linux/mtd/nand.h> -#include <linux/mtd/nand_ecc.h> #include <linux/bitops.h> #include <linux/string.h> @@ -718,7 +715,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,/* Must we save the block contents? */ if (td->options &NAND_BBT_SAVECONTENT ) {/* Make it block aligned */ - to &= ~((loff_t)((1 << this->bbt_erase_shift) -1 )); + to &= ~(((loff_t )1 << this->bbt_erase_shift) -1 ); len =1 << this->bbt_erase_shift; res =mtd_read (mtd, to, len, &retlen, buf);if (res <0 ) {@@ -1073,15 +1070,15 @@ static void verify_bbt_descr(struct mtd_info *mtd, struct nand_bbt_descr *bd)* The bad block table memory is allocated here. It must be freed by calling * the nand_free_bbt function. */ -int nand_scan_bbt (struct mtd_info *mtd,struct nand_bbt_descr *bd) +static int nand_scan_bbt (struct mtd_info *mtd,struct nand_bbt_descr *bd) {struct nand_chip *this =mtd_to_nand (mtd); -int len, res =0 ; +int len, res;uint8_t *buf;struct nand_bbt_descr *td = this->bbt_td;struct nand_bbt_descr *md = this->bbt_md; - len = mtd->size >> (this->bbt_erase_shift +2 ); + len = (mtd->size >> (this->bbt_erase_shift +2 )) ? :1 ;/* * Allocate memory (2bit per block) and clear the memory bad block * table. @@ -1097,10 +1094,9 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)if (!td) {if ((res =nand_memory_bbt (mtd, bd))) {pr_err ("nand_bbt: can't scan flash and build the RAM-based BBT\n" ); -kfree (this->bbt); - this->bbt =NULL ; + goto err; } -return res; +return 0 ; }verify_bbt_descr (mtd, td);verify_bbt_descr (mtd, md);@@ -1110,9 +1106,8 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) len += (len >> this->page_shift) * mtd->oobsize; buf =vmalloc (len);if (!buf) { -kfree (this->bbt); - this->bbt =NULL ; -return -ENOMEM ; + res = -ENOMEM ; + goto err; }/* Is the bbt at a given page? */ @@ -1124,6 +1119,8 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) } res =check_create (mtd, buf, bd); +if (res) + goto err;/* Prevent the bbt regions from erasing / writing */ mark_bbt_region (mtd, td);@@ -1131,6 +1128,11 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)mark_bbt_region (mtd, md);vfree (buf); +return 0 ; + +err: +kfree (this->bbt); + this->bbt =NULL ;return res; }@@ -1369,5 +1371,3 @@ int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs)return ret; } - -EXPORT_SYMBOL (nand_scan_bbt);drivers/mtd/nand/nand_bch.c +18
-11@@ -86,7 +86,7 @@ int nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, } }else if (count <0 ) {printk (KERN_ERR "ecc unrecoverable error\n" ); - count =-1 ; + count = -EBADMSG ; }return count; }@@ -94,9 +94,6 @@ int nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf,/** * nand_bch_init - [NAND Interface] Initialize NAND BCH error correction * @mtd: MTD block structure -* @eccsize: ecc block size in bytes -* @eccbytes: ecc length in bytes -* @ecclayout: output default layout * * Returns: * a pointer to a new NAND BCH control structure, or NULL upon failure @@ -110,14 +107,21 @@ int nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf,* @eccsize = 512 (thus, m=13 is the smallest integer such that 2^m-1 > 512*8) * @eccbytes = 7 (7 bytes are required to store m*t = 13*4 = 52 bits) */ -struct nand_bch_control * -nand_bch_init (struct mtd_info *mtd,unsigned int eccsize,unsigned int eccbytes, -struct nand_ecclayout **ecclayout) +struct nand_bch_control *nand_bch_init (struct mtd_info *mtd) { +struct nand_chip *nand =mtd_to_nand (mtd);unsigned int m, t, eccsteps, i; -struct nand_ecclayout *layout; +struct nand_ecclayout *layout = nand->ecc.layout;struct nand_bch_control *nbc =NULL ;unsigned char *erased_page; +unsigned int eccsize = nand->ecc.size; +unsigned int eccbytes = nand->ecc.bytes; +unsigned int eccstrength = nand->ecc.strength; + +if (!eccbytes && eccstrength) { + eccbytes =DIV_ROUND_UP (eccstrength *fls (8 * eccsize),8 ); + nand->ecc.bytes = eccbytes; + }if (!eccsize || !eccbytes) {printk (KERN_WARNING "ecc parameters not supplied\n" );@@ -145,7 +149,7 @@ nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes, eccsteps = mtd->writesize/eccsize;/* if no ecc placement scheme was provided, build one */ -if (!*ecclayout) { +if (!layout) {/* handle large page devices only */ if (mtd->oobsize <64 ) {@@ -171,7 +175,7 @@ nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes, layout->oobfree[0 ].offset =2 ; layout->oobfree[0 ].length = mtd->oobsize-2 -layout->eccbytes; - *ecclayout = layout; + nand->ecc.layout = layout; }/* sanity checks */ @@ -179,7 +183,7 @@ nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes,printk (KERN_WARNING "eccsize %u is too large\n" , eccsize); goto fail; } -if ((*ecclayout)->eccbytes != (eccsteps*eccbytes)) { +if (layout->eccbytes != (eccsteps*eccbytes)) {printk (KERN_WARNING "invalid ecc layout\n" ); goto fail; }@@ -203,6 +207,9 @@ nand_bch_init(struct mtd_info *mtd, unsigned int eccsize, unsigned int eccbytes,for (i =0 ; i < eccbytes; i++) nbc->eccmask[i] ^=0xff ; +if (!eccstrength) + nand->ecc.strength = (eccbytes *8 ) /fls (8 * eccsize); +return nbc; fail:nand_bch_free (nbc);drivers/mtd/nand/nand_ids.c +6
-4@@ -1,6 +1,4 @@/* -* drivers/mtd/nandids.c -* * Copyright (C) 2002 Thomas Gleixner (tglx at linutronix.de) * * This program is free software; you can redistribute it and/or modify @@ -41,6 +39,10 @@ struct nand_flash_dev nand_flash_ids[] = {* listed by full ID. We list them first so that we can easily identify * the most specific match. */ + {"TC58NVG0S3E 1G 3.3V 8-bit" , + { .id = {0x98, 0xd1, 0x90, 0x15, 0x76, 0x14, 0x01, 0x00} }, +SZ_2K ,SZ_128 ,SZ_128K ,0 ,8 ,64 ,NAND_ECC_INFO (1 ,SZ_512 ), + 2 }, {"TC58NVG2S0F 4G 3.3V 8-bit", { .id = {0x98, 0xdc, 0x90, 0x26, 0x76, 0x15, 0x01, 0x08} }, SZ_4K, SZ_512, SZ_256K, 0, 8, 224, NAND_ECC_INFO(4, SZ_512) },@@ -58,8 +60,8 @@ struct nand_flash_dev nand_flash_ids[] = { SZ_16K, SZ_8K, SZ_4M, 0, 6, 1280, NAND_ECC_INFO(40, SZ_1K) }, {"H27UCG8T2ATR-BC 64G 3.3V 8-bit" , { .id = {0xad, 0xde, 0x94, 0xda, 0x74, 0xc4} }, -SZ_8K ,SZ_8K ,SZ_2M ,0 ,6 ,640 ,NAND_ECC_INFO (40 ,SZ_1K ), - 4 }, +SZ_8K ,SZ_8K ,SZ_2M ,NAND_NEED_SCRAMBLING ,6 ,640 , + NAND_ECC_INFO(40, SZ_1K), 4 },LEGACY_ID_NAND ("NAND 4MiB 5V 8-bit" ,0x6B ,4 ,SZ_8K ,SP_OPTIONS ), LEGACY_ID_NAND("NAND 4MiB 3,3V 8-bit", 0xE3, 4, SZ_8K, SP_OPTIONS),drivers/mtd/nand/ndfc.c +1
-1@@ -1,6 +1,6 @@/* * Overview: -* Platform independend driver for NDFC (NanD Flash Controller) +* Platform independent driver for NDFC (NanD Flash Controller) * integrated into IBM/AMCC PPC4xx cores * * (C) Copyright 2006-2009 drivers/mtd/nand/omap_gpmc.c +1
-1@@ -163,7 +163,7 @@ static int __maybe_unused omap_correct_data(struct mtd_info *mtd, uint8_t *dat,return 0 ;printf ("Error: Bad compare! failed\n" );/* detected 2 bit error */ -return -1 ; +return -EBADMSG ; } }return 0 ;drivers/mtd/nand/s3c2410_nand.c +1
-1@@ -104,7 +104,7 @@ static int s3c24x0_nand_correct_data(struct mtd_info *mtd, u_char *dat,return 0 ;printf ("s3c24x0_nand_correct_data: not implemented\n" ); - return -1; + return -EBADMSG; }#endif drivers/mtd/nand/vf610_nfc.c +0
-1@@ -146,7 +146,6 @@ enum vf610_nfc_alt_buf { };struct vf610_nfc { -struct mtd_info *mtd;struct nand_chip chip;void __iomem *regs;uint buf_offset;include/linux/mtd/mtd.h +5
-0@@ -278,6 +278,11 @@ struct mtd_info {int usecount; }; +static inline int mtd_oobavail (struct mtd_info *mtd,struct mtd_oob_ops *ops) +{ +return ops->mode ==MTD_OPS_AUTO_OOB ? mtd->oobavail : mtd->oobsize; +} +int mtd_erase (struct mtd_info *mtd,struct erase_info *instr);#ifndef __UBOOT__ int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,include/linux/mtd/nand.h +41
-24@@ -25,6 +25,8 @@struct mtd_info ;struct nand_flash_dev ; +struct device_node ; +/* Scan and identify a NAND device */ extern int nand_scan (struct mtd_info *mtd,int max_chips);/* @@ -144,6 +146,14 @@ typedef enum {/* Enable Hardware ECC before syndrome is read back from flash */ #define NAND_ECC_READSYN 2 +/* +* Enable generic NAND 'page erased' check. This check is only done when +* ecc.correct() returns -EBADMSG. +* Set this flag if your implementation does not fix bitflips in erased +* pages and you want to rely on the default implementation. +*/ +#define NAND_ECC_GENERIC_ERASED_CHECK BIT(0) +/* Bit mask for flags passed to do_nand_read_ecc */ #define NAND_GET_DEVICE 0x80@@ -179,6 +189,12 @@ typedef enum {/* Device supports subpage reads */ #define NAND_SUBPAGE_READ 0x00001000 +/* +* Some MLC NANDs need data scrambling to limit bitflips caused by repeated +* patterns. +*/ +#define NAND_NEED_SCRAMBLING 0x00002000 +/* Options valid for Samsung large page devices */ #define NAND_SAMSUNG_LP_OPTIONS NAND_CACHEPRG@@ -203,6 +219,11 @@ typedef enum {* before calling nand_scan_tail. */ #define NAND_BUSWIDTH_AUTO 0x00080000 +/* +* This option could be defined by controller drivers to protect against +* kmap'ed, vmalloc'ed highmem buffers being passed from upper layers +*/ +#define NAND_USE_BOUNCE_BUFFER 0x00100000/* Options set by nand scan */ /* bbt has already been read */ @@ -292,15 +313,15 @@ struct nand_onfi_params {__le16 t_r;__le16 t_ccs;__le16 src_sync_timing_mode; -__le16 src_ssync_features; +u8 src_ssync_features;__le16 clk_pin_capacitance_typ;__le16 io_pin_capacitance_typ;__le16 input_pin_capacitance_typ;u8 input_pin_capacitance_max;u8 driver_strength_support;__le16 t_int_r; -__le16 t_ald; -u8 reserved4[7 ]; +__le16 t_adl; +u8 reserved4[8 ];/* vendor */ __le16 vendor_revision;@@ -423,7 +444,7 @@ struct nand_jedec_params {__le16 input_pin_capacitance_typ;__le16 clk_pin_capacitance_typ;u8 driver_strength_support; -__le16 t_ald; +__le16 t_adl;u8 reserved4[36 ];/* ECC and endurance block */ @@ -466,12 +487,19 @@ struct nand_hw_control {* @total: total number of ECC bytes per page * @prepad: padding information for syndrome based ECC generators * @postpad: padding information for syndrome based ECC generators +* @options: ECC specific options (see NAND_ECC_XXX flags defined above) * @layout: ECC layout control struct pointer * @priv: pointer to private ECC control data * @hwctl: function to control hardware ECC generator. Must only * be provided if an hardware ECC is available * @calculate: function for ECC calculation or readback from ECC hardware -* @correct: function for ECC correction, matching to ECC generator (sw/hw) +* @correct: function for ECC correction, matching to ECC generator (sw/hw). +* Should return a positive number representing the number of +* corrected bitflips, -EBADMSG if the number of bitflips exceed +* ECC strength, or any other error code if the error is not +* directly related to correction. +* If -EBADMSG is returned the input buffers should be left +* untouched. * @read_page_raw: function to read a raw page without ECC. This function * should hide the specific layout used by the ECC * controller and always return contiguous in-band and @@ -509,6 +537,7 @@ struct nand_ecc_ctrl {int strength;int prepad;int postpad; +unsigned int options;struct nand_ecclayout *layout;void *priv;void (*hwctl)(struct mtd_info *mtd,int mode);@@ -556,6 +585,7 @@ struct nand_buffers {/** * struct nand_chip - NAND Private Flash Chip Data +* @mtd: MTD device registered to the MTD framework * @IO_ADDR_R: [BOARDSPECIFIC] address to read the 8 I/O lines of the * flash device * @IO_ADDR_W: [BOARDSPECIFIC] address to write the 8 I/O lines of the @@ -571,10 +601,6 @@ struct nand_buffers {* @block_markbad: [REPLACEABLE] mark a block bad * @cmd_ctrl: [BOARDSPECIFIC] hardwarespecific function for controlling * ALE/CLE/nCE. Also used to write command and address -* @init_size: [BOARDSPECIFIC] hardwarespecific function for setting -* mtd->oobsize, mtd->writesize and so on. -* @id_data contains the 8 bytes values of NAND_CMD_READID. -* Return with the bus width. * @dev_ready: [BOARDSPECIFIC] hardwarespecific function for accessing * device ready/busy line. If set to NULL no access to * ready/busy is available and the ready/busy information @@ -669,11 +695,9 @@ struct nand_chip {void (*write_buf)(struct mtd_info *mtd,const uint8_t *buf,int len);void (*read_buf)(struct mtd_info *mtd,uint8_t *buf,int len);void (*select_chip)(struct mtd_info *mtd,int chip); -int (*block_bad)(struct mtd_info *mtd,loff_t ofs,int getchip); +int (*block_bad)(struct mtd_info *mtd,loff_t ofs);int (*block_markbad)(struct mtd_info *mtd,loff_t ofs);void (*cmd_ctrl)(struct mtd_info *mtd,int dat,unsigned int ctrl); -int (*init_size)(struct mtd_info *mtd,struct nand_chip *this, -u8 *id_data);int (*dev_ready)(struct mtd_info *mtd);void (*cmdfunc)(struct mtd_info *mtd,unsigned command,int column,int page_addr);@@ -873,7 +897,6 @@ struct nand_manufacturers {extern struct nand_flash_dev nand_flash_ids[];extern struct nand_manufacturers nand_manuf_ids[]; -extern int nand_scan_bbt (struct mtd_info *mtd,struct nand_bbt_descr *bd);extern int nand_default_bbt (struct mtd_info *mtd);extern int nand_markbad_bbt (struct mtd_info *mtd,loff_t offs);extern int nand_isreserved_bbt (struct mtd_info *mtd,loff_t offs);@@ -898,7 +921,6 @@ extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len,* @chip_delay: R/B delay value in us * @options: Option flags, e.g. 16bit buswidth * @bbt_options: BBT option flags, e.g. NAND_BBT_USE_FLASH -* @ecclayout: ECC layout info structure * @part_probe_types: NULL-terminated array of probe types */ struct platform_nand_chip {@@ -906,7 +928,6 @@ struct platform_nand_chip {int chip_offset;int nr_partitions;struct mtd_partition *partitions; -struct nand_ecclayout *ecclayout;int chip_delay;unsigned int options;unsigned int bbt_options;@@ -955,15 +976,6 @@ struct platform_nand_data {struct platform_nand_ctrl ctrl; }; -/* Some helpers to access the data structures */ -static inline -struct platform_nand_chip *get_platform_nandchip (struct mtd_info *mtd) -{ -struct nand_chip *chip = mtd->priv; - -return chip->priv; -} -#ifdef CONFIG_SYS_NAND_ONFI_DETECTION /* return the supported features. */ static inline int onfi_feature (struct nand_chip *chip)@@ -1081,4 +1093,9 @@ struct nand_sdr_timings {/* get timing characteristics from ONFI timing mode. */ const struct nand_sdr_timings *onfi_async_timing_mode_to_sdr_timings (int mode); + +int nand_check_erased_ecc_chunk (void *data,int datalen, +void *ecc,int ecclen, +void *extraoob,int extraooblen, +int threshold);#endif /* __LINUX_MTD_NAND_H */ include/linux/mtd/nand_bch.h +3
-7@@ -32,9 +32,7 @@ int nand_bch_correct_data(struct mtd_info *mtd, u_char *dat, u_char *read_ecc,/* * Initialize BCH encoder/decoder */ -struct nand_bch_control * -nand_bch_init (struct mtd_info *mtd,unsigned int eccsize, -unsigned int eccbytes,struct nand_ecclayout **ecclayout); +struct nand_bch_control *nand_bch_init (struct mtd_info *mtd);/* * Release BCH encoder/decoder resources */ @@ -55,12 +53,10 @@ static inline int nand_bch_correct_data(struct mtd_info *mtd, unsigned char *buf, unsigned char *read_ecc, unsigned char *calc_ecc) { - return -1; + return -ENOTSUPP; } -static inline struct nand_bch_control * -nand_bch_init (struct mtd_info *mtd,unsigned int eccsize, -unsigned int eccbytes,struct nand_ecclayout **ecclayout) +static inline struct nand_bch_control *nand_bch_init (struct mtd_info *mtd) {return NULL ; }
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 7/7 mtd: nand: Sync with Linux v4.6
In reply to Scott WoodQuoted 8 lines · On Mon, 30 May 2016 13:57:58 -0500 Scott Wood <[email protected]> wrote:
Updates the NAND code to match Linux v4.6. The previous sync was from Linux v4.1 in commit
d3963721d93fafa.Note that none of the individual NAND drivers tracked Linux closely enough to be synced themselves, other than manually applying a few cross-tree changes.
Signed-off-by Scott Wood <[email protected]>
I tested the series on sunxi (after adding the sunxi NAND driver). Not sure this is really useful to you since it was tested with a new driver, but here is my
Thanks,
Boris
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 7/7 mtd: nand: Sync with Linux v4.6
Hello Boris,
Am 06.06.2016 um 18:04 schrieb Boris Brezillon:
Quoted 10 lines
Quoted 7 lines · On Mon, 30 May 2016 13:57:58 -0500 Scott Wood <[email protected]> wrote:
Updates the NAND code to match Linux v4.6. The previous sync was from Linux v4.1 in commit
d3963721d93fafa.Note that none of the individual NAND drivers tracked Linux closely enough to be synced themselves, other than manually applying a few cross-tree changes.
Quoted 7 lines
Quoted 1 line
Signed-off-by Scott Wood <[email protected]>I tested the series on sunxi (after adding the sunxi NAND driver). Not sure this is really useful to you since it was tested with a new driver, but here is my
Tested-by Boris Brezillon <[email protected]>
All tests are useful! Thanks!
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany