]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/mtd/ubi/build.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hskinnemoen...
[linux-2.6-omap-h63xx.git] / drivers / mtd / ubi / build.c
index 08ca214abb957a80b5f76f18f99860eb3aa28b94..1cb22bfae75066f31ee73ef9385b801f36e6b01d 100644 (file)
@@ -33,6 +33,7 @@
 #include <linux/moduleparam.h>
 #include <linux/stringify.h>
 #include <linux/stat.h>
+#include <linux/log2.h>
 #include "ubi.h"
 
 /* Maximum length of the 'mtd=' parameter */
@@ -422,8 +423,7 @@ static int io_init(struct ubi_device *ubi)
        ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft;
 
        /* Make sure minimal I/O unit is power of 2 */
-       if (ubi->min_io_size == 0 ||
-           (ubi->min_io_size & (ubi->min_io_size - 1))) {
+       if (!is_power_of_2(ubi->min_io_size)) {
                ubi_err("bad min. I/O unit");
                return -EINVAL;
        }
@@ -593,8 +593,6 @@ static int attach_mtd_dev(const char *mtd_dev, int vid_hdr_offset,
        if (err)
                goto out_detach;
 
-       ubi_devices_cnt += 1;
-
        ubi_msg("attached mtd%d to ubi%d", ubi->mtd->index, ubi_devices_cnt);
        ubi_msg("MTD device name:            \"%s\"", ubi->mtd->name);
        ubi_msg("MTD device size:            %llu MiB", ubi->flash_size >> 20);
@@ -624,6 +622,7 @@ static int attach_mtd_dev(const char *mtd_dev, int vid_hdr_offset,
                wake_up_process(ubi->bgt_thread);
        }
 
+       ubi_devices_cnt += 1;
        return 0;
 
 out_detach:
@@ -686,13 +685,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;
@@ -799,7 +791,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, ",");
@@ -809,9 +801,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]);