diff mbox series

[12/13] gard: Always use MTD to access flash

Message ID 20171108085918.12590-13-oohall@gmail.com
State Accepted
Headers show
Series [01/13] gard: show: Remove "Res Recovery" field | expand

Commit Message

Oliver O'Halloran Nov. 8, 2017, 8:59 a.m. UTC
Direct mode is generally either unsafe or unsupported. We should always
access the PNOR via an MTD device so make that the default. If someone
really needs direct mode, then they can use pflash.

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 external/gard/gard.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/external/gard/gard.c b/external/gard/gard.c
index 1ee54e6b3d99..815243457cf5 100644
--- a/external/gard/gard.c
+++ b/external/gard/gard.c
@@ -879,6 +879,14 @@  int main(int argc, char **argv)
 #endif
 	}
 
+	/*
+	 * Force libflash to do flash accesses via the MTD. Direct mode is
+	 * generally unsafe since it fiddles with the flash controller state
+	 * underneath the kernel. Anyone who needs direct mode can use pflash
+	 * instead.
+	 */
+	arch_flash_access(ctx->bl, PNOR_MTD);
+
 	if (arch_flash_init(&(ctx->bl), filename, true)) {
 		/* Can fail for a few ways, most likely couldn't open MTD device */
 		fprintf(stderr, "Can't open %s\n", filename ? filename : "MTD Device. Are you root?");