Patchwork [1/2] driver:mtd:use the wrapped __get_mtd_device in get_mtd_device_nm

login
register
mail settings
Submitter wanlong.gao@gmail.com
Date May 17, 2011, 2:36 p.m.
Message ID <1305642979-7419-1-git-send-email-wanlong.gao@gmail.com>
Download mbox | patch
Permalink /patch/95945/
State New
Headers show

Comments

wanlong.gao@gmail.com - May 17, 2011, 2:36 p.m.
From: Wanlong Gao <wanlong.gao@gmail.com>

Use the wrapped function __get_mtd_device in the function
get_mtd_device_nm instead of these get device reference codes.

Signed-off-by: Wanlong Gao <wanlong.gao@gmail.com>
---
 drivers/mtd/mtdcore.c |   12 ++----------
 1 files changed, 2 insertions(+), 10 deletions(-)
Artem Bityutskiy - May 20, 2011, 5:34 a.m.
On Tue, 2011-05-17 at 22:36 +0800, Wanlong Gao wrote:
> From: Wanlong Gao <wanlong.gao@gmail.com>
> 
> Use the wrapped function __get_mtd_device in the function
> get_mtd_device_nm instead of these get device reference codes.
> 
> Signed-off-by: Wanlong Gao <wanlong.gao@gmail.com>

Pushed this patch to l2-mtd-2.6.git, thanks.

Patch

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index da69bc8..9b7ad35 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -570,21 +570,13 @@  struct mtd_info *get_mtd_device_nm(const char *name)
 	if (!mtd)
 		goto out_unlock;
 
-	if (!try_module_get(mtd->owner))
+	err = __get_mtd_device(mtd);
+	if (err)
 		goto out_unlock;
 
-	if (mtd->get_device) {
-		err = mtd->get_device(mtd);
-		if (err)
-			goto out_put;
-	}
-
-	mtd->usecount++;
 	mutex_unlock(&mtd_table_mutex);
 	return mtd;
 
-out_put:
-	module_put(mtd->owner);
 out_unlock:
 	mutex_unlock(&mtd_table_mutex);
 	return ERR_PTR(err);