From 21415c81fea1493ff3f260f7e64dda6607719e71 Mon Sep 17 00:00:00 2001
From: Laxman <laxman@inforcecomputing.com>
Date: Mon, 5 Nov 2018 13:35:14 +0530
Subject: [PATCH] qdl support for ufs and emmc storage

---
 firehose.c | 16 ++++++++--------
 qdl.c      |  7 +++++--
 qdl.h      |  2 +-
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/firehose.c b/firehose.c
index c4e9500..466a26d 100644
--- a/firehose.c
+++ b/firehose.c
@@ -265,7 +265,7 @@ static int firehose_configure_response_parser(xmlNode *node)
 	return max_size;
 }
 
-static int firehose_send_configure(int fd, size_t payload_size, bool skip_storage_init)
+static int firehose_send_configure(int fd, size_t payload_size, bool skip_storage_init, const char *storage)
 {
 	xmlNode *root;
 	xmlNode *node;
@@ -277,7 +277,7 @@ static int firehose_send_configure(int fd, size_t payload_size, bool skip_storag
 	xmlDocSetRootElement(doc, root);
 
 	node = xmlNewChild(root, NULL, (xmlChar*)"configure", NULL);
-	xml_setpropf(node, "MemoryName", "ufs");
+	xml_setpropf(node, "MemoryName",  storage);
 	xml_setpropf(node, "MaxPayloadSizeToTargetInBytes", "%d", payload_size);
 	xml_setpropf(node, "verbose", "%d", 0);
 	xml_setpropf(node, "ZLPAwareHost", "%d", 0);
@@ -291,17 +291,17 @@ static int firehose_send_configure(int fd, size_t payload_size, bool skip_storag
 	return firehose_read(fd, -1, firehose_configure_response_parser);
 }
 
-static int firehose_configure(int fd, bool skip_storage_init)
+static int firehose_configure(int fd, bool skip_storage_init, const char *storage)
 {
 	int ret;
 
-	ret = firehose_send_configure(fd, max_payload_size, skip_storage_init);
+	ret = firehose_send_configure(fd, max_payload_size, skip_storage_init, storage);
 	if (ret < 0)
 		return ret;
 
 	/* Retry if remote proposed different size */
 	if (ret != max_payload_size) {
-		ret = firehose_send_configure(fd, ret, skip_storage_init);
+		ret = firehose_send_configure(fd, ret, skip_storage_init, storage);
 		if (ret < 0)
 			return ret;
 
@@ -601,7 +601,7 @@ static int firehose_reset(int fd)
 	return firehose_read(fd, -1, firehose_nop_parser);
 }
 
-int firehose_run(int fd, const char *incdir)
+int firehose_run(int fd, const char *incdir, const char *storage)
 {
 	int bootable;
 	int ret;
@@ -618,7 +618,7 @@ int firehose_run(int fd, const char *incdir)
 		return ret;
 
 	if(ufs_need_provisioning()) {
-		ret = firehose_configure(fd, true);
+		ret = firehose_configure(fd, true, storage);
 		if (ret)
 			return ret;
 		ret = ufs_provisioning_execute(fd, firehose_apply_ufs_common,
@@ -630,7 +630,7 @@ int firehose_run(int fd, const char *incdir)
 		return ret;
 	}
 
-	ret = firehose_configure(fd, false);
+	ret = firehose_configure(fd, false, storage);
 	if (ret)
 		return ret;
 
diff --git a/qdl.c b/qdl.c
index 8cf1011..cf493b4 100644
--- a/qdl.c
+++ b/qdl.c
@@ -227,7 +227,7 @@ static void print_usage(void)
 int main(int argc, char **argv)
 {
 	struct termios tios;
-	char *prog_mbn;
+	char *prog_mbn, *storage;
 	char *incdir = NULL;
 	int type;
 	int ret;
@@ -266,6 +266,9 @@ int main(int argc, char **argv)
 		return 1;
 	}
 
+	storage = argv[1];
+	optind ++;
+
 	prog_mbn = argv[optind++];
 
 	do {
@@ -303,7 +306,7 @@ int main(int argc, char **argv)
 	if (ret < 0)
 		goto out;
 
-	ret = firehose_run(fd, incdir);
+	ret = firehose_run(fd, incdir, storage);
 
 out:
 	ret = tcsetattr(fd, TCSANOW, &tios);
diff --git a/qdl.h b/qdl.h
index 0ed2607..208ede0 100644
--- a/qdl.h
+++ b/qdl.h
@@ -6,7 +6,7 @@
 #include "patch.h"
 #include "program.h"
 
-int firehose_run(int fd, const char *incdir);
+int firehose_run(int fd, const char *incdir, const char *storage);
 int sahara_run(int fd, char *prog_mbn);
 void print_hex_dump(const char *prefix, const void *buf, size_t len);
 
-- 
2.7.4

