Changeset d51838f in mainline for uspace/drv/bus


Ignore:
Timestamp:
2017-10-14T22:49:18Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
75911d24
Parents:
ce732e74
Message:

Let leaf drivers enable/disable/clear interrupts via hw_res instead of directly using irc.

Location:
uspace/drv/bus
Files:
2 edited

Legend:

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

    rce732e74 rd51838f  
    115115}
    116116
    117 static int isa_fun_enable_interrupt(ddf_fun_t *fnode, int irq)
    118 {
    119         isa_fun_t *fun = isa_fun(fnode);
     117static bool isa_fun_owns_interrupt(isa_fun_t *fun, int irq)
     118{
    120119        const hw_resource_list_t *res = &fun->hw_resources;
    121         bool found;
    122120
    123121        /* Check that specified irq really belongs to the function */
    124         found = false;
    125122        for (size_t i = 0; i < res->count; ++i) {
    126123                if (res->resources[i].type == INTERRUPT &&
    127124                    res->resources[i].res.interrupt.irq == irq) {
    128                         found = true;
    129                         break;
    130                 }
    131         }
    132 
    133         if (!found)
     125                        return true;
     126                }
     127        }
     128
     129        return false;
     130}
     131
     132static int isa_fun_enable_interrupt(ddf_fun_t *fnode, int irq)
     133{
     134        isa_fun_t *fun = isa_fun(fnode);
     135
     136        if (!isa_fun_owns_interrupt(fun, irq))
    134137                return EINVAL;
    135138
    136139        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,
  • uspace/drv/bus/pci/pciintel/pci.c

    rce732e74 rd51838f  
    9999}
    100100
     101static int pciintel_fun_owns_interrupt(pci_fun_t *fun, int irq)
     102{
     103        size_t i;
     104        hw_resource_list_t *res = &fun->hw_resources;
     105       
     106        for (i = 0; i < res->count; i++) {
     107                if (res->resources[i].type == INTERRUPT &&
     108                    res->resources[i].res.interrupt.irq == irq) {
     109                        return true;
     110                }
     111        }
     112       
     113        return false;
     114}
     115
    101116static int pciintel_enable_interrupt(ddf_fun_t *fnode, int irq)
    102117{
    103         pci_fun_t *dev_data = pci_fun(fnode);
    104        
    105         size_t i;
    106         hw_resource_list_t *res = &dev_data->hw_resources;
    107         bool found = false;
    108        
    109         found = false;
    110         for (i = 0; i < res->count; i++) {
    111                 if (res->resources[i].type == INTERRUPT) {
    112                         found = true;
    113                         break;
    114                 }
    115         }
    116        
    117         if (!found)
     118        pci_fun_t *fun = pci_fun(fnode);
     119       
     120        if (!pciintel_fun_owns_interrupt(fun, irq))
    118121                return EINVAL;
    119        
     122
    120123        return irc_enable_interrupt(irq);
     124}
     125
     126static int pciintel_disable_interrupt(ddf_fun_t *fnode, int irq)
     127{
     128        pci_fun_t *fun = pci_fun(fnode);
     129       
     130        if (!pciintel_fun_owns_interrupt(fun, irq))
     131                return EINVAL;
     132
     133        return irc_disable_interrupt(irq);
     134}
     135
     136static int pciintel_clear_interrupt(ddf_fun_t *fnode, int irq)
     137{
     138        pci_fun_t *fun = pci_fun(fnode);
     139       
     140        if (!pciintel_fun_owns_interrupt(fun, irq))
     141                return EINVAL;
     142
     143        return irc_clear_interrupt(irq);
    121144}
    122145
     
    188211        .get_resource_list = &pciintel_get_resources,
    189212        .enable_interrupt = &pciintel_enable_interrupt,
     213        .disable_interrupt = &pciintel_disable_interrupt,
     214        .clear_interrupt = &pciintel_clear_interrupt,
    190215};
    191216
Note: See TracChangeset for help on using the changeset viewer.