Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp966735rdg; Fri, 11 Aug 2023 05:59:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHs2PznuDHgkirF3khkyUSVUaPX1Gy6Hm0UAtdDNpkh4+qHhaNXg5q4ITXObyaMPHNzjw78 X-Received: by 2002:ac2:5f4a:0:b0:4fb:74da:989a with SMTP id 10-20020ac25f4a000000b004fb74da989amr1078356lfz.3.1691758768458; Fri, 11 Aug 2023 05:59:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691758768; cv=none; d=google.com; s=arc-20160816; b=qbV97aVD6BEvn32bxHYLBw7v5zBKLV/SX8wwIX5R5v1ldJxRQ6BE6xNKzO1xnXYoSt sdEmM6Zu1lZ5yc0TgKerMrKp5GuZBziIdL2UjxTU7aNdcjhltej+iz0scWrc7NleR5VS 5+LH6LeMDO3kR+yDEwab26Miy9G54lB/MAYyVcN11D2ziErz6s4BVsl3Aw2CZr1OG120 0iG/hp9smsT+WSWSm8NK8Tzs/Xz3+cinbbOGRrz7DZk7aJKIHDHNqx6pwplUAqNgFRiY vFYdlfqgDACyUpe6KoQy8ZW0nZuPGlMLiYfa8LC0flQQfS0ZGeGogbd4Mkih1ElOxNQC OPIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=nkarAxgPawRkHPuqEmVAhp5coc9Enpd1p54z8XhUNR0=; fh=5JAiNIUqfT4kvO1C/MlfeSfqzwzAoL3Z7VEut2JDsSI=; b=aRnI0TdDK2luq4exYXcgWF01kmz4zriM9pymhj+WS7/ph3QWCZ7bcaQUiLtTF2Y2kf uFNBKg7e6AM6YTlcgueYKLiPIheBvDLwEjnOUShvjmsFdOjy1nDiDQC3Xsh4xFT5T9oj OhupO+rIIEhGHtApwbS8TYwSwdhCaIraWCG6c5WYhbb4N5kn6m4aM9t2X/4eZPKtlOUV SGn+2Dqdj8/TSsL1zgm/yw7ESA/2GOkU7FuCqDrSQFlH+AiZm50c/Wf8P1ypqA4Wauwq cPpooYb/BtpB4I0SSpVxhQ/t/7Opw3sGtuc3FKFfYbkoIYb630GE1rfTJLSzQ3e9btPg nsiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HhLQHL2q; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v13-20020a056402184d00b00523384d70eesi3403744edy.416.2023.08.11.05.59.02; Fri, 11 Aug 2023 05:59:28 -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=@linaro.org header.s=google header.b=HhLQHL2q; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235952AbjHKLLX (ORCPT + 99 others); Fri, 11 Aug 2023 07:11:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234926AbjHKLLW (ORCPT ); Fri, 11 Aug 2023 07:11:22 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16EAEED for ; Fri, 11 Aug 2023 04:11:22 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-977e0fbd742so254903166b.2 for ; Fri, 11 Aug 2023 04:11:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691752280; x=1692357080; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=nkarAxgPawRkHPuqEmVAhp5coc9Enpd1p54z8XhUNR0=; b=HhLQHL2q4FMBWaRADl7oilv0xHC0G+ChUtfzHtXBiHo+Y1e0FeA850q5x/X4QtfD41 oIEdUXY4sqQi/in1/E+jT6CzBXm820hIJ3kL+ITiFb3FzpgBUCt08NXUTYVKaAqS9Lb8 HM/qOR5DkaOHpFCuLB7lxL3DxsHMD/pZyK40pt3s+45WuS7heXildCR2He+hoy++pgfP RGR/2r2h5Ey7GCWu0WykrzqKV23q9IP4lK1qkTtv/O6VqIqThSf2t3AhgS6Ih7whNIZx QnxbSQPn0FlzHqDmqApw/GepeHuh+Pfoy/Rh4/swLiuhCS2ZHi2lOwPAYwSQeBOZr9w3 L4WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691752280; x=1692357080; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nkarAxgPawRkHPuqEmVAhp5coc9Enpd1p54z8XhUNR0=; b=Vg8OnQ3Vu3KGw+42U4xJvipoPLjFlcMZOrybz3dQsgZRLA9qb10wEeTcK1TixZcYKa xD1biZcNnYZwJhnmCgLAzKwWzf/3rYAQQ2jryru9Lgusa1rStvxFvEXKJWVqRc9zMjfs q+Hsq7m1Ohj90LS+UxTBLqH2072WbVWhLXeZgWzE9qBK5qK1WciBYGIATJIaJB8N8KRQ FtSAQSvj4L3DDXpaZ3mRy+F+/ehNwgwgJkSbPXLxkLMT20F8/4KCFH5If4T6+/vvG2Eb EmasiZsvTQguv3hs6qTr7WN2tCWHr2kiqyKh2n5wREeXMAo2OLGYEHy1BjrgiWB92WtK ssPA== X-Gm-Message-State: AOJu0YwV9ZDcqTdqPpgxU6xD4N1u4bIgv+9e0IAlhOzHV4crhRoKiunn f/4D8oWVmqdUnLs4WxJMyD/5lg== X-Received: by 2002:a17:907:7716:b0:997:eae6:9350 with SMTP id kw22-20020a170907771600b00997eae69350mr1388529ejc.51.1691752280574; Fri, 11 Aug 2023 04:11:20 -0700 (PDT) Received: from [192.168.1.195] ([5.133.47.210]) by smtp.googlemail.com with ESMTPSA id kd5-20020a17090798c500b00982d0563b11sm2101067ejc.197.2023.08.11.04.11.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Aug 2023 04:11:20 -0700 (PDT) Message-ID: <05aea50f-6692-962e-abe7-765197815f03@linaro.org> Date: Fri, 11 Aug 2023 12:11:19 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v9 1/7] nvmem: core: Create all cells before adding the nvmem device Content-Language: en-US To: Miquel Raynal 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?= References: <20230808062932.150588-1-miquel.raynal@bootlin.com> <20230808062932.150588-2-miquel.raynal@bootlin.com> <20230808092433.039e2f48@xps-13> From: Srinivas Kandagatla In-Reply-To: <20230808092433.039e2f48@xps-13> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,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 On 08/08/2023 08:24, Miquel Raynal wrote: > 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. >>> >>> 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; >> >> All the error handling paths are now messed up with this patch, put_device() 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? This looks perfectly fine, no change required. This also fixes a bug of missing device_del() in err path. pl, Ignore my old comments. > > I also see the layout_np below should be freed before jumping in the > error section. you mean missing of_node_put()? --srini