Skip to content

Commit 6f3955a

Browse files
Philipp Stannermstsirkin
authored andcommitted
vdpa: solidrun: Replace deprecated PCI functions
The PCI functions pcim_iomap_regions() pcim_iounmap_regions() pcim_iomap_table() have been deprecated by the PCI subsystem. Replace these functions with their successors pcim_iomap_region() and pcim_iounmap_region(). Signed-off-by: Philipp Stanner <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Stefano Garzarella <[email protected]>
1 parent 212c3a8 commit 6f3955a

File tree

1 file changed

+28
-29
lines changed

1 file changed

+28
-29
lines changed

drivers/vdpa/solidrun/snet_main.c

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -556,36 +556,38 @@ static const struct vdpa_config_ops snet_config_ops = {
556556
static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet)
557557
{
558558
char *name;
559-
int ret, i, mask = 0;
559+
unsigned short i;
560+
bool bars_found = false;
561+
562+
name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "psnet[%s]-bars", pci_name(pdev));
563+
if (!name)
564+
return -ENOMEM;
565+
560566
/* We don't know which BAR will be used to communicate..
561567
* We will map every bar with len > 0.
562568
*
563569
* Later, we will discover the BAR and unmap all other BARs.
564570
*/
565571
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
566-
if (pci_resource_len(pdev, i))
567-
mask |= (1 << i);
568-
}
572+
void __iomem *io;
569573

570-
/* No BAR can be used.. */
571-
if (!mask) {
572-
SNET_ERR(pdev, "Failed to find a PCI BAR\n");
573-
return -ENODEV;
574-
}
574+
if (pci_resource_len(pdev, i) == 0)
575+
continue;
575576

576-
name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "psnet[%s]-bars", pci_name(pdev));
577-
if (!name)
578-
return -ENOMEM;
577+
io = pcim_iomap_region(pdev, i, name);
578+
if (IS_ERR(io)) {
579+
SNET_ERR(pdev, "Failed to request and map PCI BARs\n");
580+
return PTR_ERR(io);
581+
}
579582

580-
ret = pcim_iomap_regions(pdev, mask, name);
581-
if (ret) {
582-
SNET_ERR(pdev, "Failed to request and map PCI BARs\n");
583-
return ret;
583+
psnet->bars[i] = io;
584+
bars_found = true;
584585
}
585586

586-
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
587-
if (mask & (1 << i))
588-
psnet->bars[i] = pcim_iomap_table(pdev)[i];
587+
/* No BAR can be used.. */
588+
if (!bars_found) {
589+
SNET_ERR(pdev, "Failed to find a PCI BAR\n");
590+
return -ENODEV;
589591
}
590592

591593
return 0;
@@ -594,20 +596,20 @@ static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet)
594596
static int snet_open_vf_bar(struct pci_dev *pdev, struct snet *snet)
595597
{
596598
char *name;
597-
int ret;
599+
void __iomem *io;
598600

599601
name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "snet[%s]-bars", pci_name(pdev));
600602
if (!name)
601603
return -ENOMEM;
602604

603605
/* Request and map BAR */
604-
ret = pcim_iomap_regions(pdev, BIT(snet->psnet->cfg.vf_bar), name);
605-
if (ret) {
606+
io = pcim_iomap_region(pdev, snet->psnet->cfg.vf_bar, name);
607+
if (IS_ERR(io)) {
606608
SNET_ERR(pdev, "Failed to request and map PCI BAR for a VF\n");
607-
return ret;
609+
return PTR_ERR(io);
608610
}
609611

610-
snet->bar = pcim_iomap_table(pdev)[snet->psnet->cfg.vf_bar];
612+
snet->bar = io;
611613

612614
return 0;
613615
}
@@ -656,15 +658,12 @@ static int psnet_detect_bar(struct psnet *psnet, u32 off)
656658

657659
static void psnet_unmap_unused_bars(struct pci_dev *pdev, struct psnet *psnet)
658660
{
659-
int i, mask = 0;
661+
unsigned short i;
660662

661663
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
662664
if (psnet->bars[i] && i != psnet->barno)
663-
mask |= (1 << i);
665+
pcim_iounmap_region(pdev, i);
664666
}
665-
666-
if (mask)
667-
pcim_iounmap_regions(pdev, mask);
668667
}
669668

670669
/* Read SNET config from PCI BAR */

0 commit comments

Comments
 (0)