From ff268fb8791cf18df536113355d7184007c269d9 Mon Sep 17 00:00:00 2001
From: Thomas Gleixner <tglx@cruncher.tec.linutronix.de>
Date: Sat, 27 May 2006 20:36:12 +0200
Subject: [MTD] NAND Consolidate oobinfo handling

The info structure for out of band data was copied into
the mtd structure. Make it a pointer and remove the ability
to set it from userspace. The position of ecc bytes is
defined by the hardware and should not be changed by software.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/mtd/mtdchar.c              | 10 ++--------
 drivers/mtd/mtdconcat.c            |  4 +---
 drivers/mtd/mtdpart.c              |  4 +---
 drivers/mtd/nand/nand_base.c       | 10 +---------
 drivers/mtd/onenand/onenand_base.c |  2 +-
 5 files changed, 6 insertions(+), 24 deletions(-)

(limited to 'drivers')

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 7a7df851c99..608f7af679c 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -512,16 +512,10 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
 		break;
 	}
 
-	case MEMSETOOBSEL:
-	{
-		if (copy_from_user(&mtd->oobinfo, argp, sizeof(struct nand_oobinfo)))
-			return -EFAULT;
-		break;
-	}
-
 	case MEMGETOOBSEL:
 	{
-		if (copy_to_user(argp, &(mtd->oobinfo), sizeof(struct nand_oobinfo)))
+		if (copy_to_user(argp, mtd->oobinfo,
+				 sizeof(struct nand_oobinfo)))
 			return -EFAULT;
 		break;
 	}
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index 6d52137988f..699fce7770d 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -766,9 +766,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[],	/* subdevices to c
 
 	}
 
-	if(concat->mtd.type == MTD_NANDFLASH)
-		memcpy(&concat->mtd.oobinfo, &subdev[0]->oobinfo,
-			sizeof(struct nand_oobinfo));
+	concat->mtd.oobinfo = subdev[0]->oobinfo;
 
 	concat->num_subdev = num_devs;
 	concat->mtd.name = name;
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index a93550ce797..b6b218952d4 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -316,7 +316,6 @@ int add_mtd_partitions(struct mtd_info *master,
 		slave->mtd.size = parts[i].size;
 		slave->mtd.writesize = master->writesize;
 		slave->mtd.oobsize = master->oobsize;
-		slave->mtd.oobavail = master->oobavail;
 		slave->mtd.ecctype = master->ecctype;
 		slave->mtd.eccsize = master->eccsize;
 
@@ -435,8 +434,7 @@ int add_mtd_partitions(struct mtd_info *master,
 				parts[i].name);
 		}
 
-		/* copy oobinfo from master */
-		memcpy(&slave->mtd.oobinfo, &master->oobinfo, sizeof(slave->mtd.oobinfo));
+		slave->mtd.oobinfo = master->oobinfo;
 
 		if(parts[i].mtdp)
 		{	/* store the object pointer (caller may or may not register it */
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 023224dd12e..20f79fec73b 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2142,14 +2142,6 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
 		}
 	}
 
-	/*
-	 * The number of bytes available for the filesystem to place fs
-	 * dependend oob data
-	 */
-	mtd->oobavail = 0;
-	for (i = 0; chip->autooob->oobfree[i][1]; i++)
-		mtd->oobavail += chip->autooob->oobfree[i][1];
-
 	/*
 	 * check ECC mode, default to software if 3byte/512byte hardware ECC is
 	 * selected and we have 256 byte pagesize fallback to software ECC
@@ -2245,7 +2237,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
 	mtd->block_markbad = nand_block_markbad;
 
 	/* and make the autooob the default one */
-	memcpy(&mtd->oobinfo, chip->autooob, sizeof(mtd->oobinfo));
+	mtd->oobinfo = chip->autooob;
 
 	/* Check, if we should skip the bad block table scan */
 	if (chip->options & NAND_SKIP_BBTSCAN)
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 7a2419186ff..b24bfa6e202 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -1762,7 +1762,7 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
 		break;
 	}
 
-	memcpy(&mtd->oobinfo, this->autooob, sizeof(mtd->oobinfo));
+	mtd->oobinfo = this->autooob;
 
 	/* Fill in remaining MTD driver data */
 	mtd->type = MTD_NANDFLASH;
-- 
cgit