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: 148609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp437169vqb; Wed, 4 Oct 2023 15:23:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEoMA502O13Ib3FKD40jUI+03+xdRimc2puxO1JmnouiB9OeJSHo9wLNKngcfefvuRHpxpy X-Received: by 2002:a05:6830:1349:b0:6bc:9799:a00c with SMTP id r9-20020a056830134900b006bc9799a00cmr3254101otq.26.1696458187383; Wed, 04 Oct 2023 15:23:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696458187; cv=none; d=google.com; s=arc-20160816; b=tmouqSmF0OS3LkkY5BtvvNryKC/kY7wgSXKlVeE1eD2WB7DJdkTI2PNIMD332s+sx0 sxy8pdByAtbXHLcY/jzRCUy2EswTVJ/EI2uyLyc5H1XpsPrT+0rvj+JRG8ptxe7qKBvR HSuVMZ95IRNBG3BdkUVPpt1LmnCqQV7b/10iS/VS1NYGUfkkejKmYRQDqxyTWzajb41x xisu0ltxSeOLS3hXCLGEBj8c9Rv1rdbdm6L5xU7E6WL+dyc32C2KJ3B3TsRXhMD2+t9e eMcqjUBGdUxHDhHY34+qub8AdQ3IiM4dzx+SdoHzartk/fgUhS41SSdF529nH1EblSGm pRnA== 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=ozTgRpH7t0hBveOF8yXGnBl2vT15HtovIkhQFtR9B74=; fh=XQzgxiPMj/Cqsom9sWl23DkvcXkGD6r/vx0NuuBn5R0=; b=SVnjZhF6KIeiZ/aQ+JeFgdfkubnDPfLfPiQEcHFSHxF4znMk2GAv3rBY26zbozYqQj mWkPnQBsq7nEfyLDP2SaTrtExEUXRU5chA+doCvd1fZwGV3rVjctLobUN/pDZbQ9R3Hm FfS3CaT+qGaKwCilFY1LdEMpj5kJ3cdNvT17VaZzTrFG/zxYPMNM98qBLi/1kbusVxwh TfcTa0M2vE4klpWETpe0IChEvzyU93nhFlq0Qh2IC2SL1Cc+vD/jhlvz6F2yGVKShbui rh0Rp1bTYWo86QaHV5RFO89a2W9Q4fmN9Akpl/Ffni6h/ngMYYN90rbJk4pP2ylmRiOJ 9BAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=cQd6LjNl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id z16-20020a656650000000b00577f4d85fdbsi77694pgv.548.2023.10.04.15.23.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 15:23:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=cQd6LjNl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 6C2DB83B6BC7; Wed, 4 Oct 2023 15:23:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235193AbjJDWXA (ORCPT + 19 others); Wed, 4 Oct 2023 18:23:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231148AbjJDWWv (ORCPT ); Wed, 4 Oct 2023 18:22:51 -0400 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> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 04 Oct 2023 15:23:06 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778865340484549317 X-GMAIL-MSGID: 1778865340484549317 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); }