summaryrefslogtreecommitdiffstats
path: root/sys/dev/fdt
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2012-07-02 23:53:08 +0000
committermarcel <marcel@FreeBSD.org>2012-07-02 23:53:08 +0000
commit1b1a4a52a8872e6c695f0442d1e09846768aefa4 (patch)
treeb94c0c1dc9a8f3e309faeb7b135623c0929c75c6 /sys/dev/fdt
parentb2c2c3980268ec7a366172393e9b0403570e3e86 (diff)
downloadFreeBSD-src-1b1a4a52a8872e6c695f0442d1e09846768aefa4.zip
FreeBSD-src-1b1a4a52a8872e6c695f0442d1e09846768aefa4.tar.gz
Simplify simplebus_setup_intr and don't call MD code directly. We can
(and have to) trust our parent to handle interrupt configuration.
Diffstat (limited to 'sys/dev/fdt')
-rw-r--r--sys/dev/fdt/simplebus.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c
index e6887b4..0868fb0 100644
--- a/sys/dev/fdt/simplebus.c
+++ b/sys/dev/fdt/simplebus.c
@@ -288,39 +288,34 @@ simplebus_setup_intr(device_t bus, device_t child, struct resource *res,
struct simplebus_devinfo *di;
enum intr_trigger trig;
enum intr_polarity pol;
- int irq, rid;
+ int error, rid;
- if (res == NULL)
- panic("simplebus_setup_intr: NULL irq resource!");
+ if (device_get_parent(child) != bus)
+ return (ECHILD);
- rid = rman_get_rid(res);
- if (rid > DI_MAX_INTR_NUM) {
- device_printf(child, "rid out of range rid = %d\n", rid);
- return (ERANGE);
- }
+ di = device_get_ivars(child);
+ if (di == NULL)
+ return (ENXIO);
- irq = rman_get_start(res);
+ if (res == NULL)
+ return (EINVAL);
- if ((di = device_get_ivars(child)) == NULL) {
- device_printf(child, "could not retrieve devinfo\n");
- return (ENXIO);
- }
+ rid = rman_get_rid(res);
+ if (rid >= DI_MAX_INTR_NUM)
+ return (ENOENT);
trig = di->di_intr_sl[rid].trig;
pol = di->di_intr_sl[rid].pol;
+ if (trig != INTR_TRIGGER_CONFORM || pol != INTR_POLARITY_CONFORM) {
+ error = bus_generic_config_intr(bus, rman_get_start(res),
+ trig, pol);
+ if (error)
+ return (error);
+ }
- debugf("intr config: irq = %d, trig = %d, pol = %d\n", irq, trig, pol);
-
-#if defined(__powerpc__)
- int err;
-
- err = powerpc_config_intr(irq, trig, pol);
- if (err)
- return (err);
-#endif
-
- return (bus_generic_setup_intr(bus, child, res, flags, filter, ihand,
- arg, cookiep));
+ error = bus_generic_setup_intr(bus, child, res, flags, filter, ihand,
+ arg, cookiep);
+ return (error);
}
static const struct ofw_bus_devinfo *
OpenPOWER on IntegriCloud