linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] PCI: designware: Simplify config accessors
@ 2016-01-06 19:54 Bjorn Helgaas
  2016-01-06 19:55 ` [PATCH 1/2] PCI: designware: Simplify control flow Bjorn Helgaas
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2016-01-06 19:54 UTC (permalink / raw)
  To: Jingoo Han, Pratyush Anand; +Cc: linux-pci, linux-kernel

These make the code slightly smaller and easier to read but shouldn't make
any functional difference.

---

Bjorn Helgaas (2):
      PCI: designware: Simplify control flow
      PCI: designware: Make config accessor override checking symmetric


 drivers/pci/host/pcie-designware.c |   53 ++++++++++++------------------------
 1 file changed, 18 insertions(+), 35 deletions(-)

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

* [PATCH 1/2] PCI: designware: Simplify control flow
  2016-01-06 19:54 [PATCH 0/2] PCI: designware: Simplify config accessors Bjorn Helgaas
@ 2016-01-06 19:55 ` Bjorn Helgaas
  2016-01-06 19:55 ` [PATCH 2/2] PCI: designware: Make config accessor override checking symmetric Bjorn Helgaas
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2016-01-06 19:55 UTC (permalink / raw)
  To: Jingoo Han, Pratyush Anand; +Cc: linux-pci, linux-kernel

Return values immediately when possible to simplify the control flow.

No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pcie-designware.c |   53 ++++++++++++------------------------
 1 file changed, 18 insertions(+), 35 deletions(-)

diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 540f077..c104bad 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -128,27 +128,19 @@ static inline void dw_pcie_writel_rc(struct pcie_port *pp, u32 val, u32 reg)
 static int dw_pcie_rd_own_conf(struct pcie_port *pp, int where, int size,
 			       u32 *val)
 {
-	int ret;
-
 	if (pp->ops->rd_own_conf)
-		ret = pp->ops->rd_own_conf(pp, where, size, val);
-	else
-		ret = dw_pcie_cfg_read(pp->dbi_base + where, size, val);
+		return pp->ops->rd_own_conf(pp, where, size, val);
 
-	return ret;
+	return dw_pcie_cfg_read(pp->dbi_base + where, size, val);
 }
 
 static int dw_pcie_wr_own_conf(struct pcie_port *pp, int where, int size,
 			       u32 val)
 {
-	int ret;
-
 	if (pp->ops->wr_own_conf)
-		ret = pp->ops->wr_own_conf(pp, where, size, val);
-	else
-		ret = dw_pcie_cfg_write(pp->dbi_base + where, size, val);
+		return pp->ops->wr_own_conf(pp, where, size, val);
 
-	return ret;
+	return dw_pcie_cfg_write(pp->dbi_base + where, size, val);
 }
 
 static void dw_pcie_prog_outbound_atu(struct pcie_port *pp, int index,
@@ -384,8 +376,8 @@ int dw_pcie_link_up(struct pcie_port *pp)
 {
 	if (pp->ops->link_up)
 		return pp->ops->link_up(pp);
-	else
-		return 0;
+
+	return 0;
 }
 
 static int dw_pcie_msi_map(struct irq_domain *domain, unsigned int irq,
@@ -659,24 +651,19 @@ static int dw_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
 			int size, u32 *val)
 {
 	struct pcie_port *pp = bus->sysdata;
-	int ret;
 
 	if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0) {
 		*val = 0xffffffff;
 		return PCIBIOS_DEVICE_NOT_FOUND;
 	}
 
-	if (bus->number != pp->root_bus_nr)
-		if (pp->ops->rd_other_conf)
-			ret = pp->ops->rd_other_conf(pp, bus, devfn,
-						where, size, val);
-		else
-			ret = dw_pcie_rd_other_conf(pp, bus, devfn,
-						where, size, val);
-	else
-		ret = dw_pcie_rd_own_conf(pp, where, size, val);
+	if (bus->number == pp->root_bus_nr)
+		return dw_pcie_rd_own_conf(pp, where, size, val);
 
-	return ret;
+	if (pp->ops->rd_other_conf)
+		return pp->ops->rd_other_conf(pp, bus, devfn, where, size, val);
+
+	return dw_pcie_rd_other_conf(pp, bus, devfn, where, size, val);
 }
 
 static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
@@ -688,17 +675,13 @@ static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
 	if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0)
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
-	if (bus->number != pp->root_bus_nr)
-		if (pp->ops->wr_other_conf)
-			ret = pp->ops->wr_other_conf(pp, bus, devfn,
-						where, size, val);
-		else
-			ret = dw_pcie_wr_other_conf(pp, bus, devfn,
-						where, size, val);
-	else
-		ret = dw_pcie_wr_own_conf(pp, where, size, val);
+	if (bus->number == pp->root_bus_nr)
+		return dw_pcie_wr_own_conf(pp, where, size, val);
 
-	return ret;
+	if (pp->ops->wr_other_conf)
+		return pp->ops->wr_other_conf(pp, bus, devfn, where, size, val);
+
+	return dw_pcie_wr_other_conf(pp, bus, devfn, where, size, val);
 }
 
 static struct pci_ops dw_pcie_ops = {


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

* [PATCH 2/2] PCI: designware: Make config accessor override checking symmetric
  2016-01-06 19:54 [PATCH 0/2] PCI: designware: Simplify config accessors Bjorn Helgaas
  2016-01-06 19:55 ` [PATCH 1/2] PCI: designware: Simplify control flow Bjorn Helgaas
