mtd: Fix the behavior of OTP write if there is not enough room for data
[deliverable/linux.git] / drivers / mtd / mtdchar.c
index 250798cf76aa548e0a0ffcba8756d988f191f8f8..7d4e7b9da3a1aceef2ea5ea664cea4e0d94752c6 100644 (file)
@@ -324,6 +324,15 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
                default:
                        ret = mtd_write(mtd, *ppos, len, &retlen, kbuf);
                }
+
+               /*
+                * Return -ENOSPC only if no data could be written at all.
+                * Otherwise just return the number of bytes that actually
+                * have been written.
+                */
+               if ((ret == -ENOSPC) && (total_retlen))
+                       break;
+
                if (!ret) {
                        *ppos += retlen;
                        total_retlen += retlen;
This page took 0.02947 seconds and 5 git commands to generate.