From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D959E449B2A for ; Wed, 29 Jul 2026 09:46:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785318421; cv=none; b=gb/+aXIoJeKpME5Zfbv357dy7wS6n9ShDX9zxKPN/8gLL6QLyd3VO4J62pDgntFPc9IdLpPvR/IeswLlypQPaSU1x7OwzOUynM8y3cafVY48CkHY32DrwlWsSprPs+b8rpMnY9ufOR5MlMA0NoVXpH6142EcTAcTHIKA8wwB8UQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785318421; c=relaxed/simple; bh=sGePICc5oBKi8z8fGFJU7OWhqjx2YqSpat36QtHagLk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r4VYUhUijTyv7iVE9rF8WTf+FaFlzBd/k/RbuN7ZtEGQGn24PVPp7o//3e8M4q5DAr2Begom+AZsxLGy6vFULuZPjMNTXBnhVhXMesy531wpFqNy/rYHIPpt+zmLWhxCY+tzQUunWcxmBwHq4hjcpKLUE/ZpSQ4HmlR3wKmYc7U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PY5J1PI8; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PY5J1PI8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B21001F00A3E; Wed, 29 Jul 2026 09:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785318419; bh=z7RId6JkdEtRGm+w9L8BXd1DRYiwQe+JhcDwpTCd6bE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PY5J1PI822+mEo1IxpwR90UqceTeGdMogOTFV5dPobsAGKOKjH16Xbyn0yZAsxokt REPMfOHG2orycF2ZKHwgllGa1g9NsujAWXcSBwyJuuXyubBKAsZnsjEQPvE8d7ILw9 5V1Y2sf5+gBIAU1l4L2U9xYE38d1pAtvq6u0SCWWN6g7k72kbeCeFDZOTQhrkIcC/S XbglaKNk9QWVe5y7yQDgRIMCrc6ZgNVBpziE+Mml24rak0mH0/AtfpmIR/krKpUQpc fszFTqFcONygeeJkVq8NcVNfxUxvMhas7YKROXnCBclK515Yl6/BUGNDJHoEIr1uFK EtJDrTClOv51w== From: srini@kernel.org To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Loic Poulain , Srinivas Kandagatla Subject: [PATCH 05/14] nvmem: remove unneeded __nvmem_device_put() Date: Wed, 29 Jul 2026 10:46:38 +0100 Message-ID: <20260729094647.111468-6-srini@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260729094647.111468-1-srini@kernel.org> References: <20260729094647.111468-1-srini@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Bartosz Golaszewski __nvmem_device_put() is wrapped by nvmem_device_put() but there's no extra functionality offered by the latter so just fold one into the other. There's still the corresponding __nvmem_device_get() so in order to keep things symmetrical: rename it to nvmem_device_match() to better reflect its functionality and not confuse users by its presence in the absence of the similarly prefixed put() counterpart. Signed-off-by: Bartosz Golaszewski Tested-by: Loic Poulain Signed-off-by: Srinivas Kandagatla --- drivers/nvmem/core.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 0a011b6b5837..b536ac7ffa11 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -1090,7 +1090,7 @@ struct nvmem_device *devm_nvmem_register(struct device *dev, } EXPORT_SYMBOL_GPL(devm_nvmem_register); -static struct nvmem_device *__nvmem_device_get(void *data, +static struct nvmem_device *nvmem_device_match(void *data, int (*match)(struct device *dev, const void *data)) { struct nvmem_device *nvmem = NULL; @@ -1118,13 +1118,6 @@ static struct nvmem_device *__nvmem_device_get(void *data, return nvmem; } -static void __nvmem_device_put(struct nvmem_device *nvmem) -{ - put_device(&nvmem->dev); - module_put(nvmem->owner); - kref_put(&nvmem->refcnt, nvmem_device_release); -} - #if IS_ENABLED(CONFIG_OF) /** * of_nvmem_device_get() - Get nvmem device from a given id @@ -1149,7 +1142,7 @@ struct nvmem_device *of_nvmem_device_get(struct device_node *np, const char *id) if (!nvmem_np) return ERR_PTR(-ENOENT); - nvmem = __nvmem_device_get(nvmem_np, device_match_of_node); + nvmem = nvmem_device_match(nvmem_np, device_match_of_node); of_node_put(nvmem_np); return nvmem; } @@ -1177,7 +1170,7 @@ struct nvmem_device *nvmem_device_get(struct device *dev, const char *dev_name) } - return __nvmem_device_get((void *)dev_name, device_match_name); + return nvmem_device_match((void *)dev_name, device_match_name); } EXPORT_SYMBOL_GPL(nvmem_device_get); @@ -1193,7 +1186,7 @@ EXPORT_SYMBOL_GPL(nvmem_device_get); struct nvmem_device *nvmem_device_find(void *data, int (*match)(struct device *dev, const void *data)) { - return __nvmem_device_get(data, match); + return nvmem_device_match(data, match); } EXPORT_SYMBOL_GPL(nvmem_device_find); @@ -1237,7 +1230,9 @@ EXPORT_SYMBOL_GPL(devm_nvmem_device_put); */ void nvmem_device_put(struct nvmem_device *nvmem) { - __nvmem_device_put(nvmem); + put_device(&nvmem->dev); + module_put(nvmem->owner); + kref_put(&nvmem->refcnt, nvmem_device_release); } EXPORT_SYMBOL_GPL(nvmem_device_put); @@ -1316,7 +1311,7 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id) if ((strcmp(lookup->dev_id, dev_id) == 0) && (strcmp(lookup->con_id, con_id) == 0)) { /* This is the right entry. */ - nvmem = __nvmem_device_get((void *)lookup->nvmem_name, + nvmem = nvmem_device_match((void *)lookup->nvmem_name, device_match_name); if (IS_ERR(nvmem)) /* Provider may not be registered yet. */ @@ -1325,12 +1320,12 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id) cell_entry = nvmem_find_cell_entry_by_name(nvmem, lookup->cell_name); if (!cell_entry) { - __nvmem_device_put(nvmem); + nvmem_device_put(nvmem); cell = ERR_PTR(-ENOENT); } else { cell = nvmem_create_cell(cell_entry, con_id, 0); if (IS_ERR(cell)) - __nvmem_device_put(nvmem); + nvmem_device_put(nvmem); } break; } @@ -1428,7 +1423,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id) } } - nvmem = __nvmem_device_get(nvmem_np, device_match_of_node); + nvmem = nvmem_device_match(nvmem_np, device_match_of_node); of_node_put(nvmem_np); if (IS_ERR(nvmem)) { of_node_put(cell_np); @@ -1438,7 +1433,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id) ret = nvmem_layout_module_get_optional(nvmem); if (ret) { of_node_put(cell_np); - __nvmem_device_put(nvmem); + nvmem_device_put(nvmem); return ERR_PTR(ret); } @@ -1447,14 +1442,14 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id) if (!cell_entry) { nvmem_layout_module_put(nvmem); ret = nvmem->layout ? -EPROBE_DEFER : -ENOENT; - __nvmem_device_put(nvmem); + nvmem_device_put(nvmem); return ERR_PTR(ret); } cell = nvmem_create_cell(cell_entry, id, cell_index); if (IS_ERR(cell)) { nvmem_layout_module_put(nvmem); - __nvmem_device_put(nvmem); + nvmem_device_put(nvmem); } return cell; @@ -1569,7 +1564,7 @@ void nvmem_cell_put(struct nvmem_cell *cell) kfree(cell); nvmem_layout_module_put(nvmem); - __nvmem_device_put(nvmem); + nvmem_device_put(nvmem); } EXPORT_SYMBOL_GPL(nvmem_cell_put); -- 2.53.0