From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/1] mtd: introduce mtd_block_isbad
Date: Thu, 1 Nov 2012 10:33:14 +0100 [thread overview]
Message-ID: <1351762394-4597-1-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <20121031120122.GF29599@game.jcrosoft.org>
this allow to do not provide block_isbad at mtd driver level
as example spi flash
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
drivers/mtd/core.c | 13 +++++++++++--
drivers/mtd/mtdraw.c | 2 +-
drivers/mtd/partition.c | 2 +-
drivers/mtd/ubi/io.c | 2 +-
include/linux/mtd/mtd.h | 2 ++
5 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 7c323a1..0139851 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -30,6 +30,15 @@
static LIST_HEAD(mtd_register_hooks);
+int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
+{
+ if (!mtd->block_isbad)
+ return 0;
+ if (ofs < 0 || ofs > mtd->size)
+ return -EINVAL;
+ return mtd->block_isbad(mtd, ofs);
+}
+
static ssize_t mtd_read(struct cdev *cdev, void* buf, size_t count,
loff_t _offset, ulong flags)
{
@@ -130,7 +139,7 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
switch (request) {
case MEMGETBADBLOCK:
dev_dbg(cdev->dev, "MEMGETBADBLOCK: 0x%08llx\n", *offset);
- ret = mtd->block_isbad(mtd, *offset);
+ ret = mtd_block_isbad(mtd, *offset);
break;
#ifdef CONFIG_MTD_WRITE
case MEMSETBADBLOCK:
@@ -189,7 +198,7 @@ static int mtd_erase(struct cdev *cdev, size_t count, loff_t offset)
while (count > 0) {
dev_dbg(cdev->dev, "erase %d %d\n", erase.addr, erase.len);
- ret = mtd->block_isbad(mtd, erase.addr);
+ ret = mtd_block_isbad(mtd, erase.addr);
if (ret > 0) {
printf("Skipping bad block at 0x%08x\n", erase.addr);
} else {
diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c
index 079575c..ec77692 100644
--- a/drivers/mtd/mtdraw.c
+++ b/drivers/mtd/mtdraw.c
@@ -241,7 +241,7 @@ static int mtdraw_erase(struct cdev *cdev, size_t count, loff_t _offset)
while (count > 0) {
debug("erase %d %d\n", erase.addr, erase.len);
- ret = mtd->block_isbad(mtd, erase.addr);
+ ret = mtd_block_isbad(mtd, erase.addr);
if (ret > 0) {
printf("Skipping bad block at 0x%08x\n", erase.addr);
} else {
diff --git a/drivers/mtd/partition.c b/drivers/mtd/partition.c
index df2eb40..85f486d 100644
--- a/drivers/mtd/partition.c
+++ b/drivers/mtd/partition.c
@@ -71,7 +71,7 @@ static int mtd_part_block_isbad(struct mtd_info *mtd, loff_t ofs)
if (ofs >= mtd->size)
return -EINVAL;
ofs += part->offset;
- return part->master->block_isbad(part->master, ofs);
+ return mtd_block_isbad(part->master, ofs);
}
static int mtd_part_block_markbad(struct mtd_info *mtd, loff_t ofs)
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index da38837..e3598b9 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -513,7 +513,7 @@ int ubi_io_is_bad(const struct ubi_device *ubi, int pnum)
if (ubi->bad_allowed) {
int ret;
- ret = mtd->block_isbad(mtd, (loff_t)pnum * ubi->peb_size);
+ ret = mtd_block_isbad(mtd, (loff_t)pnum * ubi->peb_size);
if (ret < 0)
ubi_err("error %d while checking if PEB %d is bad",
ret, pnum);
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 71d3c6f..5db884c 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -251,6 +251,8 @@ static inline void mtd_erase_callback(struct erase_info *instr)
}
#endif
+int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs);
+
/*
* Debugging macro and defines
*/
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-11-01 9:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-31 12:01 [PATCH 0/2] m25p80: re-import it againt mtd_add_host Jean-Christophe PLAGNIOL-VILLARD
2012-10-31 12:04 ` [PATCH 1/2] " Jean-Christophe PLAGNIOL-VILLARD
2012-10-31 12:04 ` [PATCH 2/2] m25p80: sync flash support with the kernel Jean-Christophe PLAGNIOL-VILLARD
2012-10-31 21:29 ` [PATCH 0/2] m25p80: re-import it againt mtd_add_host Sascha Hauer
2012-11-01 9:32 ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-01 9:33 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-11-15 10:11 ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-16 20:16 ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-20 8:41 ` Sascha Hauer
2012-11-20 12:37 ` Jean-Christophe PLAGNIOL-VILLARD
2012-11-20 14:34 ` Jean-Christophe PLAGNIOL-VILLARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351762394-4597-1-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox