Skip to content

Commit 9c7df91

Browse files
Matt Carlsondavem330
authored andcommitted
tg3: Use devfn to determine function number
The driver sometimes needs to know which function number the current device is. This patch changes the code to use devfn over internal register values. Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 57d8b88 commit 9c7df91

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

drivers/net/tg3.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,13 +1085,9 @@ static int tg3_mdio_init(struct tg3 *tp)
10851085
struct phy_device *phydev;
10861086

10871087
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717) {
1088-
u32 funcnum, is_serdes;
1088+
u32 is_serdes;
10891089

1090-
funcnum = tr32(TG3_CPMU_STATUS) & TG3_CPMU_STATUS_PCIE_FUNC;
1091-
if (funcnum)
1092-
tp->phy_addr = 2;
1093-
else
1094-
tp->phy_addr = 1;
1090+
tp->phy_addr = PCI_FUNC(tp->pdev->devfn) + 1;
10951091

10961092
if (tp->pci_chip_rev_id != CHIPREV_ID_5717_A0)
10971093
is_serdes = tr32(SG_DIG_STATUS) & SG_DIG_IS_SERDES;
@@ -13608,7 +13604,7 @@ static int __devinit tg3_get_device_address(struct tg3 *tp)
1360813604
else
1360913605
tg3_nvram_unlock(tp);
1361013606
} else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5717) {
13611-
if (tr32(TG3_CPMU_STATUS) & TG3_CPMU_STATUS_PCIE_FUNC)
13607+
if (PCI_FUNC(tp->pdev->devfn))
1361213608
mac_offset = 0xcc;
1361313609
} else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906)
1361413610
mac_offset = 0x10;

drivers/net/tg3.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,10 +1073,8 @@
10731073
#define TG3_CPMU_HST_ACC 0x0000361c
10741074
#define CPMU_HST_ACC_MACCLK_MASK 0x001f0000
10751075
#define CPMU_HST_ACC_MACCLK_6_25 0x00130000
1076-
/* 0x3620 --> 0x362c unused */
1076+
/* 0x3620 --> 0x3630 unused */
10771077

1078-
#define TG3_CPMU_STATUS 0x0000362c
1079-
#define TG3_CPMU_STATUS_PCIE_FUNC 0x20000000
10801078
#define TG3_CPMU_CLCK_STAT 0x00003630
10811079
#define CPMU_CLCK_STAT_MAC_CLCK_MASK 0x001f0000
10821080
#define CPMU_CLCK_STAT_MAC_CLCK_62_5 0x00000000

0 commit comments

Comments
 (0)