Changeset c657bd7 in mainline for uspace/drv/char/i8042/buffer.h
- Timestamp:
- 2017-11-20T10:06:59Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 19ea61d
- Parents:
- 5d50c419
- git-author:
- Jiri Svoboda <jiri@…> (2017-11-19 22:05:26)
- git-committer:
- Jiri Svoboda <jiri@…> (2017-11-20 10:06:59)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/char/i8042/buffer.h
r5d50c419 rc657bd7 113 113 * 114 114 * @param buffer Cyclic buffer to read from. 115 * @param rb Place to store byte read 116 * @param wait @c True to wait until byte is available 115 117 * 116 * @return Byte read.118 * @return EOK on success, EAGAIN if @c wait is false and no data is available 117 119 * 118 120 */ 119 static inline uint8_t buffer_read(buffer_t *buffer)121 static inline int buffer_read(buffer_t *buffer, uint8_t *rb, bool wait) 120 122 { 121 123 fibril_mutex_lock(&buffer->guard); 122 124 123 125 /* Buffer is empty. */ 124 while ( buffer->write_head == buffer->read_head)126 while (wait && buffer->write_head == buffer->read_head) 125 127 fibril_condvar_wait(&buffer->change, &buffer->guard); 128 129 if (buffer->write_head == buffer->read_head) { 130 fibril_mutex_unlock(&buffer->guard); 131 return EAGAIN; 132 } 126 133 127 134 /* Next position. */ … … 144 151 145 152 fibril_mutex_unlock(&buffer->guard); 146 return data; 153 *rb = data; 154 return EOK; 147 155 } 148 156
Note:
See TracChangeset
for help on using the changeset viewer.