From patchwork Thu Jul 13 07:55:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 119608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1661156vqm; Thu, 13 Jul 2023 00:59:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlE9cFTXJPAe1d4L33RdZG+LyBjkvi3LbYkWE+4I2/Sg+VeTDBf2HHBv138a5InWck9MwYDE X-Received: by 2002:a05:6a20:3943:b0:118:e70:6f7d with SMTP id r3-20020a056a20394300b001180e706f7dmr354406pzg.10.1689235198743; Thu, 13 Jul 2023 00:59:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689235198; cv=none; d=google.com; s=arc-20160816; b=djhRPGP0XvSiPlnMkA+Vi7VlTe3S7SxeIctZ1Rz0hRx/F8dyEqRoMrJYaxSIIhz8sR 1Lt+xEvVNdw4B246nPhlzbQIt2EZeRLX0ayLZzHa44pPW2K/Zuqs2kpJektqTWSAdDe0 pnXWcBLpmNgVHWxWkKOVCNNG5N5mmDizpVs5l5Inda3W6dzGciNt6jsQmJjP1opK44hH vFf486Cf3WVb/UnDtg4So7+ewxKob/TUN4HAUAwpOaZ3o+2MUmip5LnJm+6P4P5COAlc vehYhtBysvuDtZ8XNABKnrnO0DXgfGFCPjGrWO3ia7tHw/Ebo6OU8QUiebOiF1Yj848K 3NCg== 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=ZBivFC5SWw0lWeQfkQzZMt8E06fgq2S9EtIfz3iJ8AM=; b=X4i7nYEnsw6r5/UL28j6reSdFhVU3/JgO3nrF5EshYSl4+/u8Bt78M6zyza9wcrgXl J1FyDYeCZnMafHrf59MLF8dwhEQonDWv3agQM1pO00zbTygnpVV3JUQ7XvYyLUR8iM2X OqD+xo2LClY9g5FL6opQgWiusyrYNRG2qh1GIOCnIkA4ZK2fSg1lfEYFvtT4vaL3twvn WVHvzo+sYH0XDCHSBBNCkcOtXiNUq5NntKbp0fyaQIRmZpeCpuYxEVHqzOv+IzsCOe9i wTSSKeZC/MpuLVZmHdipr02aLFHzdC292UNlK6P6EE+5kpEvSRy+8Z14m8yKTS/ABDRV uVhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=J+NPr684; 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 c9-20020a170903234900b001b81fe65fa3si5021670plh.569.2023.07.13.00.59.46; Thu, 13 Jul 2023 00:59: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=J+NPr684; 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 S233074AbjGMHzX (ORCPT + 99 others); Thu, 13 Jul 2023 03:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232989AbjGMHzN (ORCPT ); Thu, 13 Jul 2023 03:55:13 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5C16173F for ; Thu, 13 Jul 2023 00:55:12 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id C353AC000E; Thu, 13 Jul 2023 07:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1689234911; 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=J+NPr6840Zv8RDcu2FXpfHhLZ5nHQ624tV8tSiofImoFSKQ/Z5At/i0OTkkgPQDFxvONsz smeH/ugpM6pV/kVghzzP32aKqpLzg3rlcf3wcmpXNvCOXTN/YiV1FeNyNODTNc7xUv2/os WVVDWU5da5C1xOmpgezsCPXnh0+Z5F/tCjoDe/pjX0wn+86KwkSXnTlOBzzuNu1PbEB9hl vcSj3VLD7k70tHcVJlqziaLwojCnZCU3NnplnGW/Ikr5rOSzy1CS4cTGTJnhc/hEKbDSrE iYdU9jZpiFnPBifvQI2ym0F/jtIAxBdjE9JGwYvLKpU7u3BxkT0yMdaHacn8sQ== From: Miquel Raynal To: Srinivas Kandagatla , Greg Kroah-Hartman , Cc: Thomas Petazzoni , Robert Marko , Luka Perkov , Miquel Raynal Subject: [PATCH RESEND v5 2/3] nvmem: core: Create all cells before adding the nvmem device Date: Thu, 13 Jul 2023 09:55:06 +0200 Message-Id: <20230713075508.485072-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230713075508.485072-1-miquel.raynal@bootlin.com> References: <20230713075508.485072-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 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: 1771291487887010341 X-GMAIL-MSGID: 1771291487887010341 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;