aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/orinoco
diff options
context:
space:
mode:
authorDavid Kilroy <kilroyd@googlemail.com>2009-06-18 18:21:28 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-07-10 15:01:45 -0400
commit5381956b780e82805247c2ec8e32c4c665309394 (patch)
tree04f0f203a5b89dfd48fb8821be2c4ebf9ce3ed9a /drivers/net/wireless/orinoco
parent35832c50d1d1552618f55aa5457a251df9e63b26 (diff)
orinoco: move netdev interface creation to main driver
With the move to cfg80211 it's nice to keep the hardware operations distinct from the interface, even though we can only support a single interface. This also means the driver resembles other cfg80211 drivers. Signed-off-by: David Kilroy <kilroyd@googlemail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/orinoco')
-rw-r--r--drivers/net/wireless/orinoco/airport.c23
-rw-r--r--drivers/net/wireless/orinoco/main.c111
-rw-r--r--drivers/net/wireless/orinoco/orinoco.h4
-rw-r--r--drivers/net/wireless/orinoco/orinoco_cs.c21
-rw-r--r--drivers/net/wireless/orinoco/orinoco_nortel.c14
-rw-r--r--drivers/net/wireless/orinoco/orinoco_pci.c14
-rw-r--r--drivers/net/wireless/orinoco/orinoco_plx.c14
-rw-r--r--drivers/net/wireless/orinoco/orinoco_tmd.c14
-rw-r--r--drivers/net/wireless/orinoco/spectrum_cs.c22
9 files changed, 119 insertions, 118 deletions
diff --git a/drivers/net/wireless/orinoco/airport.c b/drivers/net/wireless/orinoco/airport.c
index 9f90337344f..e46e0d7c36f 100644
--- a/drivers/net/wireless/orinoco/airport.c
+++ b/drivers/net/wireless/orinoco/airport.c
@@ -116,7 +116,7 @@ airport_detach(struct macio_dev *mdev)
116 struct airport *card = priv->card; 116 struct airport *card = priv->card;
117 117
118 if (card->ndev_registered) 118 if (card->ndev_registered)
119 unregister_netdev(dev); 119 orinoco_if_del(priv);
120 card->ndev_registered = 0; 120 card->ndev_registered = 0;
121 121
122 if (card->irq_requested) 122 if (card->irq_requested)
@@ -174,9 +174,9 @@ static int
174airport_attach(struct macio_dev *mdev, const struct of_device_id *match) 174airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
175{ 175{
176 struct orinoco_private *priv; 176 struct orinoco_private *priv;
177 struct net_device *dev;
178 struct airport *card; 177 struct airport *card;
179 unsigned long phys_addr; 178 unsigned long phys_addr;
179 unsigned int irq;
180 hermes_t *hw; 180 hermes_t *hw;
181 181
182 if (macio_resource_count(mdev) < 1 || macio_irq_count(mdev) < 1) { 182 if (macio_resource_count(mdev) < 1 || macio_irq_count(mdev) < 1) {
@@ -191,27 +191,23 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
191 printk(KERN_ERR PFX "Cannot allocate network device\n"); 191 printk(KERN_ERR PFX "Cannot allocate network device\n");
192 return -ENODEV; 192 return -ENODEV;
193 } 193 }
194 dev = priv->ndev;
195 card = priv->card; 194 card = priv->card;
196 195
197 hw = &priv->hw; 196 hw = &priv->hw;
198 card->mdev = mdev; 197 card->mdev = mdev;
199 198
200 if (macio_request_resource(mdev, 0, "airport")) { 199 if (macio_request_resource(mdev, 0, DRIVER_NAME)) {
201 printk(KERN_ERR PFX "can't request IO resource !\n"); 200 printk(KERN_ERR PFX "can't request IO resource !\n");
202 free_orinocodev(priv); 201 free_orinocodev(priv);
203 return -EBUSY; 202 return -EBUSY;
204 } 203 }
205 204
206 SET_NETDEV_DEV(dev, &mdev->ofdev.dev);
207
208 macio_set_drvdata(mdev, priv); 205 macio_set_drvdata(mdev, priv);
209 206
210 /* Setup interrupts & base address */ 207 /* Setup interrupts & base address */
211 dev->irq = macio_irq(mdev, 0); 208 irq = macio_irq(mdev, 0);
212 phys_addr = macio_resource_start(mdev, 0); /* Physical address */ 209 phys_addr = macio_resource_start(mdev, 0); /* Physical address */
213 printk(KERN_DEBUG PFX "Physical address %lx\n", phys_addr); 210 printk(KERN_DEBUG PFX "Physical address %lx\n", phys_addr);
214 dev->base_addr = phys_addr;
215 card->vaddr = ioremap(phys_addr, AIRPORT_IO_LEN); 211 card->vaddr = ioremap(phys_addr, AIRPORT_IO_LEN);
216 if (!card->vaddr) { 212 if (!card->vaddr) {
217 printk(KERN_ERR PFX "ioremap() failed\n"); 213 printk(KERN_ERR PFX "ioremap() failed\n");
@@ -228,8 +224,8 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
228 /* Reset it before we get the interrupt */ 224 /* Reset it before we get the interrupt */
229 hermes_init(hw); 225 hermes_init(hw);
230 226
231 if (request_irq(dev->irq, orinoco_interrupt, 0, dev->name, priv)) { 227 if (request_irq(irq, orinoco_interrupt, 0, DRIVER_NAME, priv)) {
232 printk(KERN_ERR PFX "Couldn't get IRQ %d\n", dev->irq); 228 printk(KERN_ERR PFX "Couldn't get IRQ %d\n", irq);
233 goto failed; 229 goto failed;
234 } 230 }
235 card->irq_requested = 1; 231 card->irq_requested = 1;
@@ -240,12 +236,11 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match)
240 goto failed; 236 goto failed;
241 } 237 }
242 238
243 /* Tell the stack we exist */ 239 /* Register an interface with the stack */
244 if (register_netdev(dev) != 0) { 240 if (orinoco_if_add(priv, phys_addr, irq) != 0) {
245 printk(KERN_ERR PFX "register_netdev() failed\n"); 241 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
246 goto failed; 242 goto failed;
247 } 243 }
248 printk(KERN_DEBUG PFX "Card registered for interface %s\n", dev->name);
249 card->ndev_registered = 1; 244 card->ndev_registered = 1;
250 return 0; 245 return 0;
251 failed: 246 failed:
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c
index 5c1cf648002..361cf09d6b7 100644
--- a/drivers/net/wireless/orinoco/main.c
+++ b/drivers/net/wireless/orinoco/main.c
@@ -1017,8 +1017,8 @@ static void orinoco_rx(struct net_device *dev,
1017 1017
1018static void orinoco_rx_isr_tasklet(unsigned long data) 1018static void orinoco_rx_isr_tasklet(unsigned long data)
1019{ 1019{
1020 struct net_device *dev = (struct net_device *) data; 1020 struct orinoco_private *priv = (struct orinoco_private *) data;
1021 struct orinoco_private *priv = ndev_priv(dev); 1021 struct net_device *dev = priv->ndev;
1022 struct orinoco_rx_data *rx_data, *temp; 1022 struct orinoco_rx_data *rx_data, *temp;
1023 struct hermes_rx_descriptor *desc; 1023 struct hermes_rx_descriptor *desc;
1024 struct sk_buff *skb; 1024 struct sk_buff *skb;
@@ -2143,7 +2143,6 @@ int orinoco_init(struct orinoco_private *priv)
2143 err = orinoco_hw_read_card_settings(priv, wiphy->perm_addr); 2143 err = orinoco_hw_read_card_settings(priv, wiphy->perm_addr);
2144 if (err) 2144 if (err)
2145 goto out; 2145 goto out;
2146 memcpy(priv->ndev->dev_addr, wiphy->perm_addr, ETH_ALEN);
2147 2146
2148 err = orinoco_hw_allocate_fid(priv); 2147 err = orinoco_hw_allocate_fid(priv);
2149 if (err) { 2148 if (err) {
@@ -2226,9 +2225,7 @@ struct orinoco_private
2226 int (*hard_reset)(struct orinoco_private *), 2225 int (*hard_reset)(struct orinoco_private *),
2227 int (*stop_fw)(struct orinoco_private *, int)) 2226 int (*stop_fw)(struct orinoco_private *, int))
2228{ 2227{
2229 struct net_device *dev;
2230 struct orinoco_private *priv; 2228 struct orinoco_private *priv;
2231 struct wireless_dev *wdev;
2232 struct wiphy *wiphy; 2229 struct wiphy *wiphy;
2233 2230
2234 /* allocate wiphy 2231 /* allocate wiphy
@@ -2240,43 +2237,20 @@ struct orinoco_private
2240 if (!wiphy) 2237 if (!wiphy)
2241 return NULL; 2238 return NULL;
2242 2239
2243 dev = alloc_etherdev(sizeof(struct wireless_dev));
2244 if (!dev) {
2245 wiphy_free(wiphy);
2246 return NULL;
2247 }
2248
2249 priv = wiphy_priv(wiphy); 2240 priv = wiphy_priv(wiphy);
2250 priv->ndev = dev; 2241 priv->dev = device;
2251 2242
2252 if (sizeof_card) 2243 if (sizeof_card)
2253 priv->card = (void *)((unsigned long)priv 2244 priv->card = (void *)((unsigned long)priv
2254 + sizeof(struct orinoco_private)); 2245 + sizeof(struct orinoco_private));
2255 else 2246 else
2256 priv->card = NULL; 2247 priv->card = NULL;
2257 priv->dev = device;
2258 2248
2259 orinoco_wiphy_init(wiphy); 2249 orinoco_wiphy_init(wiphy);
2260 2250
2261 /* Initialise wireless_dev */
2262 wdev = netdev_priv(dev);
2263 wdev->wiphy = wiphy;
2264 wdev->iftype = NL80211_IFTYPE_STATION;
2265
2266 /* Setup / override net_device fields */
2267 dev->ieee80211_ptr = wdev;
2268 dev->netdev_ops = &orinoco_netdev_ops;
2269 dev->watchdog_timeo = HZ; /* 1 second timeout */
2270 dev->ethtool_ops = &orinoco_ethtool_ops;
2271 dev->wireless_handlers = &orinoco_handler_def;
2272#ifdef WIRELESS_SPY 2251#ifdef WIRELESS_SPY
2273 priv->wireless_data.spy_data = &priv->spy_data; 2252 priv->wireless_data.spy_data = &priv->spy_data;
2274 dev->wireless_data = &priv->wireless_data;
2275#endif 2253#endif
2276 /* we use the default eth_mac_addr for setting the MAC addr */
2277
2278 /* Reserve space in skb for the SNAP header */
2279 dev->hard_header_len += ENCAPS_OVERHEAD;
2280 2254
2281 /* Set up default callbacks */ 2255 /* Set up default callbacks */
2282 priv->hard_reset = hard_reset; 2256 priv->hard_reset = hard_reset;
@@ -2293,9 +2267,8 @@ struct orinoco_private
2293 2267
2294 INIT_LIST_HEAD(&priv->rx_list); 2268 INIT_LIST_HEAD(&priv->rx_list);
2295 tasklet_init(&priv->rx_tasklet, orinoco_rx_isr_tasklet, 2269 tasklet_init(&priv->rx_tasklet, orinoco_rx_isr_tasklet,
2296 (unsigned long) dev); 2270 (unsigned long) priv);
2297 2271
2298 netif_carrier_off(dev);
2299 priv->last_linkstatus = 0xffff; 2272 priv->last_linkstatus = 0xffff;
2300 2273
2301#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) 2274#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
@@ -2310,9 +2283,82 @@ struct orinoco_private
2310} 2283}
2311EXPORT_SYMBOL(alloc_orinocodev); 2284EXPORT_SYMBOL(alloc_orinocodev);
2312 2285
2313void free_orinocodev(struct orinoco_private *priv) 2286/* We can only support a single interface. We provide a separate
2287 * function to set it up to distinguish between hardware
2288 * initialisation and interface setup.
2289 *
2290 * The base_addr and irq parameters are passed on to netdev for use
2291 * with SIOCGIFMAP.
2292 */
2293int orinoco_if_add(struct orinoco_private *priv,
2294 unsigned long base_addr,
2295 unsigned int irq)
2296{
2297 struct wiphy *wiphy = priv_to_wiphy(priv);
2298 struct wireless_dev *wdev;
2299 struct net_device *dev;
2300 int ret;
2301
2302 dev = alloc_etherdev(sizeof(struct wireless_dev));
2303
2304 if (!dev)
2305 return -ENOMEM;
2306
2307 /* Initialise wireless_dev */
2308 wdev = netdev_priv(dev);
2309 wdev->wiphy = wiphy;
2310 wdev->iftype = NL80211_IFTYPE_STATION;
2311
2312 /* Setup / override net_device fields */
2313 dev->ieee80211_ptr = wdev;
2314 dev->netdev_ops = &orinoco_netdev_ops;
2315 dev->watchdog_timeo = HZ; /* 1 second timeout */
2316 dev->ethtool_ops = &orinoco_ethtool_ops;
2317 dev->wireless_handlers = &orinoco_handler_def;
2318#ifdef WIRELESS_SPY
2319 dev->wireless_data = &priv->wireless_data;
2320#endif
2321 /* we use the default eth_mac_addr for setting the MAC addr */
2322
2323 /* Reserve space in skb for the SNAP header */
2324 dev->hard_header_len += ENCAPS_OVERHEAD;
2325
2326 netif_carrier_off(dev);
2327
2328 memcpy(dev->dev_addr, wiphy->perm_addr, ETH_ALEN);
2329
2330 dev->base_addr = base_addr;
2331 dev->irq = irq;
2332
2333 SET_NETDEV_DEV(dev, priv->dev);
2334 ret = register_netdev(dev);
2335 if (ret)
2336 goto fail;
2337
2338 priv->ndev = dev;
2339
2340 /* Report what we've done */
2341 dev_dbg(priv->dev, "Registerred interface %s.\n", dev->name);
2342
2343 return 0;
2344
2345 fail:
2346 free_netdev(dev);
2347 return ret;
2348}
2349EXPORT_SYMBOL(orinoco_if_add);
2350
2351void orinoco_if_del(struct orinoco_private *priv)
2314{ 2352{
2315 struct net_device *dev = priv->ndev; 2353 struct net_device *dev = priv->ndev;
2354
2355 unregister_netdev(dev);
2356 free_netdev(dev);
2357}
2358EXPORT_SYMBOL(orinoco_if_del);
2359
2360void free_orinocodev(struct orinoco_private *priv)
2361{
2316 struct wiphy *wiphy = priv_to_wiphy(priv); 2362 struct wiphy *wiphy = priv_to_wiphy(priv);
2317 struct orinoco_rx_data *rx_data, *temp; 2363 struct orinoco_rx_data *rx_data, *temp;
2318 2364
@@ -2339,7 +2385,6 @@ void free_orinocodev(struct orinoco_private *priv)
2339 kfree(priv->wpa_ie); 2385 kfree(priv->wpa_ie);
2340 orinoco_mic_free(priv); 2386 orinoco_mic_free(priv);
2341 orinoco_bss_data_free(priv); 2387 orinoco_bss_data_free(priv);
2342 free_netdev(dev);
2343 wiphy_free(wiphy); 2388 wiphy_free(wiphy);
2344} 2389}
2345EXPORT_SYMBOL(free_orinocodev); 2390EXPORT_SYMBOL(free_orinocodev);
diff --git a/drivers/net/wireless/orinoco/orinoco.h b/drivers/net/wireless/orinoco/orinoco.h
index 608cc5e1bd9..45aa616eb66 100644
--- a/drivers/net/wireless/orinoco/orinoco.h
+++ b/drivers/net/wireless/orinoco/orinoco.h
@@ -193,6 +193,10 @@ extern struct orinoco_private *alloc_orinocodev(
193 int (*stop_fw)(struct orinoco_private *, int)); 193 int (*stop_fw)(struct orinoco_private *, int));
194extern void free_orinocodev(struct orinoco_private *priv); 194extern void free_orinocodev(struct orinoco_private *priv);
195extern int orinoco_init(struct orinoco_private *priv); 195extern int orinoco_init(struct orinoco_private *priv);
196extern int orinoco_if_add(struct orinoco_private *priv,
197 unsigned long base_addr,
198 unsigned int irq);
199extern void orinoco_if_del(struct orinoco_private *priv);
196extern int __orinoco_up(struct orinoco_private *priv); 200extern int __orinoco_up(struct orinoco_private *priv);
197extern int __orinoco_down(struct orinoco_private *priv); 201extern int __orinoco_down(struct orinoco_private *priv);
198extern int orinoco_reinit_firmware(struct orinoco_private *priv); 202extern int orinoco_reinit_firmware(struct orinoco_private *priv);
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index 20abf021c06..4c29d368925 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -147,7 +147,7 @@ static void orinoco_cs_detach(struct pcmcia_device *link)
147 struct orinoco_private *priv = link->priv; 147 struct orinoco_private *priv = link->priv;
148 148
149 if (link->dev_node) 149 if (link->dev_node)
150 unregister_netdev(priv->ndev); 150 orinoco_if_del(priv);
151 151
152 orinoco_cs_release(link); 152 orinoco_cs_release(link);
153 153
@@ -239,7 +239,6 @@ orinoco_cs_config(struct pcmcia_device *link)
239{ 239{
240 struct orinoco_private *priv = link->priv; 240 struct orinoco_private *priv = link->priv;
241 struct orinoco_pccard *card = priv->card; 241 struct orinoco_pccard *card = priv->card;
242 struct net_device *dev = priv->ndev;
243 hermes_t *hw = &priv->hw; 242 hermes_t *hw = &priv->hw;
244 int last_fn, last_ret; 243 int last_fn, last_ret;
245 void __iomem *mem; 244 void __iomem *mem;
@@ -293,8 +292,6 @@ orinoco_cs_config(struct pcmcia_device *link)
293 pcmcia_request_configuration(link, &link->conf)); 292 pcmcia_request_configuration(link, &link->conf));
294 293
295 /* Ok, we have the configuration, prepare to register the netdev */ 294 /* Ok, we have the configuration, prepare to register the netdev */
296 dev->base_addr = link->io.BasePort1;
297 dev->irq = link->irq.AssignedIRQ;
298 card->node.major = card->node.minor = 0; 295 card->node.major = card->node.minor = 0;
299 296
300 /* Initialise the main driver */ 297 /* Initialise the main driver */
@@ -303,25 +300,19 @@ orinoco_cs_config(struct pcmcia_device *link)
303 goto failed; 300 goto failed;
304 } 301 }
305 302
306 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 303 /* Register an interface with the stack */
307 /* Tell the stack we exist */ 304 if (orinoco_if_add(priv, link->io.BasePort1,
308 if (register_netdev(dev) != 0) { 305 link->irq.AssignedIRQ) != 0) {
309 printk(KERN_ERR PFX "register_netdev() failed\n"); 306 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
310 goto failed; 307 goto failed;
311 } 308 }
312 309
313 /* At this point, the dev_node_t structure(s) needs to be 310 /* At this point, the dev_node_t structure(s) needs to be
314 * initialized and arranged in a linked list at link->dev_node. */ 311 * initialized and arranged in a linked list at link->dev_node. */
315 strcpy(card->node.dev_name, dev->name); 312 strcpy(card->node.dev_name, priv->ndev->name);
316 link->dev_node = &card->node; /* link->dev_node being non-NULL is also 313 link->dev_node = &card->node; /* link->dev_node being non-NULL is also
317 * used to indicate that the 314 * used to indicate that the
318 * net_device has been registered */ 315 * net_device has been registered */
319
320 /* Finally, report what we've done */
321 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
322 "0x%04x-0x%04x\n", dev->name, dev_name(dev->dev.parent),
323 link->irq.AssignedIRQ, link->io.BasePort1,
324 link->io.BasePort1 + link->io.NumPorts1 - 1);
325 return 0; 316 return 0;
326 317
327 cs_failed: 318 cs_failed:
diff --git a/drivers/net/wireless/orinoco/orinoco_nortel.c b/drivers/net/wireless/orinoco/orinoco_nortel.c
index 45cef818b29..c13a4c38341 100644
--- a/drivers/net/wireless/orinoco/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco/orinoco_nortel.c
@@ -144,7 +144,6 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
144 int err; 144 int err;
145 struct orinoco_private *priv; 145 struct orinoco_private *priv;
146 struct orinoco_pci_card *card; 146 struct orinoco_pci_card *card;
147 struct net_device *dev;
148 void __iomem *hermes_io, *bridge_io, *attr_io; 147 void __iomem *hermes_io, *bridge_io, *attr_io;
149 148
150 err = pci_enable_device(pdev); 149 err = pci_enable_device(pdev);
@@ -189,16 +188,14 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
189 goto fail_alloc; 188 goto fail_alloc;
190 } 189 }
191 190
192 dev = priv->ndev;
193 card = priv->card; 191 card = priv->card;
194 card->bridge_io = bridge_io; 192 card->bridge_io = bridge_io;
195 card->attr_io = attr_io; 193 card->attr_io = attr_io;
196 SET_NETDEV_DEV(dev, &pdev->dev);
197 194
198 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING); 195 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);
199 196
200 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, 197 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
201 dev->name, priv); 198 DRIVER_NAME, priv);
202 if (err) { 199 if (err) {
203 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); 200 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
204 err = -EBUSY; 201 err = -EBUSY;
@@ -223,15 +220,13 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
223 goto fail; 220 goto fail;
224 } 221 }
225 222
226 err = register_netdev(dev); 223 err = orinoco_if_add(priv, 0, 0);
227 if (err) { 224 if (err) {
228 printk(KERN_ERR PFX "Cannot register network device\n"); 225 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
229 goto fail; 226 goto fail;
230 } 227 }
231 228
232 pci_set_drvdata(pdev, priv); 229 pci_set_drvdata(pdev, priv);
233 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s\n", dev->name,
234 pci_name(pdev));
235 230
236 return 0; 231 return 0;
237 232
@@ -263,13 +258,12 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev,
263static void __devexit orinoco_nortel_remove_one(struct pci_dev *pdev) 258static void __devexit orinoco_nortel_remove_one(struct pci_dev *pdev)
264{ 259{
265 struct orinoco_private *priv = pci_get_drvdata(pdev); 260 struct orinoco_private *priv = pci_get_drvdata(pdev);
266 struct net_device *dev = priv->ndev;
267 struct orinoco_pci_card *card = priv->card; 261 struct orinoco_pci_card *card = priv->card;
268 262
269 /* Clear LEDs */ 263 /* Clear LEDs */
270 iowrite16(0, card->bridge_io + 10); 264 iowrite16(0, card->bridge_io + 10);
271 265
272 unregister_netdev(dev); 266 orinoco_if_del(priv);
273 free_irq(pdev->irq, priv); 267 free_irq(pdev->irq, priv);
274 pci_set_drvdata(pdev, NULL); 268 pci_set_drvdata(pdev, NULL);
275 free_orinocodev(priv); 269 free_orinocodev(priv);
diff --git a/drivers/net/wireless/orinoco/orinoco_pci.c b/drivers/net/wireless/orinoco/orinoco_pci.c
index d0eb4ae9bd1..fea7781948e 100644
--- a/drivers/net/wireless/orinoco/orinoco_pci.c
+++ b/drivers/net/wireless/orinoco/orinoco_pci.c
@@ -116,7 +116,6 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
116 int err; 116 int err;
117 struct orinoco_private *priv; 117 struct orinoco_private *priv;
118 struct orinoco_pci_card *card; 118 struct orinoco_pci_card *card;
119 struct net_device *dev;
120 void __iomem *hermes_io; 119 void __iomem *hermes_io;
121 120
122 err = pci_enable_device(pdev); 121 err = pci_enable_device(pdev);
@@ -147,14 +146,12 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
147 goto fail_alloc; 146 goto fail_alloc;
148 } 147 }
149 148
150 dev = priv->ndev;
151 card = priv->card; 149 card = priv->card;
152 SET_NETDEV_DEV(dev, &pdev->dev);
153 150
154 hermes_struct_init(&priv->hw, hermes_io, HERMES_32BIT_REGSPACING); 151 hermes_struct_init(&priv->hw, hermes_io, HERMES_32BIT_REGSPACING);
155 152
156 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, 153 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
157 dev->name, priv); 154 DRIVER_NAME, priv);
158 if (err) { 155 if (err) {
159 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); 156 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
160 err = -EBUSY; 157 err = -EBUSY;
@@ -173,15 +170,13 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
173 goto fail; 170 goto fail;
174 } 171 }
175 172
176 err = register_netdev(dev); 173 err = orinoco_if_add(priv, 0, 0);
177 if (err) { 174 if (err) {
178 printk(KERN_ERR PFX "Cannot register network device\n"); 175 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
179 goto fail; 176 goto fail;
180 } 177 }
181 178
182 pci_set_drvdata(pdev, priv); 179 pci_set_drvdata(pdev, priv);
183 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s\n", dev->name,
184 pci_name(pdev));
185 180
186 return 0; 181 return 0;
187 182
@@ -207,9 +202,8 @@ static int orinoco_pci_init_one(struct pci_dev *pdev,
207static void __devexit orinoco_pci_remove_one(struct pci_dev *pdev) 202static void __devexit orinoco_pci_remove_one(struct pci_dev *pdev)
208{ 203{
209 struct orinoco_private *priv = pci_get_drvdata(pdev); 204 struct orinoco_private *priv = pci_get_drvdata(pdev);
210 struct net_device *dev = priv->ndev;
211 205
212 unregister_netdev(dev); 206 orinoco_if_del(priv);
213 free_irq(pdev->irq, priv); 207 free_irq(pdev->irq, priv);
214 pci_set_drvdata(pdev, NULL); 208 pci_set_drvdata(pdev, NULL);
215 free_orinocodev(priv); 209 free_orinocodev(priv);
diff --git a/drivers/net/wireless/orinoco/orinoco_plx.c b/drivers/net/wireless/orinoco/orinoco_plx.c
index 8f225d064a7..3f2942a1e4f 100644
--- a/drivers/net/wireless/orinoco/orinoco_plx.c
+++ b/drivers/net/wireless/orinoco/orinoco_plx.c
@@ -183,7 +183,6 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
183 int err; 183 int err;
184 struct orinoco_private *priv; 184 struct orinoco_private *priv;
185 struct orinoco_pci_card *card; 185 struct orinoco_pci_card *card;
186 struct net_device *dev;
187 void __iomem *hermes_io, *attr_io, *bridge_io; 186 void __iomem *hermes_io, *attr_io, *bridge_io;
188 187
189 err = pci_enable_device(pdev); 188 err = pci_enable_device(pdev);
@@ -228,16 +227,14 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
228 goto fail_alloc; 227 goto fail_alloc;
229 } 228 }
230 229
231 dev = priv->ndev;
232 card = priv->card; 230 card = priv->card;
233 card->bridge_io = bridge_io; 231 card->bridge_io = bridge_io;
234 card->attr_io = attr_io; 232 card->attr_io = attr_io;
235 SET_NETDEV_DEV(dev, &pdev->dev);
236 233
237 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING); 234 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);
238 235
239 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, 236 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
240 dev->name, priv); 237 DRIVER_NAME, priv);
241 if (err) { 238 if (err) {
242 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); 239 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
243 err = -EBUSY; 240 err = -EBUSY;
@@ -262,15 +259,13 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
262 goto fail; 259 goto fail;
263 } 260 }
264 261
265 err = register_netdev(dev); 262 err = orinoco_if_add(priv, 0, 0);
266 if (err) { 263 if (err) {
267 printk(KERN_ERR PFX "Cannot register network device\n"); 264 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
268 goto fail; 265 goto fail;
269 } 266 }
270 267
271 pci_set_drvdata(pdev, priv); 268 pci_set_drvdata(pdev, priv);
272 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s\n", dev->name,
273 pci_name(pdev));
274 269
275 return 0; 270 return 0;
276 271
@@ -302,10 +297,9 @@ static int orinoco_plx_init_one(struct pci_dev *pdev,
302static void __devexit orinoco_plx_remove_one(struct pci_dev *pdev) 297static void __devexit orinoco_plx_remove_one(struct pci_dev *pdev)
303{ 298{
304 struct orinoco_private *priv = pci_get_drvdata(pdev); 299 struct orinoco_private *priv = pci_get_drvdata(pdev);
305 struct net_device *dev = priv->ndev;
306 struct orinoco_pci_card *card = priv->card; 300 struct orinoco_pci_card *card = priv->card;
307 301
308 unregister_netdev(dev); 302 orinoco_if_del(priv);
309 free_irq(pdev->irq, priv); 303 free_irq(pdev->irq, priv);
310 pci_set_drvdata(pdev, NULL); 304 pci_set_drvdata(pdev, NULL);
311 free_orinocodev(priv); 305 free_orinocodev(priv);
diff --git a/drivers/net/wireless/orinoco/orinoco_tmd.c b/drivers/net/wireless/orinoco/orinoco_tmd.c
index 3c04faee7ae..d3452548cc7 100644
--- a/drivers/net/wireless/orinoco/orinoco_tmd.c
+++ b/drivers/net/wireless/orinoco/orinoco_tmd.c
@@ -94,7 +94,6 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
94 int err; 94 int err;
95 struct orinoco_private *priv; 95 struct orinoco_private *priv;
96 struct orinoco_pci_card *card; 96 struct orinoco_pci_card *card;
97 struct net_device *dev;
98 void __iomem *hermes_io, *bridge_io; 97 void __iomem *hermes_io, *bridge_io;
99 98
100 err = pci_enable_device(pdev); 99 err = pci_enable_device(pdev);
@@ -132,15 +131,13 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
132 goto fail_alloc; 131 goto fail_alloc;
133 } 132 }
134 133
135 dev = priv->ndev;
136 card = priv->card; 134 card = priv->card;
137 card->bridge_io = bridge_io; 135 card->bridge_io = bridge_io;
138 SET_NETDEV_DEV(dev, &pdev->dev);
139 136
140 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING); 137 hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING);
141 138
142 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, 139 err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED,
143 dev->name, priv); 140 DRIVER_NAME, priv);
144 if (err) { 141 if (err) {
145 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); 142 printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq);
146 err = -EBUSY; 143 err = -EBUSY;
@@ -159,15 +156,13 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
159 goto fail; 156 goto fail;
160 } 157 }
161 158
162 err = register_netdev(dev); 159 err = orinoco_if_add(priv, 0, 0);
163 if (err) { 160 if (err) {
164 printk(KERN_ERR PFX "Cannot register network device\n"); 161 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
165 goto fail; 162 goto fail;
166 } 163 }
167 164
168 pci_set_drvdata(pdev, priv); 165 pci_set_drvdata(pdev, priv);
169 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s\n", dev->name,
170 pci_name(pdev));
171 166
172 return 0; 167 return 0;
173 168
@@ -196,10 +191,9 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev,
196static void __devexit orinoco_tmd_remove_one(struct pci_dev *pdev) 191static void __devexit orinoco_tmd_remove_one(struct pci_dev *pdev)
197{ 192{
198 struct orinoco_private *priv = pci_get_drvdata(pdev); 193 struct orinoco_private *priv = pci_get_drvdata(pdev);
199 struct net_device *dev = priv->ndev;
200 struct orinoco_pci_card *card = priv->card; 194 struct orinoco_pci_card *card = priv->card;
201 195
202 unregister_netdev(dev); 196 orinoco_if_del(priv);
203 free_irq(pdev->irq, priv); 197 free_irq(pdev->irq, priv);
204 pci_set_drvdata(pdev, NULL); 198 pci_set_drvdata(pdev, NULL);
205 free_orinocodev(priv); 199 free_orinocodev(priv);
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c
index 43e1aed4e4b..7b4a7e42835 100644
--- a/drivers/net/wireless/orinoco/spectrum_cs.c
+++ b/drivers/net/wireless/orinoco/spectrum_cs.c
@@ -220,7 +220,7 @@ static void spectrum_cs_detach(struct pcmcia_device *link)
220 struct orinoco_private *priv = link->priv; 220 struct orinoco_private *priv = link->priv;
221 221
222 if (link->dev_node) 222 if (link->dev_node)
223 unregister_netdev(priv->ndev); 223 orinoco_if_del(priv);
224 224
225 spectrum_cs_release(link); 225 spectrum_cs_release(link);
226 226
@@ -306,7 +306,6 @@ spectrum_cs_config(struct pcmcia_device *link)
306{ 306{
307 struct orinoco_private *priv = link->priv; 307 struct orinoco_private *priv = link->priv;
308 struct orinoco_pccard *card = priv->card; 308 struct orinoco_pccard *card = priv->card;
309 struct net_device *dev = priv->ndev;
310 hermes_t *hw = &priv->hw; 309 hermes_t *hw = &priv->hw;
311 int last_fn, last_ret; 310 int last_fn, last_ret;
312 void __iomem *mem; 311 void __iomem *mem;
@@ -360,8 +359,6 @@ spectrum_cs_config(struct pcmcia_device *link)
360 pcmcia_request_configuration(link, &link->conf)); 359 pcmcia_request_configuration(link, &link->conf));
361 360
362 /* Ok, we have the configuration, prepare to register the netdev */ 361 /* Ok, we have the configuration, prepare to register the netdev */
363 dev->base_addr = link->io.BasePort1;
364 dev->irq = link->irq.AssignedIRQ;
365 card->node.major = card->node.minor = 0; 362 card->node.major = card->node.minor = 0;
366 363
367 /* Reset card */ 364 /* Reset card */
@@ -374,26 +371,19 @@ spectrum_cs_config(struct pcmcia_device *link)
374 goto failed; 371 goto failed;
375 } 372 }
376 373
377 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 374 /* Register an interface with the stack */
378 /* Tell the stack we exist */ 375 if (orinoco_if_add(priv, link->io.BasePort1,
379 if (register_netdev(dev) != 0) { 376 link->irq.AssignedIRQ) != 0) {
380 printk(KERN_ERR PFX "register_netdev() failed\n"); 377 printk(KERN_ERR PFX "orinoco_if_add() failed\n");
381 goto failed; 378 goto failed;
382 } 379 }
383 380
384 /* At this point, the dev_node_t structure(s) needs to be 381 /* At this point, the dev_node_t structure(s) needs to be
385 * initialized and arranged in a linked list at link->dev_node. */ 382 * initialized and arranged in a linked list at link->dev_node. */
386 strcpy(card->node.dev_name, dev->name); 383 strcpy(card->node.dev_name, priv->ndev->name);
387 link->dev_node = &card->node; /* link->dev_node being non-NULL is also 384 link->dev_node = &card->node; /* link->dev_node being non-NULL is also
388 * used to indicate that the 385 * used to indicate that the
389 * net_device has been registered */ 386 * net_device has been registered */
390
391 /* Finally, report what we've done */
392 printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io "
393 "0x%04x-0x%04x\n", dev->name, dev_name(dev->dev.parent),
394 link->irq.AssignedIRQ, link->io.BasePort1,
395 link->io.BasePort1 + link->io.NumPorts1 - 1);
396
397 return 0; 387 return 0;
398 388
399 cs_failed: 389 cs_failed: