linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: Reduce the scope for a variable in pci_bridge_release_resources()
@ 2025-08-23  7:51 Markus Elfring
  2025-08-25 10:13 ` Ilpo Järvinen
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2025-08-23  7:51 UTC (permalink / raw)
  To: linux-pci, Bjorn Helgaas; +Cc: LKML, Ilpo Järvinen

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 23 Aug 2025 09:40:13 +0200

* Move the definition for the local variable “old_flags”
  into an if branch.
* Put the assignment for the local variable “type” on a separate line.

The source code was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/pci/setup-bus.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 119f97b96480..38bf4e673bd7 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1714,7 +1714,6 @@ static void pci_bridge_release_resources(struct pci_bus *bus,
 {
 	struct pci_dev *dev = bus->self;
 	struct resource *r;
-	unsigned int old_flags;
 	struct resource *b_res;
 	int idx = 1;
 
@@ -1751,7 +1750,9 @@ static void pci_bridge_release_resources(struct pci_bus *bus,
 	/* If there are children, release them all */
 	release_child_resources(r);
 	if (!release_resource(r)) {
-		type = old_flags = r->flags & PCI_RES_TYPE_MASK;
+		unsigned int old_flags = r->flags & PCI_RES_TYPE_MASK;
+
+		type = old_flags;
 		pci_info(dev, "resource %d %pR released\n",
 			 PCI_BRIDGE_RESOURCES + idx, r);
 		/* Keep the old size */
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] PCI: Reduce the scope for a variable in pci_bridge_release_resources()
  2025-08-23  7:51 [PATCH] PCI: Reduce the scope for a variable in pci_bridge_release_resources() Markus Elfring
@ 2025-08-25 10:13 ` Ilpo Järvinen
  0 siblings, 0 replies; 2+ messages in thread
From: Ilpo Järvinen @ 2025-08-25 10:13 UTC (permalink / raw)
  To: Markus Elfring; +Cc: linux-pci, Bjorn Helgaas, LKML

[-- Attachment #1: Type: text/plain, Size: 2012 bytes --]

On Sat, 23 Aug 2025, Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 23 Aug 2025 09:40:13 +0200
> 
> * Move the definition for the local variable “old_flags”
>   into an if branch.
> * Put the assignment for the local variable “type” on a separate line.
> 
> The source code was transformed by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/pci/setup-bus.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index 119f97b96480..38bf4e673bd7 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -1714,7 +1714,6 @@ static void pci_bridge_release_resources(struct pci_bus *bus,
>  {
>  	struct pci_dev *dev = bus->self;
>  	struct resource *r;
> -	unsigned int old_flags;
>  	struct resource *b_res;
>  	int idx = 1;
>  
> @@ -1751,7 +1750,9 @@ static void pci_bridge_release_resources(struct pci_bus *bus,
>  	/* If there are children, release them all */
>  	release_child_resources(r);
>  	if (!release_resource(r)) {
> -		type = old_flags = r->flags & PCI_RES_TYPE_MASK;
> +		unsigned int old_flags = r->flags & PCI_RES_TYPE_MASK;
> +
> +		type = old_flags;
>  		pci_info(dev, "resource %d %pR released\n",
>  			 PCI_BRIDGE_RESOURCES + idx, r);
>  		/* Keep the old size */

My series is going to remove these variable altogether. A) One shouldn't 
be messing with type (flags) at all which this code the tried to work 
around by carrying the type information over the code that cleared it, and 
B) there's a gross hack in how type is being handled. Both are solved by 
my series.

Although, now that you posted this patch, I ended up realizing there's a 
transient problem in my series, the assignment to type got removed too 
early (should only be removed along with the type related hack, will be 
fixed by v2 of my series).

-- 
 i.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-25 10:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-23  7:51 [PATCH] PCI: Reduce the scope for a variable in pci_bridge_release_resources() Markus Elfring
2025-08-25 10:13 ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).