Index: uspace/drv/char/i8042/buffer.h
===================================================================
--- uspace/drv/char/i8042/buffer.h	(revision acdb5bacffa0840fa18ced3443b7bcb244837b8d)
+++ uspace/drv/char/i8042/buffer.h	(revision 677cad5e3bf910241afff855ef729cbe70035d68)
@@ -113,15 +113,22 @@
  *
  * @param buffer Cyclic buffer to read from.
+ * @param rb Place to store byte read
+ * @param wait @c True to wait until byte is available
  *
- * @return Byte read.
+ * @return EOK on success, EAGAIN if @c wait is false and no data is available
  *
  */
-static inline uint8_t buffer_read(buffer_t *buffer)
+static inline int buffer_read(buffer_t *buffer, uint8_t *rb, bool wait)
 {
 	fibril_mutex_lock(&buffer->guard);
 	
 	/* Buffer is empty. */
-	while (buffer->write_head == buffer->read_head)
+	while (wait && buffer->write_head == buffer->read_head)
 		fibril_condvar_wait(&buffer->change, &buffer->guard);
+	
+	if (buffer->write_head == buffer->read_head) {
+		fibril_mutex_unlock(&buffer->guard);
+		return EAGAIN;
+	}
 	
 	/* Next position. */
@@ -144,5 +151,6 @@
 	
 	fibril_mutex_unlock(&buffer->guard);
-	return data;
+	*rb = data;
+	return EOK;
 }
 
