summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/build.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/build.c')
-rw-r--r--drivers/mtd/ubi/build.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 604fe87e53..94b4231aad 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -1,17 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) International Business Machines Corp., 2006
* Copyright (c) Nokia Corporation, 2007
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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.
- *
* Author: Artem Bityutskiy (Битюцкий Артём),
* Frank Haverkamp
*/
@@ -159,7 +150,7 @@ static int uif_init(struct ubi_device *ubi, int *ref)
dev_set_name(&ubi->dev, "%s.ubi", ubi->mtd->cdev.name);
ubi->dev.id = DEVICE_ID_SINGLE;
- ubi->dev.parent = &ubi->mtd->class_dev;
+ ubi->dev.parent = &ubi->mtd->dev;
err = register_device(&ubi->dev);
if (err)
@@ -241,8 +232,8 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024)
* is that all the bad eraseblocks of the chip are in
* the MTD partition we are attaching (ubi->mtd).
*/
- if (ubi->mtd->master)
- device_size = ubi->mtd->master->size;
+ if (ubi->mtd->parent)
+ device_size = ubi->mtd->parent->size;
else
device_size = ubi->mtd->size;
@@ -508,6 +499,14 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
struct ubi_device *ubi;
int i, err, ref = 0;
+ /*
+ * Do not try to attach an UBI device if this device has partitions
+ * as it's not a good idea to attach UBI on a raw device when the
+ * real UBI only spans the first partition.
+ */
+ if (!list_empty(&mtd->partitions))
+ return -EBUSY;
+
if (max_beb_per1024 < 0 || max_beb_per1024 > MAX_MTD_UBI_BEB_LIMIT)
return -EINVAL;