madwifi: fix compile error on kernels without net_device api compatibility
[openwrt/svn-archive/archive.git] / package / madwifi / patches / 432-netdev_ops.patch
1 Convert to net_device_ops for Linux 2.6.29+
2 http://madwifi-project.org/changeset/4005
3 --- a/ath/if_ath.c
4 +++ b/ath/if_ath.c
5 @@ -566,6 +566,20 @@ static inline int rate_factor(int mode)
6
7 /* Initialize ath_softc structure */
8
9 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
10 +static const struct net_device_ops ath_netdev_ops = {
11 + .ndo_open = ath_init,
12 + .ndo_stop = ath_stop,
13 + .ndo_start_xmit = ath_hardstart,
14 + .ndo_tx_timeout = ath_tx_timeout,
15 + .ndo_set_multicast_list = ath_mode_init,
16 + .ndo_do_ioctl = ath_ioctl,
17 + .ndo_get_stats = ath_getstats,
18 + .ndo_set_mac_address = ath_set_mac_address,
19 + .ndo_change_mtu = ath_change_mtu,
20 +};
21 +#endif
22 +
23 int
24 ath_attach(u_int16_t devid, struct net_device *dev, HAL_BUS_TAG tag)
25 {
26 @@ -865,16 +879,20 @@ ath_attach(u_int16_t devid, struct net_d
27 }
28
29 /* NB: ether_setup is done by bus-specific code */
30 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
31 dev->open = ath_init;
32 dev->stop = ath_stop;
33 dev->hard_start_xmit = ath_hardstart;
34 dev->tx_timeout = ath_tx_timeout;
35 - dev->watchdog_timeo = 5 * HZ;
36 dev->set_multicast_list = ath_mode_init;
37 dev->do_ioctl = ath_ioctl;
38 dev->get_stats = ath_getstats;
39 dev->set_mac_address = ath_set_mac_address;
40 dev->change_mtu = ath_change_mtu;
41 +#else
42 + dev->netdev_ops = &ath_netdev_ops;
43 +#endif
44 + dev->watchdog_timeo = 5 * HZ;
45 dev->tx_queue_len = ATH_TXBUF - ATH_TXBUF_MGT_RESERVED;
46 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
47 netif_napi_add(dev, &sc->sc_napi, ath_rx_poll, 64);
48 @@ -1257,7 +1275,6 @@ ath_detach(struct net_device *dev)
49 ath_dynamic_sysctl_unregister(sc);
50 ATH_LOCK_DESTROY(sc);
51 ATH_HAL_LOCK_DESTROY(sc);
52 - dev->stop = NULL; /* prevent calling ath_stop again */
53 unregister_netdev(dev);
54 return 0;
55 }
56 @@ -12729,8 +12746,13 @@ ath_rcv_dev_event(struct notifier_block
57 struct net_device *dev = (struct net_device *)ptr;
58 struct ath_softc *sc = (struct ath_softc *)netdev_priv(dev);
59
60 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
61 if (!dev || !sc || dev->open != &ath_init)
62 return 0;
63 +#else
64 + if (!dev || !sc || dev->netdev_ops->ndo_open != &ath_init)
65 + return 0;
66 +#endif
67
68 switch (event) {
69 case NETDEV_CHANGENAME:
70 --- a/net80211/ieee80211.c
71 +++ b/net80211/ieee80211.c
72 @@ -450,6 +450,18 @@ ieee80211_ifdetach(struct ieee80211com *
73 }
74 EXPORT_SYMBOL(ieee80211_ifdetach);
75
76 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
77 +static const struct net_device_ops ieee80211_netdev_ops = {
78 + .ndo_get_stats = ieee80211_getstats,
79 + .ndo_open = ieee80211_open,
80 + .ndo_stop = ieee80211_stop,
81 + .ndo_start_xmit = ieee80211_hardstart,
82 + .ndo_set_multicast_list = ieee80211_set_multicast_list,
83 + .ndo_change_mtu = ieee80211_change_mtu,
84 + .ndo_do_ioctl = ieee80211_ioctl,
85 +};
86 +#endif
87 +
88 int
89 ieee80211_vap_setup(struct ieee80211com *ic, struct net_device *dev,
90 const char *name, int opmode, int flags, struct ieee80211vap *master)
91 @@ -470,12 +482,17 @@ ieee80211_vap_setup(struct ieee80211com
92 } else
93 strncpy(dev->name, name, sizeof(dev->name));
94 }
95 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
96
97 dev->get_stats = ieee80211_getstats;
98 dev->open = ieee80211_open;
99 dev->stop = ieee80211_stop;
100 dev->hard_start_xmit = ieee80211_hardstart;
101 dev->set_multicast_list = ieee80211_set_multicast_list;
102 + dev->do_ioctl = ieee80211_ioctl;
103 +#else
104 + dev->netdev_ops = &ieee80211_netdev_ops;
105 +#endif
106 #if 0
107 dev->set_mac_address = ieee80211_set_mac_address;
108 #endif
109 @@ -1823,7 +1840,11 @@ ieee80211_set_multicast_list(struct net_
110 IEEE80211_UNLOCK_IRQ(ic);
111
112 /* XXX: Merge multicast list into parent device */
113 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
114 parent->set_multicast_list(ic->ic_dev);
115 +#else
116 + parent->netdev_ops->ndo_set_multicast_list(ic->ic_dev);
117 +#endif
118 }
119
120 void
121 --- a/net80211/ieee80211_linux.c
122 +++ b/net80211/ieee80211_linux.c
123 @@ -984,8 +984,14 @@ ieee80211_rcv_dev_event(struct notifier_
124 void *ptr)
125 {
126 struct net_device *dev = (struct net_device *) ptr;
127 +
128 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
129 if (!dev || dev->open != &ieee80211_open)
130 return 0;
131 +#else
132 + if (!dev || dev->netdev_ops->ndo_open != &ieee80211_open)
133 + return 0;
134 +#endif
135
136 switch (event) {
137 case NETDEV_CHANGENAME:
138 --- a/net80211/ieee80211_var.h
139 +++ b/net80211/ieee80211_var.h
140 @@ -740,6 +740,7 @@ void ieee80211_build_sc_ie(struct ieee80
141 void ieee80211_dfs_action(struct ieee80211com *);
142 void ieee80211_expire_channel_excl_restrictions(struct ieee80211com *);
143 void ieee80211_setpuregbasicrates(struct ieee80211_rateset *rs);
144 +int ieee80211_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
145
146 /*
147 * Iterate through ic_channels to enumerate all distinct ic_ieee channel numbers.
148 --- a/net80211/ieee80211_wireless.c
149 +++ b/net80211/ieee80211_wireless.c
150 @@ -5945,7 +5945,7 @@ static struct iw_handler_def ieee80211_i
151 /*
152 * Handle private ioctl requests.
153 */
154 -static int
155 +int
156 ieee80211_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
157 {
158 struct ieee80211vap *vap = netdev_priv(dev);
159 @@ -6035,7 +6035,6 @@ ieee80211_ioctl_vattach(struct ieee80211
160 {
161 struct net_device *dev = vap->iv_dev;
162
163 - dev->do_ioctl = ieee80211_ioctl;
164 #if IW_HANDLER_VERSION < 7
165 dev->get_wireless_stats = ieee80211_iw_getstats;
166 #endif
167 --- a/net80211/ieee80211_input.c
168 +++ b/net80211/ieee80211_input.c
169 @@ -1185,7 +1185,11 @@ ieee80211_deliver_data(struct ieee80211_
170 skb1->protocol = __constant_htons(ETH_P_802_2);
171 /* XXX insert vlan tag before queue it? */
172 ni_tmp = SKB_CB(skb1)->ni; /* remember node so we can free it */
173 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
174 ret = dev->hard_start_xmit(skb1, dev);
175 +#else
176 + ret = dev->netdev_ops->ndo_start_xmit(skb1, dev);
177 +#endif
178
179 if (ret == NETDEV_TX_BUSY)
180 ieee80211_dev_kfree_skb(&skb1);