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