Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/char/ns8250/ns8250.c

    rb19e892 rd51838f  
    5555#include <ops/char_dev.h>
    5656
    57 #include <irc.h>
    5857#include <device/hw_res.h>
    5958#include <ipc/serial_ctl.h>
     
    154153        /** DDF function node */
    155154        ddf_fun_t *fun;
     155        /** Parent session */
     156        async_sess_t *parent_sess;
    156157        /** I/O registers **/
    157158        ns8250_regs_t *regs;
     
    160161        /** The irq assigned to this device. */
    161162        int irq;
     163        /** IRQ capability handle */
     164        int irq_cap;
    162165        /** The base i/o address of the devices registers. */
    163166        uintptr_t io_addr;
     
    380383static int ns8250_dev_initialize(ns8250_t *ns)
    381384{
    382         async_sess_t *parent_sess;
    383385        int ret = EOK;
    384386       
     
    388390        memset(&hw_resources, 0, sizeof(hw_resource_list_t));
    389391       
    390         /* Connect to the parent's driver. */
    391         parent_sess = ddf_dev_parent_sess_create(ns->dev);
    392         if (parent_sess == NULL) {
    393                 ddf_msg(LVL_ERROR, "Failed to connect to parent driver of "
    394                     "device %s.", ddf_dev_get_name(ns->dev));
    395                 ret = ENOENT;
    396                 goto failed;
    397         }
    398        
    399392        /* Get hw resources. */
    400         ret = hw_res_get_resource_list(parent_sess, &hw_resources);
     393        ret = hw_res_get_resource_list(ns->parent_sess, &hw_resources);
    401394        if (ret != EOK) {
    402395                ddf_msg(LVL_ERROR, "Failed to get HW resources for device "
     
    485478{
    486479        /* Enable interrupt using IRC service. */
    487         int rc = irc_enable_interrupt(ns->irq);
     480        int rc = hw_res_enable_interrupt(ns->parent_sess, ns->irq);
    488481        if (rc != EOK)
    489482                return EIO;
     
    778771       
    779772        ns8250_read_from_device(ns);
    780         irc_disable_interrupt(ns->irq);
     773        hw_res_clear_interrupt(ns->parent_sess, ns->irq);
    781774}
    782775
     
    797790static inline int ns8250_unregister_interrupt_handler(ns8250_t *ns)
    798791{
    799         return unregister_interrupt_handler(ns->dev, ns->irq);
     792        return unregister_interrupt_handler(ns->dev, ns->irq_cap);
    800793}
    801794
     
    828821        ns->dev = dev;
    829822       
     823        ns->parent_sess = ddf_dev_parent_sess_get(ns->dev);
     824        if (ns->parent_sess == NULL) {
     825                ddf_msg(LVL_ERROR, "Failed to connect to parent driver of "
     826                    "device %s.", ddf_dev_get_name(ns->dev));
     827                rc = EIO;
     828                goto fail;
     829        }
     830       
    830831        rc = ns8250_dev_initialize(ns);
    831832        if (rc != EOK)
     
    849850       
    850851        /* Register interrupt handler. */
    851         if (ns8250_register_interrupt_handler(ns) != EOK) {
     852        ns->irq_cap = ns8250_register_interrupt_handler(ns);
     853        if (ns->irq_cap < 0) {
    852854                ddf_msg(LVL_ERROR, "Failed to register interrupt handler.");
    853855                rc = EADDRNOTAVAIL;
Note: See TracChangeset for help on using the changeset viewer.