Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4662704rwb; Tue, 8 Aug 2023 11:42:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESZrinXtAeT2piJgOoF59VXGWygm/Ex9WZu1g2ui8MWQ6eOrnxN97IzhhxNidRKClsqHzP X-Received: by 2002:a2e:a171:0:b0:2b6:c8ba:90dc with SMTP id u17-20020a2ea171000000b002b6c8ba90dcmr214697ljl.36.1691520152796; Tue, 08 Aug 2023 11:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691520152; cv=none; d=google.com; s=arc-20160816; b=TDLaihwrq4lq0abYWfrYFowBNoAjT2naUVV0v5KikXq0bpl6sr4UtbXIvb4D3MTc0S coC5SW+hErnf3jVYA+MwdLIU0KsA0yXamio2JJk/FfIPGNGlj7C/HdLz1Fvt8TI9WsGW GBV/Rm0fuHW6V/Kcy5p5GDM2KpYQeljsl6AF/MA0C/9hYlqV+adqr1y5GFJszxrcDgJc rH6wFomQytyMSnpFT+8cII8LqCyotkY6yhluiCPjiTdA4pT2mAw3O5rrePWoNkgX8czk GWVFs8mzuUcxX2Rg5iSVZl+uRmJHz021kQ+/YMWWxGP3qvy0NIzzfOK5UzmUsPcpT1x8 aL2g== 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=4ZQkFeH22rjTDOEpDXIam8py5vjasCP991vagA65hZQ=; fh=5JAiNIUqfT4kvO1C/MlfeSfqzwzAoL3Z7VEut2JDsSI=; b=XfEvUOEjXcZ+iL4drxteuYE5XJ8jYjTNlI6wxXJYzcfW35+SSFXCRnHb7iVKcpWhza W8pAD6Sk79rl1vqwMTiuAGYebb2W6Nib8zH9EL4NDbDlUmrb00ogcUJhXY5JcRWVO0xs pvT2Vq6yhpoFIJuJRAU1iF7vQbqdZxb8BcKx8sk2Uqb56F3fHwJc7EaG0QZvFR/ALhk7 /lgLaoIKy5Z/k4IiQ+EaejOqEKaACkEU11nOuwT7Aav8vrMFpV3/21DfOpA5LgF/yUhq nyG0qZ53Fh477BPnywsN1G+nOmhj8tSGFuDgkHMzWPdkNQXz3YOeKoE9vcE3rnpr65xl CdeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AOsrMQjJ; 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 m1-20020a1709060d8100b0098e3e818952si8163474eji.326.2023.08.08.11.42.07; Tue, 08 Aug 2023 11:42:32 -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=AOsrMQjJ; 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 S229947AbjHHRD5 (ORCPT + 99 others); Tue, 8 Aug 2023 13:03:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229644AbjHHRDH (ORCPT ); Tue, 8 Aug 2023 13:03:07 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17D7B61A9 for ; Tue, 8 Aug 2023 09:01:30 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-51e429e1eabso8014319a12.2 for ; Tue, 08 Aug 2023 09:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691510448; x=1692115248; 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=4ZQkFeH22rjTDOEpDXIam8py5vjasCP991vagA65hZQ=; b=AOsrMQjJAfs5ddeNPYvJ4eHpvHowbyy1zOvW/3H1neixR9X8Zi1grEv6aeAZR1xIzv xc/rqCy4b8HSwl53broXpVQl/BpfG1BFO00i01uWwSTUHKVsLkpIO+Lhgk8f0B1uQl7p kU1xOVOpJ33WqpO1Vhnc8yw8JIOxlWDOAlAR8Xg+E4ZgFR+XEJmSW9lrn71UXfeGqJ02 TeP7DVhcL92Ku7FpOtjC9kttiHKdxcq6q1j6aYYb0hUUyZJsU3nLCHOb57gS1LaLA4S1 aNjY5Cr/UUN/Fw4gLcw/1FS3RqNdKS1bDkJoPukfanHb3Ucip9zhEdgKWcMviM0wy4/O IfDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691510448; x=1692115248; 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=4ZQkFeH22rjTDOEpDXIam8py5vjasCP991vagA65hZQ=; b=bCwUS3xAERcZFXvcL2l5vgLBe6cjT4a/IdzYl+BIw77fQPtwo403XdymRDrW4DgiWn 5M/3KSjk9eB+cRKWNhDEqd/Dp2YUiZBf8xqtpZEdhuAN81doGSqVPiUQ6p3LPx7eh0Hf YFdAsHN4qQOJmbDoFHrZL0DX9bXtDs+GVgflPVcGkzbD+rLmHG2g2iWeWsN0JFX1N4Ox 3VFH7vlNZVhWcBxmZkMAUOwG7f+WXfty17McvWYHkorko+GrN/FcdAGtkuY941L6RSCb c1gcGx8bAhdNnuyVQMsBSNhn+XOwwTJWyNbJnRwlfypDn/cUqfPyYVHbHrzkh+pECpbi Mi5g== X-Gm-Message-State: AOJu0YwHk6eDWZsOUxiypxE2o4X6+6IYtOf4EKqPviwM9ZnnsmoIfj0C kV/9U7biDkpw2B0CqYBi0uDjFKAiFdwQik69rEw= X-Received: by 2002:a05:600c:c7:b0:3fb:b890:128e with SMTP id u7-20020a05600c00c700b003fbb890128emr7355183wmm.33.1691477811483; Mon, 07 Aug 2023 23:56:51 -0700 (PDT) Received: from [192.168.100.33] ([185.201.60.217]) by smtp.googlemail.com with ESMTPSA id r15-20020adff70f000000b0031763fd36c4sm12640925wrp.104.2023.08.07.23.56.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Aug 2023 23:56:50 -0700 (PDT) Message-ID: Date: Tue, 8 Aug 2023 07:56:47 +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> From: Srinivas Kandagatla In-Reply-To: <20230808062932.150588-2-miquel.raynal@bootlin.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.9 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 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. --srini > + > blocking_notifier_call_chain(&nvmem_notifier, NVMEM_ADD, nvmem); > > return nvmem;