Skip to content

Commit 52534f2

Browse files
gaowanlongDavid Woodhouse
authored andcommitted
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>
1 parent 7c802fb commit 52534f2

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

‎drivers/mtd/mtdcore.c‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,6 @@ int __get_mtd_device(struct mtd_info *mtd)
533533
return -ENODEV;
534534

535535
if (mtd->get_device) {
536-
537536
err = mtd->get_device(mtd);
538537

539538
if (err) {
@@ -571,21 +570,13 @@ struct mtd_info *get_mtd_device_nm(const char *name)
571570
if (!mtd)
572571
goto out_unlock;
573572

574-
if (!try_module_get(mtd->owner))
573+
err = __get_mtd_device(mtd);
574+
if (err)
575575
goto out_unlock;
576576

577-
if (mtd->get_device) {
578-
err = mtd->get_device(mtd);
579-
if (err)
580-
goto out_put;
581-
}
582-
583-
mtd->usecount++;
584577
mutex_unlock(&mtd_table_mutex);
585578
return mtd;
586579

587-
out_put:
588-
module_put(mtd->owner);
589580
out_unlock:
590581
mutex_unlock(&mtd_table_mutex);
591582
return ERR_PTR(err);

0 commit comments

Comments
 (0)