OSDN Git Service

nvmem: core: Deduplicate bus_find_device() by name matching
authorLukas Wunner <lukas@wunner.de>
Fri, 15 Dec 2017 14:06:04 +0000 (14:06 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 19 Dec 2017 09:39:33 +0000 (10:39 +0100)
No need to reinvent the wheel, we have bus_find_device_by_name().

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvmem/core.c

index 5a5cefd..93084ab 100644 (file)
@@ -600,16 +600,11 @@ static void __nvmem_device_put(struct nvmem_device *nvmem)
        mutex_unlock(&nvmem_mutex);
 }
 
-static int nvmem_match(struct device *dev, void *data)
-{
-       return !strcmp(dev_name(dev), data);
-}
-
 static struct nvmem_device *nvmem_find(const char *name)
 {
        struct device *d;
 
-       d = bus_find_device(&nvmem_bus_type, NULL, (void *)name, nvmem_match);
+       d = bus_find_device_by_name(&nvmem_bus_type, NULL, name);
 
        if (!d)
                return NULL;