linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Gu Zheng <guz.fnst@cn.fujitsu.com>
To: <linux-mtd@lists.infradead.org>
Cc: Gu Zheng <guz.fnst@cn.fujitsu.com>,
	computersforpeace@gmail.com, dwmw2@infradead.org,
	linux-kernel@vger.kernel.org
Subject: [RESEND PATCH 3/3] mtd/mtdblock: introduce helper macro blktrans_dev_to_mtdblk to wrap the conversion (mtd_blktrans_dev to mtdblk_dev)
Date: Wed, 3 Dec 2014 10:20:21 +0800	[thread overview]
Message-ID: <547E7365.8090603@cn.fujitsu.com> (raw)
In-Reply-To: <1417052709-22026-1-git-send-email-guz.fnst@cn.fujitsu.com>

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

.

      parent reply	other threads:[~2014-12-03  2:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 [this message]

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=547E7365.8090603@cn.fujitsu.com \
    --to=guz.fnst@cn.fujitsu.com \
    --cc=computersforpeace@gmail.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;
as well as URLs for NNTP newsgroup(s).