isa-skeleton.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  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);
  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. if (base_addr > 0x1ff) /* Check a single specified location. */
  118. return netcard_probe1(dev, base_addr);
  119. else if (base_addr != 0) /* Don't probe at all. */
  120. return -ENXIO;
  121. for (i = 0; netcard_portlist[i]; i++) {
  122. int ioaddr = netcard_portlist[i];
  123. if (netcard_probe1(dev, ioaddr) == 0)
  124. return 0;
  125. dev->irq = irq;
  126. }
  127. return -ENODEV;
  128. }
  129. static void cleanup_card(struct net_device *dev)
  130. {
  131. #ifdef jumpered_dma
  132. free_dma(dev->dma);
  133. #endif
  134. #ifdef jumpered_interrupts
  135. free_irq(dev->irq, dev);
  136. #endif
  137. release_region(dev->base_addr, NETCARD_IO_EXTENT);
  138. }
  139. #ifndef MODULE
  140. struct net_device * __init netcard_probe(int unit)
  141. {
  142. struct net_device *dev = alloc_etherdev(sizeof(struct net_local));
  143. int err;
  144. if (!dev)
  145. return ERR_PTR(-ENOMEM);
  146. sprintf(dev->name, "eth%d", unit);
  147. netdev_boot_setup_check(dev);
  148. err = do_netcard_probe(dev);
  149. if (err)
  150. goto out;
  151. return dev;
  152. out:
  153. free_netdev(dev);
  154. return ERR_PTR(err);
  155. }
  156. #endif
  157. /*
  158. * This is the real probe routine. Linux has a history of friendly device
  159. * probes on the ISA bus. A good device probes avoids doing writes, and
  160. * verifies that the correct device exists and functions.
  161. */
  162. static int __init netcard_probe1(struct net_device *dev, int ioaddr)
  163. {
  164. struct net_local *np;
  165. static unsigned version_printed;
  166. int i;
  167. int err = -ENODEV;
  168. DECLARE_MAC_BUF(mac);
  169. /* Grab the region so that no one else tries to probe our ioports. */
  170. if (!request_region(ioaddr, NETCARD_IO_EXTENT, cardname))
  171. return -EBUSY;
  172. /*
  173. * For ethernet adaptors the first three octets of the station address
  174. * contains the manufacturer's unique code. That might be a good probe
  175. * method. Ideally you would add additional checks.
  176. */
  177. if (inb(ioaddr + 0) != SA_ADDR0
  178. || inb(ioaddr + 1) != SA_ADDR1
  179. || inb(ioaddr + 2) != SA_ADDR2)
  180. goto out;
  181. if (net_debug && version_printed++ == 0)
  182. printk(KERN_DEBUG "%s", version);
  183. printk(KERN_INFO "%s: %s found at %#3x, ", dev->name, cardname, ioaddr);
  184. /* Fill in the 'dev' fields. */
  185. dev->base_addr = ioaddr;
  186. /* Retrieve and print the ethernet address. */
  187. for (i = 0; i < 6; i++)
  188. dev->dev_addr[i] = inb(ioaddr + i);
  189. printk("%s", print_mac(mac, dev->dev_addr));
  190. err = -EAGAIN;
  191. #ifdef jumpered_interrupts
  192. /*
  193. * If this board has jumpered interrupts, allocate the interrupt
  194. * vector now. There is no point in waiting since no other device
  195. * can use the interrupt, and this marks the irq as busy. Jumpered
  196. * interrupts are typically not reported by the boards, and we must
  197. * used autoIRQ to find them.
  198. */
  199. if (dev->irq == -1)
  200. ; /* Do nothing: a user-level program will set it. */
  201. else if (dev->irq < 2) { /* "Auto-IRQ" */
  202. unsigned long irq_mask = probe_irq_on();
  203. /* Trigger an interrupt here. */
  204. dev->irq = probe_irq_off(irq_mask);
  205. if (net_debug >= 2)
  206. printk(" autoirq is %d", dev->irq);
  207. } else if (dev->irq == 2)
  208. /*
  209. * Fixup for users that don't know that IRQ 2 is really
  210. * IRQ9, or don't know which one to set.
  211. */
  212. dev->irq = 9;
  213. {
  214. int irqval = request_irq(dev->irq, &net_interrupt, 0, cardname, dev);
  215. if (irqval) {
  216. printk("%s: unable to get IRQ %d (irqval=%d).\n",
  217. dev->name, dev->irq, irqval);
  218. goto out;
  219. }
  220. }
  221. #endif /* jumpered interrupt */
  222. #ifdef jumpered_dma
  223. /*
  224. * If we use a jumpered DMA channel, that should be probed for and
  225. * allocated here as well. See lance.c for an example.
  226. */
  227. if (dev->dma == 0) {
  228. if (request_dma(dev->dma, cardname)) {
  229. printk("DMA %d allocation failed.\n", dev->dma);
  230. goto out1;
  231. } else
  232. printk(", assigned DMA %d.\n", dev->dma);
  233. } else {
  234. short dma_status, new_dma_status;
  235. /* Read the DMA channel status registers. */
  236. dma_status = ((inb(DMA1_STAT_REG) >> 4) & 0x0f) |
  237. (inb(DMA2_STAT_REG) & 0xf0);
  238. /* Trigger a DMA request, perhaps pause a bit. */
  239. outw(0x1234, ioaddr + 8);
  240. /* Re-read the DMA status registers. */
  241. new_dma_status = ((inb(DMA1_STAT_REG) >> 4) & 0x0f) |
  242. (inb(DMA2_STAT_REG) & 0xf0);
  243. /*
  244. * Eliminate the old and floating requests,
  245. * and DMA4 the cascade.
  246. */
  247. new_dma_status ^= dma_status;
  248. new_dma_status &= ~0x10;
  249. for (i = 7; i > 0; i--)
  250. if (test_bit(i, &new_dma_status)) {
  251. dev->dma = i;
  252. break;
  253. }
  254. if (i <= 0) {
  255. printk("DMA probe failed.\n");
  256. goto out1;
  257. }
  258. if (request_dma(dev->dma, cardname)) {
  259. printk("probed DMA %d allocation failed.\n", dev->dma);
  260. goto out1;
  261. }
  262. }
  263. #endif /* jumpered DMA */
  264. np = netdev_priv(dev);
  265. spin_lock_init(&np->lock);
  266. dev->open = net_open;
  267. dev->stop = net_close;
  268. dev->hard_start_xmit = net_send_packet;
  269. dev->get_stats = net_get_stats;
  270. dev->set_multicast_list = &set_multicast_list;
  271. dev->tx_timeout = &net_tx_timeout;
  272. dev->watchdog_timeo = MY_TX_TIMEOUT;
  273. err = register_netdev(dev);
  274. if (err)
  275. goto out2;
  276. return 0;
  277. out2:
  278. #ifdef jumpered_dma
  279. free_dma(dev->dma);
  280. #endif
  281. out1:
  282. #ifdef jumpered_interrupts
  283. free_irq(dev->irq, dev);
  284. #endif
  285. out:
  286. release_region(base_addr, NETCARD_IO_EXTENT);
  287. return err;
  288. }
  289. static void net_tx_timeout(struct net_device *dev)
  290. {
  291. struct net_local *np = netdev_priv(dev);
  292. printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name,
  293. tx_done(dev) ? "IRQ conflict" : "network cable problem");
  294. /* Try to restart the adaptor. */
  295. chipset_init(dev, 1);
  296. np->stats.tx_errors++;
  297. /* If we have space available to accept new transmit
  298. * requests, wake up the queueing layer. This would
  299. * be the case if the chipset_init() call above just
  300. * flushes out the tx queue and empties it.
  301. *
  302. * If instead, the tx queue is retained then the
  303. * netif_wake_queue() call should be placed in the
  304. * TX completion interrupt handler of the driver instead
  305. * of here.
  306. */
  307. if (!tx_full(dev))
  308. netif_wake_queue(dev);
  309. }
  310. /*
  311. * Open/initialize the board. This is called (in the current kernel)
  312. * sometime after booting when the 'ifconfig' program is run.
  313. *
  314. * This routine should set everything up anew at each open, even
  315. * registers that "should" only need to be set once at boot, so that
  316. * there is non-reboot way to recover if something goes wrong.
  317. */
  318. static int
  319. net_open(struct net_device *dev)
  320. {
  321. struct net_local *np = netdev_priv(dev);
  322. int ioaddr = dev->base_addr;
  323. /*
  324. * This is used if the interrupt line can turned off (shared).
  325. * See 3c503.c for an example of selecting the IRQ at config-time.
  326. */
  327. if (request_irq(dev->irq, &net_interrupt, 0, cardname, dev)) {
  328. return -EAGAIN;
  329. }
  330. /*
  331. * Always allocate the DMA channel after the IRQ,
  332. * and clean up on failure.
  333. */
  334. if (request_dma(dev->dma, cardname)) {
  335. free_irq(dev->irq, dev);
  336. return -EAGAIN;
  337. }
  338. /* Reset the hardware here. Don't forget to set the station address. */
  339. chipset_init(dev, 1);
  340. outb(0x00, ioaddr);
  341. np->open_time = jiffies;
  342. /* We are now ready to accept transmit requeusts from
  343. * the queueing layer of the networking.
  344. */
  345. netif_start_queue(dev);
  346. return 0;
  347. }
  348. /* This will only be invoked if your driver is _not_ in XOFF state.
  349. * What this means is that you need not check it, and that this
  350. * invariant will hold if you make sure that the netif_*_queue()
  351. * calls are done at the proper times.
  352. */
  353. static int net_send_packet(struct sk_buff *skb, struct net_device *dev)
  354. {
  355. struct net_local *np = netdev_priv(dev);
  356. int ioaddr = dev->base_addr;
  357. short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
  358. unsigned char *buf = skb->data;
  359. /* If some error occurs while trying to transmit this
  360. * packet, you should return '1' from this function.
  361. * In such a case you _may not_ do anything to the
  362. * SKB, it is still owned by the network queueing
  363. * layer when an error is returned. This means you
  364. * may not modify any SKB fields, you may not free
  365. * the SKB, etc.
  366. */
  367. #if TX_RING
  368. /* This is the most common case for modern hardware.
  369. * The spinlock protects this code from the TX complete
  370. * hardware interrupt handler. Queue flow control is
  371. * thus managed under this lock as well.
  372. */
  373. spin_lock_irq(&np->lock);
  374. add_to_tx_ring(np, skb, length);
  375. dev->trans_start = jiffies;
  376. /* If we just used up the very last entry in the
  377. * TX ring on this device, tell the queueing
  378. * layer to send no more.
  379. */
  380. if (tx_full(dev))
  381. netif_stop_queue(dev);
  382. /* When the TX completion hw interrupt arrives, this
  383. * is when the transmit statistics are updated.
  384. */
  385. spin_unlock_irq(&np->lock);
  386. #else
  387. /* This is the case for older hardware which takes
  388. * a single transmit buffer at a time, and it is
  389. * just written to the device via PIO.
  390. *
  391. * No spin locking is needed since there is no TX complete
  392. * event. If by chance your card does have a TX complete
  393. * hardware IRQ then you may need to utilize np->lock here.
  394. */
  395. hardware_send_packet(ioaddr, buf, length);
  396. np->stats.tx_bytes += skb->len;
  397. dev->trans_start = jiffies;
  398. /* You might need to clean up and record Tx statistics here. */
  399. if (inw(ioaddr) == /*RU*/81)
  400. np->stats.tx_aborted_errors++;
  401. dev_kfree_skb (skb);
  402. #endif
  403. return 0;
  404. }
  405. #if TX_RING
  406. /* This handles TX complete events posted by the device
  407. * via interrupts.
  408. */
  409. void net_tx(struct net_device *dev)
  410. {
  411. struct net_local *np = netdev_priv(dev);
  412. int entry;
  413. /* This protects us from concurrent execution of
  414. * our dev->hard_start_xmit function above.
  415. */
  416. spin_lock(&np->lock);
  417. entry = np->tx_old;
  418. while (tx_entry_is_sent(np, entry)) {
  419. struct sk_buff *skb = np->skbs[entry];
  420. np->stats.tx_bytes += skb->len;
  421. dev_kfree_skb_irq (skb);
  422. entry = next_tx_entry(np, entry);
  423. }
  424. np->tx_old = entry;
  425. /* If we had stopped the queue due to a "tx full"
  426. * condition, and space has now been made available,
  427. * wake up the queue.
  428. */
  429. if (netif_queue_stopped(dev) && ! tx_full(dev))
  430. netif_wake_queue(dev);
  431. spin_unlock(&np->lock);
  432. }
  433. #endif
  434. /*
  435. * The typical workload of the driver:
  436. * Handle the network interface interrupts.
  437. */
  438. static irqreturn_t net_interrupt(int irq, void *dev_id)
  439. {
  440. struct net_device *dev = dev_id;
  441. struct net_local *np;
  442. int ioaddr, status;
  443. int handled = 0;
  444. ioaddr = dev->base_addr;
  445. np = netdev_priv(dev);
  446. status = inw(ioaddr + 0);
  447. if (status == 0)
  448. goto out;
  449. handled = 1;
  450. if (status & RX_INTR) {
  451. /* Got a packet(s). */
  452. net_rx(dev);
  453. }
  454. #if TX_RING
  455. if (status & TX_INTR) {
  456. /* Transmit complete. */
  457. net_tx(dev);
  458. np->stats.tx_packets++;
  459. netif_wake_queue(dev);
  460. }
  461. #endif
  462. if (status & COUNTERS_INTR) {
  463. /* Increment the appropriate 'localstats' field. */
  464. np->stats.tx_window_errors++;
  465. }
  466. out:
  467. return IRQ_RETVAL(handled);
  468. }
  469. /* We have a good packet(s), get it/them out of the buffers. */
  470. static void
  471. net_rx(struct net_device *dev)
  472. {
  473. struct net_local *lp = netdev_priv(dev);
  474. int ioaddr = dev->base_addr;
  475. int boguscount = 10;
  476. do {
  477. int status = inw(ioaddr);
  478. int pkt_len = inw(ioaddr);
  479. if (pkt_len == 0) /* Read all the frames? */
  480. break; /* Done for now */
  481. if (status & 0x40) { /* There was an error. */
  482. lp->stats.rx_errors++;
  483. if (status & 0x20) lp->stats.rx_frame_errors++;
  484. if (status & 0x10) lp->stats.rx_over_errors++;
  485. if (status & 0x08) lp->stats.rx_crc_errors++;
  486. if (status & 0x04) lp->stats.rx_fifo_errors++;
  487. } else {
  488. /* Malloc up new buffer. */
  489. struct sk_buff *skb;
  490. lp->stats.rx_bytes+=pkt_len;
  491. skb = dev_alloc_skb(pkt_len);
  492. if (skb == NULL) {
  493. printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n",
  494. dev->name);
  495. lp->stats.rx_dropped++;
  496. break;
  497. }
  498. skb->dev = dev;
  499. /* 'skb->data' points to the start of sk_buff data area. */
  500. memcpy(skb_put(skb,pkt_len), (void*)dev->rmem_start,
  501. pkt_len);
  502. /* or */
  503. insw(ioaddr, skb->data, (pkt_len + 1) >> 1);
  504. netif_rx(skb);
  505. dev->last_rx = jiffies;
  506. lp->stats.rx_packets++;
  507. lp->stats.rx_bytes += pkt_len;
  508. }
  509. } while (--boguscount);
  510. return;
  511. }
  512. /* The inverse routine to net_open(). */
  513. static int
  514. net_close(struct net_device *dev)
  515. {
  516. struct net_local *lp = netdev_priv(dev);
  517. int ioaddr = dev->base_addr;
  518. lp->open_time = 0;
  519. netif_stop_queue(dev);
  520. /* Flush the Tx and disable Rx here. */
  521. disable_dma(dev->dma);
  522. /* If not IRQ or DMA jumpered, free up the line. */
  523. outw(0x00, ioaddr+0); /* Release the physical interrupt line. */
  524. free_irq(dev->irq, dev);
  525. free_dma(dev->dma);
  526. /* Update the statistics here. */
  527. return 0;
  528. }
  529. /*
  530. * Get the current statistics.
  531. * This may be called with the card open or closed.
  532. */
  533. static struct net_device_stats *net_get_stats(struct net_device *dev)
  534. {
  535. struct net_local *lp = netdev_priv(dev);
  536. short ioaddr = dev->base_addr;
  537. /* Update the statistics from the device registers. */
  538. lp->stats.rx_missed_errors = inw(ioaddr+1);
  539. return &lp->stats;
  540. }
  541. /*
  542. * Set or clear the multicast filter for this adaptor.
  543. * num_addrs == -1 Promiscuous mode, receive all packets
  544. * num_addrs == 0 Normal mode, clear multicast list
  545. * num_addrs > 0 Multicast mode, receive normal and MC packets,
  546. * and do best-effort filtering.
  547. */
  548. static void
  549. set_multicast_list(struct net_device *dev)
  550. {
  551. short ioaddr = dev->base_addr;
  552. if (dev->flags&IFF_PROMISC)
  553. {
  554. /* Enable promiscuous mode */
  555. outw(MULTICAST|PROMISC, ioaddr);
  556. }
  557. else if((dev->flags&IFF_ALLMULTI) || dev->mc_count > HW_MAX_ADDRS)
  558. {
  559. /* Disable promiscuous mode, use normal mode. */
  560. hardware_set_filter(NULL);
  561. outw(MULTICAST, ioaddr);
  562. }
  563. else if(dev->mc_count)
  564. {
  565. /* Walk the address list, and load the filter */
  566. hardware_set_filter(dev->mc_list);
  567. outw(MULTICAST, ioaddr);
  568. }
  569. else
  570. outw(0, ioaddr);
  571. }
  572. #ifdef MODULE
  573. static struct net_device *this_device;
  574. static int io = 0x300;
  575. static int irq;
  576. static int dma;
  577. static int mem;
  578. MODULE_LICENSE("GPL");
  579. int init_module(void)
  580. {
  581. struct net_device *dev;
  582. int result;
  583. if (io == 0)
  584. printk(KERN_WARNING "%s: You shouldn't use auto-probing with insmod!\n",
  585. cardname);
  586. dev = alloc_etherdev(sizeof(struct net_local));
  587. if (!dev)
  588. return -ENOMEM;
  589. /* Copy the parameters from insmod into the device structure. */
  590. dev->base_addr = io;
  591. dev->irq = irq;
  592. dev->dma = dma;
  593. dev->mem_start = mem;
  594. if (do_netcard_probe(dev) == 0) {
  595. this_device = dev;
  596. return 0;
  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. */