summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2021-05-17 16:23:51 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-05-17 16:23:51 +0200
commitdee7a15dfaa640130d0b9bc289e5d55b358a2dbc (patch)
tree8ea7b1c341b1ea5453d1a3576fb238dc21edaa37 /include
parentc5e0e697de769d0e78a00b1cb47fe864fade9974 (diff)
parent7ef2912d40b52202f563806fbffb9f615d2d2220 (diff)
downloadbarebox-dee7a15dfaa640130d0b9bc289e5d55b358a2dbc.tar.gz
barebox-dee7a15dfaa640130d0b9bc289e5d55b358a2dbc.tar.xz
Merge branch 'for-next/usb-gadget'
Diffstat (limited to 'include')
-rw-r--r--include/bbu.h10
-rw-r--r--include/fastboot.h6
-rw-r--r--include/file-list.h12
-rw-r--r--include/linux/string.h10
-rw-r--r--include/param.h15
-rw-r--r--include/printk.h1
-rw-r--r--include/progress.h43
-rw-r--r--include/string.h1
-rw-r--r--include/stringlist.h1
-rw-r--r--include/system-partitions.h40
-rw-r--r--include/usb/gadget-multi.h1
11 files changed, 136 insertions, 4 deletions
diff --git a/include/bbu.h b/include/bbu.h
index 3b9d2f4bf1..3128339068 100644
--- a/include/bbu.h
+++ b/include/bbu.h
@@ -48,7 +48,7 @@ struct bbu_handler *bbu_find_handler_by_device(const char *devicepath);
void bbu_handlers_list(void);
-int bbu_handlers_iterate(int (*fn)(struct bbu_handler *, void *), void *);
+struct file_list;
#ifdef CONFIG_BAREBOX_UPDATE
@@ -57,6 +57,8 @@ int bbu_register_handler(struct bbu_handler *);
int bbu_register_std_file_update(const char *name, unsigned long flags,
const char *devicefile, enum filetype imagetype);
+void bbu_append_handlers_to_file_list(struct file_list *files);
+
#else
static inline int bbu_register_handler(struct bbu_handler *unused)
@@ -69,6 +71,12 @@ static inline int bbu_register_std_file_update(const char *name, unsigned long f
{
return -ENOSYS;
}
+
+static inline void bbu_append_handlers_to_file_list(struct file_list *files)
+{
+ /* none could be registered, so nothing to do */
+}
+
#endif
#if defined(CONFIG_BAREBOX_UPDATE_IMX_NAND_FCB)
diff --git a/include/fastboot.h b/include/fastboot.h
index 2eab2dfe6a..cf8a177bf1 100644
--- a/include/fastboot.h
+++ b/include/fastboot.h
@@ -58,16 +58,16 @@ enum fastboot_msg_type {
#ifdef CONFIG_FASTBOOT_BASE
bool get_fastboot_bbu(void);
-const char *get_fastboot_partitions(void);
+struct file_list *get_fastboot_partitions(void);
#else
static inline int get_fastboot_bbu(void)
{
return false;
}
-static inline const char *get_fastboot_partitions(void)
+static inline struct file_list *get_fastboot_partitions(void)
{
- return NULL;
+ return file_list_parse("");
}
#endif
diff --git a/include/file-list.h b/include/file-list.h
index 9a9edfa378..7e2a4d9205 100644
--- a/include/file-list.h
+++ b/include/file-list.h
@@ -2,6 +2,8 @@
#ifndef __FILE_LIST
#define __FILE_LIST
+#include <linux/list.h>
+
#define FILE_LIST_FLAG_SAFE (1 << 0)
#define FILE_LIST_FLAG_READBACK (1 << 1)
#define FILE_LIST_FLAG_CREATE (1 << 2)
@@ -20,14 +22,24 @@ struct file_list {
};
struct file_list *file_list_parse(const char *str);
+char *file_list_to_str(const struct file_list *files);
void file_list_free(struct file_list *);
int file_list_add_entry(struct file_list *files, const char *name, const char *filename,
unsigned long flags);
+struct file_list *file_list_dup(struct file_list *old);
+
+int file_list_detect_all(const struct file_list *files);
+
struct file_list_entry *file_list_entry_by_name(struct file_list *files, const char *name);
#define file_list_for_each_entry(files, entry) \
list_for_each_entry(entry, &files->list, list)
+static inline bool file_list_empty(struct file_list *files)
+{
+ return !files || !files->num_entries;
+}
+
#endif /* __FILE_LIST */
diff --git a/include/linux/string.h b/include/linux/string.h
index 58e2a4d2ea..55bc905c0e 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -136,4 +136,14 @@ extern int kstrtobool(const char *s, bool *res);
int match_string(const char * const *array, size_t n, const char *string);
+/**
+ * strstarts - does @str start with @prefix?
+ * @str: string to examine
+ * @prefix: prefix to look for.
+ */
+static inline bool strstarts(const char *str, const char *prefix)
+{
+ return strncmp(str, prefix, strlen(prefix)) == 0;
+}
+
#endif /* _LINUX_STRING_H_ */
diff --git a/include/param.h b/include/param.h
index 6aca1b481d..4835be4d25 100644
--- a/include/param.h
+++ b/include/param.h
@@ -10,6 +10,7 @@
#define PARAM_GLOBALVAR_UNQUALIFIED (1 << 1)
struct device_d;
+struct file_list;
typedef uint32_t IPaddr_t;
enum param_type {
@@ -23,6 +24,7 @@ enum param_type {
PARAM_TYPE_BITMASK,
PARAM_TYPE_IPV4,
PARAM_TYPE_MAC,
+ PARAM_TYPE_FILE_LIST,
};
struct param_d {
@@ -89,6 +91,11 @@ struct param_d *dev_add_param_mac(struct device_d *dev, const char *name,
int (*get)(struct param_d *p, void *priv),
u8 *mac, void *priv);
+struct param_d *dev_add_param_file_list(struct device_d *dev, const char *name,
+ int (*set)(struct param_d *p, void *priv),
+ int (*get)(struct param_d *p, void *priv),
+ struct file_list **file_list, void *priv);
+
struct param_d *dev_add_param_fixed(struct device_d *dev, const char *name, const char *value);
void dev_remove_param(struct param_d *p);
@@ -185,6 +192,14 @@ static inline struct param_d *dev_add_param_mac(struct device_d *dev, const char
return NULL;
}
+static inline struct param_d *dev_add_param_file_list(struct device_d *dev, const char *name,
+ int (*set)(struct param_d *p, void *priv),
+ int (*get)(struct param_d *p, void *priv),
+ struct file_list **file_list, void *priv)
+{
+ return NULL;
+}
+
static inline struct param_d *dev_add_param_fixed(struct device_d *dev, const char *name,
const char *value)
{
diff --git a/include/printk.h b/include/printk.h
index 94a25ec9eb..f83ad3bf07 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -141,6 +141,7 @@ extern void log_clean(unsigned int limit);
#define BAREBOX_LOG_PRINT_ALERT BIT(1)
#define BAREBOX_LOG_PRINT_EMERG BIT(0)
+int log_writefile(const char *filepath);
void log_print(unsigned flags, unsigned levels);
struct va_format {
diff --git a/include/progress.h b/include/progress.h
index 50b15fb12b..7230bd3a9b 100644
--- a/include/progress.h
+++ b/include/progress.h
@@ -3,6 +3,8 @@
#define __PROGRSS_H
#include <linux/types.h>
+#include <notifier.h>
+#include <errno.h>
/* Initialize a progress bar. If max > 0 a one line progress
* bar is printed where 'max' corresponds to 100%. If max == 0
@@ -15,4 +17,45 @@ void init_progression_bar(loff_t max);
*/
void show_progress(loff_t now);
+extern struct notifier_head progress_notifier;
+
+enum progress_stage {
+ PROGRESS_UNSPECIFIED = 0,
+ PROGRESS_UPDATING,
+ PROGRESS_UPDATE_SUCCESS,
+ PROGRESS_UPDATE_FAIL,
+};
+
+/*
+ * Notifier list for code which wants to be called at progress
+ * This could use by board code to e.g. flash a LED during updates
+ */
+extern struct notifier_head progress_notifier_list;
+
+/* generic client that just logs the state */
+extern struct notifier_block progress_log_client;
+
+static inline int progress_register_client(struct notifier_block *nb)
+{
+ if (!IS_ENABLED(CONFIG_PROGRESS_NOTIFIER))
+ return -ENOSYS;
+ return notifier_chain_register(&progress_notifier_list, nb);
+}
+
+static inline int progress_unregister_client(struct notifier_block *nb)
+{
+ if (!IS_ENABLED(CONFIG_PROGRESS_NOTIFIER))
+ return -ENOSYS;
+ return notifier_chain_unregister(&progress_notifier_list, nb);
+}
+
+static inline int progress_notifier_call_chain(enum progress_stage stage, const char *prefix)
+{
+ if (!IS_ENABLED(CONFIG_PROGRESS_NOTIFIER))
+ return -ENOSYS;
+
+ /* clients should not modify the prefix */
+ return notifier_call_chain(&progress_notifier_list, stage, (char *)(prefix ?: ""));
+}
+
#endif /* __PROGRSS_H */
diff --git a/include/string.h b/include/string.h
index ef0b5e199e..d423bee6fb 100644
--- a/include/string.h
+++ b/include/string.h
@@ -7,6 +7,7 @@
int strtobool(const char *str, int *val);
char *strsep_unescaped(char **, const char *);
char *stpcpy(char *dest, const char *src);
+bool strends(const char *str, const char *postfix);
void *__default_memset(void *, int, __kernel_size_t);
void *__nokasan_default_memset(void *, int, __kernel_size_t);
diff --git a/include/stringlist.h b/include/stringlist.h
index c5d6e70a36..01491082ea 100644
--- a/include/stringlist.h
+++ b/include/stringlist.h
@@ -14,6 +14,7 @@ int string_list_add_asprintf(struct string_list *sl, const char *fmt, ...);
int string_list_add_sorted(struct string_list *sl, const char *str);
int string_list_add_sort_uniq(struct string_list *sl, const char *str);
int string_list_contains(struct string_list *sl, const char *str);
+char *string_list_join(const struct string_list *sl, const char *joinstr);
void string_list_print_by_column(struct string_list *sl);
static inline void string_list_init(struct string_list *sl)
diff --git a/include/system-partitions.h b/include/system-partitions.h
new file mode 100644
index 0000000000..86de3612cc
--- /dev/null
+++ b/include/system-partitions.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef SYSTEM_PARTITIONS_H_
+#define SYSTEM_PARTITIONS_H_
+
+#include <file-list.h>
+
+#ifdef CONFIG_SYSTEM_PARTITIONS
+
+/* duplicates current system_partitions and returns it */
+struct file_list *system_partitions_get(void);
+
+/* takes ownership of files and store it internally */
+void system_partitions_set(struct file_list *files);
+
+/*
+ * check whether system_partitions_get would return an empty
+ * file_list without doing an allocation
+ */
+bool system_partitions_empty(void);
+
+#else
+
+static inline struct file_list *system_partitions_get(void)
+{
+ return file_list_parse("");
+}
+
+static inline bool system_partitions_empty(void)
+{
+ return true;
+}
+
+/*
+ * system_partitions_set() intentionally left unimplemented.
+ * select CONFIG_SYSTEM_PARTITIONS if you want to set it
+ */
+
+#endif
+
+#endif
diff --git a/include/usb/gadget-multi.h b/include/usb/gadget-multi.h
index 9bb6c889f3..f30dae5686 100644
--- a/include/usb/gadget-multi.h
+++ b/include/usb/gadget-multi.h
@@ -15,6 +15,7 @@ struct f_multi_opts {
int usb_multi_register(struct f_multi_opts *opts);
void usb_multi_unregister(void);
void usb_multi_opts_release(struct f_multi_opts *opts);
+unsigned usb_multi_count_functions(struct f_multi_opts *opts);
int usbgadget_register(bool dfu, const char *dfu_opts,
bool fastboot, const char *fastboot_opts,