[linux-kernel dropped, netdev added] On Fri, Jul 29, 2005 at 08:15:20PM +0800, [EMAIL PROTECTED] wrote: > We want to extract our LAN card driver from tulip core driver and make a > new file uli526x.c at tulip folder, > because we have added some ethtool interface support and non-eprom support > in our driver and may be other change > in the futher. If our controllers support are still contained in the tulip > core driver, I think it'll increase the > complexity of maintenance, you know, tulip core driver include several > files and support so many other controllers. > Furthermore, I tested the newest kernel 2.6.12 and I found the tulip driver > can not work on our lan controller, and > I no time to debug it, so I aspired want to make a single uli526x.c file > just for our controllers.
> --- linux-vanilla/drivers/net/tulip/uli526x.c > +++ linux-2.6.12/drivers/net/tulip/uli526x.c > +#define SROM_CLK_WRITE(data, ioaddr) > outl(data|CR9_SROM_READ|CR9_SRCS,ioaddr);udelay(5);outl(data|CR9_SROM_READ|CR9_SRCS|CR9_SRCLK,ioaddr);udelay(5);outl(data|CR9_SROM_READ|CR9_SRCS,ioaddr);udelay(5); #define SROM_CLK_WRITE(data, ioaddr) \ outl(data | CR9_SROM_READ | CR9_SRCS, ioaddr); \ udelay(5); \ outl(data | CR9_SROM_READ | CR9_SRCS | CR9_SRCLK, ioaddr); \ udelay(5); \ outl(data | CR9_SROM_READ | CR9_SRCS, ioaddr); \ udelay(5); is much more readable. > +/* Sten Check */ > +#define DEVICE net_device Please, drop this. > +struct tx_desc { > + u32 tdes0, tdes1, tdes2, tdes3; /* Data for the card */ __le32. > +struct rx_desc { > + u32 rdes0, rdes1, rdes2, rdes3; /* Data for the card */ __le32. > +/* ULI526X network baord routine ---------------------------- */ board > + * Search ULI526X board ,allocate space and register it ", " > +static int __devinit uli526x_init_one (struct pci_dev *pdev, > + const struct pci_device_id *ent) > +{ > + if (pci_set_dma_mask(pdev, 0xffffffff)) { DMA_32BIT_MASK > + if(configval == 0x526310b9) > + { Please, use uniform style on the whole driver: if () { ... } else { ... } > + db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * > DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr); > + db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * > TX_DESC_CNT + 4, &db->buf_pool_dma_ptr); pci_alloc_consistent() can fail. > + for (i = 0; i < 64; i++) > + ((u16 *) db->srom)[i] = cpu_to_le16(read_srom_word(db->ioaddr, > i)); (__le16 *) > +static void __devexit uli526x_remove_one (struct pci_dev *pdev) > +{ > + struct net_device *dev = pci_get_drvdata(pdev); > + if (dev) { How can dev be NULL here? uli526x_init_one() { struct net_device *dev; dev = alloc_etherdev(sizeof(*db)); if (dev == NULL) return -ENOMEM; [dev is dereferenced a couple of times] pci_set_drvdata(pdev, dev); ... } > + pci_free_consistent(db->pdev, sizeof(struct tx_desc) * > + DESC_ALL_CNT + 0x20, db->desc_pool_ptr, > + db->desc_pool_dma_ptr); > + pci_free_consistent(db->pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, > + db->buf_pool_ptr, db->buf_pool_dma_ptr); > + unregister_netdev(dev); > + pci_release_regions(pdev); > + free_netdev(dev); /* free board information */ > + pci_set_drvdata(pdev, NULL); > + } > + * The interface is opened whenever "ifconfig" actives it. activates. > +/* Initilize ULI526X board > + * Initilize TX/Rx descriptor chain structure initialize > + * Re-initilize ULI526X board ^^^^^^^^^ > +/* Description: > + * when user used insmod to add module, system invoked init_module() > + * to initilize and register. > + */ "initialize". IMO, useless comment. > +static int __init uli526x_init_module(void) > +{ > +/* > + * Description: > + * when user used rmmod to delete module, system invoked clean_module() > + * to un-register all registered services. > + */ > + > +static void __exit uli526x_cleanup_module(void) > +{ - To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html