diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2018-10-07 23:35:18 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-10-08 10:07:53 +0200 |
commit | b28a47e994ba184bbecb468b2ff9abd08f976111 (patch) | |
tree | 6598c2f03db4333f0420d41c887217624f5a7011 /common/bbu.c | |
parent | 0ad523bdb9f8380b9841c9f3078e318ae4792847 (diff) | |
download | barebox-b28a47e994ba184bbecb468b2ff9abd08f976111.tar.gz barebox-b28a47e994ba184bbecb468b2ff9abd08f976111.tar.xz |
bbu: Simplify bbu_find_handler_by_device()
Simplify bbu_find_handler_by_device() by making use of
devpath_to_name() as well as some basic recursion to avoid coding the
same loop twice.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/bbu.c')
-rw-r--r-- | common/bbu.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/common/bbu.c b/common/bbu.c index 75c3221d56..5cb09e4eb0 100644 --- a/common/bbu.c +++ b/common/bbu.c @@ -120,22 +120,18 @@ struct bbu_handler *bbu_find_handler_by_name(const char *name) struct bbu_handler *bbu_find_handler_by_device(const char *devicepath) { struct bbu_handler *handler; + const char *devname = devpath_to_name(devicepath); if (!devicepath) return NULL; - list_for_each_entry(handler, &bbu_image_handlers, list) + list_for_each_entry(handler, &bbu_image_handlers, list) { if (!strcmp(handler->devicefile, devicepath)) return handler; + } - if (strncmp(devicepath, "/dev/", 5)) - return NULL; - - devicepath += 5; - - list_for_each_entry(handler, &bbu_image_handlers, list) - if (!strcmp(handler->devicefile, devicepath)) - return handler; + if (devname != devicepath) + return bbu_find_handler_by_device(devname); return NULL; } |