Changeset c657bd7 in mainline for uspace/drv/char/i8042
- Timestamp:
- 2017-11-20T10:06:59Z (8 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)
- Location:
- uspace/drv/char/i8042
- Files:
-
- 2 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 -
uspace/drv/char/i8042/i8042.c
r5d50c419 rc657bd7 374 374 i8042_t *i8042 = port->ctl; 375 375 uint8_t *destp = (uint8_t *)dest; 376 int rc; 377 size_t i; 376 378 377 379 buffer_t *buffer = (port == i8042->aux) ? 378 380 &i8042->aux_buffer : &i8042->kbd_buffer; 379 381 380 for (size_t i = 0; i < size; ++i) 381 *destp++ = buffer_read(buffer); 382 383 return size; 382 for (i = 0; i < size; ++i) { 383 rc = buffer_read(buffer, destp, i == 0); 384 if (rc != EOK) 385 break; 386 ++destp; 387 } 388 389 return i; 384 390 } 385 391
Note:
See TracChangeset
for help on using the changeset viewer.
