Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4668080rwb; Tue, 8 Aug 2023 11:48:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVhjGr39s/+7Hj/Ji9kgerUB8eI4k7+6gPcrfJxxIvohTkV8pVw0YQVk6gibEu/RBaJEcK X-Received: by 2002:a05:6a20:551a:b0:13c:3b5e:a12a with SMTP id ko26-20020a056a20551a00b0013c3b5ea12amr336033pzb.34.1691520514493; Tue, 08 Aug 2023 11:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691520514; cv=none; d=google.com; s=arc-20160816; b=TXJmPiBrg0JwJNzXD8Jwqt3JTeOR4p8vGYXIWTAKbs0r+PaaS+w/bN5s+Vh0CREv05 MVEzw9+0Jcv88v8ADJO8jEc1KTI4/KUz7XC6XHi8HbZ6Yy9VklGZOqevnfk4agL6YkAW /2UbpV++PW95tuLEnmdtWXMVmXg6VBh6oF6sA9+7qBA4r0s3zmrLv+7JnHjekR5xuDxi p1vSJFM/+oh1IaMKTAazZzVfjbTtUtabNWerqh2djm2tXkWEQ3pHhJxrqcXl4XfuUjjh ng82NB2IJqphSHH8JmRHl/O6FwwCIc7eFlFyS4DFGSJSsTt3adZLBs65Tq5HEjh56i7V U6JA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=fDRXGZrFxcrqIVQFTqu7OIFNyRPE4XGA6YwnsV/FCAg=; fh=U3wO8OjtOiol1NLL1Tea225ywF0wDQH/x7n0HRCwKfk=; b=H8YR9UH/VzUqQYkR82ZTFnL8a3KXcWSqekDcpohQIjNRlBzreCehQucsSVbl5eUbUs rxy5ALIQs2D5EIxWRDomb8/LET3ktIrMW71R6t2jjTRKznGYRInKbIZiJuZsquOhfYpb qGAq9XlvHSNrK4GhUfbi840TRxYQ7husI1ssbNQDHD5twquDy7VvF+03cFQMiwrk1j0w 93Agq6J9+xZCB6DVk09NgZKnBoMN+TzW/8cv0Z0/1m74kOTA74/0NBpFyMRgFAYU2LB0 Ud9daunPw9UfM9y0+KpoisfpxbEWvRXuHKtiZMMmkg7gZVy1Gl5ToO8l/SnWeaZLZlal guHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=HD4Amxuy; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p16-20020a63f450000000b0056399eefcc2si7558841pgk.20.2023.08.08.11.48.21; Tue, 08 Aug 2023 11:48:34 -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=HD4Amxuy; 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 S234554AbjHHRYX (ORCPT + 99 others); Tue, 8 Aug 2023 13:24:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234222AbjHHRX5 (ORCPT ); Tue, 8 Aug 2023 13:23:57 -0400 Received: from mslow1.mail.gandi.net (mslow1.mail.gandi.net [217.70.178.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FB831FC88 for ; Tue, 8 Aug 2023 09:10:00 -0700 (PDT) Received: from relay8-d.mail.gandi.net (unknown [217.70.183.201]) by mslow1.mail.gandi.net (Postfix) with ESMTP id 0A09CD39DD for ; Tue, 8 Aug 2023 07:24:42 +0000 (UTC) Received: by mail.gandi.net (Postfix) with ESMTPSA id 398731BF20B; Tue, 8 Aug 2023 07:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1691479477; 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=fDRXGZrFxcrqIVQFTqu7OIFNyRPE4XGA6YwnsV/FCAg=; b=HD4Amxuyv6+a3yyzqLIy0t+Fyxsl/qTnAiuUtftt85ZqODENjhdmWX+G5DqTCwXIqGUyE1 KXLpei6fPf2NtJKixkMWetdH1TIfqNHPsT4l/HKKeotU/DeLe+JtbLztArVSh/Z6Xnqk7Y 3I1wUWrvAZMhnSLhli/3KbbY/rBQ6RIttCvQoxP7zFS84DDB8VKdMMqj0l55Ye14/CA7nz 2J/gfogOjw+U96+IL5hHKLrP2XHeVw4rWQzPu+51rqM0u9SBaWoJ7V2/+1t724yYlqnnoy LZTHf8VauCbglN9o9o8aU37Ysmt4TOxaMzi9VDowCEAOPexlcEUBn+H8AMLvBw== Date: Tue, 8 Aug 2023 09:24:33 +0200 From: Miquel Raynal To: Srinivas Kandagatla Cc: Greg Kroah-Hartman , 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 v9 1/7] nvmem: core: Create all cells before adding the nvmem device Message-ID: <20230808092433.039e2f48@xps-13> In-Reply-To: References: <20230808062932.150588-1-miquel.raynal@bootlin.com> <20230808062932.150588-2-miquel.raynal@bootlin.com> 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 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 Hi Srinivas, srinivas.kandagatla@linaro.org wrote on Tue, 8 Aug 2023 07:56:47 +0100: > On 08/08/2023 07:29, Miquel Raynal wrote: > > Let's pack all the cells creation in one place, so they are all created > > before we add the nvmem device. > >=20 > > Signed-off-by: Miquel Raynal > > --- > > drivers/nvmem/core.c | 12 ++++++------ > > 1 file changed, 6 insertions(+), 6 deletions(-) > >=20 > > 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 n= vmem_config *config) > > if (rval) > > goto err_remove_cells; =20 > > > - dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->nam= e); =20 > > - > > - rval =3D device_add(&nvmem->dev); > > - if (rval) > > - goto err_remove_cells; > > - > > rval =3D 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; =20 > > > + dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->nam= e); =20 > > + > > + rval =3D device_add(&nvmem->dev); > > + if (rval) > > + goto err_remove_cells; =20 >=20 > All the error handling paths are now messed up with this patch, put_devic= e() in error path will be called incorrectly from multiple places. I'm not sure what this means. Perhaps I should additionally call device_del() after device_add was successful to mimic the device_unregister() call from the remove path. Is that what you mean? I also see the layout_np below should be freed before jumping in the error section. Is there anything else I missed? Because you said "from multiple places", and I don't see this. Thanks, Miqu=C3=A8l