Skip to content

Commit e364e4c

Browse files
committed
Merge branch 'stmmac-several-pci-related-improvements'
Philipp Stanner says: ==================== stmmac: Several PCI-related improvements ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 071ccde + 45b7616 commit e364e4c

File tree

2 files changed

+12
-39
lines changed

2 files changed

+12
-39
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,10 @@ static int loongson_dwmac_fix_reset(void *priv, void __iomem *ioaddr)
533533
static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id *id)
534534
{
535535
struct plat_stmmacenet_data *plat;
536+
struct stmmac_resources res = {};
536537
struct stmmac_pci_info *info;
537-
struct stmmac_resources res;
538538
struct loongson_data *ld;
539-
int ret, i;
539+
int ret;
540540

541541
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
542542
if (!plat)
@@ -566,17 +566,10 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_id
566566
pci_set_master(pdev);
567567

568568
/* Get the base address of device */
569-
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
570-
if (pci_resource_len(pdev, i) == 0)
571-
continue;
572-
ret = pcim_iomap_regions(pdev, BIT(0), DRIVER_NAME);
573-
if (ret)
574-
goto err_disable_device;
575-
break;
576-
}
577-
578-
memset(&res, 0, sizeof(res));
579-
res.addr = pcim_iomap_table(pdev)[0];
569+
res.addr = pcim_iomap_region(pdev, 0, DRIVER_NAME);
570+
ret = PTR_ERR_OR_ZERO(res.addr);
571+
if (ret)
572+
goto err_disable_device;
580573

581574
plat->bsp_priv = ld;
582575
plat->setup = loongson_dwmac_setup;
@@ -624,7 +617,6 @@ static void loongson_dwmac_remove(struct pci_dev *pdev)
624617
struct net_device *ndev = dev_get_drvdata(&pdev->dev);
625618
struct stmmac_priv *priv = netdev_priv(ndev);
626619
struct loongson_data *ld;
627-
int i;
628620

629621
ld = priv->plat->bsp_priv;
630622
stmmac_dvr_remove(&pdev->dev);
@@ -635,13 +627,6 @@ static void loongson_dwmac_remove(struct pci_dev *pdev)
635627
if (ld->loongson_id == DWMAC_CORE_LS_MULTICHAN)
636628
loongson_dwmac_msi_clear(pdev);
637629

638-
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
639-
if (pci_resource_len(pdev, i) == 0)
640-
continue;
641-
pcim_iounmap_regions(pdev, BIT(i));
642-
break;
643-
}
644-
645630
pci_disable_device(pdev);
646631
}
647632

drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
155155
{
156156
struct stmmac_pci_info *info = (struct stmmac_pci_info *)id->driver_data;
157157
struct plat_stmmacenet_data *plat;
158-
struct stmmac_resources res;
159-
int i;
158+
struct stmmac_resources res = {};
160159
int ret;
160+
int i;
161161

162162
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
163163
if (!plat)
@@ -192,9 +192,9 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
192192
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
193193
if (pci_resource_len(pdev, i) == 0)
194194
continue;
195-
ret = pcim_iomap_regions(pdev, BIT(i), pci_name(pdev));
196-
if (ret)
197-
return ret;
195+
res.addr = pcim_iomap_region(pdev, i, STMMAC_RESOURCE_NAME);
196+
if (IS_ERR(res.addr))
197+
return PTR_ERR(res.addr);
198198
break;
199199
}
200200

@@ -204,8 +204,6 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
204204
if (ret)
205205
return ret;
206206

207-
memset(&res, 0, sizeof(res));
208-
res.addr = pcim_iomap_table(pdev)[i];
209207
res.wol_irq = pdev->irq;
210208
res.irq = pdev->irq;
211209

@@ -226,21 +224,11 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
226224
* stmmac_pci_remove
227225
*
228226
* @pdev: platform device pointer
229-
* Description: this function calls the main to free the net resources
230-
* and releases the PCI resources.
227+
* Description: this function calls the main to free the net resources.
231228
*/
232229
static void stmmac_pci_remove(struct pci_dev *pdev)
233230
{
234-
int i;
235-
236231
stmmac_dvr_remove(&pdev->dev);
237-
238-
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
239-
if (pci_resource_len(pdev, i) == 0)
240-
continue;
241-
pcim_iounmap_regions(pdev, BIT(i));
242-
break;
243-
}
244232
}
245233

246234
static int __maybe_unused stmmac_pci_suspend(struct device *dev)

0 commit comments

Comments
 (0)