aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/ubi/build.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 6ac133994f9..0ed8105f9c1 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -867,38 +867,26 @@ static void ltree_entry_ctor(struct kmem_cache *cache, void *obj)
867 * find_mtd_device - open an MTD device by its name or number. 867 * find_mtd_device - open an MTD device by its name or number.
868 * @mtd_dev: name or number of the device 868 * @mtd_dev: name or number of the device
869 * 869 *
870 * This function tries to open and MTD device with name @mtd_dev, and if it 870 * This function tries to open and MTD device described by @mtd_dev string,
871 * fails, then it tries to interpret the @mtd_dev string as an ASCII-coded 871 * which is first treated as an ASCII number, and if it is not true, it is
872 * integer and open an MTD device with this number. Returns MTD device 872 * treated as MTD device name. Returns MTD device description object in case of
873 * description object in case of success and a negative error code in case of 873 * success and a negative error code in case of failure.
874 * failure.
875 */ 874 */
876static struct mtd_info * __init open_mtd_device(const char *mtd_dev) 875static struct mtd_info * __init open_mtd_device(const char *mtd_dev)
877{ 876{
878 struct mtd_info *mtd; 877 struct mtd_info *mtd;
878 int mtd_num;
879 char *endp;
879 880
880 mtd = get_mtd_device_nm(mtd_dev); 881 mtd_num = simple_strtoul(mtd_dev, &endp, 0);
881 if (IS_ERR(mtd)) { 882 if (*endp != '\0' || mtd_dev == endp) {
882 int mtd_num;
883 char *endp;
884
885 if (PTR_ERR(mtd) != -ENODEV)
886 return mtd;
887
888 /* 883 /*
889 * Probably this is not MTD device name but MTD device number - 884 * This does not look like an ASCII integer, probably this is
890 * check this out. 885 * MTD device name.
891 */ 886 */
892 mtd_num = simple_strtoul(mtd_dev, &endp, 0); 887 mtd = get_mtd_device_nm(mtd_dev);
893 if (*endp != '\0' || mtd_dev == endp) { 888 } else
894 ubi_err("incorrect MTD device: \"%s\"", mtd_dev);
895 return ERR_PTR(-ENODEV);
896 }
897
898 mtd = get_mtd_device(NULL, mtd_num); 889 mtd = get_mtd_device(NULL, mtd_num);
899 if (IS_ERR(mtd))
900 return mtd;
901 }
902 890
903 return mtd; 891 return mtd;
904} 892}