* [RESEND PATCH 2/3] mtd: move the enum definition out of struct mtdblk_dev
[not found] <1417052709-22026-1-git-send-email-guz.fnst@cn.fujitsu.com>
@ 2014-12-03 2:20 ` Gu Zheng
2014-12-03 2:20 ` [RESEND PATCH 3/3] mtd/mtdblock: introduce helper macro blktrans_dev_to_mtdblk to wrap the conversion (mtd_blktrans_dev to mtdblk_dev) Gu Zheng
1 sibling, 0 replies; 2+ messages in thread
From: Gu Zheng @ 2014-12-03 2:20 UTC (permalink / raw)
To: linux-mtd; +Cc: Gu Zheng, computersforpeace, dwmw2, linux-kernel
Move the enum definition out of struct mtdblk_dev, just cleanup.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
---
drivers/mtd/mtdblock.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index bb4c14f..acc00f1 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -34,6 +34,11 @@
#include <linux/mutex.h>
#include <linux/major.h>
+enum CACHE_STATES {
+ STATE_EMPTY,
+ STATE_CLEAN,
+ STATE_DIRTY
+};
struct mtdblk_dev {
struct mtd_blktrans_dev mbd;
@@ -42,7 +47,7 @@ struct mtdblk_dev {
unsigned char *cache_data;
unsigned long cache_offset;
unsigned int cache_size;
- enum { STATE_EMPTY, STATE_CLEAN, STATE_DIRTY } cache_state;
+ enum CACHE_STATES cache_state;
};
/*
--
1.7.7
.
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [RESEND PATCH 3/3] mtd/mtdblock: introduce helper macro blktrans_dev_to_mtdblk to wrap the conversion (mtd_blktrans_dev to mtdblk_dev)
[not found] <1417052709-22026-1-git-send-email-guz.fnst@cn.fujitsu.com>
2014-12-03 2:20 ` [RESEND PATCH 2/3] mtd: move the enum definition out of struct mtdblk_dev Gu Zheng
@ 2014-12-03 2:20 ` Gu Zheng
1 sibling, 0 replies; 2+ messages in thread
From: Gu Zheng @ 2014-12-03 2:20 UTC (permalink / raw)
To: linux-mtd; +Cc: Gu Zheng, computersforpeace, dwmw2, linux-kernel
Introduce helper macro blktrans_dev_to_mtdblk to wrap the conversion
(mtd_blktrans_dev to mtdblk_dev), just cleanup.
Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
---
drivers/mtd/mtdblock.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index acc00f1..3af3d1c 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -50,6 +50,8 @@ struct mtdblk_dev {
enum CACHE_STATES cache_state;
};
+#define blktrans_dev_to_mtdblk(dev) container_of(dev, struct mtdblk_dev, mbd)
+
/*
* Cache stuff...
*
@@ -263,14 +265,16 @@ static int do_cached_read (struct mtdblk_dev *mtdblk, unsigned long pos,
static int mtdblock_readsect(struct mtd_blktrans_dev *dev,
unsigned long block, char *buf)
{
- struct mtdblk_dev *mtdblk = container_of(dev, struct mtdblk_dev, mbd);
+ struct mtdblk_dev *mtdblk = blktrans_dev_to_mtdblk(dev);
+
return do_cached_read(mtdblk, block<<9, 512, buf);
}
static int mtdblock_writesect(struct mtd_blktrans_dev *dev,
unsigned long block, char *buf)
{
- struct mtdblk_dev *mtdblk = container_of(dev, struct mtdblk_dev, mbd);
+ struct mtdblk_dev *mtdblk = blktrans_dev_to_mtdblk(dev);
+
if (unlikely(!mtdblk->cache_data && mtdblk->cache_size)) {
mtdblk->cache_data = vmalloc(mtdblk->mbd.mtd->erasesize);
if (!mtdblk->cache_data)
@@ -285,7 +289,7 @@ static int mtdblock_writesect(struct mtd_blktrans_dev *dev,
static int mtdblock_open(struct mtd_blktrans_dev *mbd)
{
- struct mtdblk_dev *mtdblk = container_of(mbd, struct mtdblk_dev, mbd);
+ struct mtdblk_dev *mtdblk = blktrans_dev_to_mtdblk(mbd);
pr_debug("mtdblock_open\n");
@@ -310,7 +314,7 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd)
static void mtdblock_release(struct mtd_blktrans_dev *mbd)
{
- struct mtdblk_dev *mtdblk = container_of(mbd, struct mtdblk_dev, mbd);
+ struct mtdblk_dev *mtdblk = blktrans_dev_to_mtdblk(mbd);
pr_debug("mtdblock_release\n");
@@ -333,7 +337,7 @@ static void mtdblock_release(struct mtd_blktrans_dev *mbd)
static int mtdblock_flush(struct mtd_blktrans_dev *dev)
{
- struct mtdblk_dev *mtdblk = container_of(dev, struct mtdblk_dev, mbd);
+ struct mtdblk_dev *mtdblk = blktrans_dev_to_mtdblk(dev);
mutex_lock(&mtdblk->cache_mutex);
write_cached_data(mtdblk);
--
1.7.7
.
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-12-03 2:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1417052709-22026-1-git-send-email-guz.fnst@cn.fujitsu.com>
2014-12-03 2:20 ` [RESEND PATCH 2/3] mtd: move the enum definition out of struct mtdblk_dev Gu Zheng
2014-12-03 2:20 ` [RESEND PATCH 3/3] mtd/mtdblock: introduce helper macro blktrans_dev_to_mtdblk to wrap the conversion (mtd_blktrans_dev to mtdblk_dev) Gu Zheng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).