summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/core.c')
-rw-r--r--drivers/mtd/core.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index c6c1e1e7cf..ec2c3ff7bb 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-only
/*
* (C) Copyright 2005
* 2N Telekomunikace, a.s. <www.2n.cz>
* Ladislav Michl <michl@2n.cz>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
*/
#include <common.h>
#include <linux/mtd/nand.h>
@@ -598,7 +590,7 @@ static int mtd_part_compare(struct list_head *a, struct list_head *b)
return 0;
}
-static int mtd_detect(struct device_d *dev)
+static int mtd_detect(struct device *dev)
{
struct mtd_info *mtd = container_of(dev, struct mtd_info, dev);
int bufsize = 512;
@@ -607,7 +599,10 @@ static int mtd_detect(struct device_d *dev)
enum filetype filetype;
int npebs = mtd_div_by_eb(mtd->size, mtd);
- npebs = max(npebs, 64);
+ /* No point in looking for UBI on a partition that's too small */
+ npebs = min(npebs, 64);
+ if (npebs < 5)
+ return 0;
/*
* Do not try to attach an UBI device if this device has partitions
@@ -652,8 +647,8 @@ static int mtd_partition_fixup_generic(struct mtd_info *mtd, struct device_node
np = of_find_node_by_reproducible_name(root, name);
free(name);
if (!np) {
- dev_err(&mtd->dev, "Cannot find nodepath %s, cannot fixup\n",
- mtdnp->full_name);
+ dev_err(&mtd->dev, "Cannot find nodepath %pOF, cannot fixup\n",
+ mtdnp);
return -EINVAL;
}
@@ -696,6 +691,7 @@ int add_mtd_device(struct mtd_info *mtd, const char *devname, int device_id)
mtd->dev.id);
INIT_LIST_HEAD(&mtd->partitions);
+ INIT_LIST_HEAD(&mtd->partitions_entry);
mtd->cdev.priv = mtd;
mtd->cdev.dev = &mtd->dev;
@@ -771,8 +767,7 @@ int del_mtd_device(struct mtd_info *mtd)
unregister_device(&mtd->dev);
free(mtd->param_size.value);
free(mtd->cdev.name);
- if (mtd->parent)
- list_del(&mtd->partitions_entry);
+ list_del(&mtd->partitions_entry);
return 0;
}