#include <memalign.h>
#include <div64.h>
-#include <asm/errno.h>
+#include <linux/errno.h>
#include <linux/mtd/mtd.h>
#include <nand.h>
#include <jffs2/jffs2.h>
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");
{
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);
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);
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);
{
u_char patterns[] = {0xa5, 0x5a, 0x00};
struct erase_info instr = {
- .mtd = nand,
+ .mtd = mtd,
.addr = offset,
.len = mtd->erasesize,
};
}
for (i = 0; i < patt_count; i++) {
- err = mtd->erase(mtd, &instr);
+ err = mtd_erase(mtd, &instr);
if (err) {
printf("%s: erase() failed for block at 0x%llx: %d\n",
mtd->name, instr.addr, err);
}
/* Make sure the block contains only 0xff bytes */
- err = mtd->read(mtd, offset, mtd->erasesize, &retlen, buf);
+ err = mtd_read(mtd, offset, mtd->erasesize, &retlen, buf);
if ((err && err != -EUCLEAN) || retlen != mtd->erasesize) {
printf("%s: read() failed for block at 0x%llx: %d\n",
mtd->name, instr.addr, err);
/* Write a pattern and check it */
memset(buf, patterns[i], mtd->erasesize);
- err = mtd->write(mtd, offset, mtd->erasesize, &retlen, buf);
+ err = mtd_write(mtd, offset, mtd->erasesize, &retlen, buf);
if (err || retlen != mtd->erasesize) {
printf("%s: write() failed for block at 0x%llx: %d\n",
mtd->name, instr.addr, err);
goto out;
}
- err = mtd->read(mtd, offset, mtd->erasesize, &retlen, buf);
+ err = mtd_read(mtd, offset, mtd->erasesize, &retlen, buf);
if ((err && err != -EUCLEAN) || retlen != mtd->erasesize) {
printf("%s: read() failed for block at 0x%llx: %d\n",
mtd->name, instr.addr, err);