6cb2c67827ce792f67b30bb3b98c6f6b7297e7a2
[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 @@ -12729,8 +12747,13 @@ ath_rcv_dev_event(struct notifier_block
49 struct net_device *dev = (struct net_device *)ptr;
50 struct ath_softc *sc = (struct ath_softc *)netdev_priv(dev);
51
52 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
53 if (!dev || !sc || dev->open != &ath_init)
54 return 0;
55 +#else
56 + if (!dev || !sc || dev->netdev_ops->ndo_open != &ath_init)
57 + return 0;
58 +#endif
59
60 switch (event) {
61 case NETDEV_CHANGENAME:
62 --- a/net80211/ieee80211.c
63 +++ b/net80211/ieee80211.c
64 @@ -450,6 +450,18 @@ ieee80211_ifdetach(struct ieee80211com *
65 }
66 EXPORT_SYMBOL(ieee80211_ifdetach);
67
68 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
69 +static const struct net_device_ops ieee80211_netdev_ops = {
70 + .ndo_get_stats = ieee80211_getstats,
71 + .ndo_open = ieee80211_open,
72 + .ndo_stop = ieee80211_stop,
73 + .ndo_start_xmit = ieee80211_hardstart,
74 + .ndo_set_multicast_list = ieee80211_set_multicast_list,
75 + .ndo_change_mtu = ieee80211_change_mtu,
76 + .ndo_do_ioctl = ieee80211_ioctl,
77 +};
78 +#endif
79 +
80 int
81 ieee80211_vap_setup(struct ieee80211com *ic, struct net_device *dev,
82 const char *name, int opmode, int flags, struct ieee80211vap *master)
83 @@ -470,12 +482,17 @@ ieee80211_vap_setup(struct ieee80211com
84 } else
85 strncpy(dev->name, name, sizeof(dev->name));
86 }
87 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
88
89 dev->get_stats = ieee80211_getstats;
90 dev->open = ieee80211_open;
91 dev->stop = ieee80211_stop;
92 dev->hard_start_xmit = ieee80211_hardstart;
93 dev->set_multicast_list = ieee80211_set_multicast_list;
94 + dev->do_ioctl = ieee80211_ioctl;
95 +#else
96 + dev->netdev_ops = &ieee80211_netdev_ops;
97 +#endif
98 #if 0
99 dev->set_mac_address = ieee80211_set_mac_address;
100 #endif
101 @@ -1823,7 +1840,11 @@ ieee80211_set_multicast_list(struct net_
102 IEEE80211_UNLOCK_IRQ(ic);
103
104 /* XXX: Merge multicast list into parent device */
105 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
106 parent->set_multicast_list(ic->ic_dev);
107 +#else
108 + parent->netdev_ops->ndo_set_multicast_list(ic->ic_dev);
109 +#endif
110 }
111
112 void
113 --- a/net80211/ieee80211_linux.c
114 +++ b/net80211/ieee80211_linux.c
115 @@ -984,8 +984,14 @@ ieee80211_rcv_dev_event(struct notifier_
116 void *ptr)
117 {
118 struct net_device *dev = (struct net_device *) ptr;
119 +
120 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
121 if (!dev || dev->open != &ieee80211_open)
122 return 0;
123 +#else
124 + if (!dev || dev->netdev_ops->ndo_open != &ieee80211_open)
125 + return 0;
126 +#endif
127
128 switch (event) {
129 case NETDEV_CHANGENAME:
130 --- a/net80211/ieee80211_var.h
131 +++ b/net80211/ieee80211_var.h
132 @@ -740,6 +740,7 @@ void ieee80211_build_sc_ie(struct ieee80
133 void ieee80211_dfs_action(struct ieee80211com *);
134 void ieee80211_expire_channel_excl_restrictions(struct ieee80211com *);
135 void ieee80211_setpuregbasicrates(struct ieee80211_rateset *rs);
136 +int ieee80211_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
137
138 /*
139 * Iterate through ic_channels to enumerate all distinct ic_ieee channel numbers.
140 --- a/net80211/ieee80211_wireless.c
141 +++ b/net80211/ieee80211_wireless.c
142 @@ -5945,7 +5945,7 @@ static struct iw_handler_def ieee80211_i
143 /*
144 * Handle private ioctl requests.
145 */
146 -static int
147 +int
148 ieee80211_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
149 {
150 struct ieee80211vap *vap = netdev_priv(dev);
151 @@ -6035,7 +6035,6 @@ ieee80211_ioctl_vattach(struct ieee80211
152 {
153 struct net_device *dev = vap->iv_dev;
154
155 - dev->do_ioctl = ieee80211_ioctl;
156 #if IW_HANDLER_VERSION < 7
157 dev->get_wireless_stats = ieee80211_iw_getstats;
158 #endif
159 --- a/net80211/ieee80211_input.c
160 +++ b/net80211/ieee80211_input.c
161 @@ -1185,7 +1185,11 @@ ieee80211_deliver_data(struct ieee80211_
162 skb1->protocol = __constant_htons(ETH_P_802_2);
163 /* XXX insert vlan tag before queue it? */
164 ni_tmp = SKB_CB(skb1)->ni; /* remember node so we can free it */
165 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
166 ret = dev->hard_start_xmit(skb1, dev);
167 +#else
168 + ret = dev->netdev_ops->ndo_start_xmit(skb1, dev);
169 +#endif
170
171 if (ret == NETDEV_TX_BUSY)
172 ieee80211_dev_kfree_skb(&skb1);