Skip to content

Commit 07689a8

Browse files
ajaykathatajaysk
authored andcommitted
wilc1000: added kernel version macros for 3.x version
Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
1 parent 367062c commit 07689a8

4 files changed

Lines changed: 231 additions & 8 deletions

File tree

drivers/net/wireless/microchip/wilc1000/cfg80211.c

Lines changed: 81 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,13 @@ static int set_default_key(struct wiphy *wiphy, struct net_device *netdev,
846846
return 0;
847847
}
848848

849+
#if KERNEL_VERSION(3, 16, 0) <= LINUX_VERSION_CODE
849850
static int get_station(struct wiphy *wiphy, struct net_device *dev,
850851
const u8 *mac, struct station_info *sinfo)
852+
#else
853+
static int get_station(struct wiphy *wiphy, struct net_device *dev,
854+
u8 *mac, struct station_info *sinfo)
855+
#endif
851856
{
852857
struct wilc_vif *vif = netdev_priv(dev);
853858
struct wilc_priv *priv = &vif->priv;
@@ -873,7 +878,11 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev,
873878
return -ENOENT;
874879
}
875880

881+
#if KERNEL_VERSION(3, 19, 0) <= LINUX_VERSION_CODE
876882
sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
883+
#else
884+
sinfo->filled |= STATION_INFO_INACTIVE_TIME;
885+
#endif
877886

878887
wilc_get_inactive_time(vif, mac, &inactive_time);
879888
sinfo->inactive_time = 1000 * inactive_time;
@@ -889,13 +898,19 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev,
889898
}
890899

891900
wilc_get_statistics(vif, &stats);
892-
901+
#if KERNEL_VERSION(3, 19, 0) <= LINUX_VERSION_CODE
893902
sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
894-
BIT(NL80211_STA_INFO_RX_PACKETS) |
895-
BIT(NL80211_STA_INFO_TX_PACKETS) |
896-
BIT(NL80211_STA_INFO_TX_FAILED) |
897-
BIT(NL80211_STA_INFO_TX_BITRATE);
898-
903+
BIT(NL80211_STA_INFO_RX_PACKETS) |
904+
BIT(NL80211_STA_INFO_TX_PACKETS) |
905+
BIT(NL80211_STA_INFO_TX_FAILED) |
906+
BIT(NL80211_STA_INFO_TX_BITRATE);
907+
#else
908+
sinfo->filled |= STATION_INFO_SIGNAL |
909+
STATION_INFO_RX_PACKETS |
910+
STATION_INFO_TX_PACKETS |
911+
STATION_INFO_TX_FAILED |
912+
STATION_INFO_TX_BITRATE;
913+
#endif
899914
sinfo->signal = stats.rssi;
900915
sinfo->rx_packets = stats.rx_cnt;
901916
sinfo->tx_packets = stats.tx_cnt + stats.tx_fail_cnt;
@@ -1310,15 +1325,25 @@ static int cancel_remain_on_channel(struct wiphy *wiphy,
13101325
return wilc_listen_state_expired(vif, cookie);
13111326
}
13121327

1328+
#if KERNEL_VERSION(3, 14, 0) <= LINUX_VERSION_CODE
13131329
static int mgmt_tx(struct wiphy *wiphy,
13141330
struct wireless_dev *wdev,
13151331
struct cfg80211_mgmt_tx_params *params,
13161332
u64 *cookie)
1333+
#else
1334+
static int mgmt_tx(struct wiphy *wiphy,
1335+
struct wireless_dev *wdev,
1336+
struct ieee80211_channel *chan, bool offchan,
1337+
unsigned int wait, const u8 *buf, size_t len,
1338+
bool no_cck, bool dont_wait_for_ack, u64 *cookie)
1339+
#endif
13171340
{
1341+
#if KERNEL_VERSION(3, 14, 0) <= LINUX_VERSION_CODE
13181342
struct ieee80211_channel *chan = params->chan;
13191343
unsigned int wait = params->wait;
13201344
const u8 *buf = params->buf;
13211345
size_t len = params->len;
1346+
#endif
13221347
const struct ieee80211_mgmt *mgmt;
13231348
struct wilc_p2p_mgmt_data *mgmt_tx;
13241349
struct wilc_vif *vif = netdev_priv(wdev->netdev);
@@ -1497,7 +1522,11 @@ static int dump_station(struct wiphy *wiphy, struct net_device *dev,
14971522
if (ret)
14981523
return ret;
14991524

1500-
sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
1525+
#if KERNEL_VERSION(3, 19, 0) <= LINUX_VERSION_CODE
1526+
sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
1527+
#else
1528+
sinfo->filled |= STATION_INFO_SIGNAL;
1529+
#endif
15011530

15021531
return 0;
15031532
}
@@ -1670,8 +1699,13 @@ static int stop_ap(struct wiphy *wiphy, struct net_device *dev)
16701699
return ret;
16711700
}
16721701

1702+
#if KERNEL_VERSION(3, 16, 0) <= LINUX_VERSION_CODE
16731703
static int add_station(struct wiphy *wiphy, struct net_device *dev,
16741704
const u8 *mac, struct station_parameters *params)
1705+
#else
1706+
static int add_station(struct wiphy *wiphy, struct net_device *dev,
1707+
u8 *mac, struct station_parameters *params)
1708+
#endif
16751709
{
16761710
int ret = 0;
16771711
struct wilc_vif *vif = netdev_priv(dev);
@@ -1725,10 +1759,20 @@ static int add_station(struct wiphy *wiphy, struct net_device *dev,
17251759
return ret;
17261760
}
17271761

1762+
#if KERNEL_VERSION(3, 19, 0) <= LINUX_VERSION_CODE
17281763
static int del_station(struct wiphy *wiphy, struct net_device *dev,
17291764
struct station_del_parameters *params)
1765+
#elif KERNEL_VERSION(3, 16, 0) <= LINUX_VERSION_CODE
1766+
static int del_station(struct wiphy *wiphy, struct net_device *dev,
1767+
const u8 *mac)
1768+
#else
1769+
static int del_station(struct wiphy *wiphy, struct net_device *dev,
1770+
u8 *mac)
1771+
#endif
17301772
{
1773+
#if KERNEL_VERSION(3, 19, 0) <= LINUX_VERSION_CODE
17311774
const u8 *mac = params->mac;
1775+
#endif
17321776
int ret = 0;
17331777
struct wilc_vif *vif = netdev_priv(dev);
17341778
struct wilc_priv *priv = &vif->priv;
@@ -1757,8 +1801,13 @@ static int del_station(struct wiphy *wiphy, struct net_device *dev,
17571801
return ret;
17581802
}
17591803

1804+
#if KERNEL_VERSION(3, 16, 0) <= LINUX_VERSION_CODE
17601805
static int change_station(struct wiphy *wiphy, struct net_device *dev,
17611806
const u8 *mac, struct station_parameters *params)
1807+
#else
1808+
static int change_station(struct wiphy *wiphy, struct net_device *dev,
1809+
u8 *mac, struct station_parameters *params)
1810+
#endif
17621811
{
17631812
int ret = 0;
17641813
struct wilc_vif *vif = netdev_priv(dev);
@@ -1815,11 +1864,32 @@ struct wilc_vif *wilc_get_vif_from_type(struct wilc *wl, int type)
18151864
return NULL;
18161865
}
18171866

1867+
#if KERNEL_VERSION(4, 12, 0) <= LINUX_VERSION_CODE
1868+
static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy,
1869+
const char *name,
1870+
unsigned char name_assign_type,
1871+
enum nl80211_iftype type,
1872+
struct vif_params *params)
1873+
#elif KERNEL_VERSION(4, 1, 0) <= LINUX_VERSION_CODE
18181874
static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy,
18191875
const char *name,
18201876
unsigned char name_assign_type,
18211877
enum nl80211_iftype type,
1878+
u32 *flags,
1879+
struct vif_params *params)
1880+
#elif KERNEL_VERSION(3, 7, 0) <= LINUX_VERSION_CODE
1881+
static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy,
1882+
const char *name,
1883+
enum nl80211_iftype type,
1884+
u32 *flags,
1885+
struct vif_params *params)
1886+
#else
1887+
static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy,
1888+
char *name,
1889+
enum nl80211_iftype type,
1890+
u32 *flags,
18221891
struct vif_params *params)
1892+
#endif
18231893
{
18241894
struct wilc *wl = wiphy_priv(wiphy);
18251895
struct wilc_vif *vif;
@@ -2206,7 +2276,11 @@ struct wilc *wilc_create_wiphy(struct device *dev)
22062276

22072277
wiphy->max_scan_ssids = WILC_MAX_NUM_PROBED_SSID;
22082278
#ifdef CONFIG_PM
2279+
#if KERNEL_VERSION(3, 11, 0) <= LINUX_VERSION_CODE
22092280
wiphy->wowlan = &wowlan_support;
2281+
#else
2282+
wiphy->wowlan = wowlan_support;
2283+
#endif
22102284
#endif
22112285
wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
22122286
wiphy->max_scan_ie_len = 1000;

drivers/net/wireless/microchip/wilc1000/hif.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,29 @@
99
#define WILC_HIF_SCAN_TIMEOUT_MS 5000
1010
#define WILC_HIF_CONNECT_TIMEOUT_MS 9500
1111

12-
#define WILC_FALSE_FRMWR_CHANNEL 100
12+
#define WILC_FALSE_FRMWR_CHANNEL 100
13+
14+
#if KERNEL_VERSION(3, 17, 0) > LINUX_VERSION_CODE
15+
struct ieee80211_wmm_ac_param {
16+
u8 aci_aifsn; /* AIFSN, ACM, ACI */
17+
u8 cw; /* ECWmin, ECWmax (CW = 2^ECW - 1) */
18+
__le16 txop_limit;
19+
} __packed;
20+
21+
struct ieee80211_wmm_param_ie {
22+
u8 element_id; /* Element ID: 221 (0xdd); */
23+
u8 len; /* Length: 24 */
24+
u8 oui[3]; /* 00:50:f2 */
25+
u8 oui_type; /* 2 */
26+
u8 oui_subtype; /* 1 */
27+
u8 version; /* 1 for WMM version 1.0 */
28+
u8 qos_info; /* AP/STA specific QoS info */
29+
u8 reserved; /* 0 */
30+
/* AC_BE, AC_BK, AC_VI, AC_VO */
31+
struct ieee80211_wmm_ac_param ac[4];
32+
} __packed;
33+
#endif
34+
1335
struct send_buffered_eap {
1436
void (*deliver_to_stack)(struct wilc_vif *vif, u8 *buff, u32 size,
1537
u32 pkt_offset, u8 status);

drivers/net/wireless/microchip/wilc1000/netdev.h

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,129 @@
2020

2121
extern int wait_for_recovery;
2222

23+
#if KERNEL_VERSION(3, 14, 0) > LINUX_VERSION_CODE
24+
static inline void ether_addr_copy(u8 *dst, const u8 *src)
25+
{
26+
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
27+
*(u32 *)dst = *(const u32 *)src;
28+
*(u16 *)(dst + 4) = *(const u16 *)(src + 4);
29+
#else
30+
u16 *a = (u16 *)dst;
31+
const u16 *b = (const u16 *)src;
32+
33+
a[0] = b[0];
34+
a[1] = b[1];
35+
a[2] = b[2];
36+
#endif
37+
}
38+
39+
static inline bool ether_addr_equal_unaligned(const u8 *addr1, const u8 *addr2)
40+
{
41+
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
42+
return ether_addr_equal(addr1, addr2);
43+
#else
44+
return memcmp(addr1, addr2, ETH_ALEN) == 0;
45+
#endif
46+
}
47+
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0) */
48+
49+
#if KERNEL_VERSION(3, 12, 0) > LINUX_VERSION_CODE
50+
#define PTR_ERR_OR_ZERO(ptr) PTR_RET(ptr)
51+
#endif
52+
53+
#if KERNEL_VERSION(3, 13, 0) > LINUX_VERSION_CODE
54+
/*
55+
* Create a contiguous bitmask starting at bit position @l and ending at
56+
* position @h. For example
57+
* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
58+
*/
59+
#define GENMASK(h, l) \
60+
(((~UL(0)) - (UL(1) << (l)) + 1) & \
61+
(~UL(0) >> (BITS_PER_LONG - 1 - (h))))
62+
#endif
63+
64+
#if KERNEL_VERSION(4, 9, 0) > LINUX_VERSION_CODE
65+
#ifdef __CHECKER__
66+
#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) (0)
67+
#else
68+
/* Force a compilation error if a constant expression is not a power of 2 */
69+
#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) \
70+
BUILD_BUG_ON(((n) & ((n) - 1)) != 0)
71+
#endif
72+
73+
/*
74+
* Bitfield access macros
75+
*
76+
* FIELD_{GET,PREP} macros take as first parameter shifted mask
77+
* from which they extract the base mask and shift amount.
78+
* Mask must be a compilation time constant.
79+
*
80+
* Example:
81+
*
82+
* #define REG_FIELD_A GENMASK(6, 0)
83+
* #define REG_FIELD_B BIT(7)
84+
* #define REG_FIELD_C GENMASK(15, 8)
85+
* #define REG_FIELD_D GENMASK(31, 16)
86+
*
87+
* Get:
88+
* a = FIELD_GET(REG_FIELD_A, reg);
89+
* b = FIELD_GET(REG_FIELD_B, reg);
90+
*
91+
* Set:
92+
* reg = FIELD_PREP(REG_FIELD_A, 1) |
93+
* FIELD_PREP(REG_FIELD_B, 0) |
94+
* FIELD_PREP(REG_FIELD_C, c) |
95+
* FIELD_PREP(REG_FIELD_D, 0x40);
96+
*
97+
* Modify:
98+
* reg &= ~REG_FIELD_C;
99+
* reg |= FIELD_PREP(REG_FIELD_C, c);
100+
*/
101+
102+
#define __bf_shf(x) (__builtin_ffsll(x) - 1)
103+
104+
#define __BF_FIELD_CHECK(_mask, _reg, _val, _pfx) \
105+
({ \
106+
BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask), \
107+
_pfx "mask is not constant"); \
108+
BUILD_BUG_ON_MSG(!(_mask), _pfx "mask is zero"); \
109+
BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
110+
~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \
111+
_pfx "value too large for the field"); \
112+
BUILD_BUG_ON_MSG((_mask) > (typeof(_reg))~0ull, \
113+
_pfx "type of reg too small for mask"); \
114+
__BUILD_BUG_ON_NOT_POWER_OF_2((_mask) + \
115+
(1ULL << __bf_shf(_mask))); \
116+
})
117+
/**
118+
* FIELD_GET() - extract a bitfield element
119+
* @_mask: shifted mask defining the field's length and position
120+
* @_reg: 32bit value of entire bitfield
121+
*
122+
* FIELD_GET() extracts the field specified by @_mask from the
123+
* bitfield passed in as @_reg by masking and shifting it down.
124+
*/
125+
#define FIELD_GET(_mask, _reg) \
126+
({ \
127+
__BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); \
128+
(typeof(_mask))(((_reg) & (_mask)) >> __bf_shf(_mask)); \
129+
})
130+
131+
/**
132+
* FIELD_PREP() - prepare a bitfield element
133+
* @_mask: shifted mask defining the field's length and position
134+
* @_val: value to put in the field
135+
*
136+
* FIELD_PREP() masks and shifts up the value. The result should
137+
* be combined with other fields of the bitfield using logical OR.
138+
*/
139+
#define FIELD_PREP(_mask, _val) \
140+
({ \
141+
__BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
142+
((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \
143+
})
144+
#endif
145+
23146
#define FLOW_CONTROL_LOWER_THRESHOLD 128
24147
#define FLOW_CONTROL_UPPER_THRESHOLD 256
25148

drivers/net/wireless/microchip/wilc1000/wlan.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
#define WAKE_UP_TRIAL_RETRY 10000
1414

15+
#if KERNEL_VERSION(3, 12, 21) > LINUX_VERSION_CODE
16+
#define list_next_entry(pos, member) \
17+
list_entry((pos)->member.next, typeof(*(pos)), member)
18+
#endif
1519

1620
void acquire_bus(struct wilc *wilc, enum bus_acquire acquire, int source)
1721
{

0 commit comments

Comments
 (0)