5
Line | |
---|
1 | /* Find device by device name |
---|
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 | |
---|
11 | #include <string.h> |
---|
12 | #include <drvmgr/drvmgr.h> |
---|
13 | #include "drvmgr_internal.h" |
---|
14 | |
---|
15 | static int dev_name_compare(struct drvmgr_dev *dev, void *arg) |
---|
16 | { |
---|
17 | const char *name = arg; |
---|
18 | |
---|
19 | if (dev->name && (strcmp(dev->name, name) == 0)) |
---|
20 | return (int)dev; |
---|
21 | else |
---|
22 | return 0; |
---|
23 | } |
---|
24 | |
---|
25 | /* Get device by device name or bus name */ |
---|
26 | struct drvmgr_dev *drvmgr_dev_by_name(const char *name) |
---|
27 | { |
---|
28 | if (!name) |
---|
29 | return NULL; |
---|
30 | |
---|
31 | return (struct drvmgr_dev *) |
---|
32 | drvmgr_for_each_dev(dev_name_compare, (void *)name, 0); |
---|
33 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.