mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mtd: >4GiB fixes
@ 2016-02-09  9:55 Sascha Hauer
  2016-02-09  9:55 ` [PATCH 1/7] mtd: nand-bb: Fix 8k page size nands Sascha Hauer
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Sascha Hauer @ 2016-02-09  9:55 UTC (permalink / raw)
  To: Barebox List

This series has several fixes to make mtd devices >4GiB usable. We had
several places where we still used 32bit types, these are converted to
64bit types here. Also included is a fix for 8KiB Nand page size.

Sascha

----------------------------------------------------------------
Sascha Hauer (7):
      mtd: nand-bb: Fix 8k page size nands
      mtd: Fix mtdraw for Nand > 4GiB
      mtd: Make erase_info structs 64bit where necessary
      mtd: Fix mtd_op_read for devices >4GiB
      mtd: Fix mtd_op_erase for devices >4GiB
      mtd: Fix erasing of devices >4GiB
      mtd: mtdoob device: change name to have the chip name first

 drivers/mtd/core.c          | 17 +++++++--------
 drivers/mtd/mtdoob.c        |  2 +-
 drivers/mtd/mtdraw.c        | 53 ++++++++++++++++++++++++++++-----------------
 drivers/mtd/nand/nand-bb.c  |  4 ++--
 fs/devfs-core.c             |  2 +-
 fs/devfs.c                  |  2 +-
 fs/fs.c                     |  2 +-
 include/driver.h            |  4 ++--
 include/fs.h                |  4 ++--
 include/linux/mtd/mtd-abi.h |  8 +++----
 include/linux/mtd/mtd.h     |  8 +++----
 11 files changed, 59 insertions(+), 47 deletions(-)

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/7] mtd: nand-bb: Fix 8k page size nands
  2016-02-09  9:55 [PATCH] mtd: >4GiB fixes Sascha Hauer
@ 2016-02-09  9:55 ` Sascha Hauer
  2016-02-09  9:55 ` [PATCH 2/7] mtd: Fix mtdraw for Nand > 4GiB Sascha Hauer
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2016-02-09  9:55 UTC (permalink / raw)
  To: Barebox List

As the comment states BB_WRITEBUF_SIZE must be a multiple of the largest
NAND page size. Since this is 8192 and not 4096, change it accordingly.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/nand-bb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c
index 8e4600a..5a2fd10 100644
--- a/drivers/mtd/nand/nand-bb.c
+++ b/drivers/mtd/nand/nand-bb.c
@@ -88,7 +88,7 @@ static ssize_t nand_bb_read(struct cdev *cdev, void *buf, size_t count,
 }
 
 /* Must be a multiple of the largest NAND page size */
-#define BB_WRITEBUF_SIZE	4096
+#define BB_WRITEBUF_SIZE	8192
 
 #ifdef CONFIG_MTD_WRITE
 static int nand_bb_write_buf(struct nand_bb *bb, size_t count)
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/7] mtd: Fix mtdraw for Nand > 4GiB
  2016-02-09  9:55 [PATCH] mtd: >4GiB fixes Sascha Hauer
  2016-02-09  9:55 ` [PATCH 1/7] mtd: nand-bb: Fix 8k page size nands Sascha Hauer
@ 2016-02-09  9:55 ` Sascha Hauer
  2016-02-09  9:55 ` [PATCH 3/7] mtd: Make erase_info structs 64bit where necessary Sascha Hauer
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2016-02-09  9:55 UTC (permalink / raw)
  To: Barebox List

The mtdraw code has some casts to avoid 64bit divisions. For Chips
>4GiB using 64bit types become necessary, so use them and to the
necessary 64bit math.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/mtdraw.c | 53 ++++++++++++++++++++++++++++++++--------------------
 1 file changed, 33 insertions(+), 20 deletions(-)

diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c
index ae4bec2..837dcd1 100644
--- a/drivers/mtd/mtdraw.c
+++ b/drivers/mtd/mtdraw.c
@@ -83,6 +83,20 @@ static struct mtd_info *to_mtd(struct cdev *cdev)
 	return mtdraw->mtd;
 }
 
