Make all Open Firmware internal interfaces endian-safe by using the new
OF_getencprop() API. This removes one explicit endianness conversion in ofw_iicbus.c.
This commit is contained in:
parent
0e902f8a24
commit
d3a0a0f37e
@ -214,14 +214,14 @@ ofw_bus_setup_iinfo(phandle_t node, struct ofw_bus_iinfo *ii, int intrsz)
|
||||
pcell_t addrc;
|
||||
int msksz;
|
||||
|
||||
if (OF_getprop(node, "#address-cells", &addrc, sizeof(addrc)) == -1)
|
||||
if (OF_getencprop(node, "#address-cells", &addrc, sizeof(addrc)) == -1)
|
||||
addrc = 2;
|
||||
ii->opi_addrc = addrc * sizeof(pcell_t);
|
||||
|
||||
ii->opi_imapsz = OF_getprop_alloc(node, "interrupt-map", 1,
|
||||
ii->opi_imapsz = OF_getencprop_alloc(node, "interrupt-map", 1,
|
||||
(void **)&ii->opi_imap);
|
||||
if (ii->opi_imapsz > 0) {
|
||||
msksz = OF_getprop_alloc(node, "interrupt-map-mask", 1,
|
||||
msksz = OF_getencprop_alloc(node, "interrupt-map-mask", 1,
|
||||
(void **)&ii->opi_imapmsk);
|
||||
/*
|
||||
* Failure to get the mask is ignored; a full mask is used
|
||||
@ -246,7 +246,7 @@ ofw_bus_lookup_imap(phandle_t node, struct ofw_bus_iinfo *ii, void *reg,
|
||||
("ofw_bus_lookup_imap: register size too small: %d < %d",
|
||||
regsz, ii->opi_addrc));
|
||||
if (node != -1) {
|
||||
rv = OF_getprop(node, "reg", reg, regsz);
|
||||
rv = OF_getencprop(node, "reg", reg, regsz);
|
||||
if (rv < regsz)
|
||||
panic("ofw_bus_lookup_imap: cannot get reg property");
|
||||
}
|
||||
@ -301,8 +301,8 @@ ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz,
|
||||
i = imapsz;
|
||||
while (i > 0) {
|
||||
bcopy(mptr + physsz + intrsz, &parent, sizeof(parent));
|
||||
if (OF_searchprop(OF_xref_phandle(parent), "#interrupt-cells",
|
||||
&pintrsz, sizeof(pintrsz)) == -1)
|
||||
if (OF_searchencprop(OF_xref_phandle(parent),
|
||||
"#interrupt-cells", &pintrsz, sizeof(pintrsz)) == -1)
|
||||
pintrsz = 1; /* default */
|
||||
pintrsz *= sizeof(pcell_t);
|
||||
|
||||
|
@ -106,8 +106,8 @@ cn_drvinit(void *unused)
|
||||
|
||||
SYSINIT(cndev, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE, cn_drvinit, NULL);
|
||||
|
||||
static int stdin;
|
||||
static int stdout;
|
||||
static pcell_t stdin;
|
||||
static pcell_t stdout;
|
||||
|
||||
static int
|
||||
ofwtty_open(struct tty *tp)
|
||||
@ -170,12 +170,12 @@ ofw_cnprobe(struct consdev *cp)
|
||||
return;
|
||||
}
|
||||
|
||||
if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1) {
|
||||
if (OF_getencprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1) {
|
||||
cp->cn_pri = CN_DEAD;
|
||||
return;
|
||||
}
|
||||
|
||||
if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) {
|
||||
if (OF_getencprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) {
|
||||
cp->cn_pri = CN_DEAD;
|
||||
return;
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/module.h>
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <dev/fdt/fdt_common.h>
|
||||
#include <dev/iicbus/iicbus.h>
|
||||
#include <dev/iicbus/iiconf.h>
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
@ -104,7 +103,6 @@ ofw_iicbus_attach(device_t dev)
|
||||
phandle_t child;
|
||||
pcell_t paddr;
|
||||
device_t childdev;
|
||||
uint32_t addr;
|
||||
|
||||
sc->dev = dev;
|
||||
mtx_init(&sc->lock, "iicbus", NULL, MTX_DEF);
|
||||
@ -123,11 +121,12 @@ ofw_iicbus_attach(device_t dev)
|
||||
* property, then try the reg property. It moves around
|
||||
* on different systems.
|
||||
*/
|
||||
if (OF_getprop(child, "i2c-address", &paddr, sizeof(paddr)) == -1)
|
||||
if (OF_getprop(child, "reg", &paddr, sizeof(paddr)) == -1)
|
||||
if (OF_getencprop(child, "i2c-address", &paddr,
|
||||
sizeof(paddr)) == -1)
|
||||
if (OF_getencprop(child, "reg", &paddr,
|
||||
sizeof(paddr)) == -1)
|
||||
continue;
|
||||
|
||||
addr = fdt32_to_cpu(paddr);
|
||||
/*
|
||||
* Now set up the I2C and OFW bus layer devinfo and add it
|
||||
* to the bus.
|
||||
@ -136,7 +135,7 @@ ofw_iicbus_attach(device_t dev)
|
||||
M_NOWAIT | M_ZERO);
|
||||
if (dinfo == NULL)
|
||||
continue;
|
||||
dinfo->opd_dinfo.addr = addr;
|
||||
dinfo->opd_dinfo.addr = paddr;
|
||||
if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) !=
|
||||
0) {
|
||||
free(dinfo, M_DEVBUF);
|
||||
|
@ -135,7 +135,8 @@ OF_init(void *cookie)
|
||||
rv = OFW_INIT(ofw_obj, cookie);
|
||||
|
||||
if ((chosen = OF_finddevice("/chosen")) != -1)
|
||||
if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1)
|
||||
if (OF_getencprop(chosen, "stdout", &stdout,
|
||||
sizeof(stdout)) == -1)
|
||||
stdout = -1;
|
||||
|
||||
return (rv);
|
||||
@ -354,11 +355,9 @@ OF_getencprop_alloc(phandle_t package, const char *name, int elsz, void **buf)
|
||||
pcell_t *cell;
|
||||
int i;
|
||||
|
||||
KASSERT(elsz % 4 == 0, ("Need a multiple of 4 bytes"));
|
||||
|
||||
retval = OF_getprop_alloc(package, name, elsz, buf);
|
||||
if (retval == -1)
|
||||
return (retval);
|
||||
if (retval == -1 || retval*elsz % 4 != 0)
|
||||
return (-1);
|
||||
|
||||
cell = *buf;
|
||||
for (i = 0; i < retval*elsz/4; i++)
|
||||
@ -450,9 +449,9 @@ OF_child_xref_phandle(phandle_t parent, phandle_t xref)
|
||||
if (rxref != -1)
|
||||
return (rxref);
|
||||
|
||||
if (OF_getprop(child, "phandle", &rxref, sizeof(rxref)) == -1 &&
|
||||
OF_getprop(child, "ibm,phandle", &rxref,
|
||||
sizeof(rxref)) == -1 && OF_getprop(child,
|
||||
if (OF_getencprop(child, "phandle", &rxref, sizeof(rxref)) ==
|
||||
-1 && OF_getencprop(child, "ibm,phandle", &rxref,
|
||||
sizeof(rxref)) == -1 && OF_getencprop(child,
|
||||
"linux,phandle", &rxref, sizeof(rxref)) == -1)
|
||||
continue;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user