aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorWanlong Gao <wanlong.gao@gmail.com>2011-05-17 10:36:18 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2011-05-24 21:05:49 -0400
commit52534f2dba5d033c0c33e515faa2767d7e8e986a (patch)
treec4d78a663b4c6e3fcc0f912e3be0860984fab947 /drivers/mtd
parent7c802fbd541448accec7bbc0e72ef38693a29593 (diff)
mtd: simplify get_mtd_device_nm function
'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>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/mtdcore.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index d162426416de..8e1909115924 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -533,7 +533,6 @@ int __get_mtd_device(struct mtd_info *mtd)
533 return -ENODEV; 533 return -ENODEV;
534 534
535 if (mtd->get_device) { 535 if (mtd->get_device) {
536
537 err = mtd->get_device(mtd); 536 err = mtd->get_device(mtd);
538 537
539 if (err) { 538 if (err) {
@@ -571,21 +570,13 @@ struct mtd_info *get_mtd_device_nm(const char *name)
571 if (!mtd) 570 if (!mtd)
572 goto out_unlock; 571 goto out_unlock;
573 572
574 if (!try_module_get(mtd->owner)) 573 err = __get_mtd_device(mtd);
574 if (err)
575 goto out_unlock; 575 goto out_unlock;
576 576
577 if (mtd->get_device) {
578 err = mtd->get_device(mtd);
579 if (err)
580 goto out_put;
581 }
582
583 mtd->usecount++;
584 mutex_unlock(&mtd_table_mutex); 577 mutex_unlock(&mtd_table_mutex);
585 return mtd; 578 return mtd;
586 579
587out_put:
588 module_put(mtd->owner);
589out_unlock: 580out_unlock:
590 mutex_unlock(&mtd_table_mutex); 581 mutex_unlock(&mtd_table_mutex);
591 return ERR_PTR(err); 582 return ERR_PTR(err);