Clean up parameters being passed to mtd
authorCharles Manning <cdhmanning@gmail.com>
Mon, 24 Jun 2013 05:13:30 +0000 (17:13 +1200)
committerCharles Manning <cdhmanning@gmail.com>
Mon, 24 Jun 2013 05:13:30 +0000 (17:13 +1200)
Some nand implementations are fussy about the parameters being passed in.

If the ptr or length of data or oob is zero, then clear out the whole
parameter pair.

Signed-off-by: Charles Manning <cdhmanning@gmail.com>
yaffs_mtdif_multi.c

index 265dd789eb02d55094277183adf7cf722ecfd092..fe91a9eb3d97f35d08552ba59d5c7c9958999328 100644 (file)
@@ -78,6 +78,20 @@ static       int yaffs_mtd_write(struct yaffs_dev *dev, int nand_chunk,
        struct mtd_oob_ops ops;
        int retval;
 
        struct mtd_oob_ops ops;
        int retval;
 
+       yaffs_trace(YAFFS_TRACE_MTD,
+                       "yaffs_mtd_write(%p, %d, %p, %d, %p, %d)\n",
+                       dev, nand_chunk, data, data_len, oob, oob_len);
+
+       if (!data || !data_len) {
+               data = NULL;
+               data_len = 0;
+       }
+
+       if (!oob || !oob_len) {
+               oob = NULL;
+               oob_len = 0;
+       }
+
        addr = ((loff_t) nand_chunk) * dev->param.total_bytes_per_chunk;
        memset(&ops, 0, sizeof(ops));
        ops.mode = MTD_OPS_AUTO_OOB;
        addr = ((loff_t) nand_chunk) * dev->param.total_bytes_per_chunk;
        memset(&ops, 0, sizeof(ops));
        ops.mode = MTD_OPS_AUTO_OOB;