Expose os_dev_loookup() This enables users who want to share a OS device during init to access it using the device name. This should not be called at runtime.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/9ca5d71c Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9ca5d71c Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9ca5d71c Branch: refs/heads/1_0_0_dev Commit: 9ca5d71ca2813ef79693bfa873a736383f71ad84 Parents: 9cd6ba5 Author: Sterling Hughes <[email protected]> Authored: Tue Feb 21 16:39:03 2017 -0800 Committer: Marko Kiiskila <[email protected]> Committed: Mon Mar 6 15:48:36 2017 -0800 ---------------------------------------------------------------------- kernel/os/include/os/os_dev.h | 1 + kernel/os/src/os_dev.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9ca5d71c/kernel/os/include/os/os_dev.h ---------------------------------------------------------------------- diff --git a/kernel/os/include/os/os_dev.h b/kernel/os/include/os/os_dev.h index 5af06b2..ed65a08 100644 --- a/kernel/os/include/os/os_dev.h +++ b/kernel/os/include/os/os_dev.h @@ -108,6 +108,7 @@ os_dev_resume(struct os_dev *dev) int os_dev_create(struct os_dev *dev, char *name, uint8_t stage, uint8_t priority, os_dev_init_func_t od_init, void *arg); +struct os_dev *os_dev_lookup(char *name); int os_dev_initialize_all(uint8_t stage); int os_dev_suspend_all(os_time_t, uint8_t); int os_dev_resume_all(void); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9ca5d71c/kernel/os/src/os_dev.c ---------------------------------------------------------------------- diff --git a/kernel/os/src/os_dev.c b/kernel/os/src/os_dev.c index 139fe13..07b1c54 100644 --- a/kernel/os/src/os_dev.c +++ b/kernel/os/src/os_dev.c @@ -232,13 +232,16 @@ err: } /** - * Lookup a device by name, internal function only. + * Lookup a device by name. + * + * WARNING: This should be called before any locking on the device is done, or + * the device list itself is modified in any context. There is no locking. * * @param name The name of the device to look up. * * @return A pointer to the device corresponding to name, or NULL if not found. */ -static struct os_dev * +struct os_dev * os_dev_lookup(char *name) { struct os_dev *dev;
