summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/atmel_nand.c8
-rw-r--r--drivers/mtd/nand/denali.h1
-rw-r--r--drivers/mtd/nand/nand_denali.c40
-rw-r--r--drivers/mtd/nand/nand_imx.c4
-rw-r--r--drivers/mtd/nand/nand_mrvl_nfc.c18
-rw-r--r--drivers/mtd/nand/nand_mxs.c6
-rw-r--r--drivers/mtd/nand/nand_omap_gpmc.c1
-rw-r--r--drivers/mtd/nand/nand_orion.c4
-rw-r--r--drivers/mtd/nand/nand_s3c24xx.c4
-rw-r--r--drivers/mtd/nand/nomadik_nand.c6
10 files changed, 40 insertions, 52 deletions
diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index b7c23f8f10..f3875a5648 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -77,7 +77,6 @@ static struct nand_ecclayout atmel_oobinfo_small = {
struct atmel_nand_host {
struct nand_chip nand_chip;
- struct mtd_info mtd;
void __iomem *io_base;
struct atmel_nand_data *board;
struct device_d *dev;
@@ -862,8 +861,8 @@ static int __init atmel_pmecc_nand_init_params(struct device_d *dev,
struct atmel_nand_host *host)
{
struct resource *iores;
- struct mtd_info *mtd = &host->mtd;
struct nand_chip *nand_chip = &host->nand_chip;
+ struct mtd_info *mtd = &nand_chip->mtd;
int cap, sector_size, err_no;
int ret;
@@ -1251,8 +1250,8 @@ static int atmel_hw_nand_init_params(struct device_d *dev,
struct atmel_nand_host *host)
{
struct resource *iores;
- struct mtd_info *mtd = &host->mtd;
struct nand_chip *nand_chip = &host->nand_chip;
+ struct mtd_info *mtd = &nand_chip->mtd;
iores = dev_request_mem_resource(dev, 1);
if (IS_ERR(iores))
@@ -1328,8 +1327,8 @@ static int __init atmel_nand_probe(struct device_d *dev)
return PTR_ERR(iores);
host->io_base = IOMEM(iores->start);
- mtd = &host->mtd;
nand_chip = &host->nand_chip;
+ mtd = &nand_chip->mtd;
host->board = pdata;
host->dev = dev;
@@ -1342,7 +1341,6 @@ static int __init atmel_nand_probe(struct device_d *dev)
}
nand_chip->priv = host; /* link the private data structures */
- mtd->priv = nand_chip;
mtd->parent = dev;
/* Set address of NAND IO lines */
diff --git a/drivers/mtd/nand/denali.h b/drivers/mtd/nand/denali.h
index 515353e277..7698b59720 100644
--- a/drivers/mtd/nand/denali.h
+++ b/drivers/mtd/nand/denali.h
@@ -464,7 +464,6 @@ struct nand_buf {
#define DT 3
struct denali_nand_info {
- struct mtd_info mtd;
struct nand_chip nand;
int flash_bank; /* currently selected chip */
int status;
diff --git a/drivers/mtd/nand/nand_denali.c b/drivers/mtd/nand/nand_denali.c
index f55e2bd5b0..ddb03813fe 100644
--- a/drivers/mtd/nand/nand_denali.c
+++ b/drivers/mtd/nand/nand_denali.c
@@ -76,7 +76,12 @@ static uint32_t denali_irq_mask = DENALI_IRQ_ALL;
* 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, struct denali_nand_info, mtd)
+static inline struct denali_nand_info *mtd_to_denali(struct mtd_info *mtd)
+{
+ struct nand_chip *nand = mtd_to_nand(mtd);
+
+ return container_of(nand, struct denali_nand_info, nand);
+}
/*
* These constants are defined by the driver to enable common driver
@@ -929,7 +934,7 @@ static bool handle_ecc(struct denali_nand_info *denali, uint8_t *buf,
err_device;
/* correct the ECC error */
buf[offset] ^= err_correction_value;
- denali->mtd.ecc_stats.corrected++;
+ denali->nand.mtd.ecc_stats.corrected++;
bitflips++;
}
} else {
@@ -997,7 +1002,7 @@ static int write_page(struct mtd_info *mtd, struct nand_chip *chip,
{
struct denali_nand_info *denali = mtd_to_denali(mtd);
dma_addr_t addr = (unsigned long)denali->buf.buf;
- size_t size = denali->mtd.writesize + denali->mtd.oobsize;
+ size_t size = mtd->writesize + mtd->oobsize;
uint32_t irq_status;
uint32_t irq_mask = INTR_STATUS__DMA_CMD_COMP |
INTR_STATUS__PROGRAM_FAIL;
@@ -1094,7 +1099,7 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
struct denali_nand_info *denali = mtd_to_denali(mtd);
dma_addr_t addr = (unsigned long)denali->buf.buf;
- size_t size = denali->mtd.writesize + denali->mtd.oobsize;
+ size_t size = mtd->writesize + mtd->oobsize;
uint32_t irq_status;
uint32_t irq_mask = denali->have_hw_ecc_fixup ?
@@ -1132,19 +1137,19 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip,
/* When we have hw ecc fixup, don't check oob.
* That code below looks jacked up anyway. I mean,
* look at it, wtf? */
- if (!is_erased(buf, denali->mtd.writesize))
- denali->mtd.ecc_stats.failed++;
+ if (!is_erased(buf, mtd->writesize))
+ mtd->ecc_stats.failed++;
} else {
- read_oob_data(&denali->mtd, chip->oob_poi,
+ read_oob_data(&denali->nand.mtd, chip->oob_poi,
denali->page);
/* check ECC failures that may have occurred on
* erased pages */
if (check_erased_page) {
- if (!is_erased(buf, denali->mtd.writesize))
- denali->mtd.ecc_stats.failed++;
- if (!is_erased(buf, denali->mtd.oobsize))
- denali->mtd.ecc_stats.failed++;
+ if (!is_erased(buf, mtd->writesize))
+ mtd->ecc_stats.failed++;
+ if (!is_erased(buf, mtd->oobsize))
+ mtd->ecc_stats.failed++;
}
}
}
@@ -1156,7 +1161,7 @@ static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
{
struct denali_nand_info *denali = mtd_to_denali(mtd);
dma_addr_t addr = (unsigned long)denali->buf.buf;
- size_t size = denali->mtd.writesize + denali->mtd.oobsize;
+ size_t size = mtd->writesize + mtd->oobsize;
uint32_t irq_mask = INTR_STATUS__DMA_CMD_COMP;
if (page != denali->page) {
@@ -1373,7 +1378,7 @@ static void denali_drv_init(struct denali_nand_info *denali)
int denali_init(struct denali_nand_info *denali)
{
struct nand_chip *nand = &denali->nand;
- struct mtd_info *mtd = &denali->mtd;
+ struct mtd_info *mtd = &nand->mtd;
int ret = 0;
uint32_t val;
@@ -1393,13 +1398,12 @@ int denali_init(struct denali_nand_info *denali)
if (!denali->buf.buf)
return -ENOMEM;
- denali->mtd.parent = denali->dev;
+ mtd->parent = denali->dev;
denali_hw_init(denali);
denali_drv_init(denali);
denali_set_intr_modes(denali, true);
mtd->name = "denali-nand";
- mtd->priv = &denali->nand;
/* register the driver with the NAND core subsystem */
nand->read_buf = denali_read_buf;
@@ -1413,7 +1417,7 @@ 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 failed_req_irq;
}
@@ -1535,12 +1539,12 @@ int denali_init(struct denali_nand_info *denali)
MAIN_ACCESS);
}
- if (nand_scan_tail(&denali->mtd)) {
+ if (nand_scan_tail(mtd)) {
ret = -ENXIO;
goto failed_req_irq;
}
- return add_mtd_nand_device(&denali->mtd, "nand");
+ return add_mtd_nand_device(mtd, "nand");
failed_req_irq:
denali_irq_cleanup(denali->irq, denali);
diff --git a/drivers/mtd/nand/nand_imx.c b/drivers/mtd/nand/nand_imx.c
index 02ddc661a6..1a065cb46f 100644
--- a/drivers/mtd/nand/nand_imx.c
+++ b/drivers/mtd/nand/nand_imx.c
@@ -32,7 +32,6 @@
#include <errno.h>
struct imx_nand_host {
- struct mtd_info mtd;
struct nand_chip nand;
struct mtd_partition *parts;
struct device_d *dev;
@@ -1237,8 +1236,7 @@ static int __init imxnd_probe(struct device_d *dev)
/* structures must be linked */
this = &host->nand;
- mtd = &host->mtd;
- mtd->priv = this;
+ mtd = &this->mtd;
mtd->parent = dev;
mtd->name = "imx_nand";
diff --git a/drivers/mtd/nand/nand_mrvl_nfc.c b/drivers/mtd/nand/nand_mrvl_nfc.c
index e6e7f2c2cd..15d052b5a4 100644
--- a/drivers/mtd/nand/nand_mrvl_nfc.c
+++ b/drivers/mtd/nand/nand_mrvl_nfc.c
@@ -137,7 +137,6 @@ struct mrvl_nand_variant {
};
struct mrvl_nand_host {
- struct mtd_info mtd;
struct nand_chip chip;
struct mtd_partition *parts;
struct device_d *dev;
@@ -342,7 +341,7 @@ static struct mrvl_nand_timing timings[] = {
static void mrvl_nand_set_timing(struct mrvl_nand_host *host, bool use_default)
{
- struct mtd_info *mtd = &host->mtd;
+ struct mtd_info *mtd = &host->chip.mtd;
unsigned long nand_clk = clk_get_rate(host->core_clk);
struct mrvl_nand_timing *t;
uint32_t ndtr0, ndtr1;
@@ -420,7 +419,7 @@ static unsigned int mrvl_datasize(struct mrvl_nand_host *host)
{
unsigned int datasize;
- datasize = host->mtd.writesize;
+ datasize = host->chip.mtd.writesize;
if (host->use_spare) {
datasize += host->spare_size;
if (!host->use_ecc)
@@ -572,7 +571,7 @@ static void prepare_start_command(struct mrvl_nand_host *host, int command)
if (command == NAND_CMD_READ0 ||
command == NAND_CMD_READOOB ||
command == NAND_CMD_SEQIN) {
- host->buf_count = host->mtd.writesize + host->mtd.oobsize;
+ host->buf_count = host->chip.mtd.writesize + host->chip.mtd.oobsize;
memset(host->data_buff, 0xFF, host->buf_count);
}
@@ -592,7 +591,7 @@ static int prepare_set_command(struct mrvl_nand_host *host, int command,
int addr_cycle, exec_cmd;
struct mtd_info *mtd;
- mtd = &host->mtd;
+ mtd = &host->chip.mtd;
exec_cmd = 1;
if (host->cs != 0)
@@ -878,7 +877,7 @@ static void mrvl_nand_write_buf(struct mtd_info *mtd,
static void mrvl_nand_config_flash(struct mrvl_nand_host *host)
{
struct nand_chip *chip = &host->chip;
- struct mtd_info *mtd = &host->mtd;
+ struct mtd_info *mtd = &host->chip.mtd;
uint32_t ndcr = host->reg_ndcr;
/* calculate flash information */
@@ -1115,8 +1114,7 @@ static struct mrvl_nand_host *alloc_nand_resource(struct device_d *dev)
host = xzalloc(sizeof(*host));
host->num_cs = 1;
host->cs = 0;
- mtd = &host->mtd;
- mtd->priv = &host->chip;
+ mtd = &host->chip.mtd;
mtd->parent = dev;
mtd->name = "mrvl_nand";
@@ -1216,14 +1214,14 @@ static int mrvl_nand_probe(struct device_d *dev)
return ret;
host->chip.controller = &host->chip.hwcontrol;
- ret = mrvl_nand_scan(&host->mtd);
+ ret = mrvl_nand_scan(&host->chip.mtd);
if (ret) {
dev_warn(dev, "failed to scan nand at cs %d\n",
host->cs);
return -ENODEV;
}
- ret = add_mtd_nand_device(&host->mtd, "nand");
+ ret = add_mtd_nand_device(&host->chip.mtd, "nand");
return ret;
}
diff --git a/drivers/mtd/nand/nand_mxs.c b/drivers/mtd/nand/nand_mxs.c
index 1e0d6c73e4..36b6e7ac22 100644
--- a/drivers/mtd/nand/nand_mxs.c
+++ b/drivers/mtd/nand/nand_mxs.c
@@ -200,7 +200,6 @@ struct mxs_nand_info {
void __iomem *io_base;
void __iomem *bch_base;
struct clk *clk;
- struct mtd_info mtd;
enum gpmi_type type;
int dma_channel_base;
u32 version;
@@ -2030,7 +2029,7 @@ static void mxs_nand_compute_edo_timing(struct mxs_nand_info *info,
static int mxs_nand_enable_edo_mode(struct mxs_nand_info *info)
{
struct nand_chip *chip = &info->nand_chip;
- struct mtd_info *mtd = &info->mtd;
+ struct mtd_info *mtd = &chip->mtd;
uint8_t feature[ONFI_SUBFEATURE_PARAM_LEN] = {};
int ret, mode;
@@ -2196,8 +2195,7 @@ static int mxs_nand_probe(struct device_d *dev)
/* structures must be linked */
chip = &nand_info->nand_chip;
- mtd = &nand_info->mtd;
- mtd->priv = chip;
+ mtd = &nand_info->nand_chip.mtd;
mtd->parent = dev;
chip->priv = nand_info;
diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
index ab1dac7097..9c7f5a02a1 100644
--- a/drivers/mtd/nand/nand_omap_gpmc.c
+++ b/drivers/mtd/nand/nand_omap_gpmc.c
@@ -883,7 +883,6 @@ static int gpmc_nand_probe(struct device_d *pdev)
nand->priv = (void *)oinfo;
minfo = &oinfo->minfo;
- minfo->priv = (void *)nand;
minfo->parent = pdev;
if (pdata->cs >= GPMC_NUM_CS) {
diff --git a/drivers/mtd/nand/nand_orion.c b/drivers/mtd/nand/nand_orion.c
index 0c62da4c9a..c8b89cd03c 100644
--- a/drivers/mtd/nand/nand_orion.c
+++ b/drivers/mtd/nand/nand_orion.c
@@ -21,7 +21,6 @@
#include <linux/clk.h>
struct orion_nand {
- struct mtd_info mtd;
struct nand_chip chip;
u8 ale; /* address line number connected to ALE */
@@ -91,7 +90,7 @@ static int orion_nand_probe(struct device_d *dev)
u32 val = 0;
priv = xzalloc(sizeof(struct orion_nand));
- mtd = &priv->mtd;
+ mtd = &priv->chip.mtd;
chip = &priv->chip;
iores = dev_request_mem_resource(dev, 0);
@@ -118,7 +117,6 @@ static int orion_nand_probe(struct device_d *dev)
chip->chip_delay = (u8)val;
mtd->parent = dev;
- mtd->priv = chip;
chip->priv = priv;
chip->IO_ADDR_R = chip->IO_ADDR_W = io_base;
chip->cmd_ctrl = orion_nand_cmd_ctrl;
diff --git a/drivers/mtd/nand/nand_s3c24xx.c b/drivers/mtd/nand/nand_s3c24xx.c
index 4b6e3a1b35..9fbc0f90d3 100644
--- a/drivers/mtd/nand/nand_s3c24xx.c
+++ b/drivers/mtd/nand/nand_s3c24xx.c
@@ -88,7 +88,6 @@
struct s3c24x0_nand_host {
- struct mtd_info mtd;
struct nand_chip nand;
struct mtd_partition *parts;
struct device_d *dev;
@@ -428,8 +427,7 @@ static int s3c24x0_nand_probe(struct device_d *dev)
/* structures must be linked */
chip = &host->nand;
- mtd = &host->mtd;
- mtd->priv = chip;
+ mtd = &chip->mtd;
mtd->parent = dev;
/* init the default settings */
diff --git a/drivers/mtd/nand/nomadik_nand.c b/drivers/mtd/nand/nomadik_nand.c
index 8c49f8c6ca..31bc2efc40 100644
--- a/drivers/mtd/nand/nomadik_nand.c
+++ b/drivers/mtd/nand/nomadik_nand.c
@@ -38,7 +38,6 @@
#include <errno.h>
struct nomadik_nand_host {
- struct mtd_info mtd;
struct nand_chip nand;
void __iomem *cmd_va;
void __iomem *addr_va;
@@ -198,9 +197,8 @@ static int nomadik_nand_probe(struct device_d *dev)
return PTR_ERR(host->addr_va);
/* Link all private pointers */
- mtd = &host->mtd;
nand = &host->nand;
- mtd->priv = nand;
+ mtd = &nand->mtd;
nand->priv = host;
mtd->parent = dev;
@@ -223,7 +221,7 @@ static int nomadik_nand_probe(struct device_d *dev)
/*
* Scan to find existance of the device
*/
- if (nand_scan(&host->mtd, 1)) {
+ if (nand_scan(mtd, 1)) {
ret = -ENXIO;
goto err;
}