@ 2016-01-06 19:55 ` Bjorn Helgaas
  2016-01-07 10:27 ` [PATCH 0/2] PCI: designware: Simplify config accessors Pratyush Anand
  2016-01-07 17:28 ` Bjorn Helgaas
  3 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2016-01-06 19:55 UTC (permalink / raw)
  To: Jingoo Han, Pratyush Anand; +Cc: linux-pci, linux-kernel

Drivers based on the DesignWare core can override the config read accessors
by supplying rd_own_conf() and rd_other_conf() function pointers.
dw_pcie_rd_conf() calls dw_pcie_rd_own_conf() (for accesses to the root
bus) or dw_pcie_rd_other_conf():

  dw_pcie_rd_conf
    dw_pcie_rd_own_conf                # if on root bus
    dw_pcie_rd_other_conf              # if not on root bus

Previously we checked for rd_other_conf() directly in dw_pcie_rd_conf(),
but we checked for rd_own_conf() in dw_pcie_rd_own_conf().

Check for rd_other_conf() in dw_pcie_rd_other_conf() to make this symmetric
with the rd_own_conf() checking, and similarly for the write path.

No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/host/pcie-designware.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index c104bad..7a4ee06 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -564,6 +564,9 @@ static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
 	u64 cpu_addr;
 	void __iomem *va_cfg_base;
 
+	if (pp->ops->rd_other_conf)
+		return pp->ops->rd_other_conf(pp, bus, devfn, where, size, val);
+
 	busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) |
 		 PCIE_ATU_FUNC(PCI_FUNC(devfn));
 
@@ -598,6 +601,9 @@ static int dw_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus,
 	u64 cpu_addr;
 	void __iomem *va_cfg_base;
 
+	if (pp->ops->wr_other_conf)
+		return pp->ops->wr_other_conf(pp, bus, devfn, where, size, val);
+
 	busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) |
 		 PCIE_ATU_FUNC(PCI_FUNC(devfn));
 
@@ -660,9 +666,6 @@ static int dw_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
 	if (bus->number == pp->root_bus_nr)
 		return dw_pcie_rd_own_conf(pp, where, size, val);
 
-	if (pp->ops->rd_other_conf)
-		return pp->ops->rd_other_conf(pp, bus, devfn, where, size, val);
-
 	return dw_pcie_rd_other_conf(pp, bus, devfn, where, size, val);
 }
 
@@ -678,9 +681,6 @@ static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
 	if (bus->number == pp->root_bus_nr)
 		return dw_pcie_wr_own_conf(pp, where, size, val);
 
-	if (pp->ops->wr_other_conf)
-		return pp->ops->wr_other_conf(pp, bus, devfn, where, size, val);
-
 	return dw_pcie_wr_other_conf(pp, bus, devfn, where, size, val);
 }
 


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

* Re: [PATCH 0/2] PCI: designware: Simplify config accessors
  2016-01-06 19:54 [PATCH 0/2] PCI: designware: Simplify config accessors Bjorn Helgaas
  2016-01-06 19:55 ` [PATCH 1/2] PCI: designware: Simplify control flow Bjorn Helgaas
  2016-01-06 19:55 ` [PATCH 2/2] PCI: designware: Make config accessor override checking symmetric Bjorn Helgaas
@ 2016-01-07 10:27 ` Pratyush Anand
  2016-01-07 17:28 ` Bjorn Helgaas
  3 siblings, 0 replies; 5+ messages in thread
From: Pratyush Anand @ 2016-01-07 10:27 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: Jingoo Han, linux-pci, linux-kernel

On Thu, Jan 7, 2016 at 1:24 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> These make the code slightly smaller and easier to read but shouldn't make
> any functional difference.
>
> ---
>
> Bjorn Helgaas (2):
>       PCI: designware: Simplify control flow
>       PCI: designware: Make config accessor override checking symmetric
>

For both the patches
Acked-by: Pratyush Anand <pratyush.anand@gmail.com>

>
>  drivers/pci/host/pcie-designware.c |   53 ++++++++++++------------------------
>  1 file changed, 18 insertions(+), 35 deletions(-)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 0/2] PCI: designware: Simplify config accessors
  2016-01-06 19:54 [PATCH 0/2] PCI: designware: Simplify config accessors Bjorn Helgaas
                   ` (2 preceding siblings ...)
  2016-01-07 10:27 ` [PATCH 0/2] PCI: designware: Simplify config accessors Pratyush Anand
@ 2016-01-07 17:28 ` Bjorn Helgaas
  3 siblings, 0 replies; 5+ messages in thread
From: Bjorn Helgaas @ 2016-01-07 17:28 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: Jingoo Han, Pratyush Anand, linux-pci, linux-kernel

On Wed, Jan 06, 2016 at 01:54:59PM -0600, Bjorn Helgaas wrote:
> These make the code slightly smaller and easier to read but shouldn't make
> any functional difference.
> 
> ---
> 
> Bjorn Helgaas (2):
>       PCI: designware: Simplify control flow
>       PCI: designware: Make config accessor override checking symmetric

Applied with Pratyush's ack to pci/host-designware for v4.5.

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

end of thread, other threads:[~2016-01-07 17:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-06 19:54 [PATCH 0/2] PCI: designware: Simplify config accessors Bjorn Helgaas
2016-01-06 19:55 ` [PATCH 1/2] PCI: designware: Simplify control flow Bjorn Helgaas
2016-01-06 19:55 ` [PATCH 2/2] PCI: designware: Make config accessor override checking symmetric Bjorn Helgaas
2016-01-07 10:27 ` [PATCH 0/2] PCI: designware: Simplify config accessors Pratyush Anand
2016-01-07 17:28 ` Bjorn Helgaas

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).