Remove OF_instance_to_package() hack for FDT and replace with use of the

generic OF_xref_phandle() API universally. Also replace some related
explicit uses of fdt32_to_cpu() with OF_getencprop() calls.
This commit is contained in:
Nathan Whitehorn 2013-10-23 14:04:09 +00:00
parent d3a0a0f37e
commit 755c959170
5 changed files with 9 additions and 26 deletions

View File

@ -605,7 +605,6 @@ int
platform_gpio_init(void)
{
phandle_t child, parent, root, ctrl;
ihandle_t ctrl_ihandle;
pcell_t gpios[MAX_PINS_PER_NODE * GPIOS_PROP_CELLS];
struct gpio_ctrl_entry *e;
int len, rv;
@ -639,9 +638,7 @@ platform_gpio_init(void)
* contain a ref. to a node defining GPIO
* controller.
*/
ctrl_ihandle = (ihandle_t)gpios[0];
ctrl_ihandle = fdt32_to_cpu(ctrl_ihandle);
ctrl = OF_instance_to_package(ctrl_ihandle);
ctrl = OF_xref_handle(fdt32_to_cpu(gpios[0]));
if (fdt_is_compatible(ctrl, e->compat))
/* Call a handler. */

View File

@ -523,7 +523,7 @@ fdt_intr_to_rl(phandle_t node, struct resource_list *rl,
/*
* Find #interrupt-cells of the interrupt domain.
*/
if (OF_getprop(node, "interrupt-parent", &iph, sizeof(iph)) <= 0) {
if (OF_getencprop(node, "interrupt-parent", &iph, sizeof(iph)) <= 0) {
debugf("no intr-parent phandle\n");
intr_par = OF_parent(node);
} else {
@ -583,7 +583,7 @@ fdt_get_phyaddr(phandle_t node, device_t dev, int *phy_addr, void **phy_sc)
uint32_t i;
device_t parent, child;
if (OF_getprop(node, "phy-handle", (void *)&phy_handle,
if (OF_getencprop(node, "phy-handle", (void *)&phy_handle,
sizeof(phy_handle)) <= 0)
return (ENXIO);

View File

@ -255,7 +255,7 @@ fdt_pci_route_intr(int bus, int slot, int func, int pin,
struct fdt_pci_intr *intr_info, int *interrupt)
{
pcell_t child_spec[4], masked[4];
ihandle_t iph;
phandle_t iph;
pcell_t intr_par;
pcell_t *map_ptr;
uint32_t addr;
@ -280,7 +280,7 @@ fdt_pci_route_intr(int bus, int slot, int func, int pin,
i = 0;
while (i < map_len) {
iph = fdt32_to_cpu(map_ptr[par_idx]);
intr_par = OF_instance_to_package(iph);
intr_par = OF_xref_phandle(iph);
err = fdt_addr_cells(intr_par, &par_addr_cells);
if (err != 0) {

View File

@ -339,8 +339,7 @@ simplebus_get_interrupt_parent(device_t dev)
struct simplebus_devinfo *di;
struct fdt_ic *ic;
device_t ip;
ihandle_t iph;
phandle_t ph;
phandle_t ph, iph;
ip = NULL;
@ -348,10 +347,9 @@ simplebus_get_interrupt_parent(device_t dev)
if (di == NULL)
return (NULL);
if (OF_getprop(di->di_ofw.obd_node, "interrupt-parent", &iph,
if (OF_getencprop(di->di_ofw.obd_node, "interrupt-parent", &iph,
sizeof(iph)) > 0) {
iph = fdt32_to_cpu(iph);
ph = OF_instance_to_package(iph);
ph = OF_xref_phandle(iph);
SLIST_FOREACH(ic, &fdt_ic_list_head, fdt_ics) {
if (ic->iph == ph) {
ip = ic->dev;

View File

@ -226,20 +226,8 @@ ofw_fdt_parent(ofw_t ofw, phandle_t node)
static phandle_t
ofw_fdt_instance_to_package(ofw_t ofw, ihandle_t instance)
{
int offset;
/*
* Note: FDT does not have the notion of instances, but we somewhat
* abuse the semantics and let treat as 'instance' the internal
* 'phandle' prop, so that ofw I/F consumers have a uniform way of
* translation between internal representation (which appear in some
* contexts as property values) and effective phandles.
*/
offset = fdt_node_offset_by_phandle(fdtp, instance);
if (offset < 0)
return (-1);
return (fdt_offset_phandle(offset));
return (-1);
}
/* Get the length of a property of a package. */