[1/2] mtd: gluebi: Add sync logic
diff mbox series

Message ID 1556914418-40288-1-git-send-email-clayton.shotwell@rockwellcollins.com
State Under Review
Delegated to: Richard Weinberger
Headers show
Series
  • [1/2] mtd: gluebi: Add sync logic
Related show

Commit Message

Clayton Shotwell May 3, 2019, 8:13 p.m. UTC
Adding sync function to sync the underlying ubi device when a mtd sync
is called. This is being used to ensure a JFFS2 file system running on
top of the UBI volume is able to sync the underlying device.

Signed-off-by: Clayton Shotwell <clayton.shotwell@rockwellcollins.com>
---
 drivers/mtd/ubi/gluebi.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Patch
diff mbox series

diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c
index 6b655a5..b7d1d7c 100644
--- a/drivers/mtd/ubi/gluebi.c
+++ b/drivers/mtd/ubi/gluebi.c
@@ -280,6 +280,19 @@  static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr)
 }
 
 /**
+ * gluebi_sync - sync operation of emulated MTD devices.
+ * @mtd: the MTD device description object
+ *
+ * This function syncs the underlying UBI device when the MTD device is synced.
+ */
+static void gluebi_sync(struct mtd_info *mtd)
+{
+	struct gluebi_device *gluebi;
+	gluebi = container_of(mtd, struct gluebi_device, mtd);
+	ubi_sync(gluebi->ubi_num);
+}
+
+/**
  * gluebi_create - create a gluebi device for an UBI volume.
  * @di: UBI device description object
  * @vi: UBI volume description object
@@ -318,6 +331,7 @@  static int gluebi_create(struct ubi_device_info *di,
 	mtd->_erase      = gluebi_erase;
 	mtd->_get_device = gluebi_get_device;
 	mtd->_put_device = gluebi_put_device;
+	mtd->_sync       = gluebi_sync;
 
 	/*
 	 * In case of dynamic a volume, MTD device size is just volume size. In