diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2019-05-13 16:59:08 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-05-15 10:09:41 +0200 |
commit | e6a025abdd2fcd60962d8f6a1f52048e52e35c78 (patch) | |
tree | 78adf618a7ed404cbe9e15f77396f2777f0f7a68 /include/serdev.h | |
parent | e0600e1fe20856cfbefb2d8f798076c7694a9e24 (diff) | |
download | barebox-e6a025abdd2fcd60962d8f6a1f52048e52e35c78.tar.gz barebox-e6a025abdd2fcd60962d8f6a1f52048e52e35c78.tar.xz |
serdev: Do not call .receive_buf() callback recursively
Code implementing .receive_buf() callback can potentially call
serdev_device_write(), which will call serdev_device_poller(). We need
to make sure that such a call is a no-op in order to prevent
corrupting shared data buffer as well as breaking .receive_buf
callback that most likely does not expect that to happen.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Tested-by: Cory Tusar <cory.tusar@zii.aero>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/serdev.h')
-rw-r--r-- | include/serdev.h | 2 |
1 files changed, 2 insertions, 0 deletions
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); |