Changeset d51838f in mainline for uspace/drv/platform/icp/icp.c


Ignore:
Timestamp:
2017-10-14T22:49:18Z (7 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/platform/icp/icp.c

    rce732e74 rd51838f  
    3939#include <stdio.h>
    4040#include <errno.h>
     41#include <irc.h>
    4142#include <stdbool.h>
    4243#include <stdlib.h>
     
    142143}
    143144
    144 static int icp_enable_interrupt(ddf_fun_t *fun, int irq)
    145 {
    146         /* TODO */
     145static bool icp_fun_owns_interrupt(icp_fun_t *fun, int irq)
     146{
     147        const hw_resource_list_t *res = &fun->hw_resources;
     148
     149        /* Check that specified irq really belongs to the function */
     150        for (size_t i = 0; i < res->count; ++i) {
     151                if (res->resources[i].type == INTERRUPT &&
     152                    res->resources[i].res.interrupt.irq == irq) {
     153                        return true;
     154                }
     155        }
     156
    147157        return false;
     158}
     159
     160static int icp_fun_enable_interrupt(ddf_fun_t *fnode, int irq)
     161{
     162        icp_fun_t *fun = icp_fun(fnode);
     163
     164        if (!icp_fun_owns_interrupt(fun, irq))
     165                return EINVAL;
     166
     167        return irc_enable_interrupt(irq);
    148168}
    149169
     
    155175static hw_res_ops_t icp_hw_res_ops = {
    156176        .get_resource_list = &icp_get_resources,
    157         .enable_interrupt = &icp_enable_interrupt,
     177        .enable_interrupt = &icp_fun_enable_interrupt,
    158178};
    159179
Note: See TracChangeset for help on using the changeset viewer.