Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Aug 2005 11:28:46 +0400 (MSD)
From:      "Felix-KM" <Felix-KM@yandex.ru>
To:        freebsd-hackers@freebsd.org
Subject:   bus_teardown_intr()
Message-ID:  <42F1C3AE.000003.07372@mfront7.yandex.ru>
In-Reply-To: <42F1C1F9.000001.17496@ariel.yandex.ru>
References:  <42F1C1F9.000001.17496@ariel.yandex.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
Sorry, I forgot to indicate the theme.
>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?
>_______________________________________________
>freebsd-hackers@freebsd.org mailing list
>http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
>To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


-- 
Яндекс.Лента - любимые блоги и новости на одном сайте http://lenta.yandex.ru/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?42F1C3AE.000003.07372>