+static unsigned int mtdraw_offset_to_block(struct mtd_info *mtd, loff_t offset)
+{
+	u64 ofs64 = offset;
+
+	do_div(ofs64, mtd->writesize + mtd->oobsize);
+
+	return ofs64;
+}
+
+static loff_t mtdraw_raw_to_mtd_offset(struct mtd_info *mtd, loff_t offset)
+{
+	return (loff_t)mtdraw_offset_to_block(mtd, offset) * mtd->writesize;
+}
+
 static ssize_t mtdraw_read_unaligned(struct mtd_info *mtd, void *dst,
 				     size_t count, int skip, ulong offset)
 {
@@ -117,22 +131,21 @@ err:
 }
 
 static ssize_t mtdraw_read(struct cdev *cdev, void *buf, size_t count,
-			    loff_t _offset, ulong flags)
+			    loff_t offset, ulong flags)
 {
 	struct mtd_info *mtd = to_mtd(cdev);
 	ssize_t retlen = 0, ret = 1, toread;
-	ulong numpage;
+	ulong numblock;
 	int skip;
-	unsigned long offset = _offset;
 
-	numpage = offset / (mtd->writesize + mtd->oobsize);
-	skip = offset % (mtd->writesize + mtd->oobsize);
+	numblock = mtdraw_offset_to_block(mtd, offset);
+	skip = offset - numblock * (mtd->writesize + mtd->oobsize);
 
 	while (ret > 0 && count > 0) {
 		toread = min_t(int, count,
 				mtd->writesize + mtd->oobsize - skip);
 		ret = mtdraw_read_unaligned(mtd, buf, toread,
-					    skip, numpage++ * mtd->writesize);
+					    skip, numblock++ * mtd->writesize);
 		buf += ret;
 		skip = 0;
 		count -= ret;
@@ -171,20 +184,21 @@ static void mtdraw_fillbuf(struct mtdraw *mtdraw, const void *src, int nbbytes)
 }
 
 static ssize_t mtdraw_write(struct cdev *cdev, const void *buf, size_t count,
-			    loff_t _offset, ulong flags)
+			    loff_t offset, ulong flags)
 {
 	struct mtdraw *mtdraw = to_mtdraw(cdev);
 	struct mtd_info *mtd = to_mtd(cdev);
 	int bsz = mtd->writesize + mtd->oobsize;
-	ulong numpage;
+	ulong numblock;
 	size_t retlen = 0, tofill;
-	unsigned long offset = _offset;
 	int ret = 0;
 
+	numblock = mtdraw_offset_to_block(mtd, offset);
+
 	if (mtdraw->write_fill &&
 	    mtdraw->write_ofs + mtdraw->write_fill != offset)
 		return -EINVAL;
-	if (mtdraw->write_fill == 0 && offset % bsz)
+	if (mtdraw->write_fill == 0 && offset - numblock * mtd->writesize != 0)
 		return -EINVAL;
 
 	if (mtdraw->write_fill) {
@@ -196,16 +210,16 @@ static ssize_t mtdraw_write(struct cdev *cdev, const void *buf, size_t count,
 	}
 
 	if (mtdraw->write_fill == bsz) {
-		numpage = mtdraw->write_ofs / (mtd->writesize + mtd->oobsize);
+		numblock = mtdraw_offset_to_block(mtd, mtdraw->write_ofs);
 		ret = mtdraw_blkwrite(mtd, mtdraw->writebuf,
-				      mtd->writesize * numpage);
+				      mtd->writesize * numblock);
 		mtdraw->write_fill = 0;
 	}
 
-	numpage = offset / (mtd->writesize + mtd->oobsize);
+	numblock = mtdraw_offset_to_block(mtd, offset);
 	while (ret >= 0 && count >= bsz) {
 		ret = mtdraw_blkwrite(mtd, buf + retlen,
-				   mtd->writesize * numpage++);
+				   mtd->writesize * numblock++);
 		count -= ret;
 		retlen += ret;
 		offset += ret;
@@ -225,15 +239,14 @@ static ssize_t mtdraw_write(struct cdev *cdev, const void *buf, size_t count,
 	}
 }
 
