Hi Greg,

this patch removes memcpy overhead in receive/transmit routines.
It was originally written by Adam Richter (thanks Adam) and slightly
modified by me, namely:
        - Rx socket buffer is now allocated in rtl8150_open();
        - down/up pair added in probe() because hotplug/dhcp client
          breaks the kernel;

I'll send similar patch for pegasus against 2.5.8-pre1 too.


                Petko

PS:  I'm sorry if the patch is not very readable.  I was anxious to
run Lindent on the driver. :-)
You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.

===================================================================


[EMAIL PROTECTED], 2002-04-05 13:57:21-08:00, [EMAIL PROTECTED]
  memcpy overhead removed from Rx/Tx routines.  the whole thing run thru Lindent


 rtl8150.c |  413 ++++++++++++++++++++++++++++----------------------------------
 1 files changed, 192 insertions(+), 221 deletions(-)


diff -Nru a/drivers/usb/rtl8150.c b/drivers/usb/rtl8150.c
--- a/drivers/usb/rtl8150.c     Fri Apr  5 13:58:16 2002
+++ b/drivers/usb/rtl8150.c     Fri Apr  5 13:58:16 2002
@@ -21,14 +21,11 @@
 #include <linux/usb.h>
 #include <asm/uaccess.h>
 
-
-
 /* Version Information */
-#define DRIVER_VERSION "v0.5.0 (2002/03/28)"
+#define DRIVER_VERSION "v0.5.2 (2002/04/05)"
 #define DRIVER_AUTHOR "Petko Manolov <[EMAIL PROTECTED]>"
 #define DRIVER_DESC "rtl8150 based usb-ethernet driver"
 
-
 #define        IRD                     0x0120
 #define        MAR                     0x0126
 #define        CR                      0x012e
@@ -58,59 +55,52 @@
 #define        RTL8150_REQ_GET_REGS    0x05
 #define        RTL8150_REQ_SET_REGS    0x05
 
-#define        RTL8150_MTU             1500
-#define        RTL8150_MAX_MTU         1536
+#define        RTL8150_MTU             1536
 
 #define        RTL8150_TX_TIMEOUT      (HZ)
 
 /* rtl8150 flags */
-#define        RTL8150_FLAG_HWCRC      0
+#define        RTL8150_HW_CRC          0
 #define        RX_REG_SET              1
 #define        RTL8150_UNPLUG          2
 
-
 /* Define these values to match your device */
 #define VENDOR_ID_REALTEK              0x0bda
 #define PRODUCT_ID_RTL8150             0x8150
 
 /* table of devices that work with this driver */
-static struct usb_device_id rtl8150_table [] = {
-       { USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8150) },
-       { }                             
+static struct usb_device_id rtl8150_table[] = {
+       {USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8150)},
+       {}
 };
 
-MODULE_DEVICE_TABLE (usb, rtl8150_table);
-
+MODULE_DEVICE_TABLE(usb, rtl8150_table);
 
 struct rtl8150 {
-       unsigned int            flags;
-       struct usb_device       *udev;
-       struct usb_interface    *interface;
-       struct semaphore        sem;
-       struct net_device_stats stats;
-       struct net_device       *netdev;
-       struct urb              *rx_urb, *tx_urb, *intr_urb, *ctrl_urb;
-       struct usb_ctrlrequest  dr;
-       int                     intr_interval;
-       u16                     rx_creg;
-       u8                      rx_buff[RTL8150_MAX_MTU];
-       u8                      tx_buff[RTL8150_MAX_MTU];
-       u8                      intr_buff[8];
-       u8                      phy;
+       unsigned int flags;
+       struct usb_device *udev;
+       struct usb_interface *interface;
+       struct semaphore sem;
+       struct net_device_stats stats;
+       struct net_device *netdev;
+       struct urb *rx_urb, *tx_urb, *intr_urb, *ctrl_urb;
+       struct sk_buff *tx_skb, *rx_skb;
+       struct usb_ctrlrequest dr;
+       int intr_interval;
+       u16 rx_creg;
+       u8 intr_buff[8];
+       u8 phy;
 };
 
