diff mbox series

[v2,2/2] PCI: artpec6: Remove local code block from within switch statement

Message ID 20210701204401.1636562-2-kw@linux.com (mailing list archive)
State Accepted
Delegated to: Lorenzo Pieralisi
Headers show
Series [v2,1/2] PCI: artpec6: Remove surplus break statement after return | expand

Commit Message

Krzysztof Wilczyński July 1, 2021, 8:44 p.m. UTC
At the moment, the switch statement in the artpec6_pcie_probe() has
a local code block where the local variable "val" is defined and
immediately used by the artpec6_pcie_readl() within this local scope.

This extra code block adds brackets at the same indentation level as the
switch statement itself which can hinder readability of the code.

Thus, move the variable "val" declaration and definition at the top of
the function where other variables are already present, and remove the
extra code block from within the select statement.  This also is the
preferred style in the PCI tree.

Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Krzysztof Wilczyński <kw@linux.com>
---
 drivers/pci/controller/dwc/pcie-artpec6.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Jesper Nilsson July 1, 2021, 9 p.m. UTC | #1
On Thu, Jul 01, 2021 at 10:44:01PM +0200, Krzysztof Wilczyński wrote:
> At the moment, the switch statement in the artpec6_pcie_probe() has
> a local code block where the local variable "val" is defined and
> immediately used by the artpec6_pcie_readl() within this local scope.
> 
> This extra code block adds brackets at the same indentation level as the
> switch statement itself which can hinder readability of the code.
> 
> Thus, move the variable "val" declaration and definition at the top of
> the function where other variables are already present, and remove the
> extra code block from within the select statement.  This also is the
> preferred style in the PCI tree.
> 
> Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
> Signed-off-by: Krzysztof Wilczyński <kw@linux.com>

Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>


/^JN - Jesper Nilsson
diff mbox series

Patch

diff --git a/drivers/pci/controller/dwc/pcie-artpec6.c b/drivers/pci/controller/dwc/pcie-artpec6.c
index 739871bece75..c91fc1954432 100644
--- a/drivers/pci/controller/dwc/pcie-artpec6.c
+++ b/drivers/pci/controller/dwc/pcie-artpec6.c
@@ -384,6 +384,7 @@  static int artpec6_pcie_probe(struct platform_device *pdev)
 	const struct artpec_pcie_of_data *data;
 	enum artpec_pcie_variants variant;
 	enum dw_pcie_device_mode mode;
+	u32 val;
 
 	match = of_match_device(artpec6_pcie_of_match, dev);
 	if (!match)
@@ -432,9 +433,7 @@  static int artpec6_pcie_probe(struct platform_device *pdev)
 		if (ret < 0)
 			return ret;
 		break;
-	case DW_PCIE_EP_TYPE: {
-		u32 val;
-
+	case DW_PCIE_EP_TYPE:
 		if (!IS_ENABLED(CONFIG_PCIE_ARTPEC6_EP))
 			return -ENODEV;
 
@@ -445,7 +444,6 @@  static int artpec6_pcie_probe(struct platform_device *pdev)
 		pci->ep.ops = &pcie_ep_ops;
 
 		return dw_pcie_ep_init(&pci->ep);
-	}
 	default:
 		dev_err(dev, "INVALID device type %d\n", artpec6_pcie->mode);
 	}