]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: et131x: Remove private adapter->linkspeed and use phydev->speed instead
authorMark Einon <mark.einon@gmail.com>
Sun, 4 Sep 2011 10:24:32 +0000 (11:24 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 6 Sep 2011 23:54:53 +0000 (16:54 -0700)
The phy device keeps a note of the link speed, so use that value instead of the driver private one.

Also use the phydev defines for link speeds, and remove the driver private ones.

adapter->hw_errs was never used, even in the vendor driver, so remove that too.

Signed-off-by: Mark Einon <mark.einon@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/et131x/et1310_mac.c
drivers/staging/et131x/et1310_phy.c
drivers/staging/et131x/et1310_phy.h
drivers/staging/et131x/et1310_rx.c
drivers/staging/et131x/et1310_tx.c
drivers/staging/et131x/et131x_adapter.h
drivers/staging/et131x/et131x_initpci.c

index 36f21685599a1ebdb13352be14b845aa4ba7ffcc..efabc038bb4ecc2ccfebdf906c2eaa8167b1c725 100644 (file)
@@ -82,6 +82,7 @@
 #include <linux/if_arp.h>
 #include <linux/ioport.h>
 #include <linux/crc32.h>
+#include <linux/phy.h>
 
 #include "et1310_phy.h"
 #include "et131x_adapter.h"
@@ -166,6 +167,7 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter)
 {
        int32_t delay = 0;
        struct mac_regs __iomem *mac = &adapter->regs->mac;
+       struct phy_device *phydev = adapter->phydev;
        u32 cfg1;
        u32 cfg2;
        u32 ifctrl;
@@ -178,7 +180,7 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter)
 
        /* Set up the if mode bits */
        cfg2 &= ~0x300;