-typedef        struct rtl8150  rtl8150_t;
-
+typedef struct rtl8150 rtl8150_t;
 
 /* the global usb devfs handle */
 extern devfs_handle_t usb_devfs_handle;
 unsigned long multicast_filter_limit = 32;
 
-
 static void rtl8150_disconnect(struct usb_device *dev, void *ptr);
-static void * rtl8150_probe(struct usb_device *dev, unsigned int ifnum,
-                           const struct usb_device_id *id);
-
+static void *rtl8150_probe(struct usb_device *dev, unsigned int ifnum,
+                          const struct usb_device_id *id);
 
 static struct usb_driver rtl8150_driver = {
        name:           "rtl8150",
@@ -119,33 +109,29 @@
        id_table:       rtl8150_table,
 };
 
-
-
 /*
 **
 **     device related part of the code
 **
 */
-static int get_registers(rtl8150_t *dev, u16 indx, u16 size, void *data)
+static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data)
 {
-       return usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev,0),
-                               RTL8150_REQ_GET_REGS, RTL8150_REQT_READ,
-                               indx, 0, data, size, HZ/2);
+       return usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
+                              RTL8150_REQ_GET_REGS, RTL8150_REQT_READ,
+                              indx, 0, data, size, HZ / 2);
 }
 
-
-static int set_registers(rtl8150_t *dev, u16 indx, u16 size, void *data)
+static int set_registers(rtl8150_t * dev, u16 indx, u16 size, void *data)
 {
-       return usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev,0),
-                               RTL8150_REQ_SET_REGS, RTL8150_REQT_WRITE,
-                               indx, 0, data, size, HZ/2);
+       return usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0),
+                              RTL8150_REQ_SET_REGS, RTL8150_REQT_WRITE,
+                              indx, 0, data, size, HZ / 2);
 }
 
-
 static void ctrl_callback(struct urb *urb)
 {
-       rtl8150_t       *dev;
-       
+       rtl8150_t *dev;
+
        switch (urb->status) {
        case 0:
                break;
@@ -160,23 +146,22 @@
        clear_bit(RX_REG_SET, &dev->flags);
 }
 
-
-static int async_set_registers(rtl8150_t *dev, u16 indx, u16 size, void *data)
+static int async_set_registers(rtl8150_t * dev, u16 indx, u16 size, void *data)
 {
-       int     ret;
+       int ret;
 
        if (test_bit(RX_REG_SET, &dev->flags))
                return -EAGAIN;
-       
+
        dev->dr.bRequestType = RTL8150_REQT_WRITE;
        dev->dr.bRequest = RTL8150_REQ_SET_REGS;
        dev->dr.wValue = cpu_to_le16(indx);
        dev->dr.wIndex = 0;
        dev->dr.wLength = cpu_to_le16(size);
        dev->ctrl_urb->transfer_buffer_length = size;
-       FILL_CONTROL_URB(dev->ctrl_urb, dev->udev, usb_sndctrlpipe(dev->udev,0),
-                        (char*)&dev->dr, &dev->rx_creg, size,
-                        ctrl_callback, dev);
+       FILL_CONTROL_URB(dev->ctrl_urb, dev->udev,
+                        usb_sndctrlpipe(dev->udev, 0), (char *) &dev->dr,
+                        &dev->rx_creg, size, ctrl_callback, dev);
        if ((ret = usb_submit_urb(dev->ctrl_urb, GFP_ATOMIC)))
                err("control request submission failed: %d", ret);
        else
@@ -185,11 +170,10 @@
        return ret;
 }
 
-
-static int read_mii_word(rtl8150_t *dev, u8 phy, __u8 indx, u16 *reg)
+static int read_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 * reg)
 {
-       int     i;
-       u8      data[3], tmp;
+       int i;
+       u8 data[3], tmp;
 
        data[0] = phy;
        data[1] = data[2] = 0;
@@ -210,11 +194,10 @@
                return 1;
 }
 
