Skip to contentSkip to conversation

i2c: designware: Consolidate pci_free_irq_vectors to a single place

PATCH In review Dejin Zheng 3 participants 5 messages Feb 14, 2021 – Feb 15, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: designware: Consolidate pci_free_irq_vectors to a single place

Consolidate pci_free_irq_vectors to a single place using "goto free_irq" for simplify the code.

---
 drivers/i2c/busses/i2c-designware-pcidrv.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
drivers/i2c/busses/i2c-designware-pcidrv.c +10 -12
index 55c83a7a24f3..f0c82e91870a 100644
@@ -234,10 +234,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
 
 	if (controller->setup) {
 		r = controller->setup(pdev, controller);
-		if (r) {
-			pci_free_irq_vectors(pdev);
-			return r;
-		}
+		if (r)
+			goto free_irq;
 	}
 
 	i2c_dw_adjust_bus_speed(dev);
@@ -246,10 +244,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
 		i2c_dw_acpi_configure(&pdev->dev);
 
 	r = i2c_dw_validate_speed(dev);
-	if (r) {
-		pci_free_irq_vectors(pdev);
-		return r;
-	}
+	if (r)
+		goto free_irq;
 
 	i2c_dw_configure(dev);
 
@@ -269,10 +265,8 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
 	adap->nr = controller->bus_num;
 
 	r = i2c_dw_probe(dev);
-	if (r) {
-		pci_free_irq_vectors(pdev);
-		return r;
-	}
+	if (r)
+		goto free_irq;
 
 	pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
 	pm_runtime_use_autosuspend(&pdev->dev);
@@ -280,6 +274,10 @@ static int i2c_dw_pci_probe(struct pci_dev *pdev,
 	pm_runtime_allow(&pdev->dev);
 
 	return 0;
+
+free_irq:
+	pci_free_irq_vectors(pdev);
+	return r;
 }
 
 static void i2c_dw_pci_remove(struct pci_dev *pdev)
Signature · 1 line
2.25.0
#2 lore raw
Quoted 10 lines · Jarkko Nikula
Quoted 8 lines · Dejin Zheng

Consolidate pci_free_irq_vectors to a single place using "goto free_irq" for simplify the code.

---
  drivers/i2c/busses/i2c-designware-pcidrv.c | 22 ++++++++++------------
  1 file changed, 10 insertions(+), 12 deletions(-)

Jarkko, Thanks!

Dejin

reviewer Reviewed-by on v1 1/1
#3 lore raw
In reply to Dejin Zheng
Quoted 2 lines · Dejin Zheng

Consolidate pci_free_irq_vectors to a single place using "goto free_irq" for simplify the code.

One nit below, after addressing:

...

Quoted 1 line

+free_irq:

It's quite confusing name. I would expect to see here (with current proposal) *free_irq() call, but no, I don't see a such.

Please, change to something like
err_pci_free_irq_vectors:
or alternatively
err_free_irq_vectors:
however I think first one is disambiguous.

Quoted 2 lines
drivers/i2c/busses/i2c-designware-pcidrv.c +2 -0
+	pci_free_irq_vectors(pdev);
+	return r;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Dejin Zheng

Consolidate pci_free_irq_vectors to a single place using "goto free_irq" for simplify the code.

FYI, you may rather to introduce a pcim_alloc_irq_vectors() and drop all these calls altogether.

Note to everybody: PCIm is not ideal, but this piece is being called whenever pcim_enable_device() makes resources manageable. The problem here is the naming.

Signature · 2 lines
With Best Regards,
Andy Shevchenko