aboutsummaryrefslogtreecommitdiffstats
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, 7 insertions, 18 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 555d594d1811..1cb22bfae750 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -33,6 +33,7 @@
33#include <linux/moduleparam.h> 33#include <linux/moduleparam.h>
34#include <linux/stringify.h> 34#include <linux/stringify.h>
35#include <linux/stat.h> 35#include <linux/stat.h>
36#include <linux/log2.h>
36#include "ubi.h" 37#include "ubi.h"
37 38
38/* Maximum length of the 'mtd=' parameter */ 39/* Maximum length of the 'mtd=' parameter */
@@ -369,7 +370,7 @@ static int attach_by_scanning(struct ubi_device *ubi)
369out_wl: 370out_wl:
370 ubi_wl_close(ubi); 371 ubi_wl_close(ubi);
371out_vtbl: 372out_vtbl:
372 kfree(ubi->vtbl); 373 vfree(ubi->vtbl);
373out_si: 374out_si:
374 ubi_scan_destroy_si(si); 375 ubi_scan_destroy_si(si);
375 return err; 376 return err;
@@ -422,8 +423,7 @@ static int io_init(struct ubi_device *ubi)
422 ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft; 423 ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft;
423 424
424 /* Make sure minimal I/O unit is power of 2 */ 425 /* Make sure minimal I/O unit is power of 2 */
425 if (ubi->min_io_size == 0 || 426 if (!is_power_of_2(ubi->min_io_size)) {
426 (ubi->min_io_size & (ubi->min_io_size - 1))) {
427 ubi_err("bad min. I/O unit"); 427 ubi_err("bad min. I/O unit");
428 return -EINVAL; 428 return -EINVAL;
429 } 429 }
@@ -593,8 +593,6 @@ static int attach_mtd_dev(const char *mtd_dev, int vid_hdr_offset,
593 if (err) 593 if (err)
594 goto out_detach; 594 goto out_detach;
595 595
596 ubi_devices_cnt += 1;
597
598 ubi_msg("attached mtd%d to ubi%d", ubi->mtd->index, ubi_devices_cnt); 596 ubi_msg("attached mtd%d to ubi%d", ubi->mtd->index, ubi_devices_cnt);
599 ubi_msg("MTD device name: \"%s\"", ubi->mtd->name); 597 ubi_msg("MTD device name: \"%s\"", ubi->mtd->name);
600 ubi_msg("MTD device size: %llu MiB", ubi->flash_size >> 20); 598 ubi_msg("MTD device size: %llu MiB", ubi->flash_size >> 20);
@@ -624,12 +622,13 @@ static int attach_mtd_dev(const char *mtd_dev, int vid_hdr_offset,
624 wake_up_process(ubi->bgt_thread); 622 wake_up_process(ubi->bgt_thread);
625 } 623 }
626 624
625 ubi_devices_cnt += 1;
627 return 0; 626 return 0;
628 627
629out_detach: 628out_detach:
630 ubi_eba_close(ubi); 629 ubi_eba_close(ubi);
631 ubi_wl_close(ubi); 630 ubi_wl_close(ubi);
632 kfree(ubi->vtbl); 631 vfree(ubi->vtbl);
633out_free: 632out_free:
634 kfree(ubi); 633 kfree(ubi);
635out_mtd: 634out_mtd:
@@ -650,7 +649,7 @@ static void detach_mtd_dev(struct ubi_device *ubi)
650 uif_close(ubi); 649 uif_close(ubi);
651 ubi_eba_close(ubi); 650 ubi_eba_close(ubi);
652 ubi_wl_close(ubi); 651 ubi_wl_close(ubi);
653 kfree(ubi->vtbl); 652 vfree(ubi->vtbl);
654 put_mtd_device(ubi->mtd); 653 put_mtd_device(ubi->mtd);
655 kfree(ubi_devices[ubi_num]); 654 kfree(ubi_devices[ubi_num]);
656 ubi_devices[ubi_num] = NULL; 655 ubi_devices[ubi_num] = NULL;
@@ -686,13 +685,6 @@ static int __init ubi_init(void)
686 struct mtd_dev_param *p = &mtd_dev_param[i]; 685 struct mtd_dev_param *p = &mtd_dev_param[i];
687 686
688 cond_resched(); 687 cond_resched();
689
690 if (!p->name) {
691 dbg_err("empty name");
692 err = -EINVAL;
693 goto out_detach;
694 }
695
696 err = attach_mtd_dev(p->name, p->vid_hdr_offs, p->data_offs); 688 err = attach_mtd_dev(p->name, p->vid_hdr_offs, p->data_offs);
697 if (err) 689 if (err)
698 goto out_detach; 690 goto out_detach;
@@ -799,7 +791,7 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
799 791
800 /* Get rid of the final newline */ 792 /* Get rid of the final newline */
801 if (buf[len - 1] == '\n') 793 if (buf[len - 1] == '\n')
802 buf[len - 1] = 0; 794 buf[len - 1] = '\0';
803 795
804 for (i = 0; i < 3; i++) 796 for (i = 0; i < 3; i++)
805 tokens[i] = strsep(&pbuf, ","); 797 tokens[i] = strsep(&pbuf, ",");
@@ -809,9 +801,6 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
809 return -EINVAL; 801 return -EINVAL;
810 } 802 }
811 803
812 if (tokens[0] == '\0')
813 return -EINVAL;
814
815 p = &mtd_dev_param[mtd_devs]; 804 p = &mtd_dev_param[mtd_devs];
816 strcpy(&p->name[0], tokens[0]); 805 strcpy(&p->name[0], tokens[0]);
817 806