Skip to content

Commit

Permalink
mtd: simplify get_mtd_device_nm function
Browse files Browse the repository at this point in the history
'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>
  • Loading branch information
Wanlong Gao authored and David Woodhouse committed May 25, 2011
1 parent 7c802fb commit 52534f2
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions drivers/mtd/mtdcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 52534f2

Please sign in to comment.