diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-21 10:23:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-05-21 10:23:12 -0400 |
commit | c316ba3b518bc35ce5aef5421135220389f4eb98 (patch) | |
tree | 36bb4ab299728da14f3cd1a67d7f572d50693880 | |
parent | 777cb1b53dd11dbec6157adc97e9f908f6e8458c (diff) | |
parent | be436f6238a17b8432b9de0212bcfc838afb1f85 (diff) |
Merge branch 'linux-next' of git://git.infradead.org/ubi-2.6
* 'linux-next' of git://git.infradead.org/ubi-2.6:
UBI: misc comment fixes
UBI: fix s/then/than/ typos
UBI: init even if MTD device cannot be attached, if built into kernel
UBI: remove reboot notifier
-rw-r--r-- | drivers/mtd/ubi/Kconfig | 2 | ||||
-rw-r--r-- | drivers/mtd/ubi/build.c | 60 | ||||
-rw-r--r-- | drivers/mtd/ubi/io.c | 6 | ||||
-rw-r--r-- | drivers/mtd/ubi/kapi.c | 6 | ||||
-rw-r--r-- | drivers/mtd/ubi/scan.c | 4 | ||||
-rw-r--r-- | drivers/mtd/ubi/ubi.h | 2 | ||||
-rw-r--r-- | drivers/mtd/ubi/vtbl.c | 4 | ||||
-rw-r--r-- | drivers/mtd/ubi/wl.c | 2 |
8 files changed, 35 insertions, 51 deletions
diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig index 0a8c7ea764ae..f702a163d8df 100644 --- a/drivers/mtd/ubi/Kconfig +++ b/drivers/mtd/ubi/Kconfig | |||
@@ -27,7 +27,7 @@ config MTD_UBI_WL_THRESHOLD | |||
27 | The default value should be OK for SLC NAND flashes, NOR flashes and | 27 | The default value should be OK for SLC NAND flashes, NOR flashes and |
28 | other flashes which have eraseblock life-cycle 100000 or more. | 28 | other flashes which have eraseblock life-cycle 100000 or more. |
29 | However, in case of MLC NAND flashes which typically have eraseblock | 29 | However, in case of MLC NAND flashes which typically have eraseblock |
30 | life-cycle less then 10000, the threshold should be lessened (e.g., | 30 | life-cycle less than 10000, the threshold should be lessened (e.g., |
31 | to 128 or 256, although it does not have to be power of 2). | 31 | to 128 or 256, although it does not have to be power of 2). |
32 | 32 | ||
33 | config MTD_UBI_BEB_RESERVE | 33 | config MTD_UBI_BEB_RESERVE |
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 55c726dde942..13b05cb33b08 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <linux/miscdevice.h> | 42 | #include <linux/miscdevice.h> |
43 | #include <linux/log2.h> | 43 | #include <linux/log2.h> |
44 | #include <linux/kthread.h> | 44 | #include <linux/kthread.h> |
45 | #include <linux/reboot.h> | ||
46 | #include <linux/kernel.h> | 45 | #include <linux/kernel.h> |
47 | #include <linux/slab.h> | 46 | #include <linux/slab.h> |
48 | #include "ubi.h" | 47 | #include "ubi.h" |
@@ -50,6 +49,12 @@ | |||
50 | /* Maximum length of the 'mtd=' parameter */ | 49 | /* Maximum length of the 'mtd=' parameter */ |
51 | #define MTD_PARAM_LEN_MAX 64 | 50 | #define MTD_PARAM_LEN_MAX 64 |
52 | 51 | ||
52 | #ifdef CONFIG_MTD_UBI_MODULE | ||
53 | #define ubi_is_module() 1 | ||
54 | #else | ||
55 | #define ubi_is_module() 0 | ||
56 | #endif | ||
57 | |||
53 | /** | 58 | /** |
54 | * struct mtd_dev_param - MTD device parameter description data structure. | 59 | * struct mtd_dev_param - MTD device parameter description data structure. |
55 | * @name: MTD character device node path, MTD device name, or MTD device number | 60 | * @name: MTD character device node path, MTD device name, or MTD device number |
@@ -832,34 +837,6 @@ static int autoresize(struct ubi_device *ubi, int vol_id) | |||
832 | } | 837 | } |
833 | 838 | ||
834 | /** | 839 | /** |
835 | * ubi_reboot_notifier - halt UBI transactions immediately prior to a reboot. | ||
836 | * @n: reboot notifier object | ||
837 | * @state: SYS_RESTART, SYS_HALT, or SYS_POWER_OFF | ||
838 | * @cmd: pointer to command string for RESTART2 | ||
839 | * | ||
840 | * This function stops the UBI background thread so that the flash device | ||
841 | * remains quiescent when Linux restarts the system. Any queued work will be | ||
842 | * discarded, but this function will block until do_work() finishes if an | ||
843 | * operation is already in progress. | ||
844 | * | ||
845 | * This function solves a real-life problem observed on NOR flashes when an | ||
846 | * PEB erase operation starts, then the system is rebooted before the erase is | ||
847 | * finishes, and the boot loader gets confused and dies. So we prefer to finish | ||
848 | * the ongoing operation before rebooting. | ||
849 | */ | ||
850 | static int ubi_reboot_notifier(struct notifier_block *n, unsigned long state, | ||
851 | void *cmd) | ||
852 | { | ||
853 | struct ubi_device *ubi; | ||
854 | |||
855 | ubi = container_of(n, struct ubi_device, reboot_notifier); | ||
856 | if (ubi->bgt_thread) | ||
857 | kthread_stop(ubi->bgt_thread); | ||
858 | ubi_sync(ubi->ubi_num); | ||
859 | return NOTIFY_DONE; | ||
860 | } | ||
861 | |||
862 | /** | ||
863 | * ubi_attach_mtd_dev - attach an MTD device. | 840 | * ubi_attach_mtd_dev - attach an MTD device. |
864 | * @mtd: MTD device description object | 841 | * @mtd: MTD device description object |
865 | * @ubi_num: number to assign to the new UBI device | 842 | * @ubi_num: number to assign to the new UBI device |
@@ -1016,11 +993,6 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset) | |||
1016 | wake_up_process(ubi->bgt_thread); | 993 | wake_up_process(ubi->bgt_thread); |
1017 | spin_unlock(&ubi->wl_lock); | 994 | spin_unlock(&ubi->wl_lock); |
1018 | 995 | ||
1019 | /* Flash device priority is 0 - UBI needs to shut down first */ | ||
1020 | ubi->reboot_notifier.priority = 1; | ||
1021 | ubi->reboot_notifier.notifier_call = ubi_reboot_notifier; | ||
1022 | register_reboot_notifier(&ubi->reboot_notifier); | ||
1023 | |||
1024 | ubi_devices[ubi_num] = ubi; | 996 | ubi_devices[ubi_num] = ubi; |
1025 | ubi_notify_all(ubi, UBI_VOLUME_ADDED, NULL); | 997 | ubi_notify_all(ubi, UBI_VOLUME_ADDED, NULL); |
1026 | return ubi_num; | 998 | return ubi_num; |
@@ -1091,7 +1063,6 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway) | |||
1091 | * Before freeing anything, we have to stop the background thread to | 1063 | * Before freeing anything, we have to stop the background thread to |
1092 | * prevent it from doing anything on this device while we are freeing. | 1064 | * prevent it from doing anything on this device while we are freeing. |
1093 | */ | 1065 | */ |
1094 | unregister_reboot_notifier(&ubi->reboot_notifier); | ||
1095 | if (ubi->bgt_thread) | 1066 | if (ubi->bgt_thread) |
1096 | kthread_stop(ubi->bgt_thread); | 1067 | kthread_stop(ubi->bgt_thread); |
1097 | 1068 | ||
@@ -1241,9 +1212,24 @@ static int __init ubi_init(void) | |||
1241 | p->vid_hdr_offs); | 1212 | p->vid_hdr_offs); |
1242 | mutex_unlock(&ubi_devices_mutex); | 1213 | mutex_unlock(&ubi_devices_mutex); |
1243 | if (err < 0) { | 1214 | if (err < 0) { |
1244 | put_mtd_device(mtd); | ||
1245 | ubi_err("cannot attach mtd%d", mtd->index); | 1215 | ubi_err("cannot attach mtd%d", mtd->index); |
1246 | goto out_detach; | 1216 | put_mtd_device(mtd); |
1217 | |||
1218 | /* | ||
1219 | * Originally UBI stopped initializing on any error. | ||
1220 | * However, later on it was found out that this | ||
1221 | * behavior is not very good when UBI is compiled into | ||
1222 | * the kernel and the MTD devices to attach are passed | ||
1223 | * through the command line. Indeed, UBI failure | ||
1224 | * stopped whole boot sequence. | ||
1225 | * | ||
1226 | * To fix this, we changed the behavior for the | ||
1227 | * non-module case, but preserved the old behavior for | ||
1228 | * the module case, just for compatibility. This is a | ||
1229 | * little inconsistent, though. | ||
1230 | */ | ||
1231 | if (ubi_is_module()) | ||
1232 | goto out_detach; | ||
1247 | } | 1233 | } |
1248 | } | 1234 | } |
1249 | 1235 | ||
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index 533b1a4b9af1..4b979e34b159 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c | |||
@@ -64,9 +64,9 @@ | |||
64 | * device, e.g., make @ubi->min_io_size = 512 in the example above? | 64 | * device, e.g., make @ubi->min_io_size = 512 in the example above? |
65 | * | 65 | * |
66 | * A: because when writing a sub-page, MTD still writes a full 2K page but the | 66 | * A: because when writing a sub-page, MTD still writes a full 2K page but the |
67 | * bytes which are no relevant to the sub-page are 0xFF. So, basically, writing | 67 | * bytes which are not relevant to the sub-page are 0xFF. So, basically, |
68 | * 4x512 sub-pages is 4 times slower then writing one 2KiB NAND page. Thus, we | 68 | * writing 4x512 sub-pages is 4 times slower than writing one 2KiB NAND page. |
69 | * prefer to use sub-pages only for EV and VID headers. | 69 | * Thus, we prefer to use sub-pages only for EC and VID headers. |
70 | * | 70 | * |
71 | * As it was noted above, the VID header may start at a non-aligned offset. | 71 | * As it was noted above, the VID header may start at a non-aligned offset. |
72 | * For example, in case of a 2KiB page NAND flash with a 512 bytes sub-page, | 72 | * For example, in case of a 2KiB page NAND flash with a 512 bytes sub-page, |
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c index 17f287decc36..69fa4ef03c53 100644 --- a/drivers/mtd/ubi/kapi.c +++ b/drivers/mtd/ubi/kapi.c | |||
@@ -488,7 +488,7 @@ EXPORT_SYMBOL_GPL(ubi_leb_write); | |||
488 | * | 488 | * |
489 | * This function changes the contents of a logical eraseblock atomically. @buf | 489 | * This function changes the contents of a logical eraseblock atomically. @buf |
490 | * has to contain new logical eraseblock data, and @len - the length of the | 490 | * has to contain new logical eraseblock data, and @len - the length of the |
491 | * data, which has to be aligned. The length may be shorter then the logical | 491 | * data, which has to be aligned. The length may be shorter than the logical |
492 | * eraseblock size, ant the logical eraseblock may be appended to more times | 492 | * eraseblock size, ant the logical eraseblock may be appended to more times |
493 | * later on. This function guarantees that in case of an unclean reboot the old | 493 | * later on. This function guarantees that in case of an unclean reboot the old |
494 | * contents is preserved. Returns zero in case of success and a negative error | 494 | * contents is preserved. Returns zero in case of success and a negative error |
@@ -571,7 +571,7 @@ EXPORT_SYMBOL_GPL(ubi_leb_erase); | |||
571 | * | 571 | * |
572 | * This function un-maps logical eraseblock @lnum and schedules the | 572 | * This function un-maps logical eraseblock @lnum and schedules the |
573 | * corresponding physical eraseblock for erasure, so that it will eventually be | 573 | * corresponding physical eraseblock for erasure, so that it will eventually be |
574 | * physically erased in background. This operation is much faster then the | 574 | * physically erased in background. This operation is much faster than the |
575 | * erase operation. | 575 | * erase operation. |
576 | * | 576 | * |
577 | * Unlike erase, the un-map operation does not guarantee that the logical | 577 | * Unlike erase, the un-map operation does not guarantee that the logical |
@@ -590,7 +590,7 @@ EXPORT_SYMBOL_GPL(ubi_leb_erase); | |||
590 | * | 590 | * |
591 | * The main and obvious use-case of this function is when the contents of a | 591 | * The main and obvious use-case of this function is when the contents of a |
592 | * logical eraseblock has to be re-written. Then it is much more efficient to | 592 | * logical eraseblock has to be re-written. Then it is much more efficient to |
593 | * first un-map it, then write new data, rather then first erase it, then write | 593 | * first un-map it, then write new data, rather than first erase it, then write |
594 | * new data. Note, once new data has been written to the logical eraseblock, | 594 | * new data. Note, once new data has been written to the logical eraseblock, |
595 | * UBI guarantees that the old contents has gone forever. In other words, if an | 595 | * UBI guarantees that the old contents has gone forever. In other words, if an |
596 | * unclean reboot happens after the logical eraseblock has been un-mapped and | 596 | * unclean reboot happens after the logical eraseblock has been un-mapped and |
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index dc5f688699da..aed19f33b8f3 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c | |||
@@ -231,7 +231,7 @@ static struct ubi_scan_volume *add_volume(struct ubi_scan_info *si, int vol_id, | |||
231 | * case of success this function returns a positive value, in case of failure, a | 231 | * case of success this function returns a positive value, in case of failure, a |
232 | * negative error code is returned. The success return codes use the following | 232 | * negative error code is returned. The success return codes use the following |
233 | * bits: | 233 | * bits: |
234 | * o bit 0 is cleared: the first PEB (described by @seb) is newer then the | 234 | * o bit 0 is cleared: the first PEB (described by @seb) is newer than the |
235 | * second PEB (described by @pnum and @vid_hdr); | 235 | * second PEB (described by @pnum and @vid_hdr); |
236 | * o bit 0 is set: the second PEB is newer; | 236 | * o bit 0 is set: the second PEB is newer; |
237 | * o bit 1 is cleared: no bit-flips were detected in the newer LEB; | 237 | * o bit 1 is cleared: no bit-flips were detected in the newer LEB; |
@@ -452,7 +452,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si, | |||
452 | 452 | ||
453 | if (cmp_res & 1) { | 453 | if (cmp_res & 1) { |
454 | /* | 454 | /* |
455 | * This logical eraseblock is newer then the one | 455 | * This logical eraseblock is newer than the one |
456 | * found earlier. | 456 | * found earlier. |
457 | */ | 457 | */ |
458 | err = validate_vid_hdr(vid_hdr, sv, pnum); | 458 | err = validate_vid_hdr(vid_hdr, sv, pnum); |
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index 5176d4886518..a637f0283add 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
@@ -350,7 +350,6 @@ struct ubi_wl_entry; | |||
350 | * @bgt_thread: background thread description object | 350 | * @bgt_thread: background thread description object |
351 | * @thread_enabled: if the background thread is enabled | 351 | * @thread_enabled: if the background thread is enabled |
352 | * @bgt_name: background thread name | 352 | * @bgt_name: background thread name |
353 | * @reboot_notifier: notifier to terminate background thread before rebooting | ||
354 | * | 353 | * |
355 | * @flash_size: underlying MTD device size (in bytes) | 354 | * @flash_size: underlying MTD device size (in bytes) |
356 | * @peb_count: count of physical eraseblocks on the MTD device | 355 | * @peb_count: count of physical eraseblocks on the MTD device |
@@ -436,7 +435,6 @@ struct ubi_device { | |||
436 | struct task_struct *bgt_thread; | 435 | struct task_struct *bgt_thread; |
437 | int thread_enabled; | 436 | int thread_enabled; |
438 | char bgt_name[sizeof(UBI_BGT_NAME_PATTERN)+2]; | 437 | char bgt_name[sizeof(UBI_BGT_NAME_PATTERN)+2]; |
439 | struct notifier_block reboot_notifier; | ||
440 | 438 | ||
441 | /* I/O sub-system's stuff */ | 439 | /* I/O sub-system's stuff */ |
442 | long long flash_size; | 440 | long long flash_size; |
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index cd90ff3b76b1..14c10bed94ee 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c | |||
@@ -414,7 +414,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, | |||
414 | * 0 contains more recent information. | 414 | * 0 contains more recent information. |
415 | * | 415 | * |
416 | * So the plan is to first check LEB 0. Then | 416 | * So the plan is to first check LEB 0. Then |
417 | * a. if LEB 0 is OK, it must be containing the most resent data; then | 417 | * a. if LEB 0 is OK, it must be containing the most recent data; then |
418 | * we compare it with LEB 1, and if they are different, we copy LEB | 418 | * we compare it with LEB 1, and if they are different, we copy LEB |
419 | * 0 to LEB 1; | 419 | * 0 to LEB 1; |
420 | * b. if LEB 0 is corrupted, but LEB 1 has to be OK, and we copy LEB 1 | 420 | * b. if LEB 0 is corrupted, but LEB 1 has to be OK, and we copy LEB 1 |
@@ -848,7 +848,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si) | |||
848 | goto out_free; | 848 | goto out_free; |
849 | 849 | ||
850 | /* | 850 | /* |
851 | * Get sure that the scanning information is consistent to the | 851 | * Make sure that the scanning information is consistent to the |
852 | * information stored in the volume table. | 852 | * information stored in the volume table. |
853 | */ | 853 | */ |
854 | err = check_scanning_info(ubi, si); | 854 | err = check_scanning_info(ubi, si); |
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index f64ddabd4ac8..ee7b1d8fbb92 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c | |||
@@ -350,7 +350,7 @@ static void prot_queue_add(struct ubi_device *ubi, struct ubi_wl_entry *e) | |||
350 | * @max: highest possible erase counter | 350 | * @max: highest possible erase counter |
351 | * | 351 | * |
352 | * This function looks for a wear leveling entry with erase counter closest to | 352 | * This function looks for a wear leveling entry with erase counter closest to |
353 | * @max and less then @max. | 353 | * @max and less than @max. |
354 | */ | 354 | */ |
355 | static struct ubi_wl_entry *find_wl_entry(struct rb_root *root, int max) | 355 | static struct ubi_wl_entry *find_wl_entry(struct rb_root *root, int max) |
356 | { | 356 | { |