-
-static int write_mii_word(rtl8150_t *dev, u8 phy, __u8 indx, u16 reg)
+static int write_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 reg)
 {
-       int     i;
-       u8      data[3], tmp;
+       int i;
+       u8 data[3], tmp;
 
        data[0] = phy;
        *(data + 1) = cpu_to_le16p(&reg);
@@ -225,7 +208,7 @@
        set_registers(dev, PHYCNT, 1, &tmp);
        do {
                get_registers(dev, PHYCNT, 1, data);
-       } while((data[0] & PHY_GO) && (i++ < HZ));
+       } while ((data[0] & PHY_GO) && (i++ < HZ));
 
        if (i < HZ)
                return 0;
@@ -233,31 +216,28 @@
                return 1;
 }
 
-
-static inline void set_ethernet_addr(rtl8150_t *dev)
+static inline void set_ethernet_addr(rtl8150_t * dev)
 {
-       u8      node_id[6];
+       u8 node_id[6];
 
        get_registers(dev, IRD, sizeof(node_id), node_id);
        memcpy(dev->netdev->dev_addr, node_id, sizeof(node_id));
 }
 
-
-static int rtl8150_reset(rtl8150_t *dev)
+static int rtl8150_reset(rtl8150_t * dev)
 {
-       u8      data=0x10;
-       int     i=HZ;
+       u8 data = 0x10;
+       int i = HZ;
 
        set_registers(dev, CR, 1, &data);
        do {
                get_registers(dev, CR, 1, &data);
        } while ((data & 0x10) && --i);
-       
+
        return (i > 0) ? 0 : -1;
 }
 
-
-static int alloc_all_urbs(rtl8150_t *dev)
+static int alloc_all_urbs(rtl8150_t * dev)
 {
        dev->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
        if (!dev->rx_urb)
@@ -284,8 +264,7 @@
        return 1;
 }
 
-
-static void free_all_urbs(rtl8150_t *dev)
+static void free_all_urbs(rtl8150_t * dev)
 {
        usb_free_urb(dev->rx_urb);
        usb_free_urb(dev->tx_urb);
@@ -293,8 +272,7 @@
        usb_free_urb(dev->ctrl_urb);
 }
 
-
-static void unlink_all_urbs(rtl8150_t *dev)
+static void unlink_all_urbs(rtl8150_t * dev)
 {
        usb_unlink_urb(dev->rx_urb);
        usb_unlink_urb(dev->tx_urb);
@@ -302,14 +280,13 @@
        usb_unlink_urb(dev->ctrl_urb);
 }
 
-
 static void read_bulk_callback(struct urb *urb)
 {
-       rtl8150_t       *dev;
-       unsigned        pkt_len, res;
-       struct sk_buff  *skb;
+       rtl8150_t *dev;
+       unsigned pkt_len, res;
+       struct sk_buff *skb;
        struct net_device *netdev;
-       u16             rx_stat;
+       u16 rx_stat;
 
        dev = urb->context;
        if (!dev) {
@@ -335,34 +312,38 @@
        }
 
        res = urb->actual_length;
-       rx_stat = le16_to_cpu(*(short*)(dev->rx_buff + res - 4));
+       rx_stat = le16_to_cpu(*(short *)(urb->transfer_buffer + res - 4));
        pkt_len = res - 4;
 
-       if (!(skb = dev_alloc_skb(pkt_len + 2))) 
-               goto goon;
+       if (!(skb = dev_alloc_skb(RTL8150_MTU + 2))) {
+               err("out of memory in %s()", __FUNCTION__);
+               return;
+       }
+       skb_put(dev->rx_skb, pkt_len);
+       dev->rx_skb->protocol = eth_type_trans(dev->rx_skb, netdev);
+       netif_rx(dev->rx_skb);
+       
        skb->dev = netdev;
        skb_reserve(skb, 2);
-       eth_copy_and_sum(skb, dev->rx_buff, pkt_len, 0);
-       skb_put(skb, pkt_len);
-       skb->protocol = eth_type_trans(skb, netdev);
-       netif_rx(skb);
+       dev->rx_skb = skb;
        dev->stats.rx_packets++;
        dev->stats.rx_bytes += pkt_len;
 goon:
-       FILL_BULK_URB(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev,1),
-                     dev->rx_buff, RTL8150_MAX_MTU, read_bulk_callback, dev);
-       if ((res=usb_submit_urb(dev->rx_urb, GFP_ATOMIC)))
+       FILL_BULK_URB(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1),
+                     dev->rx_skb->data, RTL8150_MTU + 4,
+                     read_bulk_callback, dev);
+       if ((res = usb_submit_urb(dev->rx_urb, GFP_ATOMIC)))
                warn("%s: Rx urb submission failed %d", netdev->name, res);
 }
 