-       if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS) {
+       if (phydev && phydev->speed == SPEED_1000) {
                cfg2 |= 0x200;
                /* Phy mode bit */
                ifctrl &= ~(1 << 24);
@@ -239,6 +241,7 @@ void et1310_config_mac_regs2(struct et131x_adapter *adapter)
 void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
 {
        struct rxmac_regs __iomem *rxmac = &adapter->regs->rxmac;
+       struct phy_device *phydev = adapter->phydev;
        u32 sa_lo;
        u32 sa_hi = 0;
        u32 pf_ctrl = 0;
@@ -351,7 +354,7 @@ void et1310_config_rxmac_regs(struct et131x_adapter *adapter)
         * bit 16: Receive frame truncated.
         * bit 17: Drop packet enable
         */
-       if (adapter->linkspeed == TRUEPHY_SPEED_100MBPS)
+       if (phydev && phydev->speed == SPEED_100)
                writel(0x30038, &rxmac->mif_ctrl);
        else
                writel(0x30030, &rxmac->mif_ctrl);
index 12345c7d32d947c54172dd4bd5fb6b0d4b8534ec..c5d0d02f4ca1d1298cdb3a0dc38e66a4a9f66839 100644 (file)
@@ -440,6 +440,7 @@ void et131x_xcvr_init(struct et131x_adapter *adapter)
 void et131x_mii_check(struct et131x_adapter *adapter,
                      u16 bmsr, u16 bmsr_ints)
 {
+       struct phy_device *phydev = adapter->phydev;
        u8 link_status;
        u32 autoneg_status;
        u32 speed;
@@ -456,7 +457,7 @@ void et131x_mii_check(struct et131x_adapter *adapter,
                        dev_warn(&adapter->pdev->dev,
                            "Link down - cable problem ?\n");
 
-                       if (adapter->linkspeed == TRUEPHY_SPEED_10MBPS) {
+                       if (phydev && phydev->speed == SPEED_10) {
                                /* NOTE - Is there a way to query this without
                                 * TruePHY?
                                 * && TRU_QueryCoreType(adapter->hTruePhy, 0) ==
@@ -476,7 +477,6 @@ void et131x_mii_check(struct et131x_adapter *adapter,
 
                        netif_carrier_off(adapter->netdev);
 
-                       adapter->linkspeed = 0;
                        adapter->duplex_mode = 0;
 
                        /* Free the packets being actively sent & stopped */
@@ -516,12 +516,11 @@ void et131x_mii_check(struct et131x_adapter *adapter,
                                             &speed, &duplex, &mdi_mdix,
                                             &masterslave, &polarity);
 
-                       adapter->linkspeed = speed;
                        adapter->duplex_mode = duplex;
 
                        adapter->boot_coma = 20;
 
-                       if (adapter->linkspeed == TRUEPHY_SPEED_10MBPS) {
+                       if (phydev && phydev->speed == SPEED_10) {
                                /*
                                 * NOTE - Is there a way to query this without
                                 * TruePHY?
@@ -542,7 +541,7 @@ void et131x_mii_check(struct et131x_adapter *adapter,
 
                        et1310_config_flow_control(adapter);
 
-                       if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS &&
+                       if (phydev && phydev->speed == SPEED_1000 &&
                                        adapter->registry_jumbo_packet > 2048)
                                et1310_phy_and_or_reg(adapter, 0x16, 0xcfff,
                                                                   0x2000);
index 88dc8cdb6efdc65d353e9aa563b7fdd049f6072f..3e95c66dfde8273b1c3d030c9fe2b1899648084d 100644 (file)
@@ -242,11 +242,6 @@ struct mi_regs {
 #define TRUEPHY_MASK                    2
 #endif
 
-/* Define speeds */
-#define TRUEPHY_SPEED_10MBPS            0
-#define TRUEPHY_SPEED_100MBPS           1
-#define TRUEPHY_SPEED_1000MBPS          2
-
 /* Define duplex modes */
 #define TRUEPHY_DUPLEX_HALF             0
 #define TRUEPHY_DUPLEX_FULL             1
index f50420c582a1f05243a6a4ff4c7acfe51945275f..c402c5e61e407ae9d02bdc330d3ffc4b0e8b1635 100644 (file)
@@ -82,6 +82,7 @@
 #include <linux/skbuff.h>
 #include <linux/if_arp.h>
 #include <linux/ioport.h>
+#include <linux/phy.h>
 
 #include "et1310_phy.h"
 #include "et131x_adapter.h"
@@ -724,11 +725,15 @@ void et131x_config_rx_dma_regs(struct et131x_adapter *adapter)
  */
 void et131x_set_rx_dma_timer(struct et131x_adapter *adapter)
 {
+       struct phy_device *phydev = adapter->phydev;
+
+       if (!phydev)
+               return;
+
        /* For version B silicon, we do not use the RxDMA timer for 10 and 100
         * Mbits/s line rates. We do not enable and RxDMA interrupt coalescing.
         */
-       if ((adapter->linkspeed == TRUEPHY_SPEED_100MBPS) ||
-           (adapter->linkspeed == TRUEPHY_SPEED_10MBPS)) {
+       if ((phydev->speed == SPEED_100) || (phydev->speed == SPEED_10)) {
                writel(0, &adapter->regs->rxdma.max_pkt_time);
                writel(1, &adapter->regs->rxdma.num_pkt_done);
        }
index aa07138069fe24d1a79ba9959ad5ae4a37597983..1f806511f6c007b5e278960c376726de8545d94e 100644 (file)
@@ -82,6 +82,7 @@
 #include <linux/skbuff.h>
 #include <linux/if_arp.h>
 #include <linux/ioport.h>
+#include <linux/phy.h>
 
 #include "et1310_phy.h"
 #include "et131x_adapter.h"
@@ -287,6 +288,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
        u32 nr_frags = skb_shinfo(skb)->nr_frags + 1;
        struct skb_frag_struct *frags = &skb_shinfo(skb)->frags[0];
        unsigned long flags;
+       struct phy_device *phydev = adapter->phydev;
 
        /* Part of the optimizations of this send routine restrict us to
         * sending 24 fragments at a pass.  In practice we should never see
@@ -400,7 +402,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
        if (frag == 0)
                return -EIO;
 
-       if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS) {
+       if (phydev && phydev->speed == SPEED_1000) {
                if (++adapter->tx_ring.since_irq == PARM_TX_NUM_BUFS_DEF) {
                        /* Last element & Interrupt flag */
                        desc[frag - 1].flags = 0x5;
@@ -478,7 +480,7 @@ static int nic_send_packet(struct et131x_adapter *adapter, struct tcb *tcb)
        /* For Gig only, we use Tx Interrupt coalescing.  Enable the software
         * timer to wake us up if this packet isn't followed by N more.
         */
-       if (adapter->linkspeed == TRUEPHY_SPEED_1000MBPS) {
+       if (phydev && phydev->speed == SPEED_1000) {
                writel(PARM_TX_TIME_INT_DEF * NANO_IN_A_MICRO,
                       &adapter->regs->global.watchdog_timer);
        }
index fbefd2e88d86935bd8eb02e11cc9d50b09f9c2af..1e65e798282bf078a4bcf29cc91030121166c56f 100644 (file)
@@ -147,7 +147,6 @@ struct et131x_adapter {
 
        /* Flags that indicate current state of the adapter */
        u32 flags;
-       u32 hw_errs;
 
        /* Configuration  */
        u8 rom_addr[ETH_ALEN];
@@ -170,7 +169,6 @@ struct et131x_adapter {
 
        /* Packet Filter and look ahead size */
        u32 packet_filter;
-       u32 linkspeed;
        u32 duplex_mode;
 
        /* multicast list */
index 3cfcc2d07b73a7e7e53311898bf70977e9215a9c..eb08889e20b0783a37b66bacb336ba0c25a5e763 100644 (file)
@@ -678,12 +678,6 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,
        /* Copy address into the net_device struct */
        memcpy(netdev->dev_addr, adapter->addr, ETH_ALEN);
 
-       /* Setup et1310 as per the documentation */
-       et131x_adapter_setup(adapter);
-
-       /* Create a timer to count errors received by the NIC */
-       init_timer(&adapter->error_timer);
-
        adapter->error_timer.expires = jiffies + TX_ERROR_PERIOD * HZ / 1000;
        adapter->error_timer.function = et131x_error_timer_handler;
        adapter->error_timer.data = (unsigned long)adapter;
@@ -726,6 +720,12 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,
                goto err_mdio_unregister;
        }
 
+       /* Setup et1310 as per the documentation */
+       et131x_adapter_setup(adapter);
+
+       /* Create a timer to count errors received by the NIC */
+       init_timer(&adapter->error_timer);
+
        /* We can enable interrupts now
         *
         *  NOTE - Because registration of interrupt handler is done in the