kernel: Compare pointers before strings when getting device binding

Most calls to device_get_binding() will pass named constants generated
by Kconfig; these constants will all point to the same place, so
compare the pointer before attempting to match the whole string.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
This commit is contained in:
Leandro Pereira 2017-10-19 14:17:37 -07:00 committed by Andrew Boie
parent 1d38d98284
commit d24daa426d
1 changed files with 9 additions and 1 deletions

View File

@ -61,7 +61,15 @@ struct device *device_get_binding(const char *name)
struct device *info;
for (info = __device_init_start; info != __device_init_end; info++) {
if (info->driver_api && !strcmp(name, info->config->name)) {
if (!info->driver_api) {
continue;
}
if (name == info->config->name) {
return info;
}
if (!strcmp(name, info->config->name)) {
return info;
}
}