(no subject)
Felix-KM
Felix-KM at yandex.ru
Thu Aug 4 07:21:38 GMT 2005
Hello.
Help me please to understand how the function bus_teardown_intr() works.
I have a device driver containing following code:
#define DEVICE2SOFTC(device) ((struct dev_softc *)device_get_softc(device))
static void dev_intr(void *arg);
struct dev_softc {
...
int rid_irq;
struct resource* res_irq;
void *intr_cookie;
...
};
static int
dev_attach(device_t device)
{
...
dev_sc->rid_irq = 0;
dev_sc->res_irq = bus_alloc_resource_any(device, SYS_RES_IRQ,
&(dev_sc->rid_irq), RF_SHAREABLE|RF_ACTIVE);
if (dev_sc->res_irq == NULL)
{
uprintf("!!! Could not map interrupt !!!\n");
goto fail;
}
if (bus_setup_intr(device, dev_sc->res_irq, INTR_TYPE_TTY,
dev_intr, dev_sc, &dev_sc->intr_cookie))
{
uprintf("!!! Could not setup irq !!!\n");
goto fail;
}
...
fail:
return ENXIO;
}
static int
dev_detach(device_t device)
{
struct dev_softc *dev_sc = DEVICE2SOFTC(device);
destroy_dev(dev_sc->device);
if (bus_teardown_intr(device, dev_sc->res_irq, dev_sc->intr_cookie) != 0);
printf("bus_teardown_intr ERROR !!!\n");
bus_release_resource(device, SYS_RES_IRQ, dev_sc->rid_irq,
dev_sc->res_irq);
...
return 0;
}
static void
dev_intr(void *arg)
{
struct dev_softc *dev_sc = (struct dev_softc *)arg;
...
}
When the driver is loaded the following message is shown:
dev0 port 0x9800-0x980f,0x9400-0x947f irq 16 at device 10.0 on pci1
i.e., as I understand, resourses are allocated normally.
But when the driver is being unloaded the following message appear:
bus_teardown_intr ERROR !!!
What have I done wrong? Hint me please how to use bus_teardown_intr()
function correctly?
More information about the freebsd-hackers
mailing list