[PATCH] powerpc/kernel: Change retrieval of pci_dn
Sam Bobroff
sam.bobroff at au1.ibm.com
Tue Aug 29 16:20:31 AEST 2017
On Mon, Aug 28, 2017 at 11:05:03AM -0500, Bryant G. Ly wrote:
> For a PCI device it's pci_dn can be retrieved from
> pdev->dev.archdata.firmware_data, PCI_DN(devnode), or parent's list.
> Thus, we should just use the generic function pci_get_pdn_by_devfn
> to get the pci_dn.
>
> Signed-off-by: Bryant G. Ly <bgly at us.ibm.com>
Reviewed-by: Sam Bobroff <sam.bobroff at au1.ibm.com>
I don't know this area but I tested it using a patched kernel with the
old and new code together. My test kernel booted fine (in QEMU+KVM) and
I saw 26 reads and 4 writes, all of which got the same value with either
code block.
I also checked that the error result in the "not found" case is the same
as well, which it is, because rtas_{read,write}_config() will return
PCIBIOS_DEVICE_NOT_FOUND if given a NULL pdn.
So, looks good to me.
Cheers,
Sam.
> ---
> arch/powerpc/kernel/rtas_pci.c | 30 ++----------------------------
> 1 file changed, 2 insertions(+), 28 deletions(-)
>
> diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
> index 73f1934..c21e6c5 100644
> --- a/arch/powerpc/kernel/rtas_pci.c
> +++ b/arch/powerpc/kernel/rtas_pci.c
> @@ -91,25 +91,13 @@ static int rtas_pci_read_config(struct pci_bus *bus,
> unsigned int devfn,
> int where, int size, u32 *val)
> {
> - struct device_node *busdn, *dn;
> struct pci_dn *pdn;
> - bool found = false;
> int ret;
>
> /* Search only direct children of the bus */
> *val = 0xFFFFFFFF;
> - busdn = pci_bus_to_OF_node(bus);
> - for (dn = busdn->child; dn; dn = dn->sibling) {
> - pdn = PCI_DN(dn);
> - if (pdn && pdn->devfn == devfn
> - && of_device_is_available(dn)) {
> - found = true;
> - break;
> - }
> - }
>
> - if (!found)
> - return PCIBIOS_DEVICE_NOT_FOUND;
> + pdn = pci_get_pdn_by_devfn(bus, devfn);
>
> ret = rtas_read_config(pdn, where, size, val);
> if (*val == EEH_IO_ERROR_VALUE(size) &&
> @@ -153,23 +141,9 @@ static int rtas_pci_write_config(struct pci_bus *bus,
> unsigned int devfn,
> int where, int size, u32 val)
> {
> - struct device_node *busdn, *dn;
> struct pci_dn *pdn;
> - bool found = false;
> -
> - /* Search only direct children of the bus */
> - busdn = pci_bus_to_OF_node(bus);
> - for (dn = busdn->child; dn; dn = dn->sibling) {
> - pdn = PCI_DN(dn);
> - if (pdn && pdn->devfn == devfn
> - && of_device_is_available(dn)) {
> - found = true;
> - break;
> - }
> - }
>
> - if (!found)
> - return PCIBIOS_DEVICE_NOT_FOUND;
> + pdn = pci_get_pdn_by_devfn(bus, devfn);
>
> return rtas_write_config(pdn, where, size, val);
> }
> --
> 2.5.4 (Apple Git-61)
More information about the Linuxppc-dev
mailing list