diff options
Diffstat (limited to 'src/loader/dev.c')
-rw-r--r-- | src/loader/dev.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/loader/dev.c b/src/loader/dev.c index 591d5a2..3cdef10 100644 --- a/src/loader/dev.c +++ b/src/loader/dev.c @@ -19,12 +19,26 @@ static const char *dev_resolve_type(enum dev_type type) } } -struct dev *dev_get(u8 id) +struct dev *dev_get_by_id(u8 id) { assert(id < COUNT(devices)); return &devices[id]; } +struct dev *dev_get_by_name(const char *name, u32 len) +{ + if (!name || !name[0]) + return NULL; + + for (u8 i = 0; i < COUNT(devices); i++) { + struct dev *dev = &devices[i]; + if (strncmp(dev->name, name, MIN(sizeof(dev->name), len)) == 0) + return dev; + } + + return NULL; +} + void dev_foreach(enum dev_type type, u8 (*cb)(struct dev *)) { for (u8 i = 0; i < COUNT(devices); i++) { |