summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/serdev.c6
-rw-r--r--include/serdev.h2
2 files changed, 8 insertions, 0 deletions
diff --git a/common/serdev.c b/common/serdev.c
index 4a6dbefe61..3e0da0846e 100644
--- a/common/serdev.c
+++ b/common/serdev.c
@@ -9,6 +9,10 @@ static void serdev_device_poller(void *context)
unsigned char *buf = serdev->buf;
int ret, len;
+ if (serdev->locked)
+ return;
+
+ serdev->locked = true;
/*
* Since this callback is a part of poller infrastructure we
* want to use _non_interruptible version of the function
@@ -37,6 +41,8 @@ static void serdev_device_poller(void *context)
} else {
poller_async_cancel(&serdev->poller);
}
+
+ serdev->locked = false;
}
static int serdev_device_set_polling_interval(struct param_d *param, void *serdev)
diff --git a/include/serdev.h b/include/serdev.h
index f5d34f5276..29030538e5 100644
--- a/include/serdev.h
+++ b/include/serdev.h
@@ -14,6 +14,7 @@
* @poller Async poller used to poll this serdev
* @polling_interval: Async poller periodicity
* @polling_window: Duration of a single busy loop poll
+ * @locked: Lock to prevent recursive polling
* @receive_buf: Function called with data received from device;
* returns number of bytes accepted;
*/
@@ -24,6 +25,7 @@ struct serdev_device {
struct poller_async poller;
uint64_t polling_interval;
uint64_t polling_window;
+ bool locked;
int (*receive_buf)(struct serdev_device *, const unsigned char *,
size_t);