mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 01:21:49 +00:00
Refactor the i8042 module to be thread-safe.
Any command/data coming from host will be placed in from_host queue, and the interrupt handler returns immediately. The i8042_command_task() will handle them later. Data reply to the host will be protected by the mutex. BUG=chrome-os-partner:10090 TEST=randomly play around on the link board. Change-Id: Ic19d5abd1abf8dc261ddaad4224cd9305c2f36a4 Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/24299 Commit-Ready: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com> Reviewed-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com> Tested-by: Yung-Chieh Lo <yjlou%chromium.org@gtempaccount.com>
This commit is contained in:
committed by
Gerrit
parent
c4ac74a11d
commit
210ddfefcf
40
include/queue.h
Normal file
40
include/queue.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*
|
||||
* Queue data structure.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/* Generic queue container.
|
||||
*
|
||||
* head: next to dequeqe
|
||||
* tail: next to enqueue
|
||||
*
|
||||
* Empty:
|
||||
* head == tail
|
||||
* Full:
|
||||
* ((tail + 1) % buf_bytes) == head
|
||||
*/
|
||||
struct queue {
|
||||
int head, tail;
|
||||
int buf_bytes; /* size of buffer (in byte) */
|
||||
int unit_bytes; /* size of unit (in byte) */
|
||||
uint8_t *buf;
|
||||
};
|
||||
|
||||
/* Reset the queue to empty state. */
|
||||
void queue_reset(struct queue *queue);
|
||||
|
||||
/* Return TRUE if the queue is empty. */
|
||||
int queue_is_empty(const struct queue *q);
|
||||
|
||||
/* Return TRUE if the queue has at least one unit space. */
|
||||
int queue_has_space(const struct queue *q, int unit_count);
|
||||
|
||||
/* Add multiple units into queue. */
|
||||
void queue_add_units(struct queue *q, const void *src, int unit_count);
|
||||
|
||||
/* Remove one unit from the begin of the queue. */
|
||||
int queue_remove_unit(struct queue *q, void *dest);
|
||||
Reference in New Issue
Block a user