From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751185AbdFDLCP (ORCPT ); Sun, 4 Jun 2017 07:02:15 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33237 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750847AbdFDLCJ (ORCPT ); Sun, 4 Jun 2017 07:02:09 -0400 From: Heiner Kallweit Subject: [PATCH 1/3] nvmem: core: remove member users from struct nvmem_device To: Srinivas Kandagatla , Linux Kernel Mailing List References: <32c019d9-656d-6214-af2a-bef7e91dc1de@gmail.com> Message-ID: Date: Sun, 4 Jun 2017 13:01:43 +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 Member users is used only to check whether we're allowed to remove the module. So in case of built-in it's not used at all and in case that owner is a module we have the module refcount for the same purpose already. Whenever users is incremented the owner's refcount is incremented too. Therefore users isn't needed. Signed-off-by: Heiner Kallweit --- drivers/nvmem/core.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 8c830a80..4e07f3f8 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -33,7 +33,6 @@ struct nvmem_device { int word_size; int ncells; int id; - int users; size_t size; bool read_only; int flags; @@ -517,13 +516,6 @@ EXPORT_SYMBOL_GPL(nvmem_register); */ int nvmem_unregister(struct nvmem_device *nvmem) { - mutex_lock(&nvmem_mutex); - if (nvmem->users) { - mutex_unlock(&nvmem_mutex); - return -EBUSY; - } - mutex_unlock(&nvmem_mutex); - if (nvmem->flags & FLAG_COMPAT) device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom); @@ -562,7 +554,6 @@ static struct nvmem_device *__nvmem_device_get(struct device_node *np, } } - nvmem->users++; mutex_unlock(&nvmem_mutex); if (!try_module_get(nvmem->owner)) { @@ -570,10 +561,6 @@ static struct nvmem_device *__nvmem_device_get(struct device_node *np, "could not increase module refcount for cell %s\n", nvmem->name); - mutex_lock(&nvmem_mutex); - nvmem->users--; - mutex_unlock(&nvmem_mutex); - return ERR_PTR(-EINVAL); } @@ -583,9 +570,6 @@ static struct nvmem_device *__nvmem_device_get(struct device_node *np, static void __nvmem_device_put(struct nvmem_device *nvmem) { module_put(nvmem->owner); - mutex_lock(&nvmem_mutex); - nvmem->users--; - mutex_unlock(&nvmem_mutex); } static int nvmem_match(struct device *dev, void *data) -- 2.13.0