source: rtems/cpukit/libdrvmgr/drvmgr_func.c @ e53daed

4.115
Last change on this file since e53daed was 0decc806, checked in by Daniel Hellstrom <daniel@…>, on 04/09/15 at 14:09:13

DRVMGR: updated license to rtems.org

  • Property mode set to 100644
File size: 851 bytes
Line 
1/* Driver Manager optional dynamic function interface
2 *
3 * COPYRIGHT (c) 2011 Cobham Gaisler AB.
4 *
5 * The license and distribution terms for this file may be
6 * found in the file LICENSE in this distribution or at
7 * http://www.rtems.org/license/LICENSE.
8 */
9
10#include <drvmgr/drvmgr.h>
11
12/* Get Function from Function ID */
13int drvmgr_func_get(void *obj, int funcid, void **func)
14{
15        int objtype;
16        struct drvmgr_func *f;
17
18        if (!obj)
19                return DRVMGR_FAIL;
20        objtype = *(int *)obj;
21
22        if (objtype == DRVMGR_OBJ_BUS)
23                f = ((struct drvmgr_bus *)obj)->funcs;
24        else if (objtype == DRVMGR_OBJ_DRV)
25                f = ((struct drvmgr_drv *)obj)->funcs;
26        else
27                return DRVMGR_FAIL;
28
29        if (f == NULL)
30                return DRVMGR_FAIL;
31
32        while (f->funcid != DRVMGR_FUNCID_NONE) {
33                if (f->funcid == funcid) {
34                        *func = f->func;
35                        return DRVMGR_OK;
36                }
37                f++;
38        }
39
40        return DRVMGR_FAIL;
41}
Note: See TracBrowser for help on using the repository browser.