diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-05-05 09:33:13 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2007-07-18 09:52:51 -0400 |
commit | 941dfb07ed91451b1c58626a0d258dfdf468b593 (patch) | |
tree | ddee58cc8960994237c83c852227a301dfc8378e | |
parent | 4ab60a0d7c92cab16f7e470f80ea039a0b174bce (diff) |
UBI: set correct gluebi device size
In case of static volumes, make emulated MTD device size to
be equivalent to data size, rather then volume size.
Reported-by: John Smith <john@arrows.demon.co.uk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r-- | drivers/mtd/ubi/cdev.c | 1 | ||||
-rw-r--r-- | drivers/mtd/ubi/gluebi.c | 27 | ||||
-rw-r--r-- | drivers/mtd/ubi/scan.c | 2 | ||||
-rw-r--r-- | drivers/mtd/ubi/ubi.h | 2 |
4 files changed, 30 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index 6612eb79bf17..959044a2ddbf 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c | |||
@@ -397,6 +397,7 @@ static ssize_t vol_cdev_write(struct file *file, const char __user *buf, | |||
397 | vol->corrupted = 1; | 397 | vol->corrupted = 1; |
398 | } | 398 | } |
399 | vol->checked = 1; | 399 | vol->checked = 1; |
400 | ubi_gluebi_updated(vol); | ||
400 | revoke_exclusive(desc, UBI_READWRITE); | 401 | revoke_exclusive(desc, UBI_READWRITE); |
401 | } | 402 | } |
402 | 403 | ||
diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c index fc9478d605ff..41ff74c60e14 100644 --- a/drivers/mtd/ubi/gluebi.c +++ b/drivers/mtd/ubi/gluebi.c | |||
@@ -282,7 +282,6 @@ int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol) | |||
282 | mtd->flags = MTD_WRITEABLE; | 282 | mtd->flags = MTD_WRITEABLE; |
283 | mtd->writesize = ubi->min_io_size; | 283 | mtd->writesize = ubi->min_io_size; |
284 | mtd->owner = THIS_MODULE; | 284 | mtd->owner = THIS_MODULE; |
285 | mtd->size = vol->usable_leb_size * vol->reserved_pebs; | ||
286 | mtd->erasesize = vol->usable_leb_size; | 285 | mtd->erasesize = vol->usable_leb_size; |
287 | mtd->read = gluebi_read; | 286 | mtd->read = gluebi_read; |
288 | mtd->write = gluebi_write; | 287 | mtd->write = gluebi_write; |
@@ -290,6 +289,15 @@ int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol) | |||
290 | mtd->get_device = gluebi_get_device; | 289 | mtd->get_device = gluebi_get_device; |
291 | mtd->put_device = gluebi_put_device; | 290 | mtd->put_device = gluebi_put_device; |
292 | 291 | ||
292 | /* | ||
293 | * In case of dynamic volume, MTD device size is just volume size. In | ||
294 | * case of a static volume the size is equivalent to the amount of data | ||
295 | * bytes, which is zero at this moment and will be changed after volume | ||
296 | * update. | ||
297 | */ | ||
298 | if (vol->vol_type == UBI_DYNAMIC_VOLUME) | ||
299 | mtd->size = vol->usable_leb_size * vol->reserved_pebs; | ||
300 | |||
293 | if (add_mtd_device(mtd)) { | 301 | if (add_mtd_device(mtd)) { |
294 | ubi_err("cannot not add MTD device\n"); | 302 | ubi_err("cannot not add MTD device\n"); |
295 | kfree(mtd->name); | 303 | kfree(mtd->name); |
@@ -321,3 +329,20 @@ int ubi_destroy_gluebi(struct ubi_volume *vol) | |||
321 | kfree(mtd->name); | 329 | kfree(mtd->name); |
322 | return 0; | 330 | return 0; |
323 | } | 331 | } |
332 | |||
333 | /** | ||
334 | * ubi_gluebi_updated - UBI volume was updated notifier. | ||
335 | * @vol: volume description object | ||
336 | * | ||
337 | * This function is called every time an UBI volume is updated. This function | ||
338 | * does nothing if volume @vol is dynamic, and changes MTD device size if the | ||
339 | * volume is static. This is needed because static volumes cannot be read past | ||
340 | * data they contain. | ||
341 | */ | ||
342 | void ubi_gluebi_updated(struct ubi_volume *vol) | ||
343 | { | ||
344 | struct mtd_info *mtd = &vol->gluebi_mtd; | ||
345 | |||
346 | if (vol->vol_type == UBI_STATIC_VOLUME) | ||
347 | mtd->size = vol->used_bytes; | ||
348 | } | ||
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c index 30d536ee10fc..197cd650356b 100644 --- a/drivers/mtd/ubi/scan.c +++ b/drivers/mtd/ubi/scan.c | |||
@@ -55,7 +55,7 @@ static int paranoid_check_si(const struct ubi_device *ubi, | |||
55 | static struct ubi_ec_hdr *ech; | 55 | static struct ubi_ec_hdr *ech; |
56 | static struct ubi_vid_hdr *vidh; | 56 | static struct ubi_vid_hdr *vidh; |
57 | 57 | ||
58 | /* | 58 | /** |
59 | * add_to_list - add physical eraseblock to a list. | 59 | * add_to_list - add physical eraseblock to a list. |
60 | * @si: scanning information | 60 | * @si: scanning information |
61 | * @pnum: physical eraseblock number to add | 61 | * @pnum: physical eraseblock number to add |
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h index feb647f108f0..c26edea96818 100644 --- a/drivers/mtd/ubi/ubi.h +++ b/drivers/mtd/ubi/ubi.h | |||
@@ -374,9 +374,11 @@ void ubi_calculate_reserved(struct ubi_device *ubi); | |||
374 | #ifdef CONFIG_MTD_UBI_GLUEBI | 374 | #ifdef CONFIG_MTD_UBI_GLUEBI |
375 | int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol); | 375 | int ubi_create_gluebi(struct ubi_device *ubi, struct ubi_volume *vol); |
376 | int ubi_destroy_gluebi(struct ubi_volume *vol); | 376 | int ubi_destroy_gluebi(struct ubi_volume *vol); |
377 | void ubi_gluebi_updated(struct ubi_volume *vol); | ||
377 | #else | 378 | #else |
378 | #define ubi_create_gluebi(ubi, vol) 0 | 379 | #define ubi_create_gluebi(ubi, vol) 0 |
379 | #define ubi_destroy_gluebi(vol) 0 | 380 | #define ubi_destroy_gluebi(vol) 0 |
381 | #define ubi_gluebi_updated(vol) | ||
380 | #endif | 382 | #endif |
381 | 383 | ||
382 | /* eba.c */ | 384 | /* eba.c */ |