diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-25 14:02:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-25 14:02:17 -0400 |
commit | 996abf053eec4d67136be8b911bbaaf989cfb99c (patch) | |
tree | e2596756d7f74d06a937b2e71306cd3827ad9947 /drivers/mtd/ubi/upd.c | |
parent | 93082f0b15841b8926c38ef224d0e6f720000635 (diff) | |
parent | d37e6bf68fc1eb34a4ad21d9ae8890ed37ea80e7 (diff) |
Merge branch 'linux-next' of git://git.infradead.org/~dedekind/ubi-2.6
* 'linux-next' of git://git.infradead.org/~dedekind/ubi-2.6: (22 commits)
UBI: always start the background thread
UBI: fix gcc warning
UBI: remove pre-sqnum images support
UBI: fix kernel-doc errors and warnings
UBI: fix checkpatch.pl errors and warnings
UBI: bugfix - do not torture PEB needlessly
UBI: rework scrubbing messages
UBI: implement multiple volumes rename
UBI: fix and re-work debugging stuff
UBI: amend commentaries
UBI: fix error message
UBI: improve mkvol request validation
UBI: add ubi_sync() interface
UBI: fix 64-bit calculations
UBI: fix LEB locking
UBI: fix memory leak on error path
UBI: do not forget to free internal volumes
UBI: fix memory leak
UBI: avoid unnecessary division operations
UBI: fix buffer padding
...
Diffstat (limited to 'drivers/mtd/ubi/upd.c')
-rw-r--r-- | drivers/mtd/ubi/upd.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/drivers/mtd/ubi/upd.c b/drivers/mtd/ubi/upd.c index ddaa1a56cc69..8b89cc18ff0b 100644 --- a/drivers/mtd/ubi/upd.c +++ b/drivers/mtd/ubi/upd.c | |||
@@ -39,7 +39,7 @@ | |||
39 | */ | 39 | */ |
40 | 40 | ||
41 | #include <linux/err.h> | 41 | #include <linux/err.h> |
42 | #include <asm/uaccess.h> | 42 | #include <linux/uaccess.h> |
43 | #include <asm/div64.h> | 43 | #include <asm/div64.h> |
44 | #include "ubi.h" | 44 | #include "ubi.h" |
45 | 45 | ||
@@ -56,11 +56,11 @@ static int set_update_marker(struct ubi_device *ubi, struct ubi_volume *vol) | |||
56 | int err; | 56 | int err; |
57 | struct ubi_vtbl_record vtbl_rec; | 57 | struct ubi_vtbl_record vtbl_rec; |
58 | 58 | ||
59 | dbg_msg("set update marker for volume %d", vol->vol_id); | 59 | dbg_gen("set update marker for volume %d", vol->vol_id); |
60 | 60 | ||
61 | if (vol->upd_marker) { | 61 | if (vol->upd_marker) { |
62 | ubi_assert(ubi->vtbl[vol->vol_id].upd_marker); | 62 | ubi_assert(ubi->vtbl[vol->vol_id].upd_marker); |
63 | dbg_msg("already set"); | 63 | dbg_gen("already set"); |
64 | return 0; | 64 | return 0; |
65 | } | 65 | } |
66 | 66 | ||
@@ -92,7 +92,7 @@ static int clear_update_marker(struct ubi_device *ubi, struct ubi_volume *vol, | |||
92 | uint64_t tmp; | 92 | uint64_t tmp; |
93 | struct ubi_vtbl_record vtbl_rec; | 93 | struct ubi_vtbl_record vtbl_rec; |
94 | 94 | ||
95 | dbg_msg("clear update marker for volume %d", vol->vol_id); | 95 | dbg_gen("clear update marker for volume %d", vol->vol_id); |
96 | 96 | ||
97 | memcpy(&vtbl_rec, &ubi->vtbl[vol->vol_id], | 97 | memcpy(&vtbl_rec, &ubi->vtbl[vol->vol_id], |
98 | sizeof(struct ubi_vtbl_record)); | 98 | sizeof(struct ubi_vtbl_record)); |
@@ -133,7 +133,7 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol, | |||
133 | int i, err; | 133 | int i, err; |
134 | uint64_t tmp; | 134 | uint64_t tmp; |
135 | 135 | ||
136 | dbg_msg("start update of volume %d, %llu bytes", vol->vol_id, bytes); | 136 | dbg_gen("start update of volume %d, %llu bytes", vol->vol_id, bytes); |
137 | ubi_assert(!vol->updating && !vol->changing_leb); | 137 | ubi_assert(!vol->updating && !vol->changing_leb); |
138 | vol->updating = 1; | 138 | vol->updating = 1; |
139 | 139 | ||
@@ -183,7 +183,7 @@ int ubi_start_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, | |||
183 | { | 183 | { |
184 | ubi_assert(!vol->updating && !vol->changing_leb); | 184 | ubi_assert(!vol->updating && !vol->changing_leb); |
185 | 185 | ||
186 | dbg_msg("start changing LEB %d:%d, %u bytes", | 186 | dbg_gen("start changing LEB %d:%d, %u bytes", |
187 | vol->vol_id, req->lnum, req->bytes); | 187 | vol->vol_id, req->lnum, req->bytes); |
188 | if (req->bytes == 0) | 188 | if (req->bytes == 0) |
189 | return ubi_eba_atomic_leb_change(ubi, vol, req->lnum, NULL, 0, | 189 | return ubi_eba_atomic_leb_change(ubi, vol, req->lnum, NULL, 0, |
@@ -237,16 +237,17 @@ static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, | |||
237 | int err; | 237 | int err; |
238 | 238 | ||
239 | if (vol->vol_type == UBI_DYNAMIC_VOLUME) { | 239 | if (vol->vol_type == UBI_DYNAMIC_VOLUME) { |
240 | len = ALIGN(len, ubi->min_io_size); | 240 | int l = ALIGN(len, ubi->min_io_size); |
241 | memset(buf + len, 0xFF, len - len); | ||
242 | 241 | ||
243 | len = ubi_calc_data_len(ubi, buf, len); | 242 | memset(buf + len, 0xFF, l - len); |
243 | len = ubi_calc_data_len(ubi, buf, l); | ||
244 | if (len == 0) { | 244 | if (len == 0) { |
245 | dbg_msg("all %d bytes contain 0xFF - skip", len); | 245 | dbg_gen("all %d bytes contain 0xFF - skip", len); |
246 | return 0; | 246 | return 0; |
247 | } | 247 | } |
248 | 248 | ||
249 | err = ubi_eba_write_leb(ubi, vol, lnum, buf, 0, len, UBI_UNKNOWN); | 249 | err = ubi_eba_write_leb(ubi, vol, lnum, buf, 0, len, |
250 | UBI_UNKNOWN); | ||
250 | } else { | 251 | } else { |
251 | /* | 252 | /* |
252 | * When writing static volume, and this is the last logical | 253 | * When writing static volume, and this is the last logical |
@@ -267,6 +268,7 @@ static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, | |||
267 | 268 | ||
268 | /** | 269 | /** |
269 | * ubi_more_update_data - write more update data. | 270 | * ubi_more_update_data - write more update data. |
271 | * @ubi: UBI device description object | ||
270 | * @vol: volume description object | 272 | * @vol: volume description object |
271 | * @buf: write data (user-space memory buffer) | 273 | * @buf: write data (user-space memory buffer) |
272 | * @count: how much bytes to write | 274 | * @count: how much bytes to write |
@@ -283,7 +285,7 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol, | |||
283 | uint64_t tmp; | 285 | uint64_t tmp; |
284 | int lnum, offs, err = 0, len, to_write = count; | 286 | int lnum, offs, err = 0, len, to_write = count; |
285 | 287 | ||
286 | dbg_msg("write %d of %lld bytes, %lld already passed", | 288 | dbg_gen("write %d of %lld bytes, %lld already passed", |
287 | count, vol->upd_bytes, vol->upd_received); | 289 | count, vol->upd_bytes, vol->upd_received); |
288 | 290 | ||
289 | if (ubi->ro_mode) | 291 | if (ubi->ro_mode) |
@@ -384,6 +386,7 @@ int ubi_more_update_data(struct ubi_device *ubi, struct ubi_volume *vol, | |||
384 | 386 | ||
385 | /** | 387 | /** |
386 | * ubi_more_leb_change_data - accept more data for atomic LEB change. | 388 | * ubi_more_leb_change_data - accept more data for atomic LEB change. |
389 | * @ubi: UBI device description object | ||
387 | * @vol: volume description object | 390 | * @vol: volume description object |
388 | * @buf: write data (user-space memory buffer) | 391 | * @buf: write data (user-space memory buffer) |
389 | * @count: how much bytes to write | 392 | * @count: how much bytes to write |
@@ -400,7 +403,7 @@ int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol, | |||
400 | { | 403 | { |
401 | int err; | 404 | int err; |
402 | 405 | ||
403 | dbg_msg("write %d of %lld bytes, %lld already passed", | 406 | dbg_gen("write %d of %lld bytes, %lld already passed", |
404 | count, vol->upd_bytes, vol->upd_received); | 407 | count, vol->upd_bytes, vol->upd_received); |
405 | 408 | ||
406 | if (ubi->ro_mode) | 409 | if (ubi->ro_mode) |
@@ -418,7 +421,8 @@ int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol, | |||
418 | if (vol->upd_received == vol->upd_bytes) { | 421 | if (vol->upd_received == vol->upd_bytes) { |
419 | int len = ALIGN((int)vol->upd_bytes, ubi->min_io_size); | 422 | int len = ALIGN((int)vol->upd_bytes, ubi->min_io_size); |
420 | 423 | ||
421 | memset(vol->upd_buf + vol->upd_bytes, 0xFF, len - vol->upd_bytes); | 424 | memset(vol->upd_buf + vol->upd_bytes, 0xFF, |
425 | len - vol->upd_bytes); | ||
422 | len = ubi_calc_data_len(ubi, vol->upd_buf, len); | 426 | len = ubi_calc_data_len(ubi, vol->upd_buf, len); |
423 | err = ubi_eba_atomic_leb_change(ubi, vol, vol->ch_lnum, | 427 | err = ubi_eba_atomic_leb_change(ubi, vol, vol->ch_lnum, |
424 | vol->upd_buf, len, UBI_UNKNOWN); | 428 | vol->upd_buf, len, UBI_UNKNOWN); |