Skip to content

Commit c8d48d9

Browse files
hkallweitdavem330
authored andcommitted
r8169: improve pci region handling
The region to be used is always the first of type IORESOURCE_MEM. We can implement this rule directly w/o having to specify which region is the first one per configuration entry. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a4328dd commit c8d48d9

File tree

1 file changed

+5
-11
lines changed
  • drivers/net/ethernet/realtek

1 file changed

+5
-11
lines changed

drivers/net/ethernet/realtek/r8169.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7974,31 +7974,27 @@ static const struct net_device_ops rtl_netdev_ops = {
79747974

79757975
static const struct rtl_cfg_info {
79767976
void (*hw_start)(struct rtl8169_private *tp);
7977-
unsigned int region;
79787977
u16 event_slow;
79797978
unsigned int has_gmii:1;
79807979
const struct rtl_coalesce_info *coalesce_info;
79817980
u8 default_ver;
79827981
} rtl_cfg_infos [] = {
79837982
[RTL_CFG_0] = {
79847983
.hw_start = rtl_hw_start_8169,
7985-
.region = 1,
79867984
.event_slow = SYSErr | LinkChg | RxOverflow | RxFIFOOver,
79877985
.has_gmii = 1,
79887986
.coalesce_info = rtl_coalesce_info_8169,
79897987
.default_ver = RTL_GIGA_MAC_VER_01,
79907988
},
79917989
[RTL_CFG_1] = {
79927990
.hw_start = rtl_hw_start_8168,
7993-
.region = 2,
79947991
.event_slow = SYSErr | LinkChg | RxOverflow,
79957992
.has_gmii = 1,
79967993
.coalesce_info = rtl_coalesce_info_8168_8136,
79977994
.default_ver = RTL_GIGA_MAC_VER_11,
79987995
},
79997996
[RTL_CFG_2] = {
80007997
.hw_start = rtl_hw_start_8101,
8001-
.region = 2,
80027998
.event_slow = SYSErr | LinkChg | RxOverflow | RxFIFOOver |
80037999
PCSTimeout,
80048000
.coalesce_info = rtl_coalesce_info_8168_8136,
@@ -8098,11 +8094,10 @@ static void rtl_hw_initialize(struct rtl8169_private *tp)
80988094
static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
80998095
{
81008096
const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data;
8101-
const unsigned int region = cfg->region;
81028097
struct rtl8169_private *tp;
81038098
struct mii_if_info *mii;
81048099
struct net_device *dev;
8105-
int chipset, i;
8100+
int chipset, region, i;
81068101
int rc;
81078102

81088103
if (netif_msg_drv(&debug)) {
@@ -8144,11 +8139,10 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
81448139
if (pcim_set_mwi(pdev) < 0)
81458140
netif_info(tp, probe, dev, "Mem-Wr-Inval unavailable\n");
81468141

8147-
/* make sure PCI base addr 1 is MMIO */
8148-
if (!(pci_resource_flags(pdev, region) & IORESOURCE_MEM)) {
8149-
netif_err(tp, probe, dev,
8150-
"region #%d not an MMIO resource, aborting\n",
8151-
region);
8142+
/* use first MMIO region */
8143+
region = ffs(pci_select_bars(pdev, IORESOURCE_MEM)) - 1;
8144+
if (region < 0) {
8145+
netif_err(tp, probe, dev, "no MMIO resource found\n");
81528146
return -ENODEV;
81538147
}
81548148

0 commit comments

Comments
 (0)