[U-Boot] [PATCH v2 02/10] dfu:core: Find DFU alt setting number by passing its name

Lukasz Majewski l.majewski at samsung.com
Tue Oct 8 14:30:38 CEST 2013


New function - dfu_get_alt() - has been added to dfu core. If present, it
returns alt setting's number corresponding to passed name.

Signed-off-by: Lukasz Majewski <l.majewski at samsung.com>

---
Changes for v2:
- None

 drivers/dfu/dfu.c |   12 ++++++++++++
 include/dfu.h     |    1 +
 2 files changed, 13 insertions(+)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index f328735..4ec330c 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -440,3 +440,15 @@ struct dfu_entity *dfu_get_entity(int alt)
 
 	return NULL;
 }
+
+int dfu_get_alt(char *name)
+{
+	struct dfu_entity *dfu;
+
+	list_for_each_entry(dfu, &dfu_list, list) {
+		if (!strncmp(dfu->name, name, strlen(dfu->name)))
+			return dfu->alt;
+	}
+
+	return -ENODEV;
+}
diff --git a/include/dfu.h b/include/dfu.h
index b2ecf1b..b144255 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -126,6 +126,7 @@ const char *dfu_get_layout(enum dfu_layout l);
 struct dfu_entity *dfu_get_entity(int alt);
 char *dfu_extract_token(char** e, int *n);
 void dfu_trigger_reset(void);
+int dfu_get_alt(char *name);
 bool dfu_reset(void);
 int dfu_init_env_entities(char *interface, int dev);
 
-- 
1.7.10.4



More information about the U-Boot mailing list