PCI: remove type return
PATCH 1/1 PCI: remove type return
I can see that the function pci_hp_add_brigde have a int return propagation. But in the drivers that pci_hp_add_bridge is called, your return never is cheked.
This make me a think that the add bridge for pci hotplug drivers is not crucial for functionaly and your failed only should show a message in logs.
Then, I maked this patch for remove your return propagation for this moment.
--- drivers/pci/pci.h | 2 +- drivers/pci/probe.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/pci/pci.h +1 -1
@@ -189,7 +189,7 @@ static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; }#endif /* Functions for PCI Hotplug drivers to use */ -int pci_hp_add_bridge (struct pci_dev *dev); +void pci_hp_add_bridge (struct pci_dev *dev);#if defined(CONFIG_SYSFS ) && defined(HAVE_PCI_LEGACY )void pci_create_legacy_files (struct pci_bus *bus);
drivers/pci/probe.c +3 -4
@@ -3352,7 +3352,7 @@ void __init pci_sort_breadthfirst(void)bus_sort_breadthfirst (&pci_bus_type, &pci_sort_bf_cmp); } -int pci_hp_add_bridge (struct pci_dev *dev) +void pci_hp_add_bridge (struct pci_dev *dev) {struct pci_bus *parent = dev->bus;int busnr, start = parent->busn_res.start;
@@ -3365,7 +3365,7 @@ int pci_hp_add_bridge(struct pci_dev *dev) }if (busnr-- > end) {pci_err (dev,"No bus number available for hot-added bridge\n" ); -return -1 ; +return ; }/* Scan bridges that are already configured */
@@ -3381,8 +3381,7 @@ int pci_hp_add_bridge(struct pci_dev *dev)pci_scan_bridge_extend (parent, dev, busnr, available_buses,1 );if (!dev->subordinate) -return -1 ; +pci_err (dev,"No bus subordinate" ); -return 0 ; }EXPORT_SYMBOL_GPL (pci_hp_add_bridge);
Signature · 1 line
2.46.0
Quoted 1 line · Guilherme Giacomo Simoes
I can see that the function
pci_hp_add_brigdehave a int return propagation.
typo in function name. Add parenthesis after function names like this:pci_hp_add_bridge()
Quoted 2 lines
But in the drivers that
pci_hp_add_bridgeis called, your return never is cheked.
checked.
Quoted 2 lines
This make me a think that the add bridge for pci hotplug drivers is not crucial for functionaly and your failed only should show a message in logs.
functionality
Quoted 2 lines
Then, I maked this patch for remove your return propagation for this moment.
Please write the commit message using imperative tone. Don't use "I", "me", "you", "your", or "we" at all.
Also, you need to signoff your patches (please read Documentation/process/submitting-patches.rst).
The lack of return value checking seems to be on the list in pci_hp_add_bridge(). So perhaps the right course of action would be to handle return values correctly.
Signature · 1 line
i.
Quoted 51 lines
--- drivers/pci/pci.h | 2 +- drivers/pci/probe.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-)drivers/pci/pci.h +1
-1@@ -189,7 +189,7 @@ static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; }#endif /* Functions for PCI Hotplug drivers to use */ -int pci_hp_add_bridge (struct pci_dev *dev); +void pci_hp_add_bridge (struct pci_dev *dev);#if defined(CONFIG_SYSFS ) && defined(HAVE_PCI_LEGACY )void pci_create_legacy_files (struct pci_bus *bus);drivers/pci/probe.c +3
-4@@ -3352,7 +3352,7 @@ void __init pci_sort_breadthfirst(void)bus_sort_breadthfirst (&pci_bus_type, &pci_sort_bf_cmp); } -int pci_hp_add_bridge (struct pci_dev *dev) +void pci_hp_add_bridge (struct pci_dev *dev) {struct pci_bus *parent = dev->bus;int busnr, start = parent->busn_res.start;@@ -3365,7 +3365,7 @@ int pci_hp_add_bridge(struct pci_dev *dev) }if (busnr-- > end) {pci_err (dev,"No bus number available for hot-added bridge\n" ); -return -1 ; +return ; }/* Scan bridges that are already configured */ @@ -3381,8 +3381,7 @@ int pci_hp_add_bridge(struct pci_dev *dev)pci_scan_bridge_extend (parent, dev, busnr, available_buses,1 );if (!dev->subordinate) -return -1 ; +pci_err (dev,"No bus subordinate" ); -return 0 ; }EXPORT_SYMBOL_GPL (pci_hp_add_bridge);
Quoted 27 lines · Ilpo Järvinen
Quoted 1 line · Guilherme Giacomo Simoes
I can see that the function
pci_hp_add_brigdehave a int return propagation.typo in function name. Add parenthesis after function names like this:
pci_hp_add_bridge()Quoted 2 lines
But in the drivers that
pci_hp_add_bridgeis called, your return never is cheked.checked.
Quoted 2 lines
This make me a think that the add bridge for pci hotplug drivers is not crucial for functionaly and your failed only should show a message in logs.
functionality
Quoted 2 lines
Then, I maked this patch for remove your return propagation for this moment.
Please write the commit message using imperative tone. Don't use "I", "me", "you", "your", or "we" at all.
Also, you need to signoff your patches (please read
Documentation/process/submitting-patches.rst).
Quoted 7 lines
The lack of return value checking seems to be on the list in
pci_hp_add_bridge(). So perhaps the right course of action would be to handle return values correctly.--
i.
Ok, so if the right course is for the driver to handle return value, then this is a
task for the driver developers, because only they know what to do when pci_hp_add_bridge() doesn't work correctly, right?
Quoted 7 lines · Guilherme Giácomo Simões
Quoted 4 lines · Ilpo Järvinen
Quoted 2 lines · Guilherme Giacomo Simoes
I can see that the function
pci_hp_add_brigdehave a int return propagation....
Quoted 8 lines
Quoted 3 lines
The lack of return value checking seems to be on the list in
pci_hp_add_bridge(). So perhaps the right course of action would be to handle return values correctly.Ok, so if the right course is for the driver to handle return value, then this is a
task for the driver developers, because only they know what to do whenpci_hp_add_bridge()doesn't work correctly, right?
pci_hp_add_bridge() is only for hotplug drivers, so the list of callers is short and completely under our control. There's plenty of opportunity for improving this. Beyond just the return value, all the callers of pci_hp_add_bridge() should be doing much of the same work that could potentially be factored out.
Bjorn
Quoted 18 lines · Bjorn Helgaas
Quoted 7 lines · Guilherme Giácomo Simões
Quoted 4 lines · Ilpo Järvinen
Quoted 2 lines · Guilherme Giacomo Simoes
I can see that the function
pci_hp_add_brigdehave a int return propagation....
Quoted 8 lines
Quoted 3 lines
The lack of return value checking seems to be on the list in
pci_hp_add_bridge(). So perhaps the right course of action would be to handle return values correctly.Ok, so if the right course is for the driver to handle return value, then this is a
task for the driver developers, because only they know what to do whenpci_hp_add_bridge()doesn't work correctly, right?
Quoted 7 lines
pci_hp_add_bridge()is only for hotplug drivers, so the list of callers is short and completely under our control. There's plenty of opportunity for improving this. Beyond just the return value, all the callers ofpci_hp_add_bridge()should be doing much of the same work that could potentially be factored out.Bjorn
Okay, then what the action that the drivers must be do when the add bridge is failed?
Guilherme Giácomo Simões <[email protected]> write:
Quoted 26 lines
Quoted 24 lines · Bjorn Helgaas
Quoted 7 lines · Guilherme Giácomo Simões
Quoted 4 lines · Ilpo Järvinen
Quoted 2 lines · Guilherme Giacomo Simoes
I can see that the function
pci_hp_add_brigdehave a int return propagation....
Quoted 8 lines
Quoted 3 lines
The lack of return value checking seems to be on the list in
pci_hp_add_bridge(). So perhaps the right course of action would be to handle return values correctly.Ok, so if the right course is for the driver to handle return value, then this is a
task for the driver developers, because only they know what to do whenpci_hp_add_bridge()doesn't work correctly, right?
pci_hp_add_bridge()is only for hotplug drivers, so the list of callers is short and completely under our control. There's plenty of opportunity for improving this. Beyond just the return value, all the callers ofpci_hp_add_bridge()should be doing much of the same work that could potentially be factored out.
Quoted 4 lines
Quoted 1 line
Bjorn
Okay, then what the action that the drivers must be do when the add bridge is failed?
Maybe we can make a change to the drivers that use pci_hp_add_brigde() to check the return of the function and return an error to its caller like this:
ret = pci_hp_add_bridge(dev);
if (ret)
goto out;
I have looked at all the drivers that use pci_hp_add_brigde() and they all have an out flag to call pci_unlock_rescan_remove() to unlock the mutex and return a code.
We can return in the out flag the code that is the return of pci_hp_add_brigde() and
then we can set that return code to some #define to identify the error that is returned.
Quoted 19 lines · Guilherme Giácomo Simões
Quoted 18 lines · Bjorn Helgaas
Quoted 15 lines · Guilherme Giácomo Simões
Quoted 4 lines · Ilpo Järvinen
Quoted 2 lines · Guilherme Giacomo Simoes
I can see that the function
pci_hp_add_brigdehave a int return propagation....
Quoted 3 lines
The lack of return value checking seems to be on the list in
pci_hp_add_bridge(). So perhaps the right course of action would be to handle return values correctly.Ok, so if the right course is for the driver to handle return value, then this is a
task for the driver developers, because only they know what to do whenpci_hp_add_bridge()doesn't work correctly, right?
Quoted 8 lines
Quoted 5 lines
pci_hp_add_bridge()is only for hotplug drivers, so the list of callers is short and completely under our control. There's plenty of opportunity for improving this. Beyond just the return value, all the callers ofpci_hp_add_bridge()should be doing much of the same work that could potentially be factored out.Okay, then what the action that the drivers must be do when the add bridge is failed?
pci_hp_add_bridge() fails when there's no bus number available to assign to new hot-added devices. When that happens, there's really nothing the hotplug drivers can do to improve the situation. pci_hp_add_bridge() already logs a message for one of the failure cases. It may be that it should also log a message for the other failure case. The end result is that we can't use the hot-added devices because there's no space for them in the PCI bus number space, so we can't address them.
Bjorn