mtd: move the enum definition out of struct mtdblk_dev
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH RESEND 2/3 mtd: move the enum definition out of struct mtdblk_dev
Move the enum definition out of struct mtdblk_dev, just cleanup.
Signed-off-by Gu Zheng <[email protected]>
--- drivers/mtd/mtdblock.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/mtd/mtdblock.c +6 -1
@@ -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; };/*
Signature · 3 lines
1.7.7 .
PATCH RESEND 3/3 mtd/mtdblock: introduce helper macro blktrans_dev_to_mtdblk to wrap the conversion (mtd_blktrans_dev to mtdblk_dev)
In reply to a message not in the archiveIntroduce helper macro blktrans_dev_to_mtdblk to wrap the conversion (mtd_blktrans_dev to mtdblk_dev), just cleanup.
Signed-off-by Gu Zheng <[email protected]>
--- drivers/mtd/mtdblock.c | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-)
drivers/mtd/mtdblock.c +9 -5
@@ -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);
Signature · 3 lines
1.7.7 .