diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2020-06-11 07:35:39 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-06-11 07:35:39 +0200 |
commit | d6757bacf8180b17692682c58dd6a9938d0c3c1d (patch) | |
tree | fd6f9212d69257b428800d338b6726652b7c11c5 /common/ratp/ratp.c | |
parent | 8e5951b62e26d271b44c5c1e22fcfbd5102aa9ed (diff) | |
parent | 6767726557cb32bccea6fa2fc125c0e8a957fe5f (diff) | |
download | barebox-d6757bacf8180b17692682c58dd6a9938d0c3c1d.tar.gz barebox-d6757bacf8180b17692682c58dd6a9938d0c3c1d.tar.xz |
Merge branch 'for-next/ratp'
Diffstat (limited to 'common/ratp/ratp.c')
-rw-r--r-- | common/ratp/ratp.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/common/ratp/ratp.c b/common/ratp/ratp.c index 556dc638d8..d2fdb631b3 100644 --- a/common/ratp/ratp.c +++ b/common/ratp/ratp.c @@ -97,11 +97,24 @@ static int init_ratp_command_list(void) late_initcall(init_ratp_command_list); +static bool console_exists(struct console_device *cdev) +{ + struct console_device *cs; + + list_for_each_entry(cs, &console_list, list) + if (cs == cdev) + return true; + return false; +} + static int console_recv(struct ratp *r, uint8_t *data) { struct ratp_ctx *ctx = container_of(r, struct ratp_ctx, ratp); struct console_device *cdev = ctx->cdev; + if (!console_exists(cdev)) + return -ENODEV; + if (ctx->have_synch) { ctx->have_synch = 0; *data = 0x01; @@ -123,6 +136,9 @@ static int console_send(struct ratp *r, void *pkt, int len) const uint8_t *buf = pkt; int i; + if (!console_exists(cdev)) + return -ENODEV; + for (i = 0; i < len; i++) cdev->putc(cdev, buf[i]); @@ -400,7 +416,6 @@ int barebox_ratp_fs_call(struct ratp_bb_pkt *tx, struct ratp_bb_pkt **rx) start = get_time_ns(); while (!ctx->fs_rx) { - poller_call(); if (ratp_closed(&ctx->ratp)) return -EIO; if (is_timeout(start, 10 * SECOND)) |