]> err.no Git - linux-2.6/blobdiff - drivers/mtd/ubi/build.c
Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[linux-2.6] / drivers / mtd / ubi / build.c
index 336482a55f84cff6f5bb65f84e031079b26ab02d..023653977a1ad762ecf1bc371d6b68fc328211fe 100644 (file)
@@ -565,7 +565,7 @@ static int attach_mtd_dev(const char *mtd_dev, int vid_hdr_offset,
                }
 
        ubi = ubi_devices[ubi_devices_cnt] = kzalloc(sizeof(struct ubi_device),
-                                                     GFP_KERNEL);
+                                                    GFP_KERNEL);
        if (!ubi) {
                err = -ENOMEM;
                goto out_mtd;
@@ -583,6 +583,22 @@ static int attach_mtd_dev(const char *mtd_dev, int vid_hdr_offset,
        if (err)
                goto out_free;
 
+       mutex_init(&ubi->buf_mutex);
+       ubi->peb_buf1 = vmalloc(ubi->peb_size);
+       if (!ubi->peb_buf1)
+               goto out_free;
+
+       ubi->peb_buf2 = vmalloc(ubi->peb_size);
+       if (!ubi->peb_buf2)
+                goto out_free;
+
+#ifdef CONFIG_MTD_UBI_DEBUG
+       mutex_init(&ubi->dbg_buf_mutex);
+       ubi->dbg_peb_buf = vmalloc(ubi->peb_size);
+       if (!ubi->dbg_peb_buf)
+                goto out_free;
+#endif
+
        err = attach_by_scanning(ubi);
        if (err) {
                dbg_err("failed to attach by scanning, error %d", err);
@@ -630,6 +646,11 @@ out_detach:
        ubi_wl_close(ubi);
        vfree(ubi->vtbl);
 out_free:
+       vfree(ubi->peb_buf1);
+       vfree(ubi->peb_buf2);
+#ifdef CONFIG_MTD_UBI_DEBUG
+       vfree(ubi->dbg_peb_buf);
+#endif
        kfree(ubi);
 out_mtd:
        put_mtd_device(mtd);
@@ -651,6 +672,11 @@ static void detach_mtd_dev(struct ubi_device *ubi)
        ubi_wl_close(ubi);
        vfree(ubi->vtbl);
        put_mtd_device(ubi->mtd);
+       vfree(ubi->peb_buf1);
+       vfree(ubi->peb_buf2);
+#ifdef CONFIG_MTD_UBI_DEBUG
+       vfree(ubi->dbg_peb_buf);
+#endif
        kfree(ubi_devices[ubi_num]);
        ubi_devices[ubi_num] = NULL;
        ubi_devices_cnt -= 1;
@@ -685,13 +711,6 @@ static int __init ubi_init(void)
                struct mtd_dev_param *p = &mtd_dev_param[i];
 
                cond_resched();
-
-               if (!p->name) {
-                       dbg_err("empty name");
-                       err = -EINVAL;
-                       goto out_detach;
-               }
-
                err = attach_mtd_dev(p->name, p->vid_hdr_offs, p->data_offs);
                if (err)
                        goto out_detach;
@@ -798,7 +817,7 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
 
        /* Get rid of the final newline */
        if (buf[len - 1] == '\n')
-               buf[len - 1] = 0;
+               buf[len - 1] = '\0';
 
        for (i = 0; i < 3; i++)
                tokens[i] = strsep(&pbuf, ",");
@@ -808,9 +827,6 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
                return -EINVAL;
        }
 
-       if (tokens[0] == '\0')
-               return -EINVAL;
-
        p = &mtd_dev_param[mtd_devs];
        strcpy(&p->name[0], tokens[0]);