isa-skeleton.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. /* isa-skeleton.c: A network driver outline for linux.
  2. *
  3. * Written 1993-94 by Donald Becker.
  4. *
  5. * Copyright 1993 United States Government as represented by the
  6. * Director, National Security Agency.
  7. *
  8. * This software may be used and distributed according to the terms
  9. * of the GNU General Public License, incorporated herein by reference.
  10. *
  11. * The author may be reached as becker@scyld.com, or C/O
  12. * Scyld Computing Corporation
  13. * 410 Severn Ave., Suite 210
  14. * Annapolis MD 21403
  15. *
  16. * This file is an outline for writing a network device driver for the
  17. * the Linux operating system.
  18. *
  19. * To write (or understand) a driver, have a look at the "loopback.c" file to
  20. * get a feel of what is going on, and then use the code below as a skeleton
  21. * for the new driver.
  22. *
  23. */
  24. static const char *version =
  25. "isa-skeleton.c:v1.51 9/24/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n";
  26. /*
  27. * Sources:
  28. * List your sources of programming information to document that
  29. * the driver is your own creation, and give due credit to others
  30. * that contributed to the work. Remember that GNU project code
  31. * cannot use proprietary or trade secret information. Interface
  32. * definitions are generally considered non-copyrightable to the
  33. * extent that the same names and structures must be used to be
  34. * compatible.
  35. *
  36. * Finally, keep in mind that the Linux kernel is has an API, not
  37. * ABI. Proprietary object-code-only distributions are not permitted
  38. * under the GPL.
  39. */
  40. #include <linux/module.h>
  41. #include <linux/kernel.h>
  42. #include <linux/types.h>
  43. #include <linux/fcntl.h>
  44. #include <linux/interrupt.h>
  45. #include <linux/ioport.h>
  46. #include <linux/in.h>
  47. #include <linux/slab.h>
  48. #include <linux/string.h>
  49. #include <linux/spinlock.h>
  50. #include <linux/errno.h>
  51. #include <linux/init.h>
  52. #include <linux/netdevice.h>
  53. #include <linux/etherdevice.h>
  54. #include <linux/skbuff.h>
  55. #include <linux/bitops.h>
  56. #include <asm/system.h>
  57. #include <asm/io.h>
  58. #include <asm/dma.h>
  59. /*
  60. * The name of the card. Is used for messages and in the requests for
  61. * io regions, irqs and dma channels
  62. */
  63. static const char* cardname = "netcard";
  64. /* First, a few definitions that the brave might change. */
  65. /* A zero-terminated list of I/O addresses to be probed. */
  66. static unsigned int netcard_portlist[] __initdata =
  67. { 0x200, 0x240, 0x280, 0x2C0, 0x300, 0x320, 0x340, 0};
  68. /* use 0 for production, 1 for verification, >2 for debug */
  69. #ifndef NET_DEBUG
  70. #define NET_DEBUG 2
  71. #endif
  72. static unsigned int net_debug = NET_DEBUG;
  73. /* The number of low I/O ports used by the ethercard. */
  74. #define NETCARD_IO_EXTENT 32
  75. #define MY_TX_TIMEOUT ((400*HZ)/1000)
  76. /* Information that need to be kept for each board. */
  77. struct net_local {
  78. struct net_device_stats stats;
  79. long open_time; /* Useless example local info. */
  80. /* Tx control lock. This protects the transmit buffer ring
  81. * state along with the "tx full" state of the driver. This
  82. * means all netif_queue flow control actions are protected
  83. * by this lock as well.
  84. */
  85. spinlock_t lock;
  86. };
  87. /* The station (ethernet) address prefix, used for IDing the board. */
  88. #define SA_ADDR0 0x00
  89. #define SA_ADDR1 0x42
  90. #define SA_ADDR2 0x65
  91. /* Index to functions, as function prototypes. */
  92. static int netcard_probe1(struct net_device *dev, int ioaddr);
  93. static int net_open(struct net_device *dev);
  94. static int net_send_packet(struct sk_buff *skb, struct net_device *dev);
  95. static irqreturn_t net_interrupt(int irq, void *dev_id, struct pt_regs *regs);
  96. static void net_rx(struct net_device *dev);
  97. static int net_close(struct net_device *dev);
  98. static struct net_device_stats *net_get_stats(struct net_device *dev);
  99. static void set_multicast_list(struct net_device *dev);
  100. static void net_tx_timeout(struct net_device *dev);
  101. /* Example routines you must write ;->. */
  102. #define tx_done(dev) 1
  103. static void hardware_send_packet(short ioaddr, char *buf, int length);
  104. static void chipset_init(struct net_device *dev, int startp);
  105. /*
  106. * Check for a network adaptor of this type, and return '0' iff one exists.
  107. * If dev->base_addr == 0, probe all likely locations.
  108. * If dev->base_addr == 1, always return failure.
  109. * If dev->base_addr == 2, allocate space for the device and return success
  110. * (detachable devices only).
  111. */
  112. static int __init do_netcard_probe(struct net_device *dev)
  113. {
  114. int i;
  115. int base_addr = dev->base_addr;
  116. int irq = dev->irq;
  117. SET_MODULE_OWNER(dev);
  118. if (base_addr > 0x1ff) /* Check a single specified location. */
  119. return netcard_probe1(dev, base_addr);
  120. else if (base_addr != 0) /* Don't probe at all. */
  121. return -ENXIO;
  122. for (i = 0; netcard_portlist[i]; i++) {
  123. int ioaddr = netcard_portlist[i];
  124. if (netcard_probe1(dev, ioaddr) == 0)
  125. return 0;
  126. dev->irq = irq;
  127. }
  128. return -ENODEV;
  129. }
  130. static void cleanup_card(struct net_device *dev)
  131. {
  132. #ifdef jumpered_dma
  133. free_dma(dev->dma);
  134. #endif
  135. #ifdef jumpered_interrupts
  136. free_irq(dev->irq, dev);
  137. #endif
  138. release_region(dev->base_addr, NETCARD_IO_EXTENT);
  139. }
  140. #ifndef MODULE
  141. struct net_device * __init netcard_probe(int unit)
  142. {
  143. struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
  144. int err;
  145. if (!dev)
  146. return ERR_PTR(-ENOMEM);
  147. sprintf(dev->name, "eth%d", unit);
  148. netdev_boot_setup_check(dev);
  149. err = do_netcard_probe(dev);
  150. if (err)
  151. goto out;
  152. err = register_netdev(dev);
  153. if (err)
  154. goto out1;
  155. return dev;
  156. out1:
  157. cleanup_card(dev);
  158. out:
  159. free_netdev(dev);
  160. return ERR_PTR(err);
  161. }
  162. #endif
  163. /*
  164. * This is the real probe routine. Linux has a history of friendly device
  165. * probes on the ISA bus. A good device probes avoids doing writes, and
  166. * verifies that the correct device exists and functions.
  167. */
  168. static int __init netcard_probe1(struct net_device *dev, int ioaddr)
  169. {
  170. struct net_local *np;
  171. static unsigned version_printed;
  172. int i;
  173. int err = -ENODEV;
  174. /* Grab the region so that no one else tries to probe our ioports. */
  175. if (!request_region(ioaddr, NETCARD_IO_EXTENT, cardname))
  176. return -EBUSY;
  177. /*
  178. * For ethernet adaptors the first three octets of the station address
  179. * contains the manufacturer's unique code. That might be a good probe
  180. * method. Ideally you would add additional checks.
  181. */
  182. if (inb(ioaddr + 0) != SA_ADDR0
  183. || inb(ioaddr + 1) != SA_ADDR1
  184. || inb(ioaddr + 2) != SA_ADDR2)
  185. goto out;
  186. if (net_debug && version_printed++ == 0)
  187. printk(KERN_DEBUG "%s", version);
  188. printk(KERN_INFO "%s: %s found at %#3x, ", dev->name, cardname, ioaddr);
  189. /* Fill in the 'dev' fields. */
  190. dev->base_addr = ioaddr;
  191. /* Retrieve and print the ethernet address. */
  192. for (i = 0; i < 6; i++)
  193. printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i));
  194. err = -EAGAIN;
  195. #ifdef jumpered_interrupts
  196. /*
  197. * If this board has jumpered interrupts, allocate the interrupt
  198. * vector now. There is no point in waiting since no other device
  199. * can use the interrupt, and this marks the irq as busy. Jumpered
  200. * interrupts are typically not reported by the boards, and we must
  201. * used autoIRQ to find them.
  202. */
  203. if (dev->irq == -1)
  204. ; /* Do nothing: a user-level program will set it. */
  205. else if (dev->irq < 2) { /* "Auto-IRQ" */
  206. unsigned long irq_mask = probe_irq_on();
  207. /* Trigger an interrupt here. */
  208. dev->irq = probe_irq_off(irq_mask);
  209. if (net_debug >= 2)
  210. printk(" autoirq is %d", dev->irq);
  211. } else if (dev->irq == 2)
  212. /*
  213. * Fixup for users that don't know that IRQ 2 is really
  214. * IRQ9, or don't know which one to set.
  215. */
  216. dev->irq = 9;
  217. {
  218. int irqval = request_irq(dev->irq, &net_interrupt, 0, cardname, dev);
  219. if (irqval) {
  220. printk("%s: unable to get IRQ %d (irqval=%d).\n",
  221. dev->name, dev->irq, irqval);
  222. goto out;
  223. }
  224. }
  225. #endif /* jumpered interrupt */
  226. #ifdef jumpered_dma
  227. /*
  228. * If we use a jumpered DMA channel, that should be probed for and
  229. * allocated here as well. See lance.c for an example.
  230. */
  231. if (dev->dma == 0) {
  232. if (request_dma(dev->dma, cardname)) {
  233. printk("DMA %d allocation failed.\n", dev->dma);
  234. goto out1;
  235. } else
  236. printk(", assigned DMA %d.\n", dev->dma);
  237. } else {
  238. short dma_status, new_dma_status;
  239. /* Read the DMA channel status registers. */
  240. dma_status = ((inb(DMA1_STAT_REG) >> 4) & 0x0f) |
  241. (inb(DMA2_STAT_REG) & 0xf0);
  242. /* Trigger a DMA request, perhaps pause a bit. */
  243. outw(0x1234, ioaddr + 8);
  244. /* Re-read the DMA status registers. */
  245. new_dma_status = ((inb(DMA1_STAT_REG) >> 4) & 0x0f) |
  246. (inb(DMA2_STAT_REG) & 0xf0);
  247. /*
  248. * Eliminate the old and floating requests,
  249. * and DMA4 the cascade.
  250. */
  251. new_dma_status ^= dma_status;
  252. new_dma_status &= ~0x10;
  253. for (i = 7; i > 0; i--)
  254. if (test_bit(i, &new_dma_status)) {
  255. dev->dma = i;
  256. break;
  257. }
  258. if (i <= 0) {
  259. printk("DMA probe failed.\n");
  260. goto out1;
  261. }
  262. if (request_dma(dev->dma, cardname)) {
  263. printk("probed DMA %d allocation failed.\n", dev->dma);
  264. goto out1;
  265. }
  266. }
  267. #endif /* jumpered DMA */
  268. np = netdev_priv(dev);
  269. spin_lock_init(&np->lock);
  270. dev->open = net_open;
  271. dev->stop = net_close;
  272. dev->hard_start_xmit = net_send_packet;
  273. dev->get_stats = net_get_stats;
  274. dev->set_multicast_list = &set_multicast_list;
  275. dev->tx_timeout = &net_tx_timeout;
  276. dev->watchdog_timeo = MY_TX_TIMEOUT;
  277. return 0;
  278. out1:
  279. #ifdef jumpered_interrupts
  280. free_irq(dev->irq, dev);
  281. #endif
  282. out:
  283. release_region(base_addr, NETCARD_IO_EXTENT);
  284. return err;
  285. }
  286. static void net_tx_timeout(struct net_device *dev)
  287. {
  288. struct net_local *np = netdev_priv(dev);
  289. printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name,
  290. tx_done(dev) ? "IRQ conflict" : "network cable problem");
  291. /* Try to restart the adaptor. */
  292. chipset_init(dev, 1);
  293. np->stats.tx_errors++;
  294. /* If we have space available to accept new transmit
  295. * requests, wake up the queueing layer. This would
  296. * be the case if the chipset_init() call above just
  297. * flushes out the tx queue and empties it.
  298. *
  299. * If instead, the tx queue is retained then the
  300. * netif_wake_queue() call should be placed in the
  301. * TX completion interrupt handler of the driver instead
  302. * of here.
  303. */
  304. if (!tx_full(dev))
  305. netif_wake_queue(dev);
  306. }
  307. /*
  308. * Open/initialize the board. This is called (in the current kernel)
  309. * sometime after booting when the 'ifconfig' program is run.
  310. *
  311. * This routine should set everything up anew at each open, even
  312. * registers that "should" only need to be set once at boot, so that
  313. * there is non-reboot way to recover if something goes wrong.
  314. */
  315. static int
  316. net_open(struct net_device *dev)
  317. {
  318. struct net_local *np = netdev_priv(dev);
  319. int ioaddr = dev->base_addr;
  320. /*
  321. * This is used if the interrupt line can turned off (shared).
  322. * See 3c503.c for an example of selecting the IRQ at config-time.
  323. */
  324. if (request_irq(dev->irq, &net_interrupt, 0, cardname, dev)) {
  325. return -EAGAIN;
  326. }
  327. /*
  328. * Always allocate the DMA channel after the IRQ,
  329. * and clean up on failure.
  330. */
  331. if (request_dma(dev->dma, cardname)) {
  332. free_irq(dev->irq, dev);
  333. return -EAGAIN;
  334. }
  335. /* Reset the hardware here. Don't forget to set the station address. */
  336. chipset_init(dev, 1);
  337. outb(0x00, ioaddr);
  338. np->open_time = jiffies;
  339. /* We are now ready to accept transmit requeusts from
  340. * the queueing layer of the networking.
  341. */
  342. netif_start_queue(dev);
  343. return 0;
  344. }
  345. /* This will only be invoked if your driver is _not_ in XOFF state.
  346. * What this means is that you need not check it, and that this
  347. * invariant will hold if you make sure that the netif_*_queue()
  348. * calls are done at the proper times.
  349. */
  350. static int net_send_packet(struct sk_buff *skb, struct net_device *dev)
  351. {
  352. struct net_local *np = netdev_priv(dev);
  353. int ioaddr = dev->base_addr;
  354. short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
  355. unsigned char *buf = skb->data;
  356. /* If some error occurs while trying to transmit this
  357. * packet, you should return '1' from this function.
  358. * In such a case you _may not_ do anything to the
  359. * SKB, it is still owned by the network queueing
  360. * layer when an error is returned. This means you
  361. * may not modify any SKB fields, you may not free
  362. * the SKB, etc.
  363. */
  364. #if TX_RING
  365. /* This is the most common case for modern hardware.
  366. * The spinlock protects this code from the TX complete
  367. * hardware interrupt handler. Queue flow control is
  368. * thus managed under this lock as well.
  369. */
  370. spin_lock_irq(&np->lock);
  371. add_to_tx_ring(np, skb, length);
  372. dev->trans_start = jiffies;
  373. /* If we just used up the very last entry in the
  374. * TX ring on this device, tell the queueing
  375. * layer to send no more.
  376. */
  377. if (tx_full(dev))
  378. netif_stop_queue(dev);
  379. /* When the TX completion hw interrupt arrives, this
  380. * is when the transmit statistics are updated.
  381. */
  382. spin_unlock_irq(&np->lock);
  383. #else
  384. /* This is the case for older hardware which takes
  385. * a single transmit buffer at a time, and it is
  386. * just written to the device via PIO.
  387. *
  388. * No spin locking is needed since there is no TX complete
  389. * event. If by chance your card does have a TX complete
  390. * hardware IRQ then you may need to utilize np->lock here.
  391. */
  392. hardware_send_packet(ioaddr, buf, length);
  393. np->stats.tx_bytes += skb->len;
  394. dev->trans_start = jiffies;
  395. /* You might need to clean up and record Tx statistics here. */
  396. if (inw(ioaddr) == /*RU*/81)
  397. np->stats.tx_aborted_errors++;
  398. dev_kfree_skb (skb);
  399. #endif
  400. return 0;
  401. }
  402. #if TX_RING
  403. /* This handles TX complete events posted by the device
  404. * via interrupts.
  405. */
  406. void net_tx(struct net_device *dev)
  407. {
  408. struct net_local *np = netdev_priv(dev);
  409. int entry;
  410. /* This protects us from concurrent execution of
  411. * our dev->hard_start_xmit function above.
  412. */
  413. spin_lock(&np->lock);
  414. entry = np->tx_old;
  415. while (tx_entry_is_sent(np, entry)) {
  416. struct sk_buff *skb = np->skbs[entry];
  417. np->stats.tx_bytes += skb->len;
  418. dev_kfree_skb_irq (skb);
  419. entry = next_tx_entry(np, entry);
  420. }
  421. np->tx_old = entry;
  422. /* If we had stopped the queue due to a "tx full"
  423. * condition, and space has now been made available,
  424. * wake up the queue.
  425. */
  426. if (netif_queue_stopped(dev) && ! tx_full(dev))
  427. netif_wake_queue(dev);
  428. spin_unlock(&np->lock);
  429. }
  430. #endif
  431. /*
  432. * The typical workload of the driver:
  433. * Handle the network interface interrupts.
  434. */
  435. static irqreturn_t net_interrupt(int irq, void *dev_id, struct pt_regs * regs)
  436. {
  437. struct net_device *dev = dev_id;
  438. struct net_local *np;
  439. int ioaddr, status;
  440. int handled = 0;
  441. ioaddr = dev->base_addr;
  442. np = netdev_priv(dev);
  443. status = inw(ioaddr + 0);
  444. if (status == 0)
  445. goto out;
  446. handled = 1;
  447. if (status & RX_INTR) {
  448. /* Got a packet(s). */
  449. net_rx(dev);
  450. }
  451. #if TX_RING
  452. if (status & TX_INTR) {
  453. /* Transmit complete. */
  454. net_tx(dev);
  455. np->stats.tx_packets++;
  456. netif_wake_queue(dev);
  457. }
  458. #endif
  459. if (status & COUNTERS_INTR) {
  460. /* Increment the appropriate 'localstats' field. */
  461. np->stats.tx_window_errors++;
  462. }
  463. out:
  464. return IRQ_RETVAL(handled);
  465. }
  466. /* We have a good packet(s), get it/them out of the buffers. */
  467. static void
  468. net_rx(struct net_device *dev)
  469. {
  470. struct net_local *lp = netdev_priv(dev);
  471. int ioaddr = dev->base_addr;
  472. int boguscount = 10;
  473. do {
  474. int status = inw(ioaddr);
  475. int pkt_len = inw(ioaddr);
  476. if (pkt_len == 0) /* Read all the frames? */
  477. break; /* Done for now */
  478. if (status & 0x40) { /* There was an error. */
  479. lp->stats.rx_errors++;
  480. if (status & 0x20) lp->stats.rx_frame_errors++;
  481. if (status & 0x10) lp->stats.rx_over_errors++;
  482. if (status & 0x08) lp->stats.rx_crc_errors++;
  483. if (status & 0x04) lp->stats.rx_fifo_errors++;
  484. } else {
  485. /* Malloc up new buffer. */
  486. struct sk_buff *skb;
  487. lp->stats.rx_bytes+=pkt_len;
  488. skb = dev_alloc_skb(pkt_len);
  489. if (skb == NULL) {
  490. printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n",
  491. dev->name);
  492. lp->stats.rx_dropped++;
  493. break;
  494. }
  495. skb->dev = dev;
  496. /* 'skb->data' points to the start of sk_buff data area. */
  497. memcpy(skb_put(skb,pkt_len), (void*)dev->rmem_start,
  498. pkt_len);
  499. /* or */
  500. insw(ioaddr, skb->data, (pkt_len + 1) >> 1);
  501. netif_rx(skb);
  502. dev->last_rx = jiffies;
  503. lp->stats.rx_packets++;
  504. lp->stats.rx_bytes += pkt_len;
  505. }
  506. } while (--boguscount);
  507. return;
  508. }
  509. /* The inverse routine to net_open(). */
  510. static int
  511. net_close(struct net_device *dev)
  512. {
  513. struct net_local *lp = netdev_priv(dev);
  514. int ioaddr = dev->base_addr;
  515. lp->open_time = 0;
  516. netif_stop_queue(dev);
  517. /* Flush the Tx and disable Rx here. */
  518. disable_dma(dev->dma);
  519. /* If not IRQ or DMA jumpered, free up the line. */
  520. outw(0x00, ioaddr+0); /* Release the physical interrupt line. */
  521. free_irq(dev->irq, dev);
  522. free_dma(dev->dma);
  523. /* Update the statistics here. */
  524. return 0;
  525. }
  526. /*
  527. * Get the current statistics.
  528. * This may be called with the card open or closed.
  529. */
  530. static struct net_device_stats *net_get_stats(struct net_device *dev)
  531. {
  532. struct net_local *lp = netdev_priv(dev);
  533. short ioaddr = dev->base_addr;
  534. /* Update the statistics from the device registers. */
  535. lp->stats.rx_missed_errors = inw(ioaddr+1);
  536. return &lp->stats;
  537. }
  538. /*
  539. * Set or clear the multicast filter for this adaptor.
  540. * num_addrs == -1 Promiscuous mode, receive all packets
  541. * num_addrs == 0 Normal mode, clear multicast list
  542. * num_addrs > 0 Multicast mode, receive normal and MC packets,
  543. * and do best-effort filtering.
  544. */
  545. static void
  546. set_multicast_list(struct net_device *dev)
  547. {
  548. short ioaddr = dev->base_addr;
  549. if (dev->flags&IFF_PROMISC)
  550. {
  551. /* Enable promiscuous mode */
  552. outw(MULTICAST|PROMISC, ioaddr);
  553. }
  554. else if((dev->flags&IFF_ALLMULTI) || dev->mc_count > HW_MAX_ADDRS)
  555. {
  556. /* Disable promiscuous mode, use normal mode. */
  557. hardware_set_filter(NULL);
  558. outw(MULTICAST, ioaddr);
  559. }
  560. else if(dev->mc_count)
  561. {
  562. /* Walk the address list, and load the filter */
  563. hardware_set_filter(dev->mc_list);
  564. outw(MULTICAST, ioaddr);
  565. }
  566. else
  567. outw(0, ioaddr);
  568. }
  569. #ifdef MODULE
  570. static struct net_device *this_device;
  571. static int io = 0x300;
  572. static int irq;
  573. static int dma;
  574. static int mem;
  575. MODULE_LICENSE("GPL");
  576. int init_module(void)
  577. {
  578. struct net_device *dev;
  579. int result;
  580. if (io == 0)
  581. printk(KERN_WARNING "%s: You shouldn't use auto-probing with insmod!\n",
  582. cardname);
  583. dev = alloc_etherdev(sizeof(struct net_local));
  584. if (!dev)
  585. return -ENOMEM;
  586. /* Copy the parameters from insmod into the device structure. */
  587. dev->base_addr = io;
  588. dev->irq = irq;
  589. dev->dma = dma;
  590. dev->mem_start = mem;
  591. if (do_netcard_probe(dev) == 0) {
  592. if (register_netdev(dev) == 0)
  593. this_device = dev;
  594. return 0;
  595. }
  596. cleanup_card(dev);
  597. }
  598. free_netdev(dev);
  599. return -ENXIO;
  600. }
  601. void
  602. cleanup_module(void)
  603. {
  604. unregister_netdev(this_device);
  605. cleanup_card(this_device);
  606. free_netdev(this_device);
  607. }
  608. #endif /* MODULE */
  609. /*
  610. * Local variables:
  611. * compile-command:
  612. * gcc -D__KERNEL__ -Wall -Wstrict-prototypes -Wwrite-strings
  613. * -Wredundant-decls -O2 -m486 -c skeleton.c
  614. * version-control: t
  615. * kept-new-versions: 5
  616. * tab-width: 4
  617. * c-indent-level: 4
  618. * End:
  619. */