aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/gluebi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/ubi/gluebi.c')
-rw-r--r--drivers/mtd/ubi/gluebi.c27
1 files changed, 26 insertions, 1 deletions
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 */
342void 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}