diff options
author | Gregory Herrero <gregory.herrero@intel.com> | 2015-11-05 09:41:42 +0100 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-12-15 09:12:41 -0600 |
commit | b9392d9920fdce50abbe4af758cd1a24b922c81c (patch) | |
tree | fc4157601ccc25c186d192e0d040862860ea9bbc /drivers/usb/dwc2/hcd.h | |
parent | 2b046bc5aaefd4aba7195e6a73afe14f7f786692 (diff) | |
download | linux-b9392d9920fdce50abbe4af758cd1a24b922c81c.tar.gz linux-b9392d9920fdce50abbe4af758cd1a24b922c81c.tar.bz2 linux-b9392d9920fdce50abbe4af758cd1a24b922c81c.zip |
usb: dwc2: host: add function to compare frame index
This function allow comparing frame index used for
descriptor list which has 64 entries.
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc2/hcd.h')
-rw-r--r-- | drivers/usb/dwc2/hcd.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/usb/dwc2/hcd.h b/drivers/usb/dwc2/hcd.h index f105bada2fd1..a19837f655c9 100644 --- a/drivers/usb/dwc2/hcd.h +++ b/drivers/usb/dwc2/hcd.h @@ -535,6 +535,19 @@ static inline bool dbg_perio(void) { return false; } #define dwc2_max_packet(wmaxpacketsize) ((wmaxpacketsize) & 0x07ff) /* + * Returns true if frame1 index is greater than frame2 index. The comparison + * is done modulo FRLISTEN_64_SIZE. This accounts for the rollover of the + * frame number when the max index frame number is reached. + */ +static inline bool dwc2_frame_idx_num_gt(u16 fr_idx1, u16 fr_idx2) +{ + u16 diff = fr_idx1 - fr_idx2; + u16 sign = diff & (FRLISTEN_64_SIZE >> 1); + + return diff && !sign; +} + +/* * Returns true if frame1 is less than or equal to frame2. The comparison is * done modulo HFNUM_MAX_FRNUM. This accounts for the rollover of the * frame number when the max frame number is reached. |