Mutex nvmem_mutex is used in __nvmem_device_get only and isn't needed
due to:

- of_nvmem_find just calls bus_find_device which doesn't need locking
- nvmem_find_cell is protected by nvmem_cells_mutex

Signed-off-by: Heiner Kallweit <[email protected]>
---
 drivers/nvmem/core.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 1aa6d25a..783eb431 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -55,7 +55,6 @@ struct nvmem_cell {
        struct list_head        node;
 };
 
-static DEFINE_MUTEX(nvmem_mutex);
 static DEFINE_IDA(nvmem_ida);
 
 static LIST_HEAD(nvmem_cells);
@@ -538,14 +537,10 @@ static struct nvmem_device *__nvmem_device_get(struct 
device_node *np,
 {
        struct nvmem_device *nvmem = NULL;
 
-       mutex_lock(&nvmem_mutex);
-
        if (np) {
                nvmem = of_nvmem_find(np);
-               if (!nvmem) {
-                       mutex_unlock(&nvmem_mutex);
+               if (!nvmem)
                        return ERR_PTR(-EPROBE_DEFER);
-               }
        } else {
                struct nvmem_cell *cell = nvmem_find_cell(cell_id);
 
@@ -554,14 +549,10 @@ static struct nvmem_device *__nvmem_device_get(struct 
device_node *np,
                        *cellp = cell;
                }
 
-               if (!nvmem) {
-                       mutex_unlock(&nvmem_mutex);
+               if (!nvmem)
                        return ERR_PTR(-ENOENT);
-               }
        }
 
-       mutex_unlock(&nvmem_mutex);
-
        if (!try_module_get(nvmem->owner)) {
                dev_err(&nvmem->dev,
                        "could not increase module refcount for cell %s\n",
-- 
2.13.0


Reply via email to