-static int mtdraw_erase(struct cdev *cdev, size_t count, loff_t _offset)
+static int mtdraw_erase(struct cdev *cdev, size_t count, loff_t offset)
 {
 	struct mtd_info *mtd = to_mtd(cdev);
 	struct erase_info erase;
-	unsigned long offset = _offset;
 	int ret;
 
-	offset = offset / (mtd->writesize + mtd->oobsize) * mtd->writesize;
-	count = count / (mtd->writesize + mtd->oobsize) * mtd->writesize;
+	offset = mtdraw_raw_to_mtd_offset(mtd, offset);
+	count = mtdraw_raw_to_mtd_offset(mtd, count);
 
 	memset(&erase, 0, sizeof(erase));
 	erase.mtd = mtd;
@@ -241,7 +254,7 @@ static int mtdraw_erase(struct cdev *cdev, size_t count, loff_t _offset)
 	erase.len = mtd->erasesize;
 
 	while (count > 0) {
-		debug("erase %d %d\n", erase.addr, erase.len);
+		debug("erase 0x%08llx len: 0x%08llx\n", erase.addr, erase.len);
 
 		if (!mtd->allow_erasebad)
 			ret = mtd_block_isbad(mtd, erase.addr);
@@ -249,7 +262,7 @@ static int mtdraw_erase(struct cdev *cdev, size_t count, loff_t _offset)
 			ret = 0;
 
 		if (ret > 0) {
-			printf("Skipping bad block at 0x%08x\n", erase.addr);
+			printf("Skipping bad block at 0x%08llx\n", erase.addr);
 		} else {
 			ret = mtd_erase(mtd, &erase);
 			if (ret)
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/7] mtd: Make erase_info structs 64bit where necessary
  2016-02-09  9:55 [PATCH] mtd: >4GiB fixes Sascha Hauer
  2016-02-09  9:55 ` [PATCH 1/7] mtd: nand-bb: Fix 8k page size nands Sascha Hauer
  2016-02-09  9:55 ` [PATCH 2/7] mtd: Fix mtdraw for Nand > 4GiB Sascha Hauer
@ 2016-02-09  9:55 ` Sascha Hauer
  2016-02-09  9:55 ` [PATCH 4/7] mtd: Fix mtd_op_read for devices >4GiB Sascha Hauer
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2016-02-09  9:55 UTC (permalink / raw)
  To: Barebox List

Make the userspace structs 64bit where necessary. Since we do not have
separated kernel/userspace in barebox we can just modifiy the original
structs instead of adding separate 64bit structs.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/core.c          | 2 +-
 include/linux/mtd/mtd-abi.h | 8 ++++----
 include/linux/mtd/mtd.h     | 8 ++++----
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 62307db..586b4a0 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -169,7 +169,7 @@ static int mtd_op_erase(struct cdev *cdev, size_t count, loff_t offset)
 	erase.len = mtd->erasesize;
 
 	while (count > 0) {
-		dev_dbg(cdev->dev, "erase %d %d\n", addr, erase.len);
+		dev_dbg(cdev->dev, "erase 0x%08llx len: 0x%08llx\n", addr, erase.len);
 
 		if (mtd->allow_erasebad || (mtd->master && mtd->master->allow_erasebad))
 			ret = 0;
diff --git a/include/linux/mtd/mtd-abi.h b/include/linux/mtd/mtd-abi.h
index c46605d..8e778df 100644
--- a/include/linux/mtd/mtd-abi.h
+++ b/include/linux/mtd/mtd-abi.h
@@ -10,13 +10,13 @@
 #include <asm-generic/div64.h>
 
 struct erase_info_user {
-	uint32_t start;
-	uint32_t length;
+	uint64_t start;
+	uint64_t length;
 };
 
 struct mtd_oob_buf {
-	uint32_t start;
-	uint32_t length;
+	uint64_t start;
+	uint64_t length;
 	unsigned char *ptr;
 };
 
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 7e828bc..e430217 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -31,9 +31,9 @@
    specific to any particular block. */
 struct erase_info {
 	struct mtd_info *mtd;
-	u_int32_t addr;
-	u_int32_t len;
-	u_int32_t fail_addr;
+	u_int64_t addr;
+	u_int64_t len;
+	u_int64_t fail_addr;
 	u_long time;
 	u_long retries;
 	u_int dev;
@@ -45,7 +45,7 @@ struct erase_info {
 };
 
 struct mtd_erase_region_info {
-	u_int32_t offset;			/* At which this region starts, from the beginning of the MTD */
+	u_int64_t offset;			/* At which this region starts, from the beginning of the MTD */
 	u_int32_t erasesize;		/* For this region */
 	u_int32_t numblocks;		/* Number of blocks of erasesize in this region */
 	unsigned long *lockmap;		/* If keeping bitmap of locks */
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/7] mtd: Fix mtd_op_read for devices >4GiB
  2016-02-09  9:55 [PATCH] mtd: >4GiB fixes Sascha Hauer
                   ` (2 preceding siblings ...)
  2016-02-09  9:55 ` [PATCH 3/7] mtd: Make erase_info structs 64bit where necessary Sascha Hauer
@ 2016-02-09  9:55 ` Sascha Hauer
  2016-02-09  9:55 ` [PATCH 5/7] mtd: Fix mtd_op_erase " Sascha Hauer
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2016-02-09  9:55 UTC (permalink / raw)
  To: Barebox List

The mtd read file operation has a unnecessary conversion to unsigned
long in the read offset. Remove it to make it work with chips >4GiB

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 586b4a0..3251bbc 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -67,14 +67,13 @@ int mtd_all_ff(const void *buf, unsigned int len)
 }
 
 static ssize_t mtd_op_read(struct cdev *cdev, void* buf, size_t count,
-			  loff_t _offset, ulong flags)
+			  loff_t offset, ulong flags)
 {
 	struct mtd_info *mtd = cdev->priv;
 	size_t retlen;
 	int ret;
-	unsigned long offset = _offset;
 
-	dev_dbg(cdev->dev, "read ofs: 0x%08lx count: 0x%08zx\n",
+	dev_dbg(cdev->dev, "read ofs: 0x%08llx count: 0x%08zx\n",
 			offset, count);
 
 	ret = mtd_read(mtd, offset, count, &retlen, buf);
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 5/7] mtd: Fix mtd_op_erase for devices >4GiB
  2016-02-09  9:55 [PATCH] mtd: >4GiB fixes Sascha Hauer
                   ` (3 preceding siblings ...)
  2016-02-09  9:55 ` [PATCH 4/7] mtd: Fix mtd_op_read for devices >4GiB Sascha Hauer
@ 2016-02-09  9:55 ` Sascha Hauer
  2016-02-09  9:55 ` [PATCH 6/7] mtd: Fix erasing of " Sascha Hauer
  2016-02-09  9:55 ` [PATCH 7/7] mtd: mtdoob device: change name to have the chip name first Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2016-02-09  9:55 UTC (permalink / raw)
  To: Barebox List

The mtd erase file operation has a unnecessary conversion to unsigned
long in the offset. Remove it to make it work with chips >4GiB.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 3251bbc..0bc9fed 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -148,7 +148,7 @@ static int mtd_op_erase(struct cdev *cdev, size_t count, loff_t offset)
 {
 	struct mtd_info *mtd = cdev->priv;
 	struct erase_info erase;
-	uint32_t addr;
+	loff_t addr;
 	int ret;
 
 	ret = mtd_erase_align(mtd, &count, &offset);
@@ -178,7 +178,7 @@ static int mtd_op_erase(struct cdev *cdev, size_t count, loff_t offset)
 		erase.addr = addr;
 
 		if (ret > 0) {
-			printf("Skipping bad block at 0x%08x\n", addr);
+			printf("Skipping bad block at 0x%08llx\n", addr);
 		} else {
 			ret = mtd_erase(mtd, &erase);
 			if (ret)
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 6/7] mtd: Fix erasing of devices >4GiB
  2016-02-09  9:55 [PATCH] mtd: >4GiB fixes Sascha Hauer
                   ` (4 preceding siblings ...)
  2016-02-09  9:55 ` [PATCH 5/7] mtd: Fix mtd_op_erase " Sascha Hauer
@ 2016-02-09  9:55 ` Sascha Hauer
  2016-02-09  9:55 ` [PATCH 7/7] mtd: mtdoob device: change name to have the chip name first Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2016-02-09  9:55 UTC (permalink / raw)
  To: Barebox List

When a device >4GiB is erased, not only the offset can be bigger
than 4GiB, but also the size. This happens with the simplest command
to erase a device: erase /dev/nand0. Make the size argument a 64bit
type to make this work.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/core.c         | 6 +++---
 drivers/mtd/mtdraw.c       | 2 +-
 drivers/mtd/nand/nand-bb.c | 2 +-
 fs/devfs-core.c            | 2 +-
 fs/devfs.c                 | 2 +-
 fs/fs.c                    | 2 +-
 include/driver.h           | 4 ++--
 include/fs.h               | 4 ++--
 8 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 0bc9fed..9234525 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -114,13 +114,13 @@ static struct mtd_erase_region_info *mtd_find_erase_region(struct mtd_info *mtd,
 	return NULL;
 }
 
-static int mtd_erase_align(struct mtd_info *mtd, size_t *count, loff_t *offset)
+static int mtd_erase_align(struct mtd_info *mtd, loff_t *count, loff_t *offset)
 {
 	struct mtd_erase_region_info *e;
 	loff_t ofs;
 
 	if (mtd->numeraseregions == 0) {
-		ofs = *offset & ~(mtd->erasesize - 1);
+		ofs = *offset & ~(loff_t)(mtd->erasesize - 1);
 		*count += (*offset - ofs);
 		*count = ALIGN(*count, mtd->erasesize);
 		*offset = ofs;
@@ -144,7 +144,7 @@ static int mtd_erase_align(struct mtd_info *mtd, size_t *count, loff_t *offset)
 	return 0;
 }
 
-static int mtd_op_erase(struct cdev *cdev, size_t count, loff_t offset)
+static int mtd_op_erase(struct cdev *cdev, loff_t count, loff_t offset)
 {
 	struct mtd_info *mtd = cdev->priv;
 	struct erase_info erase;
diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c
index 837dcd1..4d6ac72 100644
--- a/drivers/mtd/mtdraw.c
+++ b/drivers/mtd/mtdraw.c
@@ -239,7 +239,7 @@ static ssize_t mtdraw_write(struct cdev *cdev, const void *buf, size_t count,
 	}
 }
 
-static int mtdraw_erase(struct cdev *cdev, size_t count, loff_t offset)
+static int mtdraw_erase(struct cdev *cdev, loff_t count, loff_t offset)
 {
 	struct mtd_info *mtd = to_mtd(cdev);
 	struct erase_info erase;
diff --git a/drivers/mtd/nand/nand-bb.c b/drivers/mtd/nand/nand-bb.c
index 5a2fd10..e6d4277 100644
--- a/drivers/mtd/nand/nand-bb.c
+++ b/drivers/mtd/nand/nand-bb.c
@@ -157,7 +157,7 @@ static ssize_t nand_bb_write(struct cdev *cdev, const void *buf, size_t count,
 	return bytes;
 }
 
-static int nand_bb_erase(struct cdev *cdev, size_t count, loff_t offset)
+static int nand_bb_erase(struct cdev *cdev, loff_t count, loff_t offset)
 {
 	struct nand_bb *bb = cdev->priv;
 	struct erase_info erase = {};
diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index 88a7e3a..deacaaa 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -259,7 +259,7 @@ int cdev_ioctl(struct cdev *cdev, int request, void *buf)
 	return cdev->ops->ioctl(cdev, request, buf);
 }
 
-int cdev_erase(struct cdev *cdev, size_t count, loff_t offset)
+int cdev_erase(struct cdev *cdev, loff_t count, loff_t offset)
 {
 	if (!cdev->ops->erase)
 		return -ENOSYS;
diff --git a/fs/devfs.c b/fs/devfs.c
index 0b8d4fd..6fabcf8 100644
--- a/fs/devfs.c
+++ b/fs/devfs.c
@@ -66,7 +66,7 @@ static loff_t devfs_lseek(struct device_d *_dev, FILE *f, loff_t pos)
 	return ret - cdev->offset;
 }
 
-static int devfs_erase(struct device_d *_dev, FILE *f, size_t count, loff_t offset)
+static int devfs_erase(struct device_d *_dev, FILE *f, loff_t count, loff_t offset)
 {
 	struct cdev *cdev = f->priv;
 
diff --git a/fs/fs.c b/fs/fs.c
index ace72f7..c4b3583 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -924,7 +924,7 @@ out:
 }
 EXPORT_SYMBOL(lseek);
 
-int erase(int fd, size_t count, loff_t offset)
+int erase(int fd, loff_t count, loff_t offset)
 {
 	struct fs_driver_d *fsdrv;
 	FILE *f;
diff --git a/include/driver.h b/include/driver.h
index 31c6734..ce8c966 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -425,7 +425,7 @@ struct file_operations {
 	int (*open)(struct cdev*, unsigned long flags);
 	int (*close)(struct cdev*);
 	int (*flush)(struct cdev*);
-	int (*erase)(struct cdev*, size_t count, loff_t offset);
+	int (*erase)(struct cdev*, loff_t count, loff_t offset);
 	int (*protect)(struct cdev*, size_t count, loff_t offset, int prot);
 	int (*memmap)(struct cdev*, void **map, int flags);
 };
@@ -470,7 +470,7 @@ int cdev_flush(struct cdev *cdev);
 ssize_t cdev_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags);
 ssize_t cdev_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags);
 int cdev_ioctl(struct cdev *cdev, int cmd, void *buf);
-int cdev_erase(struct cdev *cdev, size_t count, loff_t offset);
+int cdev_erase(struct cdev *cdev, loff_t count, loff_t offset);
 
 #define DEVFS_PARTITION_FIXED		(1U << 0)
 #define DEVFS_PARTITION_READONLY	(1U << 1)
diff --git a/include/fs.h b/include/fs.h
index 23156ea..9f4164e 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -70,7 +70,7 @@ struct fs_driver_d {
 	int (*stat)(struct device_d *dev, const char *file, struct stat *stat);
 
 	int (*ioctl)(struct device_d *dev, FILE *f, int request, void *buf);
-	int (*erase)(struct device_d *dev, FILE *f, size_t count,
+	int (*erase)(struct device_d *dev, FILE *f, loff_t count,
 			loff_t offset);
 	int (*protect)(struct device_d *dev, FILE *f, size_t count,
 			loff_t offset, int prot);
@@ -145,7 +145,7 @@ int mount (const char *device, const char *fsname, const char *path,
 int umount(const char *pathname);
 
 /* not-so-standard functions */
-int erase(int fd, size_t count, loff_t offset);
+int erase(int fd, loff_t count, loff_t offset);
 int protect(int fd, size_t count, loff_t offset, int prot);
 int protect_file(const char *file, int prot);
 void *memmap(int fd, int flags);
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 7/7] mtd: mtdoob device: change name to have the chip name first
  2016-02-09  9:55 [PATCH] mtd: >4GiB fixes Sascha Hauer
                   ` (5 preceding siblings ...)
  2016-02-09  9:55 ` [PATCH 6/7] mtd: Fix erasing of " Sascha Hauer
@ 2016-02-09  9:55 ` Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2016-02-09  9:55 UTC (permalink / raw)
  To: Barebox List

Normally all device files assoctiated to a mtd device begin with
the chip name itself. Only the mtdoob device is an exception:
it begins with the chip name without the index end ends with the
index. Change the name to be like the other names, i.e. change
nand_oob0 to nand0.oob.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/mtdoob.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/mtdoob.c b/drivers/mtd/mtdoob.c
index 6160ddb..4dcf2f5 100644
--- a/drivers/mtd/mtdoob.c
+++ b/drivers/mtd/mtdoob.c
@@ -79,7 +79,7 @@ static int add_mtdoob_device(struct mtd_info *mtd, const char *devname, void **p
 	mtdoob = xzalloc(sizeof(*mtdoob));
 	mtdoob->cdev.ops = &mtd_ops_oob;
 	mtdoob->cdev.size = mtd_div_by_wb(mtd->size, mtd) * mtd->oobsize;
-	mtdoob->cdev.name = asprintf("%s_oob%d", devname, mtd->class_dev.id);
+	mtdoob->cdev.name = asprintf("%s.oob", mtd->cdev.name);
 	mtdoob->cdev.priv = mtdoob;
 	mtdoob->cdev.dev = &mtd->class_dev;
 	mtdoob->mtd = mtd;
-- 
2.7.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-02-09  9:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-09  9:55 [PATCH] mtd: >4GiB fixes Sascha Hauer
2016-02-09  9:55 ` [PATCH 1/7] mtd: nand-bb: Fix 8k page size nands Sascha Hauer
2016-02-09  9:55 ` [PATCH 2/7] mtd: Fix mtdraw for Nand > 4GiB Sascha Hauer
2016-02-09  9:55 ` [PATCH 3/7] mtd: Make erase_info structs 64bit where necessary Sascha Hauer
2016-02-09  9:55 ` [PATCH 4/7] mtd: Fix mtd_op_read for devices >4GiB Sascha Hauer
2016-02-09  9:55 ` [PATCH 5/7] mtd: Fix mtd_op_erase " Sascha Hauer
2016-02-09  9:55 ` [PATCH 6/7] mtd: Fix erasing of " Sascha Hauer
2016-02-09  9:55 ` [PATCH 7/7] mtd: mtdoob device: change name to have the chip name first Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox