diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-07-17 08:12:09 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-07-22 08:11:08 +0200 |
commit | 057a57448debbb942babf0a307294a9022863760 (patch) | |
tree | 528d0f2e32895752c6c85c99c09b9c369b732cf8 /include | |
parent | 55ebc3849381d7f9e139762aa13e9e2a512fdbd2 (diff) | |
download | barebox-057a57448debbb942babf0a307294a9022863760.tar.gz barebox-057a57448debbb942babf0a307294a9022863760.tar.xz |
Add function to parse a string in dfu format
The dfu command parses a string which contains a list of
devices and flags. This format is useful for other users
aswell, so add common helper functions to parse it and
let the dfu command use this format.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/file-list.h | 26 | ||||
-rw-r--r-- | include/usb/dfu.h | 14 |
2 files changed, 28 insertions, 12 deletions
diff --git a/include/file-list.h b/include/file-list.h new file mode 100644 index 0000000000..608181ff8d --- /dev/null +++ b/include/file-list.h @@ -0,0 +1,26 @@ +#ifndef __FILE_LIST +#define __FILE_LIST + +#define FILE_LIST_FLAG_SAFE (1 << 0) +#define FILE_LIST_FLAG_READBACK (1 << 1) +#define FILE_LIST_FLAG_CREATE (1 << 2) + +struct file_list_entry { + char *name; + char *filename; + unsigned long flags; + struct list_head list; +}; + +struct file_list { + struct list_head list; + int num_entries; +}; + +struct file_list *file_list_parse(const char *str); +void file_list_free(struct file_list *); + +#define file_list_for_each_entry(files, entry) \ + list_for_each_entry(entry, &files->list, list) + +#endif /* __FILE_LIST */ diff --git a/include/usb/dfu.h b/include/usb/dfu.h index db504376ce..f9dd38169e 100644 --- a/include/usb/dfu.h +++ b/include/usb/dfu.h @@ -21,20 +21,10 @@ */ #include <linux/types.h> - -#define DFU_FLAG_SAFE (1 << 0) -#define DFU_FLAG_READBACK (1 << 1) -#define DFU_FLAG_CREATE (1 << 2) - -struct usb_dfu_dev { - char *name; - char *dev; - unsigned long flags; -}; +#include <file-list.h> struct usb_dfu_pdata { - struct usb_dfu_dev *alts; - int num_alts; + struct file_list *files; }; int usb_dfu_register(struct usb_dfu_pdata *); |