From mboxrd@z Thu Jan 1 00:00:00 1970 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 7D4A3C41513 for ; Mon, 7 Aug 2023 12:11:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233342AbjHGMLu (ORCPT ); Mon, 7 Aug 2023 08:11:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233297AbjHGMLp (ORCPT ); Mon, 7 Aug 2023 08:11:45 -0400 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB5CAE47 for ; Mon, 7 Aug 2023 05:11:16 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id B78A34000A; Mon, 7 Aug 2023 12:10:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1691410261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zA0Pqt8JIxag0Qxf0Qj9I/LI0SmbQ7bxHc5QrMxN8pU=; b=A8gMQ035qKR7tPaLmCmG+XF1bt0w2wj91ufeIiUZM45cNeuwmFzd8N4jA8gPZmATF4UJBk 0UFAuHIid6Ciha0Xwwc6MLB4PQhta/ufLaC2moy49vBRsxQkru4NOMU9t8fhlFX+WNj34N fJS/XGzBboxIWeO4wlFbMaBY+o107CDMGbh8n0onUqYPMMJcj8HTSg0srv8ei5GwUzMauF 9FK/z5h5FqI0eZtcLyFLXVrmCpz01ZGNJkuDOrM/A8SsFb54hsx3f5eyGA07xvH0f5xBF7 YrZM+O4AcTCMAJl+BstMoBy5xHn67c8irpbrqqgA5I0m9YeaktFXi9e6GJ/wMg== Date: Mon, 7 Aug 2023 14:10:57 +0200 From: Miquel Raynal To: Greg Kroah-Hartman Cc: Srinivas Kandagatla , Thomas Petazzoni , Robert Marko , Luka Perkov , Michael Walle , linux-kernel@vger.kernel.org, Randy Dunlap , Chen-Yu Tsai , Daniel Golle , =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= Subject: Re: [PATCH v8 4/8] nvmem: core: Track the registered devices Message-ID: <20230807141057.64976ee1@xps-13> In-Reply-To: <2023080732-gulp-pancake-93a5@gregkh> References: <20230807082419.38780-1-miquel.raynal@bootlin.com> <20230807082419.38780-5-miquel.raynal@bootlin.com> <2023080732-gulp-pancake-93a5@gregkh> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Greg, gregkh@linuxfoundation.org wrote on Mon, 7 Aug 2023 11:02:35 +0200: > On Mon, Aug 07, 2023 at 10:24:15AM +0200, Miquel Raynal wrote: > > Create a list with all the NVMEM devices registered in the > > subsystem. This way we can iterate through them when needed (unused for > > now). > >=20 > > Signed-off-by: Miquel Raynal > > --- > > drivers/nvmem/core.c | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > >=20 > > 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); =20 >=20 > But this list should already be in the driver core, why create > yet-another-list-and-lock? I did not think about using it. I believe you mean using bus_for_each_dev() here? Could definitely make the trick; I'll try. >=20 > Why is "when needed" not sufficient to use the list already present? >=20 > And now note, you have the same structure on 2 different lists, watch > out for device lifetime rules :( >=20 > thanks, >=20 > greg k-h Thanks, Miqu=C3=A8l