From nobody Mon Feb 9 17:22:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFEF2C0015E for ; Tue, 1 Aug 2023 18:21:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232136AbjHASV4 (ORCPT ); Tue, 1 Aug 2023 14:21:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231837AbjHASVp (ORCPT ); Tue, 1 Aug 2023 14:21:45 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E53DF213E for ; Tue, 1 Aug 2023 11:21:42 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 0DF99E0006; Tue, 1 Aug 2023 18:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1690914101; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZIUXjeBWaacBxz6WsBbjN0nfgEPspA1Ri8UkX9Lqn/c=; b=m0Y3FQU7ZWxAVvM4lVxGVpPnJD1KykoHWeve45Ufs3yQIG6QC9Q0wkUZGJ3Ze5diPZ4jBU 2QGQzsy//qSArcxQ3hGtTHAoaWuLEKzltIUmu6gH9D+f/0hu+v3RoXyMrrBceMuU/J6qvX wABtexQ48Lyj1yF6wUZ0aDUDs5/uV397D5k+vbYasGEIdsvE7rQGNdGWcA3h+/CyYw+LeC ZP43Qdr7QXHjN0Rh2+C1fJthZkfRiPYFP6KhNL69lGKN6U/KgX/5GbxdkGQwqVuLA9GjO6 XhxaypvVOTsIIvIY5LU/cSfljQwXQa37v9n2CaaBwYOpm62j8ysXQEvpXTR7eQ== From: Miquel Raynal To: Srinivas Kandagatla Cc: Greg Kroah-Hartman , Thomas Petazzoni , Robert Marko , Luka Perkov , Michael Walle , , Randy Dunlap , Chen-Yu Tsai , Daniel Golle , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Miquel Raynal Subject: [PATCH v7 3/7] nvmem: core: Track the registered devices Date: Tue, 1 Aug 2023 20:21:28 +0200 Message-Id: <20230801182132.1058707-4-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230801182132.1058707-1-miquel.raynal@bootlin.com> References: <20230801182132.1058707-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Create a list with all the NVMEM devices registered in the subsystem. This way we can iterate through them when needed (unused for now). Signed-off-by: Miquel Raynal --- drivers/nvmem/core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 257328887263..4e81e0aaf433 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -23,6 +23,7 @@ struct nvmem_device { struct module *owner; struct device dev; + struct list_head node; int stride; int word_size; int id; @@ -76,6 +77,9 @@ static LIST_HEAD(nvmem_cell_tables); static DEFINE_MUTEX(nvmem_lookup_mutex); static LIST_HEAD(nvmem_lookup_list); =20 +static DEFINE_MUTEX(nvmem_devices_mutex); +static LIST_HEAD(nvmem_devices_list); + static BLOCKING_NOTIFIER_HEAD(nvmem_notifier); =20 static DEFINE_SPINLOCK(nvmem_layout_lock); @@ -1012,6 +1016,10 @@ struct nvmem_device *nvmem_register(const struct nvm= em_config *config) if (rval) goto err_remove_cells; =20 + mutex_lock(&nvmem_devices_mutex); + list_add_tail(&nvmem->node, &nvmem_devices_list); + mutex_unlock(&nvmem_devices_mutex); + blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem); =20 return nvmem; @@ -1037,6 +1045,10 @@ static void nvmem_device_release(struct kref *kref) =20 blocking_notifier_call_chain(&nvmem_notifier, NVMEM_REMOVE, nvmem); =20 + mutex_lock(&nvmem_devices_mutex); + list_del(&nvmem->node); + mutex_unlock(&nvmem_devices_mutex); + if (nvmem->flags & FLAG_COMPAT) device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom); =20 --=20 2.34.1