-
 static void write_bulk_callback(struct urb *urb)
 {
-       rtl8150_t       *dev;
+       rtl8150_t *dev;
 
        dev = urb->context;
        if (!dev)
                return;
+       dev_kfree_skb_irq(dev->tx_skb);
        if (!netif_device_present(dev->netdev))
                return;
        if (urb->status)
@@ -371,43 +352,42 @@
        netif_wake_queue(dev->netdev);
 }
 
-
 void intr_callback(struct urb *urb)
 {
-       rtl8150_t       *dev;
+       rtl8150_t *dev;
 
        dev = urb->context;
        if (!dev)
                return;
        switch (urb->status) {
-               case 0:
-                       break;
-               case -ENOENT:
-                       return;
-               default:
-                       info("%s: intr status %d", dev->netdev->name,
-                            urb->status);
+       case 0:
+               break;
+       case -ENOENT:
+               return;
+       default:
+               info("%s: intr status %d", dev->netdev->name, urb->status);
        }
 }
 
-
 /*
 **
 **     network related part of the code
 **
 */
 
-
-static int enable_net_traffic(rtl8150_t *dev)
+static int enable_net_traffic(rtl8150_t * dev)
 {
-       u8      cr, tcr, rcr, msr;
+       u8 cr, tcr, rcr, msr;
 
        if (rtl8150_reset(dev)) {
                warn("%s - device reset failed", __FUNCTION__);
        }
-       dev->rx_creg = rcr = 0x9e;      /* bit7=1 attach Rx info at the end */
-       tcr = 0xd8;             /* bit0=1 no CRC at the end of the frame */
+       /* RCR bit7=1 attach Rx info at the end;  =0 HW CRC (which is broken) */
+       dev->rx_creg = rcr = 0x9e;
+       tcr = 0xd8;
        cr = 0x0c;
+       if (!(rcr & 0x80))
+               set_bit(RTL8150_HW_CRC, &dev->flags);
        set_registers(dev, RCR, 1, &rcr);
        set_registers(dev, TCR, 1, &tcr);
        set_registers(dev, CR, 1, &cr);
@@ -416,26 +396,23 @@
        return 0;
 }
 
-
-static void disable_net_traffic(rtl8150_t *dev)
+static void disable_net_traffic(rtl8150_t * dev)
 {
-       u8      cr;
+       u8 cr;
 
        get_registers(dev, CR, 1, &cr);
        cr &= 0xf3;
        set_registers(dev, CR, 1, &cr);
 }
 
-
 static struct net_device_stats *rtl8150_netdev_stats(struct net_device *dev)
 {
-       return &((rtl8150_t *)dev->priv)->stats;
+       return &((rtl8150_t *) dev->priv)->stats;
 }
 
-
 static void rtl8150_tx_timeout(struct net_device *netdev)
 {
-       rtl8150_t       *dev;
+       rtl8150_t *dev;
 
        dev = netdev->priv;
        if (!dev)
@@ -446,10 +423,9 @@
        dev->stats.tx_errors++;
 }
 
