Commit 2ee951ba2ac9874d2a93d52e7a187d3184be937e

Authored by Stefan Roese
1 parent 9def12cae3

UBI: Enable re-initializing of the "ubi part" command

With this patch now, the user can call "ubi part" multiple times to
re-connect the UBI device to another MTD partition.

Signed-off-by: Stefan Roese <sr@denx.de>

Showing 3 changed files with 13 additions and 0 deletions Side-by-side Diff

... ... @@ -31,6 +31,7 @@
31 31 /* Private own data */
32 32 static struct ubi_device *ubi;
33 33 static char buffer[80];
  34 +static int ubi_initialized;
34 35  
35 36 struct selected_dev {
36 37 char dev_name[32]; /* NAND/OneNAND etc */
... ... @@ -428,6 +429,8 @@
428 429 return err;
429 430 }
430 431  
  432 + ubi_initialized = 1;
  433 +
431 434 return 0;
432 435 }
433 436  
... ... @@ -462,6 +465,14 @@
462 465  
463 466 /* todo: get dev number for NAND... */
464 467 ubi_dev.nr = 0;
  468 +
  469 + /*
  470 + * Call ubi_exit() before re-initializing the UBI subsystem
  471 + */
  472 + if (ubi_initialized) {
  473 + ubi_exit();
  474 + del_mtd_partitions(ubi_dev.mtd_info);
  475 + }
465 476  
466 477 /*
467 478 * Check for nand|onenand selection
drivers/mtd/ubi/build.c
... ... @@ -1059,6 +1059,7 @@
1059 1059 misc_deregister(&ubi_ctrl_cdev);
1060 1060 class_remove_file(ubi_class, &ubi_version);
1061 1061 class_destroy(ubi_class);
  1062 + mtd_devs = 0;
1062 1063 }
1063 1064 module_exit(ubi_exit);
1064 1065  
... ... @@ -211,6 +211,7 @@
211 211 /* functions */
212 212 extern int ubi_mtd_param_parse(const char *val, struct kernel_param *kp);
213 213 extern int ubi_init(void);
  214 +extern void ubi_exit(void);
214 215  
215 216 extern struct ubi_device *ubi_devices[];
216 217