From patchwork Wed Oct 4 22:22:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 730867 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C1F024208 for ; Wed, 4 Oct 2023 22:22:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="cQd6LjNl" Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84554D8; Wed, 4 Oct 2023 15:22:47 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id EF33E1C0008; Wed, 4 Oct 2023 22:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1696458166; 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=ozTgRpH7t0hBveOF8yXGnBl2vT15HtovIkhQFtR9B74=; b=cQd6LjNlsF+BeoUk5ZXFpdCXxeLsrgtit+isxZblQAIm+u0fis071wiB28G/L1Zz1WDzQo V49sfOGDgm9EasASWJkh35SANIbV2rLjPSOpUw4VBSaRChVqqQ/gSSvEpHG3+dINiDwagi j7piMSDMXA0HUPkfDf+PfDzPRlvRL1sK5xwKkPEsgguRmwmSTZC3Zh9h1uShJLeybEF0ai qnt8HdDjLAdjPDAVx5hEhLDZZlpnPa1dYTiifRAJZFVkBJCx1j/5meSksA/IwNIHuNjdcT sz5FSx5NHXaDOOYUs/wLZq7qF2lEn6nVtAA/sZT6WqkdchcGnftsEi/rOYMYxg== From: Miquel Raynal To: Srinivas Kandagatla , Greg Kroah-Hartman Cc: Michael Walle , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Rob Herring , Frank Rowand , devicetree@vger.kernel.org, , Robert Marko , Thomas Petazzoni , Luka Perkov , Randy Dunlap , Chen-Yu Tsai , Daniel Golle , Miquel Raynal Subject: [PATCH v11 2/7] nvmem: Clarify the situation when there is no DT node available Date: Thu, 5 Oct 2023 00:22:31 +0200 Message-Id: <20231004222236.411248-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004222236.411248-1-miquel.raynal@bootlin.com> References: <20231004222236.411248-1-miquel.raynal@bootlin.com> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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 At a first look it might seem that the presence of the of_node pointer in the nvmem device does not matter much, but in practice, after looking deep into the DT core, nvmem_add_cells_from_dt() will simply and always return NULL if this field is not provided. As most mtd devices don't populate this field (this could evolve later), it means none of their children cells will be populated unless no_of_node is explicitly set to false. In order to clarify the logic, let's add clear check at the beginning of this helper. Signed-off-by: Miquel Raynal --- drivers/nvmem/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index eaf6a3fe8ca6..286efd3f5a31 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -743,6 +743,9 @@ static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_nod static int nvmem_add_cells_from_legacy_of(struct nvmem_device *nvmem) { + if (!nvmem->dev.of_node) + return 0; + return nvmem_add_cells_from_dt(nvmem, nvmem->dev.of_node); }