Commit 151c06ec authored by Scott Wood's avatar Scott Wood

mtd: nand: Remove nand_info_t typedef

This typedef serves no purpose other than causing confusion with
struct nand_chip.
Signed-off-by: 's avatarScott Wood <oss@buserror.net>
parent ea7d1eec
......@@ -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 at 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
}
......
......@@ -242,11 +242,11 @@ static int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *d
static 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;
......
This diff is collapsed.
......@@ -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 {
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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 / \
......
......@@ -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)
......
......@@ -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,
......
......@@ -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];
......
......@@ -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 / \
......
This diff is collapsed.
......@@ -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;
......
......@@ -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)
{
......
......@@ -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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment