mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-23 19:43:54 +07:00
c9c13ba428
Code that iterates over all standard PCI BARs typically uses PCI_STD_RESOURCE_END. However, that requires the unusual test "i <= PCI_STD_RESOURCE_END" rather than something the typical "i < PCI_STD_NUM_BARS". Add a definition for PCI_STD_NUM_BARS and change loops to use the more idiomatic C style to help avoid fencepost errors. Link: https://lore.kernel.org/r/20190927234026.23342-1-efremov@linux.com Link: https://lore.kernel.org/r/20190927234308.23935-1-efremov@linux.com Link: https://lore.kernel.org/r/20190916204158.6889-3-efremov@linux.com Signed-off-by: Denis Efremov <efremov@linux.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Sebastian Ott <sebott@linux.ibm.com> # arch/s390/ Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> # video/fbdev/ Acked-by: Gustavo Pimentel <gustavo.pimentel@synopsys.com> # pci/controller/dwc/ Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com> # scsi/pm8001/ Acked-by: Martin K. Petersen <martin.petersen@oracle.com> # scsi/pm8001/ Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # memstick/
79 lines
2.2 KiB
C
79 lines
2.2 KiB
C
/* Synopsys DesignWare Core Enterprise Ethernet (XLGMAC) Driver
|
|
*
|
|
* Copyright (c) 2017 Synopsys, Inc. (www.synopsys.com)
|
|
*
|
|
* This program is dual-licensed; you may select either version 2 of
|
|
* the GNU General Public License ("GPL") or BSD license ("BSD").
|
|
*
|
|
* This Synopsys DWC XLGMAC software driver and associated documentation
|
|
* (hereinafter the "Software") is an unsupported proprietary work of
|
|
* Synopsys, Inc. unless otherwise expressly agreed to in writing between
|
|
* Synopsys and you. The Software IS NOT an item of Licensed Software or a
|
|
* Licensed Product under any End User Software License Agreement or
|
|
* Agreement for Licensed Products with Synopsys or any supplement thereto.
|
|
* Synopsys is a registered trademark of Synopsys, Inc. Other names included
|
|
* in the SOFTWARE may be the trademarks of their respective owners.
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/pci.h>
|
|
|
|
#include "dwc-xlgmac.h"
|
|
#include "dwc-xlgmac-reg.h"
|
|
|
|
static int xlgmac_probe(struct pci_dev *pcidev, const struct pci_device_id *id)
|
|
{
|
|
struct device *dev = &pcidev->dev;
|
|
struct xlgmac_resources res;
|
|
int i, ret;
|
|
|
|
ret = pcim_enable_device(pcidev);
|
|
if (ret) {
|
|
dev_err(dev, "ERROR: failed to enable device\n");
|
|
return ret;
|
|
}
|
|
|
|
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
|
|
if (pci_resource_len(pcidev, i) == 0)
|
|
continue;
|
|
ret = pcim_iomap_regions(pcidev, BIT(i), XLGMAC_DRV_NAME);
|
|
if (ret)
|
|
return ret;
|
|
break;
|
|
}
|
|
|
|
pci_set_master(pcidev);
|
|
|
|
memset(&res, 0, sizeof(res));
|
|
res.irq = pcidev->irq;
|
|
res.addr = pcim_iomap_table(pcidev)[i];
|
|
|
|
return xlgmac_drv_probe(&pcidev->dev, &res);
|
|
}
|
|
|
|
static void xlgmac_remove(struct pci_dev *pcidev)
|
|
{
|
|
xlgmac_drv_remove(&pcidev->dev);
|
|
}
|
|
|
|
static const struct pci_device_id xlgmac_pci_tbl[] = {
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, 0x7302) },
|
|
{ 0 }
|
|
};
|
|
MODULE_DEVICE_TABLE(pci, xlgmac_pci_tbl);
|
|
|
|
static struct pci_driver xlgmac_pci_driver = {
|
|
.name = XLGMAC_DRV_NAME,
|
|
.id_table = xlgmac_pci_tbl,
|
|
.probe = xlgmac_probe,
|
|
.remove = xlgmac_remove,
|
|
};
|
|
|
|
module_pci_driver(xlgmac_pci_driver);
|
|
|
|
MODULE_DESCRIPTION(XLGMAC_DRV_DESC);
|
|
MODULE_VERSION(XLGMAC_DRV_VERSION);
|
|
MODULE_AUTHOR("Jie Deng <jiedeng@synopsys.com>");
|
|
MODULE_LICENSE("Dual BSD/GPL");
|