Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/isa/isa.c

    rce04ea44 rd51838f  
    115115}
    116116
    117 static bool isa_fun_enable_interrupt(ddf_fun_t *fnode)
    118 {
    119         /* This is an old ugly way, copied from pci driver */
    120         assert(fnode);
     117static bool isa_fun_owns_interrupt(isa_fun_t *fun, int irq)
     118{
     119        const hw_resource_list_t *res = &fun->hw_resources;
     120
     121        /* Check that specified irq really belongs to the function */
     122        for (size_t i = 0; i < res->count; ++i) {
     123                if (res->resources[i].type == INTERRUPT &&
     124                    res->resources[i].res.interrupt.irq == irq) {
     125                        return true;
     126                }
     127        }
     128
     129        return false;
     130}
     131
     132static int isa_fun_enable_interrupt(ddf_fun_t *fnode, int irq)
     133{
    121134        isa_fun_t *fun = isa_fun(fnode);
    122         assert(fun);
    123 
    124         const hw_resource_list_t *res = &fun->hw_resources;
    125         assert(res);
    126         for (size_t i = 0; i < res->count; ++i) {
    127                 if (res->resources[i].type == INTERRUPT) {
    128                         int rc = irc_enable_interrupt(
    129                             res->resources[i].res.interrupt.irq);
    130 
    131                         if (rc != EOK)
    132                                 return false;
    133                 }
    134         }
    135 
    136         return true;
     135
     136        if (!isa_fun_owns_interrupt(fun, irq))
     137                return EINVAL;
     138
     139        return irc_enable_interrupt(irq);
     140}
     141
     142static int isa_fun_disable_interrupt(ddf_fun_t *fnode, int irq)
     143{
     144        isa_fun_t *fun = isa_fun(fnode);
     145
     146        if (!isa_fun_owns_interrupt(fun, irq))
     147                return EINVAL;
     148
     149        return irc_disable_interrupt(irq);
     150}
     151
     152static int isa_fun_clear_interrupt(ddf_fun_t *fnode, int irq)
     153{
     154        isa_fun_t *fun = isa_fun(fnode);
     155
     156        if (!isa_fun_owns_interrupt(fun, irq))
     157                return EINVAL;
     158
     159        return irc_clear_interrupt(irq);
    137160}
    138161
     
    185208        .get_resource_list = isa_fun_get_resources,
    186209        .enable_interrupt = isa_fun_enable_interrupt,
     210        .disable_interrupt = isa_fun_disable_interrupt,
     211        .clear_interrupt = isa_fun_clear_interrupt,
    187212        .dma_channel_setup = isa_fun_setup_dma,
    188213        .dma_channel_remain = isa_fun_remain_dma,
     
    643668        list_initialize(&isa->functions);
    644669
    645         sess = ddf_dev_parent_sess_create(dev);
     670        sess = ddf_dev_parent_sess_get(dev);
    646671        if (sess == NULL) {
    647672                ddf_msg(LVL_ERROR, "isa_dev_add failed to connect to the "
Note: See TracChangeset for help on using the changeset viewer.