diff mbox

[29/30] i7300_idle: deprecate pci_get_bus_and_slot()

Message ID 1511328675-21981-30-git-send-email-okaya@codeaurora.org (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Sinan Kaya Nov. 22, 2017, 5:31 a.m. UTC
pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as
where a PCI device is present. This restricts the device drivers to be
reused for other domain numbers.

Use pci_get_domain_bus_and_slot() with a domain number of 0 where we can't
extract the domain number. Other places, use the actual domain number from
the device.

Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
 include/linux/i7300_idle.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Greg KH Nov. 22, 2017, 7:53 a.m. UTC | #1
On Wed, Nov 22, 2017 at 12:31:14AM -0500, Sinan Kaya wrote:
> pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as
> where a PCI device is present. This restricts the device drivers to be
> reused for other domain numbers.
> 
> Use pci_get_domain_bus_and_slot() with a domain number of 0 where we can't
> extract the domain number. Other places, use the actual domain number from
> the device.
> 
> Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
> ---
>  include/linux/i7300_idle.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/i7300_idle.h b/include/linux/i7300_idle.h
> index 4dbe651..58cd9c6 100644
> --- a/include/linux/i7300_idle.h
> +++ b/include/linux/i7300_idle.h
> @@ -48,7 +48,7 @@ static inline int i7300_idle_platform_probe(struct pci_dev **fbd_dev,
>  	int i;
>  	struct pci_dev *memdev, *dmadev;
>  
> -	memdev = pci_get_bus_and_slot(MEMCTL_BUS, MEMCTL_DEVFN);
> +	memdev = pci_get_domain_bus_and_slot(0, MEMCTL_BUS, MEMCTL_DEVFN);

You have a pci_dev, why can't you use it here to get the domain?

>  	if (!memdev)
>  		return -ENODEV;
>  
> @@ -61,7 +61,7 @@ static inline int i7300_idle_platform_probe(struct pci_dev **fbd_dev,
>  	if (pci_tbl[i].vendor == 0)
>  		return -ENODEV;
>  
> -	dmadev = pci_get_bus_and_slot(IOAT_BUS, IOAT_DEVFN);
> +	dmadev = pci_get_domain_bus_and_slot(0, IOAT_BUS, IOAT_DEVFN);

Same here.

thanks,

greg k-h
Sinan Kaya Nov. 22, 2017, 4:15 p.m. UTC | #2
On 11/22/2017 2:53 AM, Greg Kroah-Hartman wrote:
>> +++ b/include/linux/i7300_idle.h
>> @@ -48,7 +48,7 @@ static inline int i7300_idle_platform_probe(struct pci_dev **fbd_dev,
>>  	int i;
>>  	struct pci_dev *memdev, *dmadev;
>>  
>> -	memdev = pci_get_bus_and_slot(MEMCTL_BUS, MEMCTL_DEVFN);
>> +	memdev = pci_get_domain_bus_and_slot(0, MEMCTL_BUS, MEMCTL_DEVFN);
> You have a pci_dev, why can't you use it here to get the domain?
> 

Both fbd_dev and ioat_dev are output parameters. 

dmadev = pci_get_bus_and_slot(IOAT_BUS, IOAT_DEVFN);
memdev = pci_get_bus_and_slot(MEMCTL_BUS, MEMCTL_DEVFN);

	for (i = 0; fbd_ioat_list[i].vendor != 0; i++) {
		if (dmadev->vendor == fbd_ioat_list[i].vendor &&
		    dmadev->device == fbd_ioat_list[i].ioat_dev) {
			if (!(fbd_ioat_list[i].enabled || enable_all))
				continue;

			if (fbd_dev)
				*fbd_dev = memdev;
			if (ioat_dev)
				*ioat_dev = dmadev;

Funny thing is nobody is calling this function. Maybe, I should just kill it
instead.
Greg KH Nov. 22, 2017, 4:45 p.m. UTC | #3
On Wed, Nov 22, 2017 at 11:15:47AM -0500, Sinan Kaya wrote:
> On 11/22/2017 2:53 AM, Greg Kroah-Hartman wrote:
> >> +++ b/include/linux/i7300_idle.h
> >> @@ -48,7 +48,7 @@ static inline int i7300_idle_platform_probe(struct pci_dev **fbd_dev,
> >>  	int i;
> >>  	struct pci_dev *memdev, *dmadev;
> >>  
> >> -	memdev = pci_get_bus_and_slot(MEMCTL_BUS, MEMCTL_DEVFN);
> >> +	memdev = pci_get_domain_bus_and_slot(0, MEMCTL_BUS, MEMCTL_DEVFN);
> > You have a pci_dev, why can't you use it here to get the domain?
> > 
> 
> Both fbd_dev and ioat_dev are output parameters. 
> 
> dmadev = pci_get_bus_and_slot(IOAT_BUS, IOAT_DEVFN);
> memdev = pci_get_bus_and_slot(MEMCTL_BUS, MEMCTL_DEVFN);
> 
> 	for (i = 0; fbd_ioat_list[i].vendor != 0; i++) {
> 		if (dmadev->vendor == fbd_ioat_list[i].vendor &&
> 		    dmadev->device == fbd_ioat_list[i].ioat_dev) {
> 			if (!(fbd_ioat_list[i].enabled || enable_all))
> 				continue;
> 
> 			if (fbd_dev)
> 				*fbd_dev = memdev;
> 			if (ioat_dev)
> 				*ioat_dev = dmadev;
> 
> Funny thing is nobody is calling this function. Maybe, I should just kill it
> instead.

Yes, delete it.  Why doesn't the build warn about it not being used?

thanks,

greg k-h
Sinan Kaya Nov. 22, 2017, 4:50 p.m. UTC | #4
On 11/22/2017 11:45 AM, Greg Kroah-Hartman wrote:
>> Funny thing is nobody is calling this function. Maybe, I should just kill it
>> instead.
> Yes, delete it.  Why doesn't the build warn about it not being used?
> 

OK. Because it is in a header file that nobody includes.
Greg KH Nov. 22, 2017, 4:58 p.m. UTC | #5
On Wed, Nov 22, 2017 at 11:50:53AM -0500, Sinan Kaya wrote:
> On 11/22/2017 11:45 AM, Greg Kroah-Hartman wrote:
> >> Funny thing is nobody is calling this function. Maybe, I should just kill it
> >> instead.
> > Yes, delete it.  Why doesn't the build warn about it not being used?
> > 
> 
> OK. Because it is in a header file that nobody includes.

Even better, just delete the whole file!  :)
diff mbox

Patch

diff --git a/include/linux/i7300_idle.h b/include/linux/i7300_idle.h
index 4dbe651..58cd9c6 100644
--- a/include/linux/i7300_idle.h
+++ b/include/linux/i7300_idle.h
@@ -48,7 +48,7 @@  static inline int i7300_idle_platform_probe(struct pci_dev **fbd_dev,
 	int i;
 	struct pci_dev *memdev, *dmadev;
 
-	memdev = pci_get_bus_and_slot(MEMCTL_BUS, MEMCTL_DEVFN);
+	memdev = pci_get_domain_bus_and_slot(0, MEMCTL_BUS, MEMCTL_DEVFN);
 	if (!memdev)
 		return -ENODEV;
 
@@ -61,7 +61,7 @@  static inline int i7300_idle_platform_probe(struct pci_dev **fbd_dev,
 	if (pci_tbl[i].vendor == 0)
 		return -ENODEV;
 
-	dmadev = pci_get_bus_and_slot(IOAT_BUS, IOAT_DEVFN);
+	dmadev = pci_get_domain_bus_and_slot(0, IOAT_BUS, IOAT_DEVFN);
 	if (!dmadev)
 		return -ENODEV;