Commit ae65a391 authored by linas's avatar linas Committed by Paul Mackerras

[PATCH] ppc64: uniform usage of bus unit id interfaces

01-pci-dn-uniformization.patch

This patch changes the rtas_pci interface to use the new struct pci_dn
structure for two routines that work with pci device nodes.

This patch also does some minor janitorial work: it uses some handy macros
and cleans up some trailing whitespace in the affected file.
Signed-off-by: default avatarLinas Vepstas <linas@austin.ibm.com>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent 77ac166f
...@@ -71,10 +71,6 @@ ...@@ -71,10 +71,6 @@
* and sent out for processing. * and sent out for processing.
*/ */
/** Bus Unit ID macros; get low and hi 32-bits of the 64-bit BUID */
#define BUID_HI(buid) ((buid) >> 32)
#define BUID_LO(buid) ((buid) & 0xffffffff)
/* EEH event workqueue setup. */ /* EEH event workqueue setup. */
static DEFINE_SPINLOCK(eeh_eventlist_lock); static DEFINE_SPINLOCK(eeh_eventlist_lock);
LIST_HEAD(eeh_eventlist); LIST_HEAD(eeh_eventlist);
......
...@@ -47,7 +47,7 @@ static int write_pci_config; ...@@ -47,7 +47,7 @@ static int write_pci_config;
static int ibm_read_pci_config; static int ibm_read_pci_config;
static int ibm_write_pci_config; static int ibm_write_pci_config;
static int config_access_valid(struct pci_dn *dn, int where) static inline int config_access_valid(struct pci_dn *dn, int where)
{ {
if (where < 256) if (where < 256)
return 1; return 1;
...@@ -72,16 +72,14 @@ static int of_device_available(struct device_node * dn) ...@@ -72,16 +72,14 @@ static int of_device_available(struct device_node * dn)
return 0; return 0;
} }
static int rtas_read_config(struct device_node *dn, int where, int size, u32 *val) static int rtas_read_config(struct pci_dn *pdn, int where, int size, u32 *val)
{ {
int returnval = -1; int returnval = -1;
unsigned long buid, addr; unsigned long buid, addr;
int ret; int ret;
struct pci_dn *pdn;
if (!dn || !dn->data) if (!pdn)
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
pdn = dn->data;
if (!config_access_valid(pdn, where)) if (!config_access_valid(pdn, where))
return PCIBIOS_BAD_REGISTER_NUMBER; return PCIBIOS_BAD_REGISTER_NUMBER;
...@@ -90,7 +88,7 @@ static int rtas_read_config(struct device_node *dn, int where, int size, u32 *va ...@@ -90,7 +88,7 @@ static int rtas_read_config(struct device_node *dn, int where, int size, u32 *va
buid = pdn->phb->buid; buid = pdn->phb->buid;
if (buid) { if (buid) {
ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval, ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval,
addr, buid >> 32, buid & 0xffffffff, size); addr, BUID_HI(buid), BUID_LO(buid), size);
} else { } else {
ret = rtas_call(read_pci_config, 2, 2, &returnval, addr, size); ret = rtas_call(read_pci_config, 2, 2, &returnval, addr, size);
} }
...@@ -100,7 +98,7 @@ static int rtas_read_config(struct device_node *dn, int where, int size, u32 *va ...@@ -100,7 +98,7 @@ static int rtas_read_config(struct device_node *dn, int where, int size, u32 *va
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
if (returnval == EEH_IO_ERROR_VALUE(size) && if (returnval == EEH_IO_ERROR_VALUE(size) &&
eeh_dn_check_failure (dn, NULL)) eeh_dn_check_failure (pdn->node, NULL))
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
return PCIBIOS_SUCCESSFUL; return PCIBIOS_SUCCESSFUL;
...@@ -118,23 +116,23 @@ static int rtas_pci_read_config(struct pci_bus *bus, ...@@ -118,23 +116,23 @@ static int rtas_pci_read_config(struct pci_bus *bus,
busdn = bus->sysdata; /* must be a phb */ busdn = bus->sysdata; /* must be a phb */
/* Search only direct children of the bus */ /* Search only direct children of the bus */
for (dn = busdn->child; dn; dn = dn->sibling) for (dn = busdn->child; dn; dn = dn->sibling) {
if (dn->data && PCI_DN(dn)->devfn == devfn struct pci_dn *pdn = PCI_DN(dn);
if (pdn && pdn->devfn == devfn
&& of_device_available(dn)) && of_device_available(dn))
return rtas_read_config(dn, where, size, val); return rtas_read_config(pdn, where, size, val);
}
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
} }
int rtas_write_config(struct device_node *dn, int where, int size, u32 val) int rtas_write_config(struct pci_dn *pdn, int where, int size, u32 val)
{ {
unsigned long buid, addr; unsigned long buid, addr;
int ret; int ret;
struct pci_dn *pdn;
if (!dn || !dn->data) if (!pdn)
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
pdn = dn->data;
if (!config_access_valid(pdn, where)) if (!config_access_valid(pdn, where))
return PCIBIOS_BAD_REGISTER_NUMBER; return PCIBIOS_BAD_REGISTER_NUMBER;
...@@ -142,7 +140,8 @@ int rtas_write_config(struct device_node *dn, int where, int size, u32 val) ...@@ -142,7 +140,8 @@ int rtas_write_config(struct device_node *dn, int where, int size, u32 val)
(pdn->devfn << 8) | (where & 0xff); (pdn->devfn << 8) | (where & 0xff);
buid = pdn->phb->buid; buid = pdn->phb->buid;
if (buid) { if (buid) {
ret = rtas_call(ibm_write_pci_config, 5, 1, NULL, addr, buid >> 32, buid & 0xffffffff, size, (ulong) val); ret = rtas_call(ibm_write_pci_config, 5, 1, NULL, addr,
BUID_HI(buid), BUID_LO(buid), size, (ulong) val);
} else { } else {
ret = rtas_call(write_pci_config, 3, 1, NULL, addr, size, (ulong)val); ret = rtas_call(write_pci_config, 3, 1, NULL, addr, size, (ulong)val);
} }
...@@ -165,10 +164,12 @@ static int rtas_pci_write_config(struct pci_bus *bus, ...@@ -165,10 +164,12 @@ static int rtas_pci_write_config(struct pci_bus *bus,
busdn = bus->sysdata; /* must be a phb */ busdn = bus->sysdata; /* must be a phb */
/* Search only direct children of the bus */ /* Search only direct children of the bus */
for (dn = busdn->child; dn; dn = dn->sibling) for (dn = busdn->child; dn; dn = dn->sibling) {
if (dn->data && PCI_DN(dn)->devfn == devfn struct pci_dn *pdn = PCI_DN(dn);
if (pdn && pdn->devfn == devfn
&& of_device_available(dn)) && of_device_available(dn))
return rtas_write_config(dn, where, size, val); return rtas_write_config(pdn, where, size, val);
}
return PCIBIOS_DEVICE_NOT_FOUND; return PCIBIOS_DEVICE_NOT_FOUND;
} }
......
...@@ -26,6 +26,10 @@ extern unsigned long find_and_init_phbs(void); ...@@ -26,6 +26,10 @@ extern unsigned long find_and_init_phbs(void);
extern struct pci_dev *ppc64_isabridge_dev; /* may be NULL if no ISA bus */ extern struct pci_dev *ppc64_isabridge_dev; /* may be NULL if no ISA bus */
/** Bus Unit ID macros; get low and hi 32-bits of the 64-bit BUID */
#define BUID_HI(buid) ((buid) >> 32)
#define BUID_LO(buid) ((buid) & 0xffffffff)
/* PCI device_node operations */ /* PCI device_node operations */
struct device_node; struct device_node;
typedef void *(*traverse_func)(struct device_node *me, void *data); typedef void *(*traverse_func)(struct device_node *me, void *data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment