From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751246AbdFDLCh (ORCPT ); Sun, 4 Jun 2017 07:02:37 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35209 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751162AbdFDLCL (ORCPT ); Sun, 4 Jun 2017 07:02:11 -0400 From: Heiner Kallweit Subject: [PATCH 3/3] nvmem: core: remove nvmem_mutex To: Srinivas Kandagatla , Linux Kernel Mailing List References: <32c019d9-656d-6214-af2a-bef7e91dc1de@gmail.com> Message-ID: <10bbabba-377c-804f-6466-167699138ab3@gmail.com> Date: Sun, 4 Jun 2017 13:02:02 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <32c019d9-656d-6214-af2a-bef7e91dc1de@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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