-
 static void rtl8150_set_multicast(struct net_device *netdev)
 {
-       rtl8150_t       *dev;
+       rtl8150_t *dev;
 
        dev = netdev->priv;
        netif_stop_queue(netdev);
@@ -457,7 +433,7 @@
                dev->rx_creg |= 0x0001;
                info("%s: promiscuous mode", netdev->name);
        } else if ((netdev->mc_count > multicast_filter_limit) ||
-                  (netdev->flags & IFF_ALLMULTI)) {
+                  (netdev->flags & IFF_ALLMULTI)) {
                dev->rx_creg &= 0xfffe;
                dev->rx_creg |= 0x0002;
                info("%s: allmulti set", netdev->name);
@@ -469,20 +445,18 @@
        netif_wake_queue(netdev);
 }
 
-
 static int rtl8150_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 {
-       rtl8150_t       *dev;
-       int             count, res;
+       rtl8150_t *dev;
+       int count, res;
 
        netif_stop_queue(netdev);
        dev = netdev->priv;
        count = (skb->len < 60) ? 60 : skb->len;
        count = (count & 0x3f) ? count : count + 1;
-       memcpy(dev->tx_buff, skb->data, skb->len);
-       FILL_BULK_URB(dev->tx_urb, dev->udev, usb_sndbulkpipe(dev->udev,2),
-                     dev->tx_buff, RTL8150_MAX_MTU, write_bulk_callback, dev);
-       dev->tx_urb->transfer_buffer_length = count;
+       dev->tx_skb = skb;
+       FILL_BULK_URB(dev->tx_urb, dev->udev, usb_sndbulkpipe(dev->udev, 2),
+                     skb->data, count, write_bulk_callback, dev);
 
        if ((res = usb_submit_urb(dev->tx_urb, GFP_KERNEL))) {
                warn("failed tx_urb %d\n", res);
@@ -493,31 +467,35 @@
                dev->stats.tx_bytes += skb->len;
                netdev->trans_start = jiffies;
        }
-       dev_kfree_skb(skb);
 
        return 0;
 }
 
-
 static int rtl8150_open(struct net_device *netdev)
 {
-       rtl8150_t       *dev;
-       int             res;
-       
+       rtl8150_t *dev;
+       int res;
+
        dev = netdev->priv;
        if (dev == NULL) {
                return -ENODEV;
        }
 
+       if (!(dev->rx_skb = dev_alloc_skb(RTL8150_MTU + 2)))
+               return -ENOMEM;
+       dev->rx_skb->dev = netdev;
+       skb_reserve(dev->rx_skb, 2);
+
        down(&dev->sem);
-       FILL_BULK_URB(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev,1),
-                       dev->rx_buff, RTL8150_MAX_MTU, read_bulk_callback, dev);
-       if ((res=usb_submit_urb(dev->rx_urb, GFP_KERNEL)))
+       FILL_BULK_URB(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1),
+                     dev->rx_skb->data, RTL8150_MTU + 4,
+                     read_bulk_callback, dev);
+       if ((res = usb_submit_urb(dev->rx_urb, GFP_KERNEL)))
                warn("%s: rx_urb submit failed: %d", __FUNCTION__, res);
-       FILL_INT_URB(dev->intr_urb, dev->udev, usb_rcvintpipe(dev->udev,3),
-                       dev->intr_buff, sizeof(dev->intr_buff), intr_callback,
-                       dev, dev->intr_interval);
-       if ((res=usb_submit_urb(dev->intr_urb, GFP_KERNEL)))
+       FILL_INT_URB(dev->intr_urb, dev->udev, usb_rcvintpipe(dev->udev, 3),
+                    dev->intr_buff, sizeof(dev->intr_buff), intr_callback,
+                    dev, dev->intr_interval);
+       if ((res = usb_submit_urb(dev->intr_urb, GFP_KERNEL)))
                warn("%s: intr_urb submit failed: %d", __FUNCTION__, res);
        netif_start_queue(netdev);
        enable_net_traffic(dev);
@@ -526,7 +504,6 @@
        return res;
 }
 
