gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / net / wireless / mediatek / mt76 / util.h
blob48a71e7479e5da8d9afcc93161f9fd7e8c06ec55
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
4 * Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
5 */
7 #ifndef __MT76_UTIL_H
8 #define __MT76_UTIL_H
10 #include <linux/skbuff.h>
11 #include <linux/bitops.h>
12 #include <linux/bitfield.h>
14 #define MT76_INCR(_var, _size) \
15 (_var = (((_var) + 1) % (_size)))
17 int mt76_wcid_alloc(unsigned long *mask, int size);
19 static inline bool
20 mt76_wcid_mask_test(unsigned long *mask, int idx)
22 return mask[idx / BITS_PER_LONG] & BIT(idx % BITS_PER_LONG);
25 static inline void
26 mt76_wcid_mask_set(unsigned long *mask, int idx)
28 mask[idx / BITS_PER_LONG] |= BIT(idx % BITS_PER_LONG);
31 static inline void
32 mt76_wcid_mask_clear(unsigned long *mask, int idx)
34 mask[idx / BITS_PER_LONG] &= ~BIT(idx % BITS_PER_LONG);
37 static inline void
38 mt76_skb_set_moredata(struct sk_buff *skb, bool enable)
40 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
42 if (enable)
43 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA);
44 else
45 hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_MOREDATA);
48 #endif