diff options
| author | Ingo Molnar <[email protected]> | 2016-10-16 11:31:39 +0200 |
|---|---|---|
| committer | Ingo Molnar <[email protected]> | 2016-10-16 11:31:39 +0200 |
| commit | 1d33369db25eb7f37b7a8bd22d736888b4501a9c (patch) | |
| tree | 116d764339be1bca928870151decbedc53a9e1d1 /drivers/hid/intel-ish-hid/ipc/utils.h | |
| parent | 23446cb66c073b827779e5eb3dec301623299b32 (diff) | |
| parent | 1001354ca34179f3db924eb66672442a173147dc (diff) | |
Merge tag 'v4.9-rc1' into x86/urgent, to pick up updates
Signed-off-by: Ingo Molnar <[email protected]>
Diffstat (limited to 'drivers/hid/intel-ish-hid/ipc/utils.h')
| -rw-r--r-- | drivers/hid/intel-ish-hid/ipc/utils.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/drivers/hid/intel-ish-hid/ipc/utils.h b/drivers/hid/intel-ish-hid/ipc/utils.h new file mode 100644 index 000000000000..5a82123dc7b4 --- /dev/null +++ b/drivers/hid/intel-ish-hid/ipc/utils.h @@ -0,0 +1,64 @@ +/* + * Utility macros of ISH + * + * Copyright (c) 2014-2016, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ +#ifndef UTILS__H +#define UTILS__H + +#define WAIT_FOR_SEND_SLICE (HZ / 10) +#define WAIT_FOR_CONNECT_SLICE (HZ / 10) + +/* + * Waits for specified event when a thread that triggers event can't signal + * Also, waits *at_least* `timeinc` after condition is satisfied + */ +#define timed_wait_for(timeinc, condition) \ + do { \ + int completed = 0; \ + do { \ + unsigned long j; \ + int done = 0; \ + \ + completed = (condition); \ + for (j = jiffies, done = 0; !done; ) { \ + schedule_timeout(timeinc); \ + if (time_is_before_eq_jiffies(j + timeinc)) \ + done = 1; \ + } \ + } while (!(completed)); \ + } while (0) + + +/* + * Waits for specified event when a thread that triggers event + * can't signal with timeout (use whenever we may hang) + */ +#define timed_wait_for_timeout(timeinc, condition, timeout) \ + do { \ + int t = timeout; \ + do { \ + unsigned long j; \ + int done = 0; \ + \ + for (j = jiffies, done = 0; !done; ) { \ + schedule_timeout(timeinc); \ + if (time_is_before_eq_jiffies(j + timeinc)) \ + done = 1; \ + } \ + t -= timeinc; \ + if (t <= 0) \ + break; \ + } while (!(condition)); \ + } while (0) + +#endif /* UTILS__H */ |