From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 4/6] mtd: Use mtd_* functions where appropriate
Date: Fri, 15 Feb 2013 09:04:57 +0100 [thread overview]
Message-ID: <1360915499-1659-5-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1360915499-1659-1-git-send-email-s.hauer@pengutronix.de>
Instead of dereferencing struct mtd_info members directly use
the wrapper functions which have an additional check if the
callback exists if it is optional, like mark_bad or is_bad.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mtd/core.c | 8 ++++----
drivers/mtd/mtdraw.c | 2 +-
drivers/mtd/nand/nand_bbt.c | 4 ++--
drivers/mtd/ubi/io.c | 8 ++++----
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 47c0226..e852fb6 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -41,7 +41,7 @@ static ssize_t mtd_op_read(struct cdev *cdev, void* buf, size_t count,
dev_dbg(cdev->dev, "read ofs: 0x%08lx count: 0x%08x\n",
offset, count);
- ret = mtd->read(mtd, offset, count, &retlen, buf);
+ ret = mtd_read(mtd, offset, count, &retlen, buf);
if(ret) {
printf("err %d\n", ret);
@@ -61,7 +61,7 @@ static ssize_t mtd_op_write(struct cdev* cdev, const void *buf, size_t _count,
size_t retlen;
int ret;
- ret = mtd->write(mtd, _offset, _count, &retlen, buf);
+ ret = mtd_write(mtd, _offset, _count, &retlen, buf);
return ret ? ret : _count;
}
@@ -84,7 +84,7 @@ static int mtd_op_erase(struct cdev *cdev, size_t count, loff_t offset)
if (ret > 0) {
printf("Skipping bad block at 0x%08x\n", erase.addr);
} else {
- ret = mtd->erase(mtd, &erase);
+ ret = mtd_erase(mtd, &erase);
if (ret)
return ret;
}
@@ -119,7 +119,7 @@ int mtd_ioctl(struct cdev *cdev, int request, void *buf)
#ifdef CONFIG_MTD_WRITE
case MEMSETBADBLOCK:
dev_dbg(cdev->dev, "MEMSETBADBLOCK: 0x%08llx\n", *offset);
- ret = mtd->block_markbad(mtd, *offset);
+ ret = mtd_block_markbad(mtd, *offset);
break;
case MEMERASE:
ret = mtd_op_erase(cdev, ei->length, ei->start + cdev->offset);
diff --git a/drivers/mtd/mtdraw.c b/drivers/mtd/mtdraw.c
index ec77692..5aaa017 100644
--- a/drivers/mtd/mtdraw.c
+++ b/drivers/mtd/mtdraw.c
@@ -245,7 +245,7 @@ static int mtdraw_erase(struct cdev *cdev, size_t count, loff_t _offset)
if (ret > 0) {
printf("Skipping bad block at 0x%08x\n", erase.addr);
} else {
- ret = mtd->erase(mtd, &erase);
+ ret = mtd_erase(mtd, &erase);
if (ret)
return ret;
}
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index f7ae7cd..56396bf 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -160,7 +160,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
while (totlen) {
len = min(totlen, (size_t) (1 << this->bbt_erase_shift));
- res = mtd->read(mtd, from, len, &retlen, buf);
+ res = mtd_read(mtd, from, len, &retlen, buf);
if (res < 0) {
if (retlen != len) {
pr_info("nand_bbt: Error reading bad block table\n");
@@ -669,7 +669,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
/* Make it block aligned */
to &= ~((loff_t) ((1 << this->bbt_erase_shift) - 1));
len = 1 << this->bbt_erase_shift;
- res = mtd->read(mtd, to, len, &retlen, buf);
+ res = mtd_read(mtd, to, len, &retlen, buf);
if (res < 0) {
if (retlen != len) {
pr_info("nand_bbt: Error "
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index e3598b9..000fc5d 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -151,7 +151,7 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
addr = (loff_t)pnum * ubi->peb_size + offset;
retry:
- err = ubi->mtd->read(ubi->mtd, addr, len, &read, buf);
+ err = mtd_read(ubi->mtd, addr, len, &read, buf);
if (err) {
if (err == -EUCLEAN) {
/*
@@ -265,7 +265,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
}
addr = (loff_t)pnum * ubi->peb_size + offset;
- err = ubi->mtd->write(ubi->mtd, addr, len, &written, buf);
+ err = mtd_write(ubi->mtd, addr, len, &written, buf);
if (err) {
ubi_err("error %d while writing %d bytes to PEB %d:%d, written"
" %zd bytes", err, len, pnum, offset, written);
@@ -315,7 +315,7 @@ retry:
ei.callback = erase_callback;
ei.priv = (unsigned long)&wq;
- err = ubi->mtd->erase(ubi->mtd, &ei);
+ err = mtd_erase(ubi->mtd, &ei);
if (err) {
if (retries++ < UBI_IO_RETRIES) {
dbg_io("error %d while erasing PEB %d, retry",
@@ -1239,7 +1239,7 @@ static int paranoid_check_all_ff(struct ubi_device *ubi, int pnum, int offset,
loff_t addr = (loff_t)pnum * ubi->peb_size + offset;
mutex_lock(&ubi->dbg_buf_mutex);
- err = ubi->mtd->read(ubi->mtd, addr, len, &read, ubi->dbg_peb_buf);
+ err = mtd_read(ubi->mtd, addr, len, &read, ubi->dbg_peb_buf);
if (err && err != -EUCLEAN) {
ubi_err("error %d while reading %d bytes from PEB %d:%d, "
"read %zd bytes", err, len, pnum, offset, read);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-02-15 8:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-15 8:04 [PATCH] integrate CFI Flash driver into mtd Sascha Hauer
2013-02-15 8:04 ` [PATCH 1/6] libmtd: rename functions from mtd_* to libmtd_* Sascha Hauer
2013-02-15 8:04 ` [PATCH 2/6] mtd: rename mtd file operations callback functions Sascha Hauer
2013-02-15 8:04 ` [PATCH 3/6] mtd: Add mtd_* functions Sascha Hauer
2013-02-15 8:04 ` Sascha Hauer [this message]
2013-02-15 8:04 ` [PATCH 5/6] mtd: implement mtd_lock and mtd_unlock Sascha Hauer
2013-02-15 8:04 ` [PATCH 6/6] nor flash: integrate into mtd Sascha Hauer
2013-02-15 8:11 ` [PATCH] " Sascha Hauer
2013-02-15 8:12 ` Sascha Hauer
2013-02-17 10:59 ` Alexander Aring
2013-02-18 10:24 ` Sascha Hauer
2013-02-19 13:23 ` Alexander Aring
2013-02-19 18:45 ` Sascha Hauer
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=1360915499-1659-5-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--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