From patchwork Tue Aug 1 18:21:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 129426 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2866922vqg; Tue, 1 Aug 2023 11:52:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlF8UdezURgzhfn7oF8EFAVizIvD+mfxGmCs0uZD0WjmWmtvDeFaATuLtiCSwR1xP4uawHEG X-Received: by 2002:ac2:4e95:0:b0:4fe:1e74:3f3a with SMTP id o21-20020ac24e95000000b004fe1e743f3amr2417389lfr.58.1690915978604; Tue, 01 Aug 2023 11:52:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690915978; cv=none; d=google.com; s=arc-20160816; b=pm6bcbSGHGQQd4LyUBYaqpI4sE1imPzaKPFRbEdH9jtHZ+abxUXWTJayLFCdtg8ztS 7Fq8xmWFhUMLV/Zz8nAkuKQDDMGxjW+V/7U7/xmoCygcBFaGwtnXfVH8N/IgAVbU4On7 0ySlmlTBZDOYX4xECs128ji5gIP7AGelCG88Ujn61qLbWekI1ZcUDHUV9z1OrurYB/wK 2OG6J29DF/pALZECr20+BXr5VTLDPCc2KTio6v38Rm5Opbyn9vU7F9EE5DLWt6pFmmih Ws7WO7mk64vJ1NjOBD6OWXQMb//5fr1+BOcOSAYktzdnI9Hq9dc3AAjAY/eBXomC7EOF XvtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=un3Uwaotmlox+IhpuLnflkjcgnz89/YG1Do8CcofnC8=; fh=OHS2tDwbcHt81zFnYeyYq8ynDfpjq+e2h9R20vebRfM=; b=RSqOSrSJenglse5eaRnokvPEjRjx7jwjPct4IwaheI1mSL1Sa0EHeTU8YL20HyR1PB 1llFmog/H5OTZ/ilETNaKLdOYkSpyhlLwPbsfsjatkaXxBjihkc/60zjV5BPtz+5mcQt BqJhF/NhEUkah3gK9oh7Eu74upF5vRClZk4lR/RFqxzvN90l3FK1x8TPhWDITTuHY25U yzhhLyskO8AhNRM7mwoQPC4qkhlnnNlXaSxwqa+gdUmD24RfQd3Y65bpBgrpMQJ2pqb3 aisBg64FtCiwIypwyNyNRBHlrUwFPx155O+hGFcMJTRUEPnom0pegL5bQTwRyRghsH1h OAWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=KSm9vmu0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m2-20020a50ef02000000b005222af123bfsi8687461eds.301.2023.08.01.11.52.20; Tue, 01 Aug 2023 11:52:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=KSm9vmu0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231796AbjHASVt (ORCPT + 99 others); Tue, 1 Aug 2023 14:21:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231734AbjHASVn (ORCPT ); Tue, 1 Aug 2023 14:21:43 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8815F2689 for ; Tue, 1 Aug 2023 11:21:39 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9F357E0003; Tue, 1 Aug 2023 18:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1690914098; 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=un3Uwaotmlox+IhpuLnflkjcgnz89/YG1Do8CcofnC8=; b=KSm9vmu0f8IIcuOFIlEzau9XSapvbuGrbGmh2i1glN+GtLBpvJYtMLcriL7sQVfOKWyS0o PtghWB/Bn5vMHBcPOhw4J84WduNNP8bNjuuMKSVtjmaZK0sig+/YQhHXYkO/skQVsA4dVi tPbJkpVL3r0mHUfCaZPeTeKmjqe9K7sTK1gck/4Bbc/vp5CAp1SYBE7v87p+f/h5bH1eXS BPoFabs50SX8imkphZYTSwZE8aQxqKBtFjg09NStYeyj7TGiVBdvb4gLHx5tqSkrETQHnI kn31uhXsxa5z47ZpFRwqL0QMPgt7wGtHB/uvN4nMNcWNruNMK53qcQbhTU3Avw== 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?b?UmFmYcWCIE1pxYJlY2tp?= , Miquel Raynal Subject: [PATCH v7 1/7] nvmem: core: Create all cells before adding the nvmem device Date: Tue, 1 Aug 2023 20:21:26 +0200 Message-Id: <20230801182132.1058707-2-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 X-GND-Sasl: miquel.raynal@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773053912857393906 X-GMAIL-MSGID: 1773053912857393906 Let's pack all the cells creation in one place, so they are all created before we add the nvmem device. Signed-off-by: Miquel Raynal --- drivers/nvmem/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 3f8c7718412b..48659106a1e2 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -998,12 +998,6 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) if (rval) goto err_remove_cells; - dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name); - - rval = device_add(&nvmem->dev); - if (rval) - goto err_remove_cells; - rval = nvmem_add_cells_from_fixed_layout(nvmem); if (rval) goto err_remove_cells; @@ -1012,6 +1006,12 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) if (rval) goto err_remove_cells; + dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name); + + rval = device_add(&nvmem->dev); + if (rval) + goto err_remove_cells; + blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem); return nvmem;