diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2007-11-16 16:49:51 +0100 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2007-11-19 10:41:17 +0100 |
commit | afe0eaee4323e9211c37b9a57b963dc843296980 (patch) | |
tree | c062dcb3f49d6f3673ee8378aa4259561b19f4de | |
parent | 7b498d9838e68eb0b58450ec54ed968e7848c8e0 (diff) | |
download | barebox-afe0eaee4323e9211c37b9a57b963dc843296980.tar.gz barebox-afe0eaee4323e9211c37b9a57b963dc843296980.tar.xz |
get_device_by_path now obeys cwd
With this patch get_device_by_path obeys the cwd, which allows a more
intuitive devinfo command.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r-- | lib/driver.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/driver.c b/lib/driver.c index d3d3dc4458..27971e883c 100644 --- a/lib/driver.c +++ b/lib/driver.c @@ -182,10 +182,17 @@ EXPORT_SYMBOL(register_driver); */ struct device_d *get_device_by_path(const char *path) { - if (strncmp(path, "/dev/", 5)) - return NULL; + struct device_d *dev = NULL; + char *npath = normalise_path(path); + + if (strncmp(npath, "/dev/", 5)) + goto out; + + dev = get_device_by_id(npath + 5); - return get_device_by_id(path + 5); + out: + free(npath); + return dev; } EXPORT_SYMBOL(get_device_by_path); |