vdpa: solidrun: Replace deprecated PCI functions
Subsystems (2)
PATCH v4 1/1 vdpa: solidrun: Replace deprecated PCI functions
From: Philipp Stanner <[email protected]>
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().
---
Changes in v4:
- snet_open_vf_bar(): use distinct temporary variable to ensure
snet->bar is never an ERR_PTR. (Stefano)
Changes in v3:
- Move __iomem *io declaration into the loop. (Stefano)
Changes in v2:
- Fix build warning because of dead variable.
- Make "bars_found" a boolean, since only true or false are relevant.
--- drivers/vdpa/solidrun/snet_main.c | 57 +++++++++++++++---------------- 1 file changed, 28 insertions(+), 29 deletions(-)
drivers/vdpa/solidrun/snet_main.c +28 -29
@@ -556,58 +556,60 @@ static const struct vdpa_config_ops snet_config_ops = {static int psnet_open_pf_bar (struct pci_dev *pdev,struct psnet *psnet) {char *name; -int ret, i, mask =0 ; +unsigned short i; +bool bars_found = false; + + name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"psnet[%s]-bars" ,pci_name (pdev)); +if (!name) +return -ENOMEM ; +/* We don't know which BAR will be used to communicate.. * We will map every bar with len > 0. * * Later, we will discover the BAR and unmap all other BARs. */ for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (pci_resource_len (pdev, i)) - mask |= (1 << i); +void __iomem *io; + +if (pci_resource_len (pdev, i) ==0 ) +continue ; + + io =pcim_iomap_region (pdev, i, name); +if (IS_ERR (io)) { +SNET_ERR (pdev,"Failed to request and map PCI BARs\n" ); +return PTR_ERR (io); + } + + psnet->bars[i] = io; + bars_found = true; }/* No BAR can be used.. */ -if (!mask) { +if (!bars_found) {SNET_ERR (pdev,"Failed to find a PCI BAR\n" );return -ENODEV ; } - name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"psnet[%s]-bars" ,pci_name (pdev)); -if (!name) -return -ENOMEM ; - - ret =pcim_iomap_regions (pdev, mask, name); -if (ret) { -SNET_ERR (pdev,"Failed to request and map PCI BARs\n" ); -return ret; - } - -for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (mask & (1 << i)) - psnet->bars[i] =pcim_iomap_table (pdev)[i]; - } -return 0 ; }static int snet_open_vf_bar (struct pci_dev *pdev,struct snet *snet) {char *name; -int ret; +void __iomem *io; name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"snet[%s]-bars" ,pci_name (pdev));if (!name)return -ENOMEM ;/* Request and map BAR */ - ret =pcim_iomap_regions (pdev,BIT (snet->psnet->cfg.vf_bar), name); -if (ret) { + io =pcim_iomap_region (pdev, snet->psnet->cfg.vf_bar, name); +if (IS_ERR (io)) {SNET_ERR (pdev,"Failed to request and map PCI BAR for a VF\n" ); -return ret; +return PTR_ERR (io); } - snet->bar =pcim_iomap_table (pdev)[snet->psnet->cfg.vf_bar]; + snet->bar = io;return 0 ; }
@@ -656,15 +658,12 @@ static int psnet_detect_bar(struct psnet *psnet, u32 off)static void psnet_unmap_unused_bars (struct pci_dev *pdev,struct psnet *psnet) { -int i, mask =0 ; +unsigned short i;for (i =0 ; i <PCI_STD_NUM_BARS ; i++) {if (psnet->bars[i] && i != psnet->barno) - mask |= (1 << i); +pcim_iounmap_region (pdev, i); } - -if (mask) -pcim_iounmap_regions (pdev, mask); }/* Read SNET config from PCI BAR */
Signature · 1 line
2.47.1
Quoted 10 lines · Philipp Stanner
From: Philipp Stanner <[email protected]>
The PCI functions
pcim_iomap_regions()
pcim_iounmap_regions()
pcim_iomap_table()have been deprecated by the PCI subsystem.
Quoted 8 lines
Replace these functions with their successors
pcim_iomap_region()andpcim_iounmap_region().Signed-off-by Philipp Stanner <[email protected]>---
Changes in v4:
-snet_open_vf_bar(): use distinct temporary variable to ensuresnet->baris never anERR_PTR. (Stefano)
Thanks for that!
I don't have a device to test, but it LGTM:
Quoted 122 lines
Changes in v3:
- Move__iomem*io declaration into the loop. (Stefano)Changes in v2:
- Fix build warning because of dead variable.
- Make "bars_found" a boolean, since only true or false are relevant.
---drivers/vdpa/solidrun/snet_main.c| 57 +++++++++++++++----------------1 file changed, 28 insertions(+), 29 deletions(-)drivers/vdpa/solidrun/snet_main.c +28
-29@@ -556,58 +556,60 @@ static const struct vdpa_config_ops snet_config_ops = {static int psnet_open_pf_bar (struct pci_dev *pdev,struct psnet *psnet) {char *name; -int ret, i, mask =0 ; +unsigned short i; +bool bars_found = false; + + name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"psnet[%s]-bars" ,pci_name (pdev)); +if (!name) +return -ENOMEM ; +/* We don't know which BAR will be used to communicate.. * We will map every bar with len > 0. * * Later, we will discover the BAR and unmap all other BARs. */ for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (pci_resource_len (pdev, i)) - mask |= (1 << i); +void __iomem *io; + +if (pci_resource_len (pdev, i) ==0 ) +continue ; + + io =pcim_iomap_region (pdev, i, name); +if (IS_ERR (io)) { +SNET_ERR (pdev,"Failed to request and map PCI BARs\n" ); +return PTR_ERR (io); + } + + psnet->bars[i] = io; + bars_found = true; }/* No BAR can be used.. */ -if (!mask) { +if (!bars_found) {SNET_ERR (pdev,"Failed to find a PCI BAR\n" );return -ENODEV ; } - name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"psnet[%s]-bars" ,pci_name (pdev)); -if (!name) -return -ENOMEM ; - - ret =pcim_iomap_regions (pdev, mask, name); -if (ret) { -SNET_ERR (pdev,"Failed to request and map PCI BARs\n" ); -return ret; - } - -for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (mask & (1 << i)) - psnet->bars[i] =pcim_iomap_table (pdev)[i]; - } -return 0 ; }static int snet_open_vf_bar (struct pci_dev *pdev,struct snet *snet) {char *name; -int ret; +void __iomem *io; name =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"snet[%s]-bars" ,pci_name (pdev));if (!name)return -ENOMEM ;/* Request and map BAR */ - ret =pcim_iomap_regions (pdev,BIT (snet->psnet->cfg.vf_bar), name); -if (ret) { + io =pcim_iomap_region (pdev, snet->psnet->cfg.vf_bar, name); +if (IS_ERR (io)) {SNET_ERR (pdev,"Failed to request and map PCI BAR for a VF\n" ); -return ret; +return PTR_ERR (io); } - snet->bar =pcim_iomap_table (pdev)[snet->psnet->cfg.vf_bar]; + snet->bar = io;return 0 ; }@@ -656,15 +658,12 @@ static int psnet_detect_bar(struct psnet *psnet, u32 off)static void psnet_unmap_unused_bars (struct pci_dev *pdev,struct psnet *psnet) { -int i, mask =0 ; +unsigned short i;for (i =0 ; i <PCI_STD_NUM_BARS ; i++) {if (psnet->bars[i] && i != psnet->barno) - mask |= (1 << i); +pcim_iounmap_region (pdev, i); } - -if (mask) -pcim_iounmap_regions (pdev, mask); }/* Read SNET config from PCI BAR */ Signature · 1 line
2.47.1
Quoted 21 lines · Stefano Garzarella
Quoted 14 lines · Philipp Stanner
From: Philipp Stanner <[email protected]>
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()andpcim_iounmap_region().Quoted 5 lines
Signed-off-by Philipp Stanner <[email protected]>---
Changes in v4:
-snet_open_vf_bar(): use distinct temporary variable to ensuresnet->baris never anERR_PTR. (Stefano)
Quoted 5 lines
Thanks for that!
I don't have a device to test, but it LGTM:
Hi all,
can someone please finally merge this?
Thanks,
Philipp
Quoted 144 lines
Quoted 143 lines
Changes in v3:
- Move__iomem*io declaration into the loop. (Stefano)Changes in v2:
- Fix build warning because of dead variable.
- Make "bars_found" a boolean, since only true or false are relevant.
---drivers/vdpa/solidrun/snet_main.c| 57 +++++++++++++++-------------
---1 file changed, 28 insertions(+), 29 deletions(-)drivers/vdpa/solidrun/snet_main.c +0
-0@@ -556,58 +556,60 @@ static const struct vdpa_config_ops snet_config_ops = {static int
psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet){ char *name;drivers/vdpa/solidrun/snet_main.c +4
-1-int ret, i, mask =0 ; +unsigned short i; +bool bars_found = false; + + name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "psnet[%s]-bars",
pci_name(pdev));drivers/vdpa/solidrun/snet_main.c +3
-0+if (!name) +return -ENOMEM ; +/* We don't know which BAR will be used to communicate.. * We will map every bar with len > 0. * * Later, we will discover the BAR and unmap all other BARs. */ for (i = 0; i < PCI_STD_NUM_BARS; i++) {drivers/vdpa/solidrun/snet_main.c +8
-2-if (pci_resource_len (pdev, i)) - mask |= (1 << i); +void __iomem *io; + +if (pci_resource_len (pdev, i) ==0 ) +continue ; + + io =pcim_iomap_region (pdev, i, name); +if (IS_ERR (io)) { + SNET_ERR(pdev, "Failed to request and mapPCI BARs\n");
drivers/vdpa/solidrun/snet_main.c +5
-0+return PTR_ERR (io); + } + + psnet->bars[i] = io; + bars_found = true;} /* No BAR can be used.. */drivers/vdpa/solidrun/snet_main.c +1
-1-if (!mask) { +if (!bars_found) {SNET_ERR(pdev, "Failed to find a PCI BAR\n"); return -ENODEV; }drivers/vdpa/solidrun/snet_main.c +0
-1- name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "psnet[%s]-bars",
pci_name(pdev));drivers/vdpa/solidrun/snet_main.c +0
-6-if (!name) -return -ENOMEM ; - - ret =pcim_iomap_regions (pdev, mask, name); -if (ret) { - SNET_ERR(pdev, "Failed to request and map PCIBARs\n");
drivers/vdpa/solidrun/snet_main.c +0
-6-return ret; - } - -for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (mask & (1 << i)) - psnet->bars[i] =pcim_iomap_table(pdev)[i];
drivers/vdpa/solidrun/snet_main.c +0
-2- } -return 0; }static int
snet_open_vf_bar(struct pci_dev *pdev, struct snet *snet){ char *name;drivers/vdpa/solidrun/snet_main.c +1
-1-int ret; +void __iomem *io;name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "snet[%s]- bars", pci_name(pdev)); if (!name) return -ENOMEM; /* Request and map BAR */drivers/vdpa/solidrun/snet_main.c +0
-1- ret = pcim_iomap_regions(pdev, BIT(snet->psnet-Quoted 1 line
cfg.vf_bar), name);
drivers/vdpa/solidrun/snet_main.c +1
-1-if (ret) { + io = pcim_iomap_region(pdev, snet->psnet->cfg.vf_bar,name);
drivers/vdpa/solidrun/snet_main.c +1
-0+if (IS_ERR (io)) {SNET_ERR(pdev, "Failed to request and map PCI BAR
for a VF\n");drivers/vdpa/solidrun/snet_main.c +1
-1-return ret; +return PTR_ERR (io);}drivers/vdpa/solidrun/snet_main.c +0
-1- snet->bar = pcim_iomap_table(pdev)[snet->psnet-Quoted 1 line
cfg.vf_bar];
drivers/vdpa/solidrun/snet_main.c +1
-0+ snet->bar = io;return 0; }drivers/vdpa/solidrun/snet_main.c +0
-0@@ -656,15 +658,12 @@ static int psnet_detect_bar(struct psnet *psnet, u32 off)static void
psnet_unmap_unused_bars(struct pci_dev *pdev, struct psnet *psnet)
{drivers/vdpa/solidrun/snet_main.c +1
-1-int i, mask =0 ; +unsigned short i;for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (psnet->bars[i] && i != psnet->barno)drivers/vdpa/solidrun/snet_main.c +1
-1- mask |= (1 << i); +pcim_iounmap_region (pdev, i);}drivers/vdpa/solidrun/snet_main.c +0
-3- -if (mask) -pcim_iounmap_regions (pdev, mask);}
/* Read SNET config from PCI BAR */
Signature · 1 line
2.47.1
Michael S. Tsirkin
maintainerQuoted 26 lines · Philipp Stanner
Quoted 25 lines · Stefano Garzarella
Quoted 14 lines · Philipp Stanner
From: Philipp Stanner <[email protected]>
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()andpcim_iounmap_region().Quoted 5 lines
Signed-off-by Philipp Stanner <[email protected]>---
Changes in v4:
-snet_open_vf_bar(): use distinct temporary variable to ensuresnet->baris never anERR_PTR. (Stefano)Thanks for that!
I don't have a device to test, but it LGTM:
Quoted 154 lines
Quoted 1 line
Hi all,
can someone please finally merge this?
Thanks,
PhilippQuoted 144 lines
Quoted 143 lines
Changes in v3:
- Move__iomem*io declaration into the loop. (Stefano)Changes in v2:
- Fix build warning because of dead variable.
- Make "bars_found" a boolean, since only true or false are relevant.
---drivers/vdpa/solidrun/snet_main.c| 57 +++++++++++++++-------------
---1 file changed, 28 insertions(+), 29 deletions(-)drivers/vdpa/solidrun/snet_main.c +0
-0@@ -556,58 +556,60 @@ static const struct vdpa_config_ops snet_config_ops = {static int
psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet){ char *name;drivers/vdpa/solidrun/snet_main.c +4
-1-int ret, i, mask =0 ; +unsigned short i; +bool bars_found = false; + + name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "psnet[%s]-bars",
pci_name(pdev));drivers/vdpa/solidrun/snet_main.c +3
-0+if (!name) +return -ENOMEM ; +/* We don't know which BAR will be used to communicate.. * We will map every bar with len > 0. * * Later, we will discover the BAR and unmap all other BARs. */ for (i = 0; i < PCI_STD_NUM_BARS; i++) {drivers/vdpa/solidrun/snet_main.c +8
-2-if (pci_resource_len (pdev, i)) - mask |= (1 << i); +void __iomem *io; + +if (pci_resource_len (pdev, i) ==0 ) +continue ; + + io =pcim_iomap_region (pdev, i, name); +if (IS_ERR (io)) { + SNET_ERR(pdev, "Failed to request and mapPCI BARs\n");
drivers/vdpa/solidrun/snet_main.c +5
-0+return PTR_ERR (io); + } + + psnet->bars[i] = io; + bars_found = true;} /* No BAR can be used.. */drivers/vdpa/solidrun/snet_main.c +1
-1-if (!mask) { +if (!bars_found) {SNET_ERR(pdev, "Failed to find a PCI BAR\n"); return -ENODEV; }drivers/vdpa/solidrun/snet_main.c +0
-1- name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "psnet[%s]-bars",
pci_name(pdev));drivers/vdpa/solidrun/snet_main.c +0
-6-if (!name) -return -ENOMEM ; - - ret =pcim_iomap_regions (pdev, mask, name); -if (ret) { - SNET_ERR(pdev, "Failed to request and map PCIBARs\n");
drivers/vdpa/solidrun/snet_main.c +0
-6-return ret; - } - -for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (mask & (1 << i)) - psnet->bars[i] =pcim_iomap_table(pdev)[i];
drivers/vdpa/solidrun/snet_main.c +0
-2- } -return 0; }static int
snet_open_vf_bar(struct pci_dev *pdev, struct snet *snet){ char *name;drivers/vdpa/solidrun/snet_main.c +1
-1-int ret; +void __iomem *io;name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "snet[%s]- bars", pci_name(pdev)); if (!name) return -ENOMEM; /* Request and map BAR */drivers/vdpa/solidrun/snet_main.c +0
-1- ret = pcim_iomap_regions(pdev, BIT(snet->psnet-Quoted 1 line
cfg.vf_bar), name);
drivers/vdpa/solidrun/snet_main.c +1
-1-if (ret) { + io = pcim_iomap_region(pdev, snet->psnet->cfg.vf_bar,name);
drivers/vdpa/solidrun/snet_main.c +1
-0+if (IS_ERR (io)) {SNET_ERR(pdev, "Failed to request and map PCI BAR
for a VF\n");drivers/vdpa/solidrun/snet_main.c +1
-1-return ret; +return PTR_ERR (io);}drivers/vdpa/solidrun/snet_main.c +0
-1- snet->bar = pcim_iomap_table(pdev)[snet->psnet-Quoted 1 line
cfg.vf_bar];
drivers/vdpa/solidrun/snet_main.c +1
-0+ snet->bar = io;return 0; }drivers/vdpa/solidrun/snet_main.c +0
-0@@ -656,15 +658,12 @@ static int psnet_detect_bar(struct psnet *psnet, u32 off)static void
psnet_unmap_unused_bars(struct pci_dev *pdev, struct psnet *psnet)
{drivers/vdpa/solidrun/snet_main.c +1
-1-int i, mask =0 ; +unsigned short i;for (i = 0; i < PCI_STD_NUM_BARS; i++) { if (psnet->bars[i] && i != psnet->barno)drivers/vdpa/solidrun/snet_main.c +1
-1- mask |= (1 << i); +pcim_iounmap_region (pdev, i);}drivers/vdpa/solidrun/snet_main.c +0
-3- -if (mask) -pcim_iounmap_regions (pdev, mask);}
/* Read SNET config from PCI BAR */
Signature · 1 line
2.47.1
it's in my tree and linux-next