From patchwork Tue Aug 8 06:29: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: 132763 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2332638vqr; Tue, 8 Aug 2023 12:02:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgJuhlJDpGQMaa3M9+D71gqYOXdbMyYPwhh4z8Mx/mx/CGOc38ycRtiBPPxMDtbXITqdQ1 X-Received: by 2002:a5d:684d:0:b0:317:6513:da83 with SMTP id o13-20020a5d684d000000b003176513da83mr262031wrw.43.1691521339785; Tue, 08 Aug 2023 12:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691521339; cv=none; d=google.com; s=arc-20160816; b=vM/IsDh8f/WMDFW2S+5gR1mizwV49beAgvONnwEO5Q6sDqlzBKuP6jVQ1RKdyH97g/ phW5icRW+NuVCyY3EudVOmdk8DeuVLh2GKf2+XKC8HZ0VZGGBUM2m9vDPU8sLvWxTWaw 86Sf+7XdZtq5PEiLwPbCtIZt+7Z0tGDER/d67fRK4bMoyeVYE5Kxb5i9LPsoL0kZOJ8J ciRPI841wsOqaRYtnctSP6SvNuAYWc1X77Qd49+jr7QAuLZ2PGAnavRiAlL4qPP21ZuK vroEw8evdWUiBlQE+9wac8JESlrjtEslfvDZ15Vjvx13mCuhYsSCBcXR2VumrqFoiiBR +MaA== 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=deFHTfKtsiK3fIUTO5dxK20yHHqrhqSjB5+h9NbX9KJBqr/dTUJwsBO5yebPElvhx9 ab5W4GwfgQc9pqzbsMw7MmCy/TyHW57iPDQ1jvCJ+oHrKAZRwHXq2B0QQGrGJGQ8gS7j ukXaN8LMcJs3m3ZUmx9vddG1UrEi5Py+HDwBSnvp3xyKuP3HTNKD1eMfRnBnldPdzDvq gh5jj+bBMoCGxb1xNiL+oHADkrgQ7Maau7u4E3wdC1zirSmsrOti0N/1eQg7nXrRtAbq dytE1EiOEaFNwa84erZGhsCqCEDH88I8G/9VfrX9+w+IGB7LpF3Ehryv/ABToVYt54qu u/4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=m09o8WMv; 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 r25-20020aa7c159000000b0051e16fd4d9asi7525619edp.223.2023.08.08.12.01.55; Tue, 08 Aug 2023 12:02:19 -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=m09o8WMv; 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 S234725AbjHHRdS (ORCPT + 99 others); Tue, 8 Aug 2023 13:33:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234756AbjHHRck (ORCPT ); Tue, 8 Aug 2023 13:32:40 -0400 Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [217.70.178.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 343D6F980 for ; Tue, 8 Aug 2023 09:14:10 -0700 (PDT) Received: from relay1-d.mail.gandi.net (unknown [IPv6:2001:4b98:dc4:8::221]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 53A85D2E91 for ; Tue, 8 Aug 2023 06:29:41 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 8C7E8240002; Tue, 8 Aug 2023 06:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1691476176; 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=m09o8WMveylXIA6+Wxh05/Wjd4mUGCqxw+Q6xeYqPZYiU3wK95n/gIcX20uwb8X9VB+Z3W JcvC8NIkpn4ka2KXwDwxSs14CzsLkexWtSHmDIGcmq+DKqEj17TtpnDv/FIAFGu52e3c1S efIYy+fPq4Swu5/ETkwBqP4O8+W1Q8KMUzQJn6qjZnCKbae8FzRfVfIfLtji1sx+uU0S5E bPQa80hjjd2hI5OZeITss+kviY7Q9O9BfHRAQKNG5CiRFh3JpZQg4DlY3vJhLXKTlEQNCJ c1b4CBWCLF02QxsC8xWdZAntPnM0EUZr9wa+JPTUqW+tcA4wRl0H7TWoqPfI8Q== 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 v9 1/7] nvmem: core: Create all cells before adding the nvmem device Date: Tue, 8 Aug 2023 08:29:26 +0200 Message-Id: <20230808062932.150588-2-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230808062932.150588-1-miquel.raynal@bootlin.com> References: <20230808062932.150588-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,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: 1773683299655425408 X-GMAIL-MSGID: 1773688680145057343 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;