Skip to contentSkip to conversation

r8169: switch to device-managed functions in probe (part 2)

PATCH In review Andy Shevchenko 2 participants 4 messages Feb 4, 2018 – Feb 6, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 r8169: switch to device-managed functions in probe (part 2)

This is a follow up to the commit

4c45d24a759d ("r8169: switch to device-managed functions in probe")

to move towards managed resources even more.

---
 drivers/net/ethernet/realtek/r8169.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/net/ethernet/realtek/r8169.c +4 -12
index 0bf7d1759250..88aa3728d674 100644
@@ -8397,7 +8397,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	struct rtl8169_private *tp;
 	struct mii_if_info *mii;
 	struct net_device *dev;
-	void __iomem *ioaddr;
 	int chipset, i;
 	int rc;
 
@@ -8455,20 +8454,13 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 		return -ENODEV;
 	}
 
-	rc = pci_request_regions(pdev, MODULENAME);
+	rc = pcim_iomap_regions(pdev, BIT(region), MODULENAME);
 	if (rc < 0) {
-		netif_err(tp, probe, dev, "could not request regions\n");
+		netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n");
 		return rc;
 	}
 
-	/* ioremap MMIO region */
-	ioaddr = devm_ioremap(&pdev->dev, pci_resource_start(pdev, region),
-			      R8169_REGS_SIZE);
-	if (!ioaddr) {
-		netif_err(tp, probe, dev, "cannot remap MMIO, aborting\n");
-		return -EIO;
-	}
-	tp->mmio_addr = ioaddr;
+	tp->mmio_addr = pcim_iomap_table(pdev)[region];
 
 	if (!pci_is_pcie(pdev))
 		netif_info(tp, probe, dev, "not PCI Express\n");
