diff options
author | Simon Glass <sjg@chromium.org> | 2020-09-12 12:28:49 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-10-10 16:50:11 -0400 |
commit | 3d03ab6361a4a2b60e84da46c547b8ace01a60eb (patch) | |
tree | b7cab1ed0489fd262afc76cf6ec72606c9dc51c5 /common/log.c | |
parent | bd180db2cc73c7dc00076b0517978a8cdd557519 (diff) | |
download | u-boot-3d03ab6361a4a2b60e84da46c547b8ace01a60eb.zip u-boot-3d03ab6361a4a2b60e84da46c547b8ace01a60eb.tar.gz u-boot-3d03ab6361a4a2b60e84da46c547b8ace01a60eb.tar.bz2 |
log: Add a way to enable/disable a log device
At present all log devices are enabled by default. Add a function to allow
devices to be disabled or enabled at runtime.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/log.c')
-rw-r--r-- | common/log.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/common/log.c b/common/log.c index d6dfabb..1b10f6f 100644 --- a/common/log.c +++ b/common/log.c @@ -308,6 +308,44 @@ int log_remove_filter(const char *drv_name, int filter_num) return -ENOENT; } +/** + * log_find_device_by_drv() - Find a device by its driver + * + * @drv: Log driver + * @return Device associated with that driver, or NULL if not found + */ +static struct log_device *log_find_device_by_drv(struct log_driver *drv) +{ + struct log_device *ldev; + + list_for_each_entry(ldev, &gd->log_head, sibling_node) { + if (ldev->drv == drv) + return ldev; + } + /* + * It is quite hard to pass an invalid driver since passing an unknown + * LOG_GET_DRIVER(xxx) would normally produce a compilation error. But + * it is possible to pass NULL, for example, so this + */ + + return NULL; +} + +int log_device_set_enable(struct log_driver *drv, bool enable) +{ + struct log_device *ldev; + + ldev = log_find_device_by_drv(drv); + if (!ldev) + return -ENOENT; + if (enable) + ldev->flags |= LOGDF_ENABLE; + else + ldev->flags &= ~LOGDF_ENABLE; + + return 0; +} + int log_init(void) { struct log_driver *drv = ll_entry_start(struct log_driver, log_driver); |