[PATCH 2.5 25/25] 8390-cleanup for pcmcia/pcnet_cs.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



pcmcia/pcnet_cs.c
- kill struct net_device from private struct
- kill ethdev_init()
- use ei_alloc_dev()
- fix bug: fastpoll was using (jiffies + 1), but (jiffies + HZ/100) is better
  with HZ=1000
compile tested.


--- 1.19/drivers/net/pcmcia/pcnet_cs.c	Sun May 18 22:57:38 2003
+++ edited/pcmcia/pcnet_cs.c	Mon Jun 30 23:58:48 2003
@@ -224,7 +224,6 @@
 static hw_info_t dl10022_info = { 0, 0, 0, 0, IS_DL10022|HAS_MII };
 
 typedef struct pcnet_dev_t {
-    struct net_device	dev;	/* so &dev == &pcnet_dev_t */
     dev_link_t		link;
     dev_node_t		node;
     u_int		flags;
@@ -280,6 +279,7 @@
     pcnet_dev_t *info;
     dev_link_t *link;
     struct net_device *dev;
+    struct ei_device *ei_local;
     client_reg_t client_reg;
     int i, ret;
 
@@ -287,12 +287,20 @@
     flush_stale_links();
 
     /* Create new ethernet device */
-    info = kmalloc(sizeof(*info), GFP_KERNEL);
-    if (!info) return NULL;
-    memset(info, 0, sizeof(*info));
-    link = &info->link; dev = &info->dev;
-    link->priv = info;
+    dev = ei_alloc_dev();
+    if (!dev)
+	return NULL;
+    ei_local = dev->priv;
 
+    info = kmalloc(sizeof(pcnet_dev_t), GFP_KERNEL);
+    if (!info) {
+	kfree(dev);
+	return NULL;
+    }
+    ei_local->priv = (unsigned long) info;
+    link = &info->link;
+    link->priv = dev;
+    
     init_timer(&link->release);
     link->release.function = &pcnet_release;
     link->release.data = (u_long)link;
@@ -306,7 +314,6 @@
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
 
-    ethdev_init(dev);
     SET_MODULE_OWNER(dev);
     dev->init = &pcnet_init;
     dev->open = &pcnet_open;
@@ -346,7 +353,9 @@
 
 static void pcnet_detach(dev_link_t *link)
 {
-    pcnet_dev_t *info = link->priv;
+    struct net_device *dev = link->priv;
+    struct ei_device *ei_local = dev->priv;
+    pcnet_dev_t *info = (pcnet_dev_t *) ei_local->priv;
     dev_link_t **linkp;
 
     DEBUG(0, "pcnet_detach(0x%p)\n", link);
@@ -372,8 +381,9 @@
     /* Unlink device structure, free bits */
     *linkp = link->next;
     if (link->dev)
-	unregister_netdev(&info->dev);
+	unregister_netdev(dev);
     kfree(info);
+    kfree(dev);
 
 } /* pcnet_detach */
 
@@ -606,8 +616,9 @@
 static void pcnet_config(dev_link_t *link)
 {
     client_handle_t handle = link->handle;
-    pcnet_dev_t *info = link->priv;
-    struct net_device *dev = &info->dev;
+    struct net_device *dev = link->priv;
+    struct ei_device *ei_local = dev->priv;
+    pcnet_dev_t *info = (pcnet_dev_t *) ei_local->priv;
     tuple_t tuple;
     cisparse_t parse;
     int i, last_ret, last_fn, start_pg, stop_pg, cm_offset;
@@ -803,7 +814,9 @@
 static void pcnet_release(u_long arg)
 {
     dev_link_t *link = (dev_link_t *)arg;
-    pcnet_dev_t *info = link->priv;
+    struct net_device *dev = link->priv;
+    struct ei_device *ei_local = dev->priv;
+    pcnet_dev_t *info = (pcnet_dev_t *) ei_local->priv;
 
     DEBUG(0, "pcnet_release(0x%p)\n", link);
 
@@ -839,7 +852,7 @@
 		       event_callback_args_t *args)
 {
     dev_link_t *link = args->client_data;
-    pcnet_dev_t *info = link->priv;
+    struct net_device *dev = link->priv;
 
     DEBUG(2, "pcnet_event(0x%06x)\n", event);
 
@@ -847,7 +860,7 @@
     case CS_EVENT_CARD_REMOVAL:
 	link->state &= ~DEV_PRESENT;
 	if (link->state & DEV_CONFIG) {
-	    netif_device_detach(&info->dev);
+	    netif_device_detach(dev);
 	    mod_timer(&link->release, jiffies + HZ/20);
 	}
 	break;
@@ -861,7 +874,7 @@
     case CS_EVENT_RESET_PHYSICAL:
 	if (link->state & DEV_CONFIG) {
 	    if (link->open)
-		netif_device_detach(&info->dev);
+		netif_device_detach(dev);
 	    CardServices(ReleaseConfiguration, link->handle);
 	}
 	break;
@@ -872,9 +885,9 @@
 	if (link->state & DEV_CONFIG) {
 	    CardServices(RequestConfiguration, link->handle, &link->conf);
 	    if (link->open) {
-		pcnet_reset_8390(&info->dev);
-		NS8390_init(&info->dev, 1);
-		netif_device_attach(&info->dev);
+		pcnet_reset_8390(dev);
+		NS8390_init(dev, 1);
+		netif_device_attach(dev);
 	    }
 	}
 	break;
@@ -960,7 +973,8 @@
 static void set_misc_reg(struct net_device *dev)
 {
     ioaddr_t nic_base = dev->base_addr;
-    pcnet_dev_t *info = (pcnet_dev_t *)dev;
+    struct ei_device *ei_local = dev->priv;
+    pcnet_dev_t *info = (pcnet_dev_t *) ei_local->priv;
     u_char tmp;
     
     if (info->flags & HAS_MISC_REG) {
@@ -990,7 +1004,8 @@
 
 static void mii_phy_probe(struct net_device *dev)
 {
-    pcnet_dev_t *info = (pcnet_dev_t *)dev;	
+    struct ei_device *ei_local = dev->priv;
+    pcnet_dev_t *info = (pcnet_dev_t *) ei_local->priv;
     ioaddr_t mii_addr = dev->base_addr + DLINK_GPIO;
     int i;
     u_int tmp, phyid;
@@ -1014,7 +1029,8 @@
 
 static int pcnet_open(struct net_device *dev)
 {
-    pcnet_dev_t *info = (pcnet_dev_t *)dev;
+    struct ei_device *ei_local = dev->priv;
+    pcnet_dev_t *info = (pcnet_dev_t *) ei_local->priv;
     dev_link_t *link = &info->link;
     
     DEBUG(2, "pcnet_open('%s')\n", dev->name);
@@ -1031,7 +1047,7 @@
     info->link_status = 0x00;
     init_timer(&info->watchdog);
     info->watchdog.function = &ei_watchdog;
-    info->watchdog.data = (u_long)info;
+    info->watchdog.data = (u_long) dev;
     info->watchdog.expires = jiffies + HZ;
     add_timer(&info->watchdog);
 
@@ -1042,7 +1058,8 @@
 
 static int pcnet_close(struct net_device *dev)
 {
-    pcnet_dev_t *info = (pcnet_dev_t *)dev;
+    struct ei_device *ei_local = dev->priv;
+    pcnet_dev_t *info = (pcnet_dev_t *) ei_local->priv;
     dev_link_t *link = &info->link;
 
     DEBUG(2, "pcnet_close('%s')\n", dev->name);
@@ -1095,7 +1112,8 @@
 
 static int set_config(struct net_device *dev, struct ifmap *map)
 {
-    pcnet_dev_t *info = (pcnet_dev_t *)dev;
+    struct ei_device *ei_local = dev->priv;
+    pcnet_dev_t *info = (pcnet_dev_t *) ei_local->priv;
     if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) {
 	if (!(info->flags & HAS_MISC_REG))
 	    return -EOPNOTSUPP;
@@ -1113,7 +1131,8 @@
 
 static irqreturn_t ei_irq_wrapper(int irq, void *dev_id, struct pt_regs *regs)
 {
-    pcnet_dev_t *info = dev_id;
+    struct ei_device *ei_local = ((struct net_device *) dev_id)->priv;
+    pcnet_dev_t *info = (pcnet_dev_t *) ei_local->priv;
     info->stale = 0;
     ei_interrupt(irq, dev_id, regs);
     /* FIXME! Was it really ours? */
@@ -1122,8 +1141,9 @@
 
 static void ei_watchdog(u_long arg)
 {
-    pcnet_dev_t *info = (pcnet_dev_t *)(arg);
-    struct net_device *dev = &info->dev;
+    struct net_device *dev = (struct net_device *) arg;
+    struct ei_device *ei_local = dev->priv;
+    pcnet_dev_t *info = (pcnet_dev_t *) ei_local->priv;
     ioaddr_t nic_base = dev->base_addr;
     ioaddr_t mii_addr = nic_base + DLINK_GPIO;
     u_short link;
@@ -1141,7 +1161,7 @@
     }
     if (info->fast_poll) {
 	info->fast_poll--;
-	info->watchdog.expires = jiffies + 1;
+	info->watchdog.expires = jiffies + HZ/100;
 	add_timer(&info->watchdog);
 	return;
     }
@@ -1233,9 +1253,11 @@
 
 static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-    pcnet_dev_t *info = (pcnet_dev_t *)dev;
+    struct ei_device *ei_local = dev->priv;
+    pcnet_dev_t *info = (pcnet_dev_t *) ei_local->priv;
     u16 *data = (u16 *)&rq->ifr_data;
     ioaddr_t mii_addr = dev->base_addr + DLINK_GPIO;
+
     switch (cmd) {
     case SIOCETHTOOL:
         return netdev_ethtool_ioctl(dev, (void *) rq->ifr_data);
@@ -1357,7 +1379,8 @@
 			     const u_char *buf, const int start_page)
 {
     ioaddr_t nic_base = dev->base_addr;
-    pcnet_dev_t *info = (pcnet_dev_t *)dev;
+    struct ei_device *ei_local = dev->priv;
+    pcnet_dev_t *info = (pcnet_dev_t *) ei_local->priv;
 #ifdef PCMCIA_DEBUG
     int retries = 0;
 #endif
@@ -1543,7 +1566,8 @@
 			      int stop_pg, int cm_offset)
 {
     struct net_device *dev = link->priv;
-    pcnet_dev_t *info = link->priv;
+    struct ei_device *ei_local = dev->priv;
+    pcnet_dev_t *info = (pcnet_dev_t *) ei_local->priv;
     win_req_t req;
     memreq_t mem;
     int i, window_size, offset, last_ret, last_fn;

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux