nvmem: core: Avoid useless iterations in nvmem_cell_get_from_lookup()
authorAlban Bedel <albeu@free.fr>
Mon, 28 Jan 2019 15:55:06 +0000 (15:55 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 31 Jan 2019 15:24:15 +0000 (16:24 +0100)
Once the correct cell has been found there is no need to continue
iterating, just stop there. While at it replace the goto used to leave
the loop with simple break statements.

Signed-off-by: Alban Bedel <albeu@free.fr>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvmem/core.c

index 5400017ef6168dce52b4c1d40fb0191bff4902e9..9dd07eae1f3ec73740ef6feb4db6569c29003420 100644 (file)
@@ -977,7 +977,7 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id)
                        if (IS_ERR(nvmem)) {
                                /* Provider may not be registered yet. */
                                cell = ERR_CAST(nvmem);
-                               goto out;
+                               break;
                        }
 
                        cell = nvmem_find_cell_by_name(nvmem,
@@ -985,12 +985,11 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id)
                        if (!cell) {
                                __nvmem_device_put(nvmem);
                                cell = ERR_PTR(-ENOENT);
-                               goto out;
                        }
+                       break;
                }
        }
 
-out:
        mutex_unlock(&nvmem_lookup_mutex);
        return cell;
 }