@@ -8667,7 +8659,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	pci_set_drvdata(pdev, dev);
 
 	netif_info(tp, probe, dev, "%s at 0x%p, %pM, XID %08x IRQ %d\n",
-		   rtl_chip_infos[chipset].name, ioaddr, dev->dev_addr,
+		   rtl_chip_infos[chipset].name, tp->mmio_addr, dev->dev_addr,
 		   (u32)(RTL_R32(TxConfig) & 0x9cf0f8ff), pdev->irq);
 	if (rtl_chip_infos[chipset].jumbo_max != JUMBO_1K) {
 		netif_info(tp, probe, dev, "jumbo features [frames: %d bytes, "
Signature · 1 line
2.15.1
#1 lore raw
Quoted 6 lines · Andy Shevchenko

This is a follow up to the commit

4c45d24a759d ("r8169: switch to device-managed functions in probe")

to move towards managed resources even more.

Oops, sorry, it's not ready-yet version.

Quoted 63 lines
---
 drivers/net/ethernet/realtek/r8169.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/net/ethernet/realtek/r8169.c +2 -8
index 0bf7d1759250..88aa3728d674 100644
@@ -8397,7 +8397,6 @@ static int rtl_init_one(struct pci_dev *pdev,
 const struct pci_device_id *ent)
 	struct rtl8169_private *tp;
 	struct mii_if_info *mii;
 	struct net_device *dev;
-	void __iomem *ioaddr;
 	int chipset, i;
 	int rc;
@@ -8455,20 +8454,13 @@ static int rtl_init_one(struct pci_dev *pdev,
 const struct pci_device_id *ent)
 		return -ENODEV;
 	}
 
-	rc = pci_request_regions(pdev, MODULENAME);
+	rc = pcim_iomap_regions(pdev, BIT(region), MODULENAME);
 	if (rc < 0) {
-		netif_err(tp, probe, dev, "could not request
 regions\n");
+		netif_err(tp, probe, dev, "cannot remap MMIO,
 aborting\n");
 		return rc;
 	}
 
-	/* ioremap MMIO region */
-	ioaddr = devm_ioremap(&pdev->dev, pci_resource_start(pdev,
 region),
-			      R8169_REGS_SIZE);
-	if (!ioaddr) {
-		netif_err(tp, probe, dev, "cannot remap MMIO,

aborting\n");

drivers/net/ethernet/realtek/r8169.c +2 -4
-		return -EIO;
-	}
-	tp->mmio_addr = ioaddr;
+	tp->mmio_addr = pcim_iomap_table(pdev)[region];
 
 	if (!pci_is_pcie(pdev))
 		netif_info(tp, probe, dev, "not PCI Express\n");
@@ -8667,7 +8659,7 @@ static int rtl_init_one(struct pci_dev *pdev,
 const struct pci_device_id *ent)
 	pci_set_drvdata(pdev, dev);
 
 	netif_info(tp, probe, dev, "%s at 0x%p, %pM, XID %08x IRQ
 %d\n",
-		   rtl_chip_infos[chipset].name, ioaddr, dev-
 >dev_addr,
+		   rtl_chip_infos[chipset].name, tp->mmio_addr, dev-
Quoted 1 line

dev_addr,

drivers/net/ethernet/realtek/r8169.c +0 -0
 		   (u32)(RTL_R32(TxConfig) & 0x9cf0f8ff), pdev->irq);
 	if (rtl_chip_infos[chipset].jumbo_max != JUMBO_1K) {
 		netif_info(tp, probe, dev, "jumbo features [frames:

%d bytes, "

Signature · 2 lines
Andy Shevchenko <[email protected]>
Intel Finland Oy
#2 lore raw
In reply to Andy Shevchenko
I love your patch! Yet something to improve:

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]
[also build test ERROR on next-20180206]
[cannot apply to v4.15]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Andy-Shevchenko/r8169-switch-to-device-managed-functions-in-probe-part-2/20180207-053113
config: x86_64-randconfig-x001-201805 (attached as .config)
compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025 reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

drivers/net//ethernet/realtek/r8169.c: In function 'rtl_init_one':

>> drivers/net//ethernet/realtek/r8169.c:102:43: error: 'ioaddr' undeclared (first use in this function); did you mean 'in_addr'?
    #define RTL_W8(reg, val8) writeb ((val8), ioaddr + (reg))
                                              ^
>> drivers/net//ethernet/realtek/r8169.c:8513:2: note: in expansion of macro 'RTL_W8'
     RTL_W8(Cfg9346, Cfg9346_Unlock);
     ^~~~~~
   drivers/net//ethernet/realtek/r8169.c:102:43: note: each undeclared identifier is reported only once for each function it appears in
    #define RTL_W8(reg, val8) writeb ((val8), ioaddr + (reg))
                                              ^
>> drivers/net//ethernet/realtek/r8169.c:8513:2: note: in expansion of macro 'RTL_W8'
     RTL_W8(Cfg9346, Cfg9346_Unlock);
     ^~~~~~

vim +102 drivers/net//ethernet/realtek/r8169.c

^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16 100

^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16  101  /* write/read MMIO register */
^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16 @102  #define RTL_W8(reg, val8)	writeb ((val8), ioaddr + (reg))
^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16  103  #define RTL_W16(reg, val16)	writew ((val16), ioaddr + (reg))
^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16  104  #define RTL_W32(reg, val32)	writel ((val32), ioaddr + (reg))
^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16  105  #define RTL_R8(reg)		readb (ioaddr + (reg))
^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16  106  #define RTL_R16(reg)		readw (ioaddr + (reg))
06f555f3 drivers/net/r8169.c Junchang Wang  2010-05-30  107  #define RTL_R32(reg)		readl (ioaddr + (reg))

^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16 108

:::::: The code at line 102 was first introduced by commit :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <[email protected]> :::::: CC: Linus Torvalds <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw
In reply to Andy Shevchenko
I love your patch! Yet something to improve:

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]
[cannot apply to v4.15]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Andy-Shevchenko/r8169-switch-to-device-managed-functions-in-probe-part-2/20180207-053113
config: i386-randconfig-a0-02070503 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4 reproduce:

        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

drivers/net/ethernet/realtek/r8169.c: In function 'rtl_init_one':

>> drivers/net/ethernet/realtek/r8169.c:102:43: error: 'ioaddr' undeclared (first use in this function)
    #define RTL_W8(reg, val8) writeb ((val8), ioaddr + (reg))
                                              ^
   drivers/net/ethernet/realtek/r8169.c:8513:2: note: in expansion of macro 'RTL_W8'
     RTL_W8(Cfg9346, Cfg9346_Unlock);
     ^
   drivers/net/ethernet/realtek/r8169.c:102:43: note: each undeclared identifier is reported only once for each function it appears in
    #define RTL_W8(reg, val8) writeb ((val8), ioaddr + (reg))
                                              ^
   drivers/net/ethernet/realtek/r8169.c:8513:2: note: in expansion of macro 'RTL_W8'
     RTL_W8(Cfg9346, Cfg9346_Unlock);
     ^

vim +/ioaddr +102 drivers/net/ethernet/realtek/r8169.c

^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16 100

^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16  101  /* write/read MMIO register */
^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16 @102  #define RTL_W8(reg, val8)	writeb ((val8), ioaddr + (reg))
^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16  103  #define RTL_W16(reg, val16)	writew ((val16), ioaddr + (reg))
^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16  104  #define RTL_W32(reg, val32)	writel ((val32), ioaddr + (reg))
^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16  105  #define RTL_R8(reg)		readb (ioaddr + (reg))
^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16  106  #define RTL_R16(reg)		readw (ioaddr + (reg))
06f555f3 drivers/net/r8169.c Junchang Wang  2010-05-30  107  #define RTL_R32(reg)		readl (ioaddr + (reg))

^1da177e drivers/net/r8169.c Linus Torvalds 2005-04-16 108

:::::: The code at line 102 was first introduced by commit :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <[email protected]> :::::: CC: Linus Torvalds <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation