diff options
author | Marcel Moolenaar <marcel@FreeBSD.org> | 2012-07-02 23:53:08 +0000 |
---|---|---|
committer | Marcel Moolenaar <marcel@FreeBSD.org> | 2012-07-02 23:53:08 +0000 |
commit | 120c7e2eb77ac5a438ad5e576fca1b02438840e0 (patch) | |
tree | b94c0c1dc9a8f3e309faeb7b135623c0929c75c6 | |
parent | 8c4c7216e630a2b2b87763e8a63eeb8c88f17960 (diff) | |
download | src-120c7e2eb77ac5a438ad5e576fca1b02438840e0.tar.gz src-120c7e2eb77ac5a438ad5e576fca1b02438840e0.zip |
Simplify simplebus_setup_intr and don't call MD code directly. We can
(and have to) trust our parent to handle interrupt configuration.
Notes
Notes:
svn path=/head/; revision=238044
-rw-r--r-- | sys/dev/fdt/simplebus.c | 45 |
1 files changed, 20 insertions, 25 deletions
diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c index e6887b48c2ed..0868fb0e8b55 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 * |