summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-07-26 14:47:34 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-07-27 07:19:52 +0200
commitb655b1e110df253ad7f4775a921aa172f2adc401 (patch)
treec28810bd7c4afde3497fc3f942bc8e85bb6a3204 /drivers
parent50f75a1a0e3c51fca1576bd41588d6e71caff02e (diff)
downloadbarebox-b655b1e110df253ad7f4775a921aa172f2adc401.tar.gz
barebox-b655b1e110df253ad7f4775a921aa172f2adc401.tar.xz
mtd: ubi: implement ubi_volume_notify
This is necessary to update the fastmap after ubi manipulations. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/ubi/build.c32
-rw-r--r--drivers/mtd/ubi/cdev.c1
-rw-r--r--drivers/mtd/ubi/vmt.c4
3 files changed, 37 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 92f7a28892..c4bffae7f6 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -64,6 +64,38 @@ static bool fm_autoconvert = 1;
struct ubi_device *ubi_devices[UBI_MAX_DEVICES];
/**
+ * ubi_volume_notify - send a volume change notification.
+ * @ubi: UBI device description object
+ * @vol: volume description object of the changed volume
+ * @ntype: notification type to send (%UBI_VOLUME_ADDED, etc)
+ *
+ * This is a helper function which notifies all subscribers about a volume
+ * change event (creation, removal, re-sizing, re-naming, updating). Returns
+ * zero in case of success and a negative error code in case of failure.
+ */
+int ubi_volume_notify(struct ubi_device *ubi, struct ubi_volume *vol, int ntype)
+{
+ struct ubi_notification nt;
+
+ ubi_do_get_device_info(ubi, &nt.di);
+ ubi_do_get_volume_info(ubi, vol, &nt.vi);
+
+#ifdef CONFIG_MTD_UBI_FASTMAP
+ switch (ntype) {
+ case UBI_VOLUME_ADDED:
+ case UBI_VOLUME_REMOVED:
+ case UBI_VOLUME_RESIZED:
+ case UBI_VOLUME_RENAMED:
+ if (ubi_update_fastmap(ubi)) {
+ ubi_err("Unable to update fastmap!");
+ ubi_ro_mode(ubi);
+ }
+ }
+#endif
+ return 0;
+}
+
+/**
* ubi_get_device - get UBI device.
* @ubi_num: UBI device number
*
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 1ac05bdae0..3907673386 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -137,6 +137,7 @@ static int ubi_volume_cdev_close(struct cdev *cdev)
}
vol->checked = 1;
+ ubi_volume_notify(ubi, vol, UBI_VOLUME_UPDATED);
}
return 0;
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index e8253dc440..65339efb93 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -173,6 +173,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
ubi->volumes[vol_id] = vol;
ubi->vol_count += 1;
+ ubi_volume_notify(ubi, vol, UBI_VOLUME_ADDED);
self_check_volumes(ubi);
return err;
@@ -251,6 +252,7 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
ubi_update_reserved(ubi);
ubi->vol_count -= 1;
+ ubi_volume_notify(ubi, vol, UBI_VOLUME_REMOVED);
if (!no_vtbl)
self_check_volumes(ubi);
@@ -359,6 +361,7 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
(long long)vol->used_ebs * vol->usable_leb_size;
}
+ ubi_volume_notify(ubi, vol, UBI_VOLUME_RESIZED);
self_check_volumes(ubi);
return err;
@@ -400,6 +403,7 @@ int ubi_rename_volumes(struct ubi_device *ubi, struct list_head *rename_list)
vol->name_len = re->new_name_len;
memcpy(vol->name, re->new_name, re->new_name_len + 1);
+ ubi_volume_notify(ubi, vol, UBI_VOLUME_RENAMED);
}
}