[netdrvr] ns83820: add ethtool media support
[safe/jmp/linux-2.6] / drivers / net / via-velocity.c
index 25b75b6..a4729bc 100644 (file)
@@ -890,8 +890,7 @@ static void __devinit velocity_init_info(struct pci_dev *pdev,
 
 static int __devinit velocity_get_pci_info(struct velocity_info *vptr, struct pci_dev *pdev)
 {
-       if (pci_read_config_byte(pdev, PCI_REVISION_ID, &vptr->rev_id) < 0)
-               return -EIO;
+       vptr->rev_id = pdev->revision;
 
        pci_set_master(pdev);
 
@@ -1072,14 +1071,12 @@ static int velocity_rx_refill(struct velocity_info *vptr)
 
 static int velocity_init_rd_ring(struct velocity_info *vptr)
 {
-       int ret = -ENOMEM;
-       unsigned int rsize = sizeof(struct velocity_rd_info) *
-                                       vptr->options.numrx;
+       int ret;
 
-       vptr->rd_info = kmalloc(rsize, GFP_KERNEL);
-       if(vptr->rd_info == NULL)
-               goto out;
-       memset(vptr->rd_info, 0, rsize);
+       vptr->rd_info = kcalloc(vptr->options.numrx,
+                               sizeof(struct velocity_rd_info), GFP_KERNEL);
+       if (!vptr->rd_info)
+               return -ENOMEM;
 
        vptr->rd_filled = vptr->rd_dirty = vptr->rd_curr = 0;
 
@@ -1089,7 +1086,7 @@ static int velocity_init_rd_ring(struct velocity_info *vptr)
                        "%s: failed to allocate RX buffer.\n", vptr->dev->name);
                velocity_free_rd_ring(vptr);
        }
-out:
+
        return ret;
 }
 
@@ -1143,21 +1140,19 @@ static int velocity_init_td_ring(struct velocity_info *vptr)
        dma_addr_t curr;
        struct tx_desc *td;
        struct velocity_td_info *td_info;
-       unsigned int tsize = sizeof(struct velocity_td_info) *
-                                       vptr->options.numtx;
 
        /* Init the TD ring entries */
        for (j = 0; j < vptr->num_txq; j++) {
                curr = vptr->td_pool_dma[j];
 
-               vptr->td_infos[j] = kmalloc(tsize, GFP_KERNEL);
-               if(vptr->td_infos[j] == NULL)
-               {
+               vptr->td_infos[j] = kcalloc(vptr->options.numtx,
+                                           sizeof(struct velocity_td_info),
+                                           GFP_KERNEL);
+               if (!vptr->td_infos[j]) {
                        while(--j >= 0)
                                kfree(vptr->td_infos[j]);
                        return -ENOMEM;
                }
-               memset(vptr->td_infos[j], 0, tsize);
 
                for (i = 0; i < vptr->options.numtx; i++, curr += sizeof(struct tx_desc)) {
                        td = &(vptr->td_rings[j][i]);
@@ -1562,7 +1557,7 @@ static void velocity_print_link_status(struct velocity_info *vptr)
        if (vptr->mii_status & VELOCITY_LINK_FAIL) {
                VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: failed to detect cable link\n", vptr->dev->name);
        } else if (vptr->options.spd_dpx == SPD_DPX_AUTO) {
-               VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link autonegation", vptr->dev->name);
+               VELOCITY_PRT(MSG_LEVEL_INFO, KERN_NOTICE "%s: Link auto-negotiation", vptr->dev->name);
 
                if (vptr->mii_status & VELOCITY_SPEED_1000)
                        VELOCITY_PRT(MSG_LEVEL_INFO, " speed 1000M bps");
@@ -1614,7 +1609,7 @@ static void velocity_error(struct velocity_info *vptr, int status)
        if (status & ISR_TXSTLI) {
                struct mac_regs __iomem * regs = vptr->mac_regs;
 
-               printk(KERN_ERR "TD structure errror TDindex=%hx\n", readw(&regs->TDIdx[0]));
+               printk(KERN_ERR "TD structure error TDindex=%hx\n", readw(&regs->TDIdx[0]));
                BYTE_REG_BITS_ON(TXESR_TDSTR, &regs->TXESR);
                writew(TRDCSR_RUN, &regs->TDCSRClr);
                netif_stop_queue(vptr->dev);