mtd: simplify get_mtd_device_nm function
authorWanlong Gao <wanlong.gao@gmail.com>
Tue, 17 May 2011 14:36:18 +0000 (22:36 +0800)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Wed, 25 May 2011 01:05:49 +0000 (02:05 +0100)
'get_mtd_device_nm()' has a piece of code which equivalent to what
'__get_mtd_device()' does - remove this duplicated code and use
''__get_mtd_device()' instead.

Artem: changed commit message.
Artem: while on it, remove an unnecessary extra empty line

Signed-off-by: Wanlong Gao <wanlong.gao@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/mtdcore.c

index d162426416de817cf24706060a4b73bc980cbe0e..8e1909115924e03624a1e81b398c75a9e75eed6b 100644 (file)
@@ -533,7 +533,6 @@ int __get_mtd_device(struct mtd_info *mtd)
                return -ENODEV;
 
        if (mtd->get_device) {
-
                err = mtd->get_device(mtd);
 
                if (err) {
@@ -571,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);