dfu: defer parsing of device string to IO backend

Devices are not all identified by a single integer. To support
this, defer the parsing of the device string to the IO backed, so that
it can apply the appropriate rules.

SPI devices are specified as controller:chip_select. SPI/SF support will
be added soon.

MMC devices can also be specified as controller[.hwpart][:partition] in
many commands, although we don't support that syntax in DFU.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 1bf66d0..26d3b44 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -44,7 +44,7 @@
 	return ++i;
 }
 
-int dfu_init_env_entities(char *interface, int dev)
+int dfu_init_env_entities(char *interface, char *devstr)
 {
 	const char *str_env;
 	char *env_bkp;
@@ -57,7 +57,7 @@
 	}
 
 	env_bkp = strdup(str_env);
-	ret = dfu_config_entities(env_bkp, interface, dev);
+	ret = dfu_config_entities(env_bkp, interface, devstr);
 	if (ret) {
 		error("DFU entities configuration failed!\n");
 		return ret;
@@ -389,26 +389,25 @@
 }
 
 static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt,
-			   char *interface, int num)
+			   char *interface, char *devstr)
 {
 	char *st;
 
-	debug("%s: %s interface: %s num: %d\n", __func__, s, interface, num);
+	debug("%s: %s interface: %s dev: %s\n", __func__, s, interface, devstr);
 	st = strsep(&s, " ");
 	strcpy(dfu->name, st);
 
-	dfu->dev_num = num;
 	dfu->alt = alt;
 
 	/* Specific for mmc device */
 	if (strcmp(interface, "mmc") == 0) {
-		if (dfu_fill_entity_mmc(dfu, s))
+		if (dfu_fill_entity_mmc(dfu, devstr, s))
 			return -1;
 	} else if (strcmp(interface, "nand") == 0) {
-		if (dfu_fill_entity_nand(dfu, s))
+		if (dfu_fill_entity_nand(dfu, devstr, s))
 			return -1;
 	} else if (strcmp(interface, "ram") == 0) {
-		if (dfu_fill_entity_ram(dfu, s))
+		if (dfu_fill_entity_ram(dfu, devstr, s))
 			return -1;
 	} else {
 		printf("%s: Device %s not (yet) supported!\n",
@@ -434,7 +433,7 @@
 	alt_num_cnt = 0;
 }
 
-int dfu_config_entities(char *env, char *interface, int num)
+int dfu_config_entities(char *env, char *interface, char *devstr)
 {
 	struct dfu_entity *dfu;
 	int i, ret;
@@ -457,7 +456,8 @@
 	for (i = 0; i < dfu_alt_num; i++) {
 
 		s = strsep(&env, ";");
-		ret = dfu_fill_entity(&dfu[i], s, alt_num_cnt, interface, num);
+		ret = dfu_fill_entity(&dfu[i], s, alt_num_cnt, interface,
+				      devstr);
 		if (ret)
 			return -1;