Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp433148rdb; Thu, 5 Oct 2023 09:59:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHz2D5EByxpyFRcdGxjiCk/+XJ6KhqkN8jRDZFcraFY6deu4ogIgx2xvqgL+5TJgHc+//c+ X-Received: by 2002:a05:6a20:5610:b0:13a:ccb9:d5b7 with SMTP id ir16-20020a056a20561000b0013accb9d5b7mr4841119pzc.41.1696525185160; Thu, 05 Oct 2023 09:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696525185; cv=none; d=google.com; s=arc-20160816; b=fH0kfoLrr8D4Nmz9kFZqKlmF7uhWxxhK3xBMGGaIVsShNuhXMv2IRdLBrwoXTC638C x1IU8H4CBF+Jb/3ac+j1P8qm4X44beEBLwJz48xbJ1lunGeBTe3vwtoHhxNQukKJqg97 AosaZ3cYFjgL3uWqqEd0eGCL6s0/aEtCSLyuW7oSRO9bByC6f7oaP3XC8EeuvbAm8AtY vZENn5r69eJEAM9lJT1JJ5X1JKlSAcP/I8ZaRTORrN5FKPoQ8uhZ3VU/XFfajTrs45lk IrpqOchmo7t0BlrhntqFHDCEjx7cZIij0d4LhYRXCDC52m6n1W1o4uzGerXw2CiXW/wj J0kg== 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=RNTdnfVQ4H7LtA9NOJwZVY/ap3UKde8fYrt3+jXaqS+poLVXHPwx1Loi4xZzF04RYW WqCCGxlRh3vgjG7pPp7X0EAIfp3RPGyCdlVxLviadBxfrHs22FgBbOV03dTUNBY1yazf vP/7yBmloOcI1SD5gPa07vGTu2jvRm4V6PLMabUC0U7eIvbOKGKncd2YwKRtjfkdsJM9 /XKi5oCdbiayGLAFuTZy12498fbc8f/1FFYUjBwpLCP6bzkmkf5boCqzli/9R1R3cO66 ANwfu9dNZ1ckBC5yMCehi2rjhrbwTgJ+d9oEAtZnuirHaKNHfmkttYpqgD7zsvhc6Ysl vAPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Ck3ZN1IJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o4-20020a170902d4c400b001c73f81b24asi1955201plg.521.2023.10.05.09.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:59:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Ck3ZN1IJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 763588343523; Thu, 5 Oct 2023 09:59:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242676AbjJEQSp (ORCPT + 99 others); Thu, 5 Oct 2023 12:18:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242025AbjJEQPD (ORCPT ); Thu, 5 Oct 2023 12:15:03 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99AEE7285; Thu, 5 Oct 2023 08:59:16 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 838311BF213; Thu, 5 Oct 2023 15:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1696521554; 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=Ck3ZN1IJji2OY+dMnjA+DdC2x6VAfE4ZZp7r6kuL50L/U58uuF4Frsm3crOYTr2Xr6QRD0 +2km3T173WAQtA58ghw76qM5qNQ+nteaRCDHz1tugcKisNuWXIpTq8+UDJ1G8xw6o/VNT6 CzzExtKtwXEV5OrA0fYuK9Hjz/MY2F9mGltJW1omwlUgWWk3MUpjiZdlF3IOY4yGTFdMik 9M1Yp7SfHZwOfk4rh9oJaJdvXJUj6rEg6HvBo6kKScUGUobTXOrdG3JH3y3h2LsBM5yL0Z 4+V8yieOVFLwOKkYmxKjHHkXDeL7yw0rt57oMPF6CufiaU2NdAxEhjAINHjiKQ== From: Miquel Raynal To: Srinivas Kandagatla , Greg Kroah-Hartman Cc: Michael Walle , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , 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 v12 2/7] nvmem: Clarify the situation when there is no DT node available Date: Thu, 5 Oct 2023 17:59:02 +0200 Message-Id: <20231005155907.2701706-3-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005155907.2701706-1-miquel.raynal@bootlin.com> References: <20231005155907.2701706-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 (snail.vger.email [0.0.0.0]); Thu, 05 Oct 2023 09:59:44 -0700 (PDT) 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); } -- 2.34.1