aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel/src/chqueues.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-10-23 11:39:45 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-10-23 11:39:45 +0000
commit309b1e411426e8d36d9a552ef2870da3db912a80 (patch)
tree5567c549d2ec3ed75d9deb228f2f6542e4b21b25 /os/kernel/src/chqueues.c
parent78325ebdf2db30514e6b61e25b0c1894a8e29b79 (diff)
downloadChibiOS-309b1e411426e8d36d9a552ef2870da3db912a80.tar.gz
ChibiOS-309b1e411426e8d36d9a552ef2870da3db912a80.tar.bz2
ChibiOS-309b1e411426e8d36d9a552ef2870da3db912a80.zip
Improvements to the USB driver, first phase.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3449 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel/src/chqueues.c')
-rw-r--r--os/kernel/src/chqueues.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/os/kernel/src/chqueues.c b/os/kernel/src/chqueues.c
index cf3d21732..b32ccf803 100644
--- a/os/kernel/src/chqueues.c
+++ b/os/kernel/src/chqueues.c
@@ -152,9 +152,8 @@ msg_t chIQPutI(InputQueue *iqp, uint8_t b) {
* @details This function reads a byte value from an input queue. If the queue
* is empty then the calling thread is suspended until a byte arrives
* in the queue or a timeout occurs.
- * @note The callback is invoked if the queue is empty before entering the
- * @p THD_STATE_WTQUEUE state in order to solicit the low level to
- * start queue filling.
+ * @note The callback is invoked before reading the character from the
+ * buffer or before entering the state @p THD_STATE_WTQUEUE.
*
* @param[in] iqp pointer to an @p InputQueue structure
* @param[in] time the number of ticks before the operation timeouts,
@@ -172,12 +171,11 @@ msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) {
uint8_t b;
chSysLock();
+ if (iqp->q_notify)
+ iqp->q_notify(iqp);
+
while (chIQIsEmptyI(iqp)) {
msg_t msg;
-
- if (iqp->q_notify)
- iqp->q_notify(iqp);
-
if ((msg = qwait((GenericQueue *)iqp, time)) < Q_OK) {
chSysUnlock();
return msg;
@@ -201,9 +199,8 @@ msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) {
* been reset.
* @note The function is not atomic, if you need atomicity it is suggested
* to use a semaphore or a mutex for mutual exclusion.
- * @note The callback is invoked if the queue is empty before entering the
- * @p THD_STATE_WTQUEUE state in order to solicit the low level to
- * start queue filling.
+ * @note The callback is invoked before reading each character from the
+ * buffer or before entering the state @p THD_STATE_WTQUEUE.
*
* @param[in] iqp pointer to an @p InputQueue structure
* @param[out] bp pointer to the data buffer
@@ -227,10 +224,10 @@ size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp,
chSysLock();
while (TRUE) {
- while (chIQIsEmptyI(iqp)) {
- if (nfy)
- nfy(iqp);
+ if (nfy)
+ nfy(iqp);
+ while (chIQIsEmptyI(iqp)) {
if (qwait((GenericQueue *)iqp, time) != Q_OK) {
chSysUnlock();
return r;