Skip to content

Commit

Permalink
staging: et131x: Remove private adapter->linkspeed and use phydev->sp…
Browse files Browse the repository at this point in the history
…eed instead

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>
  • Loading branch information
Mark Einon authored and Greg Kroah-Hartman committed Sep 6, 2011
1 parent 740b7a2 commit 412f8e0
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 24 deletions.
7 changes: 5 additions & 2 deletions drivers/staging/et131x/et1310_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 4 additions & 5 deletions drivers/staging/et131x/et1310_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) ==
Expand All @@ -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 */
Expand Down Expand Up @@ -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?
Expand All @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions drivers/staging/et131x/et1310_phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions drivers/staging/et131x/et1310_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 4 additions & 2 deletions drivers/staging/et131x/et1310_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 0 additions & 2 deletions drivers/staging/et131x/et131x_adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -170,7 +169,6 @@ struct et131x_adapter {

/* Packet Filter and look ahead size */
u32 packet_filter;
u32 linkspeed;
u32 duplex_mode;

/* multicast list */
Expand Down
12 changes: 6 additions & 6 deletions drivers/staging/et131x/et131x_initpci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 412f8e0

Please sign in to comment.