From: Alexander Stein <alexander.stein@systec-electronic.com>
To: linux-mtd@lists.infradead.org
Cc: David Woodhouse <dwmw2@infradead.org>,
linux-kernel@vger.kernel.org,
Alexander Stein <alexander.stein@systec-electronic.com>
Subject: [PATCH] [MTD] Only call mtd->sync() method in mtdblock_release if opened for write.
Date: Tue, 10 Jan 2012 13:26:58 +0100 [thread overview]
Message-ID: <1326198418-8996-1-git-send-email-alexander.stein@systec-electronic.com> (raw)
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
---
drivers/mtd/mtd_blkdevs.c | 1 +
drivers/mtd/mtdblock.c | 7 +++++--
include/linux/mtd/blktrans.h | 1 +
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index ed8b5e7..e8aac1d 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -234,6 +234,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
if (ret)
goto error_release;
+ dev->file_mode = mode;
unlock:
mutex_unlock(&dev->lock);
blktrans_dev_put(dev);
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index 7c1dc90..3904df1 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -321,8 +321,11 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd)
mutex_unlock(&mtdblk->cache_mutex);
if (!--mtdblk->count) {
- /* It was the last usage. Free the cache */
- if (mbd->mtd->sync)
+ /*
+ * It was the last usage. Free the cache
+ * But only sync if opened writeable
+ */
+ if ((mbd->file_mode & FMODE_WRITE) && mbd->mtd->sync)
mbd->mtd->sync(mbd->mtd);
vfree(mtdblk->cache_data);
}
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h
index 1bbd9f2..ed270bd 100644
--- a/include/linux/mtd/blktrans.h
+++ b/include/linux/mtd/blktrans.h
@@ -47,6 +47,7 @@ struct mtd_blktrans_dev {
struct request_queue *rq;
spinlock_t queue_lock;
void *priv;
+ fmode_t file_mode;
};
struct mtd_blktrans_ops {
--
1.7.3.4
next reply other threads:[~2012-01-10 12:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-10 12:26 Alexander Stein [this message]
2012-01-14 14:55 ` Artem Bityutskiy
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=1326198418-8996-1-git-send-email-alexander.stein@systec-electronic.com \
--to=alexander.stein@systec-electronic.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@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
all inboxes | Powered by JetHome®