summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-02-04 08:30:31 -0500
committerTom Rini <trini@konsulko.com>2018-02-04 08:30:31 -0500
commit211a3a23b92798e870b85262ef07265845813a6c (patch)
tree4644a36131351691d98a6c0a60c303106122bce9 /include
parentab1af91093e3a5e3e86b77ebaf568facd386a1df (diff)
parent1973b381a1b3545783c3238080f566746579e923 (diff)
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'include')
-rw-r--r--include/asm-generic/global_data.h1
-rw-r--r--include/dm/uclass.h8
-rw-r--r--include/log.h65
3 files changed, 72 insertions, 2 deletions
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index fd8cd45b05..1de67e8e8f 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -119,6 +119,7 @@ typedef struct global_data {
int log_drop_count; /* Number of dropped log messages */
int default_log_level; /* For devices with no filters */
struct list_head log_head; /* List of struct log_device */
+ int log_fmt; /* Mask containing log format info */
#endif
} gd_t;
#endif
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index 709f661f20..3a01abc239 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -128,6 +128,14 @@ int uclass_get(enum uclass_id key, struct uclass **ucp);
const char *uclass_get_name(enum uclass_id id);
/**
+ * uclass_get_by_name() - Look up a uclass by its driver name
+ *
+ * @name: Name to look up
+ * @returns the associated uclass ID, or UCLASS_INVALID if not found
+ */
+enum uclass_id uclass_get_by_name(const char *name);
+
+/**
* uclass_get_device() - Get a uclass device based on an ID and index
*
* The device is probed to activate it ready for use.
diff --git a/include/log.h b/include/log.h
index 8083b64831..20dc5289c7 100644
--- a/include/log.h
+++ b/include/log.h
@@ -27,8 +27,10 @@ enum log_level_t {
LOGL_DEBUG_IO, /* Debug message showing hardware I/O access */
LOGL_COUNT,
+ LOGL_NONE,
+
LOGL_FIRST = LOGL_EMERG,
- LOGL_MAX = LOGL_DEBUG,
+ LOGL_MAX = LOGL_DEBUG_IO,
};
/**
@@ -42,7 +44,9 @@ enum log_category_t {
LOGC_ARCH,
LOGC_BOARD,
LOGC_CORE,
- LOGC_DT,
+ LOGC_DM, /* Core driver-model */
+ LOGC_DT, /* Device-tree */
+ LOGL_EFI, /* EFI implementation */
LOGC_COUNT,
LOGC_END,
@@ -156,6 +160,17 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line,
({ if (!(x) && _DEBUG) \
__assert_fail(#x, __FILE__, __LINE__, __func__); })
+#ifdef CONFIG_LOG_ERROR_RETURN
+#define log_ret(_ret) ({ \
+ int __ret = (_ret); \
+ if (__ret < 0) \
+ log(LOG_CATEGORY, LOGL_ERR, "returning err=%d\n", __ret); \
+ __ret; \
+ })
+#else
+#define log_ret(_ret) (_ret)
+#endif
+
/**
* struct log_rec - a single log record
*
@@ -256,6 +271,52 @@ struct log_filter {
#define LOG_DRIVER(_name) \
ll_entry_declare(struct log_driver, _name, log_driver)
+/**
+ * log_get_cat_name() - Get the name of a category
+ *
+ * @cat: Category to look up
+ * @return category name (which may be a uclass driver name)
+ */
+const char *log_get_cat_name(enum log_category_t cat);
+
+/**
+ * log_get_cat_by_name() - Look up a category by name
+ *
+ * @name: Name to look up
+ * @return category ID, or LOGC_NONE if not found
+ */
+enum log_category_t log_get_cat_by_name(const char *name);
+
+/**
+ * log_get_level_name() - Get the name of a log level
+ *
+ * @level: Log level to look up
+ * @return log level name (in ALL CAPS)
+ */
+const char *log_get_level_name(enum log_level_t level);
+
+/**
+ * log_get_level_by_name() - Look up a log level by name
+ *
+ * @name: Name to look up
+ * @return log level ID, or LOGL_NONE if not found
+ */
+enum log_level_t log_get_level_by_name(const char *name);
+
+/* Log format flags (bit numbers) for gd->log_fmt. See log_fmt_chars */
+enum log_fmt {
+ LOGF_CAT = 0,
+ LOGF_LEVEL,
+ LOGF_FILE,
+ LOGF_LINE,
+ LOGF_FUNC,
+ LOGF_MSG,
+
+ LOGF_COUNT,
+ LOGF_DEFAULT = (1 << LOGF_FUNC) | (1 << LOGF_MSG),
+ LOGF_ALL = 0x3f,
+};
+
/* Handle the 'log test' command */
int do_log_test(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);