diff mbox

[v4,5/6] PCI: aardvark: Introduce an advk_pcie_valid_device() helper

Message ID 20180406145536.19637-6-thomas.petazzoni@bootlin.com (mailing list archive)
State New, archived
Headers show

Commit Message

Thomas Petazzoni April 6, 2018, 2:55 p.m. UTC
In other to mimic other PCIe host controller drivers, introduce an
advk_pcie_valid_device() helper, used in the configuration read/write
functions.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
Changes since v4:
 - Move later into the series, so that it doesn't need to be pushed as
   a fix for stable.
Changes since v3:
 - Make the new helper return a bool instead of int
Changes since v2:
 - New patch
---
 drivers/pci/host/pci-aardvark.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Comments

Lorenzo Pieralisi June 27, 2018, 4:51 p.m. UTC | #1
On Fri, Apr 06, 2018 at 04:55:35PM +0200, Thomas Petazzoni wrote:
> In other to mimic other PCIe host controller drivers, introduce an
> advk_pcie_valid_device() helper, used in the configuration read/write
> functions.
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> ---
> Changes since v4:
>  - Move later into the series, so that it doesn't need to be pushed as
>    a fix for stable.
> Changes since v3:
>  - Make the new helper return a bool instead of int
> Changes since v2:
>  - New patch
> ---
>  drivers/pci/host/pci-aardvark.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)

Hi Thomas,

please rebase patch 5 (this patch) and 6 and resend, I will apply them
straight away, sorry for the delay.

Thanks,
Lorenzo

> diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c
> index 9abf549631b4..69c4fd50947e 100644
> --- a/drivers/pci/host/pci-aardvark.c
> +++ b/drivers/pci/host/pci-aardvark.c
> @@ -431,6 +431,15 @@ static int advk_pcie_wait_pio(struct advk_pcie *pcie)
>  	return -ETIMEDOUT;
>  }
>  
> +static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus,
> +				  int devfn)
> +{
> +	if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0)
> +		return false;
> +
> +	return true;
> +}
> +
>  static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
>  			     int where, int size, u32 *val)
>  {
> @@ -438,7 +447,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
>  	u32 reg;
>  	int ret;
>  
> -	if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) {
> +	if (!advk_pcie_valid_device(pcie, bus, devfn)) {
>  		*val = 0xffffffff;
>  		return PCIBIOS_DEVICE_NOT_FOUND;
>  	}
> @@ -492,7 +501,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
>  	int offset;
>  	int ret;
>  
> -	if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0)
> +	if (!advk_pcie_valid_device(pcie, bus, devfn))
>  		return PCIBIOS_DEVICE_NOT_FOUND;
>  
>  	if (where % size)
> -- 
> 2.14.3
>
Lorenzo Pieralisi June 27, 2018, 5:18 p.m. UTC | #2
On Wed, Jun 27, 2018 at 05:51:24PM +0100, Lorenzo Pieralisi wrote:
> On Fri, Apr 06, 2018 at 04:55:35PM +0200, Thomas Petazzoni wrote:
> > In other to mimic other PCIe host controller drivers, introduce an
> > advk_pcie_valid_device() helper, used in the configuration read/write
> > functions.
> > 
> > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> > ---
> > Changes since v4:
> >  - Move later into the series, so that it doesn't need to be pushed as
> >    a fix for stable.
> > Changes since v3:
> >  - Make the new helper return a bool instead of int
> > Changes since v2:
> >  - New patch
> > ---
> >  drivers/pci/host/pci-aardvark.c | 13 +++++++++++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> Hi Thomas,
> 
> please rebase patch 5 (this patch) and 6 and resend, I will apply them
> straight away, sorry for the delay.

Never mind, I handled the host->controller dir move myself, applied both
to pci/aardvark for v4.19, thanks.

Lorenzo

> Thanks,
> Lorenzo
> 
> > diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c
> > index 9abf549631b4..69c4fd50947e 100644
> > --- a/drivers/pci/host/pci-aardvark.c
> > +++ b/drivers/pci/host/pci-aardvark.c
> > @@ -431,6 +431,15 @@ static int advk_pcie_wait_pio(struct advk_pcie *pcie)
> >  	return -ETIMEDOUT;
> >  }
> >  
> > +static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus,
> > +				  int devfn)
> > +{
> > +	if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0)
> > +		return false;
> > +
> > +	return true;
> > +}
> > +
> >  static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
> >  			     int where, int size, u32 *val)
> >  {
> > @@ -438,7 +447,7 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
> >  	u32 reg;
> >  	int ret;
> >  
> > -	if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) {
> > +	if (!advk_pcie_valid_device(pcie, bus, devfn)) {
> >  		*val = 0xffffffff;
> >  		return PCIBIOS_DEVICE_NOT_FOUND;
> >  	}
> > @@ -492,7 +501,7 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
> >  	int offset;
> >  	int ret;
> >  
> > -	if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0)
> > +	if (!advk_pcie_valid_device(pcie, bus, devfn))
> >  		return PCIBIOS_DEVICE_NOT_FOUND;
> >  
> >  	if (where % size)
> > -- 
> > 2.14.3
> >
Thomas Petazzoni June 27, 2018, 6:52 p.m. UTC | #3
Hello,

On Wed, 27 Jun 2018 18:18:11 +0100, Lorenzo Pieralisi wrote:

> > please rebase patch 5 (this patch) and 6 and resend, I will apply them
> > straight away, sorry for the delay.  
> 
> Never mind, I handled the host->controller dir move myself, applied both
> to pci/aardvark for v4.19, thanks.

Great, thanks for doing this. I'm working on other Aardvark patches, so
I'll make sure to rebase on top of the latest changes.

Thanks,

Thomas
diff mbox

Patch

diff --git a/drivers/pci/host/pci-aardvark.c b/drivers/pci/host/pci-aardvark.c
index 9abf549631b4..69c4fd50947e 100644
--- a/drivers/pci/host/pci-aardvark.c
+++ b/drivers/pci/host/pci-aardvark.c
@@ -431,6 +431,15 @@  static int advk_pcie_wait_pio(struct advk_pcie *pcie)
 	return -ETIMEDOUT;
 }
 
+static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus,
+				  int devfn)
+{
+	if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0)
+		return false;
+
+	return true;
+}
+
 static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
 			     int where, int size, u32 *val)
 {
@@ -438,7 +447,7 @@  static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn,
 	u32 reg;
 	int ret;
 
-	if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0) {
+	if (!advk_pcie_valid_device(pcie, bus, devfn)) {
 		*val = 0xffffffff;
 		return PCIBIOS_DEVICE_NOT_FOUND;
 	}
@@ -492,7 +501,7 @@  static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
 	int offset;
 	int ret;
 
-	if ((bus->number == pcie->root_bus_nr) && PCI_SLOT(devfn) != 0)
+	if (!advk_pcie_valid_device(pcie, bus, devfn))
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
 	if (where % size)