source: rtems/cpukit/libdrvmgr/drvmgr_for_each_list_dev.c @ 7075fb11

Last change on this file since 7075fb11 was 0decc80, checked in by Daniel Hellstrom <daniel@…>, on Apr 9, 2015 at 2:09:13 PM

DRVMGR: updated license to rtems.org

  • Property mode set to 100644
File size: 1014 bytes
Line 
1/* Iterate over one list of devices used internally by driver manager
2 *
3 * COPYRIGHT (c) 2009 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#include <drvmgr/drvmgr_list.h>
12#include "drvmgr_internal.h"
13
14int drvmgr_for_each_listdev(
15        struct drvmgr_list *devlist,
16        unsigned int state_set_mask,
17        unsigned int state_clr_mask,
18        int (*func)(struct drvmgr_dev *dev, void *arg),
19        void *arg
20        )
21{
22        struct drvmgr_dev *dev;
23        int ret = 0;
24
25        DRVMGR_LOCK_READ();
26
27        /* Get First Device */
28        dev = DEV_LIST_HEAD(devlist);
29        while (dev) {
30                if (((state_set_mask != 0) && ((dev->state & state_set_mask) == state_set_mask)) ||
31                    ((state_clr_mask != 0) && ((dev->state & state_clr_mask) == 0)) ||
32                    ((state_set_mask == 0) && (state_clr_mask == 0))) {
33                        ret = func(dev, arg);
34                        if (ret != 0)
35                                break;
36                }
37                dev = dev->next;
38        }
39
40        DRVMGR_UNLOCK();
41
42        return ret;
43}
Note: See TracBrowser for help on using the repository browser.