-
 static int rtl8150_close(struct net_device *netdev)
 {
        rtl8150_t *dev;
@@ -543,97 +520,95 @@
        netif_stop_queue(netdev);
        up(&dev->sem);
 
-
        return res;
 }
 
-
 static int rtl8150_ethtool_ioctl(struct net_device *netdev, void *uaddr)
 {
-       rtl8150_t       *dev;
-       int             cmd;
-       char            tmp[128];
+       rtl8150_t *dev;
+       int cmd;
+       char tmp[128];
 
        dev = netdev->priv;
-       if (get_user(cmd, (int *)uaddr))
+       if (get_user(cmd, (int *) uaddr))
                return -EFAULT;
 
        switch (cmd) {
-       case ETHTOOL_GDRVINFO: {
-               struct ethtool_drvinfo info = {ETHTOOL_GDRVINFO};
-               
-               strncpy(info.driver, DRIVER_DESC, ETHTOOL_BUSINFO_LEN);
-               strncpy(info.version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN);
-               sprintf(tmp, "usb%d:%d", dev->udev->bus->busnum,
-                       dev->udev->devnum);
-               strncpy(info.bus_info, tmp, ETHTOOL_BUSINFO_LEN);
-               if (copy_to_user(uaddr, &info, sizeof(info)))
-                       return -EFAULT;
-               return 0;
-       }
-       case ETHTOOL_GSET: {
-               struct ethtool_cmd ecmd;
-               short   lpa, bmcr;
-
-               if (copy_from_user(&ecmd, uaddr, sizeof(ecmd)))
-                       return -EFAULT;
-               ecmd.supported = (SUPPORTED_10baseT_Half |
-                                 SUPPORTED_10baseT_Full |
-                                 SUPPORTED_100baseT_Half |
-                                 SUPPORTED_100baseT_Full |
-                                 SUPPORTED_Autoneg |
-                                 SUPPORTED_TP |
-                                 SUPPORTED_MII);
-               ecmd.port = PORT_TP;
-               ecmd.transceiver = XCVR_INTERNAL;
-               ecmd.phy_address = dev->phy;
-               get_registers(dev, BMCR, 2, &bmcr);
-               get_registers(dev, ANLP, 2, &lpa);
-               if (bmcr & BMCR_ANENABLE) {
-                       ecmd.autoneg = AUTONEG_ENABLE;
-                       ecmd.speed = (lpa & (LPA_100HALF | LPA_100FULL)) ?
-                                    SPEED_100 : SPEED_10;
-                       if (ecmd.speed == SPEED_100)
-                               ecmd.duplex = (lpa & LPA_100FULL) ?
-                                             DUPLEX_FULL : DUPLEX_HALF;
-                       else
-                               ecmd.duplex = (lpa & LPA_10FULL) ?
-                                             DUPLEX_FULL : DUPLEX_HALF;
-               } else {
-                       ecmd.autoneg = AUTONEG_DISABLE;
-                       ecmd.speed = (bmcr & BMCR_SPEED100) ?
-                                    SPEED_100 : SPEED_10;
-                       ecmd.duplex = (bmcr & BMCR_FULLDPLX) ?
-                                     DUPLEX_FULL : DUPLEX_HALF;
+       case ETHTOOL_GDRVINFO:{
+                       struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
+
+                       strncpy(info.driver, DRIVER_DESC, ETHTOOL_BUSINFO_LEN);
+                       strncpy(info.version, DRIVER_VERSION,
+                               ETHTOOL_BUSINFO_LEN);
+                       sprintf(tmp, "usb%d:%d", dev->udev->bus->busnum,
+                               dev->udev->devnum);
+                       strncpy(info.bus_info, tmp, ETHTOOL_BUSINFO_LEN);
+                       if (copy_to_user(uaddr, &info, sizeof(info)))
+                               return -EFAULT;
+                       return 0;
+               }
+       case ETHTOOL_GSET:{
+                       struct ethtool_cmd ecmd;
+                       short lpa, bmcr;
+
+                       if (copy_from_user(&ecmd, uaddr, sizeof(ecmd)))
+                               return -EFAULT;
+                       ecmd.supported = (SUPPORTED_10baseT_Half |
+                                         SUPPORTED_10baseT_Full |
+                                         SUPPORTED_100baseT_Half |
+                                         SUPPORTED_100baseT_Full |
+                                         SUPPORTED_Autoneg |
+                                         SUPPORTED_TP | SUPPORTED_MII);
+                       ecmd.port = PORT_TP;
+                       ecmd.transceiver = XCVR_INTERNAL;
+                       ecmd.phy_address = dev->phy;
+                       get_registers(dev, BMCR, 2, &bmcr);
+                       get_registers(dev, ANLP, 2, &lpa);
+                       if (bmcr & BMCR_ANENABLE) {
+                               ecmd.autoneg = AUTONEG_ENABLE;
+                               ecmd.speed =
+                                   (lpa & (LPA_100HALF | LPA_100FULL)) ?
+                                   SPEED_100 : SPEED_10;
+                               if (ecmd.speed == SPEED_100)
+                                       ecmd.duplex = (lpa & LPA_100FULL) ?
+                                           DUPLEX_FULL : DUPLEX_HALF;
+                               else
+                                       ecmd.duplex = (lpa & LPA_10FULL) ?
+                                           DUPLEX_FULL : DUPLEX_HALF;
+                       } else {
+                               ecmd.autoneg = AUTONEG_DISABLE;
+                               ecmd.speed = (bmcr & BMCR_SPEED100) ?
+                                   SPEED_100 : SPEED_10;
+                               ecmd.duplex = (bmcr & BMCR_FULLDPLX) ?
+                                   DUPLEX_FULL : DUPLEX_HALF;
+                       }
+                       if (copy_to_user(uaddr, &ecmd, sizeof(ecmd)))
+                               return -EFAULT;
+                       return 0;
                }
-               if (copy_to_user(uaddr, &ecmd, sizeof(ecmd)))
-                       return -EFAULT;
-               return 0;
-       }
        case ETHTOOL_SSET:
                return -ENOTSUPP;
-       case ETHTOOL_GLINK: {
-               struct ethtool_value edata = {ETHTOOL_GLINK};
+       case ETHTOOL_GLINK:{
+                       struct ethtool_value edata = { ETHTOOL_GLINK };
 
-               edata.data = netif_carrier_ok(netdev);
-               if (copy_to_user(uaddr, &edata, sizeof(edata)))
-                       return -EFAULT;
-               return 0;
-       }
+                       edata.data = netif_carrier_ok(netdev);
+                       if (copy_to_user(uaddr, &edata, sizeof(edata)))
+                               return -EFAULT;
+                       return 0;
+               }
        default:
                return -EOPNOTSUPP;
        }
 }
 
-
-static int rtl8150_ioctl (struct net_device *netdev, struct ifreq *rq, int cmd)
+static int rtl8150_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
 {
        rtl8150_t *dev;
-       u16     *data;
-       int     res;
+       u16 *data;
+       int res;
 
        dev = netdev->priv;
-       data = (u16 *)&rq->ifr_data;
+       data = (u16 *) & rq->ifr_data;
        res = 0;
 
        down(&dev->sem);
@@ -643,10 +618,10 @@
                break;
        case SIOCDEVPRIVATE:
                data[0] = dev->phy;
-       case SIOCDEVPRIVATE+1:
+       case SIOCDEVPRIVATE + 1:
                read_mii_word(dev, dev->phy, (data[1] & 0x1f), &data[3]);
                break;
-       case SIOCDEVPRIVATE+2:
+       case SIOCDEVPRIVATE + 2:
                if (!capable(CAP_NET_ADMIN)) {
                        up(&dev->sem);
                        return -EPERM;
@@ -660,26 +635,24 @@
        return res;
 }
 
-
-static void * rtl8150_probe(struct usb_device *udev, unsigned int ifnum,
-                           const struct usb_device_id *id)
+static void *rtl8150_probe(struct usb_device *udev, unsigned int ifnum,
+                          const struct usb_device_id *id)
 {
        rtl8150_t *dev;
        struct net_device *netdev;
 
-       udev->config[0].bConfigurationValue = 1;
        if (usb_set_configuration(udev, udev->config[0].bConfigurationValue)) {
                err("usb_set_configuration() failed");
                return NULL;
        }
        if ((udev->descriptor.idVendor != VENDOR_ID_REALTEK) ||
            (udev->descriptor.idProduct != PRODUCT_ID_RTL8150)) {
-               err("Not the one we are interested about");
+               err("Not the one we are interested about");
                return NULL;
        }
        dev = kmalloc(sizeof(rtl8150_t), GFP_KERNEL);
        if (!dev) {
-               err ("Out of memory");
+               err("Out of memory");
                goto exit;
        } else
                memset(dev, 0, sizeof(rtl8150_t));
@@ -691,8 +664,9 @@
                dev = NULL;
                goto exit;
        }
-               
+
        init_MUTEX(&dev->sem);
+       down(&dev->sem);
        dev->udev = udev;
        dev->netdev = netdev;
        SET_MODULE_OWNER(netdev);
@@ -721,10 +695,10 @@
        set_ethernet_addr(dev);
        info("%s: rtl8150 is detected", netdev->name);
 exit:
+       up(&dev->sem);
        return dev;
 }
 
-
 static void rtl8150_disconnect(struct usb_device *udev, void *ptr)
 {
        rtl8150_t *dev;
@@ -734,26 +708,23 @@
        unregister_netdev(dev->netdev);
        unlink_all_urbs(dev);
        free_all_urbs(dev);
+       dev_kfree_skb(dev->rx_skb);
        kfree(dev->netdev);
        kfree(dev);
        dev->netdev = NULL;
        dev = NULL;
 }
 
-
-
 static int __init usb_rtl8150_init(void)
 {
        info(DRIVER_DESC " " DRIVER_VERSION);
        return usb_register(&rtl8150_driver);
 }
 
-
 static void __exit usb_rtl8150_exit(void)
 {
        usb_deregister(&rtl8150_driver);
 }
-
 
 module_init(usb_rtl8150_init);
 module_exit(usb_rtl8150_exit);

===================================================================


This BitKeeper patch contains the following changesets:
1.430
## Wrapped with gzip_uu ##


begin 664 bkpatch704
M'XL(`/@=KCP``]T::W/:2/(S^A5SWDI*.-C66X*<<\$6ME7!F,.0W=LDI1)B
ML%6`1/3PX^+\]^ON$>9AXB2;^W!UJ40CS?2[>[I[AOS&!AE/&Y4YSR=!+/W&
MSI(L;U1F099'DV!_&M_=[H?)#!9Z20(+!T66'F1I".-P3]LW)5CI!GEXS6YX
MFC4JZK[^.)/?SWFCTFN=#MK-GB0='K+CZR"^XI<\9X>'TG#R=E3PZ?XD38+K
M_22]>GA<?M`41555S51TTU+-!\W1=>-!M93A"%Y'FET?#ZVZ=)7RJ[<"'61<
M1]<40S$TQ53-^H.EV;HMN4S=-W2%*=J!8APH)E/UAFDW-'5/<1J*PH0)WFZJ
MSEZI;$^1CMBORWLLA6S&9^'\GB5@KFL>C%C*9_`^8N,46/7N#OIW+$V*/(IY
MML]8?LW9[74RY?`6Q5<L+6)X2PO6CN(1CW/I';-TR[:E[M*VTMY/_I$D)5"D
M-VS#G*,T0I^BIP_2?.JHIK(?/II640W-=!Y4T]:U!W-L&L/`&H:A-;2'PV^9
M\GF2I@;$U/J#9BF60^&R%1Q#Y[\FZ5^@5']0'<?2*)RTS6!2Z]\-IKK&]C1-
M_=\-*&'_"[:7WM)?")#N=E?\A4AS-8.![32;J9)'S]]&?`S",;?GO6_U?/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