[RESEND][PATCH] Add a commande extcsd write <offset> <value> <device>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There was a command to read the extcsd and some command
to enable or configure feature, but not generic write in
the extcsd. Such generic write may be usefull for the
manufacturer registers.

Signed-off-by: Philippe Reynes <philippe.reynes@xxxxxxxxxxxx>
---
 mmc.c      |    5 +++++
 mmc_cmds.c |   30 ++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/mmc.c b/mmc.c
index 50c9c9e..de820eb 100644
--- a/mmc.c
+++ b/mmc.c
@@ -58,6 +58,11 @@ static struct Command commands[] = {
 		"Print extcsd data from <device>.",
 	  NULL
 	},
+	{ do_write_extcsd, -1,
+	  "extcsd write", "<offset> " "<value> " "<device>\n"
+		"Write <value> at offset <offset> to <device> extcsd.",
+	  NULL
+	},
 	{ do_writeprotect_boot_get, -1,
 	  "writeprotect boot get", "<device>\n"
 		"Print the boot partitions write protect status for <device>.",
diff --git a/mmc_cmds.c b/mmc_cmds.c
index 6b86115..ba79ffe 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -1750,6 +1750,36 @@ out_free:
 	return ret;
 }
 
+int do_write_extcsd(int nargs, char **argv)
+{
+	int fd, ret;
+	int offset, value;
+	char *device;
+
+	CHECK(nargs != 4, "Usage: mmc extcsd write <offset> <value> </path/to/mmcblkX>\n",
+			  exit(1));
+
+	offset = strtol(argv[1], NULL, 0);
+	value  = strtol(argv[2], NULL, 0);
+	device = argv[3];
+
+	fd = open(device, O_RDWR);
+	if (fd < 0) {
+		perror("open");
+		exit(1);
+	}
+
+	ret = write_extcsd_value(fd, offset, value);
+	if (ret) {
+		fprintf(stderr,
+			"Could not write 0x%02x to EXT_CSD[%d] in %s\n",
+			value, offset, device);
+		exit(1);
+	}
+
+	return ret;
+}
+
 int do_sanitize(int nargs, char **argv)
 {
 	int fd, ret;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux