summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2021-02-11 18:09:42 +0300
committerTom Rini <trini@konsulko.com>2021-02-16 19:16:08 +0300
commit400797cad36850797307be3c56d2d5bc16aa02bb (patch)
tree145e8fcdee8bdf50ca07849cffd41b80a3bcaeaa /common
parentb672c1619bb9615aff3ebbe15c20083fd0f58f9b (diff)
downloadu-boot-400797cad36850797307be3c56d2d5bc16aa02bb.tar.xz
IOMUX: Split out for_each_console_dev() helper macro
It is not only less lines of code, but also better readability when new macro is being in use. Introduce for_each_console_dev() helper macro and convert current users to it. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'common')
-rw-r--r--common/console.c15
-rw-r--r--common/iomux.c4
2 files changed, 6 insertions, 13 deletions
diff --git a/common/console.c b/common/console.c
index 523fb45a99..561cdf36a7 100644
--- a/common/console.c
+++ b/common/console.c
@@ -293,8 +293,7 @@ static int console_tstc(int file)
int prev;
prev = disable_ctrlc(1);
- for (i = 0; i < cd_count[file]; i++) {
- dev = console_devices[file][i];
+ for_each_console_dev(i, file, dev) {
if (dev->tstc != NULL) {
ret = dev->tstc(dev);
if (ret > 0) {
@@ -314,8 +313,7 @@ static void console_putc(int file, const char c)
int i;
struct stdio_dev *dev;
- for (i = 0; i < cd_count[file]; i++) {
- dev = console_devices[file][i];
+ for_each_console_dev(i, file, dev) {
if (dev->putc != NULL)
dev->putc(dev, c);
}
@@ -334,11 +332,9 @@ static void console_puts_select(int file, bool serial_only, const char *s)
int i;
struct stdio_dev *dev;
- for (i = 0; i < cd_count[file]; i++) {
- bool is_serial;
+ for_each_console_dev(i, file, dev) {
+ bool is_serial = console_dev_is_serial(dev);
- dev = console_devices[file][i];
- is_serial = console_dev_is_serial(dev);
if (dev->puts && serial_only == is_serial)
dev->puts(dev, s);
}
@@ -354,8 +350,7 @@ static void console_puts(int file, const char *s)
int i;
struct stdio_dev *dev;
- for (i = 0; i < cd_count[file]; i++) {
- dev = console_devices[file][i];
+ for_each_console_dev(i, file, dev) {
if (dev->puts != NULL)
dev->puts(dev, s);
}
diff --git a/common/iomux.c b/common/iomux.c
index a8be1ac7d8..5290b13b66 100644
--- a/common/iomux.c
+++ b/common/iomux.c
@@ -15,10 +15,8 @@ void iomux_printdevs(const int console)
int i;
struct stdio_dev *dev;
- for (i = 0; i < cd_count[console]; i++) {
- dev = console_devices[console][i];
+ for_each_console_dev(i, console, dev)
printf("%s ", dev->name);
- }
printf("\n");
}