From patchwork Mon Jul 17 07:51:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 121106 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp970587vqt; Mon, 17 Jul 2023 01:07:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlEO1u/ahcnQ7n1D7qdHqB9i/6WgSjIxnJHGbe2sIEITVpgVbMbNwOdeq13dpchqs6+VRDsd X-Received: by 2002:a05:6a20:8405:b0:133:c170:6ee9 with SMTP id c5-20020a056a20840500b00133c1706ee9mr11163529pzd.42.1689581242596; Mon, 17 Jul 2023 01:07:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689581242; cv=none; d=google.com; s=arc-20160816; b=YC39J18Q5VhPG5kcGeVkDnrBVNBoqLrNQwD3EQtNfcwpPotS5QldZ7JOJKXCs/qiv3 mhO7z4cLV8XtuQaGyRXuomB5ihuNW2aXwSoXQ/zndsPhPKqy/w6WWxbD4VJOe9PUG7vJ L/SDcii3lPO5QZX7EpVvzD74eEvQdDQTWg8rvZBahcteFxFqR9qkTkBv3yBRcExsBBMq xmhmfuLh4bQc9nj5ztZjHJQUExv7MaIbxQUhMpbqXRejEz9+OoHWm8e1TMbiswPg74Se JYvMh6VaIf+AOrcgiLudCLvv4RnDo4cO+eCJlrNcghyxib0yx9Y4laKH8Y8WPxL1gqm3 x03A== 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=JpygR/0v0UTOXdyljMXVkuezv/HjT4xrIjOwJ6y50X0=; b=LfnbrTcmZFn9VsSu9P7EeggPcSxgUF8O1E0S9nssfPa7DRL1gzyccb7mh0J05QEAOW 3sCxfCY0xJiJJ5y8xP87SIyo3whXfSx3FW6jVA8M++1XnWpf964Lfq0eZVsU2LBJcl+0 Kwu0ZwW5Qx9gnr5zOHkbxrJWCnYUZJuXHSXFRR6LH8aBMyrQ+gHFr6PQRPZkbGxAqC2f kiQn9tU4PBj58eT8X+H//sBKQnR2L3U5NYzjEgyS1fxQ7oRSAXAwKJF594q2YQ8Xxgbu fS2wRgmXuAh8GaHUFjTBBDfJOZEV8K+gelVLmOVA5jIc+BxzbUcUHXrEN5wKRPALQpNC flBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=lVX2afz+; 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 bv10-20020a056a00414a00b006724753efe8si11157318pfb.192.2023.07.17.01.07.09; Mon, 17 Jul 2023 01:07:22 -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=lVX2afz+; 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 S231193AbjGQHwO (ORCPT + 99 others); Mon, 17 Jul 2023 03:52:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231187AbjGQHwD (ORCPT ); Mon, 17 Jul 2023 03:52:03 -0400 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9D9E11F for ; Mon, 17 Jul 2023 00:51:53 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9237360006; Mon, 17 Jul 2023 07:51:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1689580312; 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=lVX2afz+B4qHgh/0ieV127PWztHw9UJvh71z5wscYgDB5/SvgkKR28zKhnY88MpfJ31hF9 5HDWe6wAG8fQvwv2dGi9OLO7TIWBQnbp8HUQs2OcxsUSVHpMGPHU0q8RBU9T3dRLdSFVcm UB81cej5nuRO2KkhXGtjs0uxXsKvytd9mn5Mb/8TfnTymzPH3XEG6sDBEayofBwF2tSB34 NVNaGLUoqVyaCIGM6TbL0707/IkBJ/rr3jTPSzHZkbQNZwsTmbGwK6N9TYbR4sMv4EmZhW ggw34CztVbuFV8j2dz6a4oTcl1d0b4eoT/5bXGncQePmzTzfbgLp0e0ZODGPYQ== From: Miquel Raynal To: Srinivas Kandagatla , Greg Kroah-Hartman , Cc: Thomas Petazzoni , Robert Marko , Luka Perkov , Michael Walle , Randy Dunlap , Miquel Raynal Subject: [PATCH v6 2/3] nvmem: core: Create all cells before adding the nvmem device Date: Mon, 17 Jul 2023 09:51:46 +0200 Message-Id: <20230717075147.43326-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230717075147.43326-1-miquel.raynal@bootlin.com> References: <20230717075147.43326-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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: 1771654341152095963 X-GMAIL-MSGID: 1771654341152095963 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;