mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-22 17:27:53 +00:00
DM USB: introduce helper functions: index_inc and index_valid
Introduce helper functions to make code shorter and cleaner. Tracked-On: #3628 Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
@@ -230,6 +230,21 @@ enum USB_ERRCODE {
|
||||
|
||||
#define USB_DROPPED_XFER_MAGIC 0xaaaaaaaa55555555
|
||||
|
||||
inline bool
|
||||
index_valid(int head, int tail, int maxcnt, int idx) {
|
||||
if (head <= tail)
|
||||
return (idx >= head && idx < tail);
|
||||
else
|
||||
return (idx >= head && idx < maxcnt) ||
|
||||
(idx >= 0 && idx < tail);
|
||||
}
|
||||
|
||||
inline int
|
||||
index_inc(int idx, int maxcnt)
|
||||
{
|
||||
return (idx + 1) % maxcnt;
|
||||
}
|
||||
|
||||
extern int usb_log_level;
|
||||
static inline int usb_get_log_level(void) { return usb_log_level; }
|
||||
static inline void usb_set_log_level(int level) { usb_log_level = level; }
|
||||
|
Reference in New Issue
Block a user