Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4519374pxv; Tue, 27 Jul 2021 09:14:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxQhhXYGV32ltu9e0LjOA45yA6NQ9E89+NPXBeE8tYK7+eydDNF6Nsb5cuCVwdYzLVVWE7 X-Received: by 2002:a05:6e02:1529:: with SMTP id i9mr17074907ilu.163.1627402478516; Tue, 27 Jul 2021 09:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627402478; cv=none; d=google.com; s=arc-20160816; b=Lws3AA3iZHuL+cYQ50pmzloSvUjHkdBVNKiSPmWxw/x3tzU4L2WmPjtAO8LiBxxCSI /wHJqzHDouuiV3iIi9xnVohXfMs7KkjXYFzUowNugum8158Eudw7ZkzuWfR8K2Uhi9Us W9fJ7w6KOUyGyVpoehtpZ3M1hi+x4yjo5rB5eHrFEoYiCNM7l0KnvOLfyzdiNXMqaGii IXIgZ0/0js1dqRpz480TwtlXgRKfyae4hNoTl9wxgGHhWPZ5dFHphHNuTnSXu7OGX2pN wtXHbfATcrWUWFO07KcRREgcPQhkYTzAqBTuqLUaco8uO7jnltYhHoo+sNXkdduQKQWA XwyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=oGIIAIEtOtHgKbmGPPyB7IwdLckcnLZsSlXRV9xpJ34=; b=G96slj8Oqrp1PuAjSyrYMTYtpl8EdTaeaKIGZI3NVylePZZpFuiWCiSEDDJ7zMABdS OH81KqdhVLH1Rqr7281MpbrEEF0UPfOCZyJwtnOkWgz+tbaxXQ6wSwcv1namBSGxMdRX oN04KM3Lpvh/uSeO2njt4Lwhr5DFKyQ53hfg72fbEywSqi8yI1oBIhIMSsy9MiGNdK+r vhwEscZVLwSoirC7hTFyfWTpz1/l0wWJs8rbAxZyigIeEY5uEM4UkA7tJJXLMsROUAAm +J8TIffZki/DzmSCYk2G3BTJZ9F/GbKnWhmiq525+65CM6U75Q3VgYRoOetZVPbX5RRl 0KLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t4si3926968iom.26.2021.07.27.09.14.27; Tue, 27 Jul 2021 09:14:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229899AbhG0QNk (ORCPT + 99 others); Tue, 27 Jul 2021 12:13:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbhG0QNh (ORCPT ); Tue, 27 Jul 2021 12:13:37 -0400 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D89DC061757 for ; Tue, 27 Jul 2021 09:13:36 -0700 (PDT) Received: from martin by viti.kaiser.cx with local (Exim 4.89) (envelope-from ) id 1m8Phv-0007rV-0H; Tue, 27 Jul 2021 18:13:27 +0200 Date: Tue, 27 Jul 2021 18:13:26 +0200 From: Martin Kaiser To: Manivannan Sadhasivam Cc: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, boris.brezillon@collabora.com, tudor.ambarus@microchip.com, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, dan.carpenter@oracle.com Subject: Re: [PATCH] mtd: rawnand: Fix probe failure due to of_get_nand_secure_regions() Message-ID: <20210727161326.wozj23a3sblibwpk@viti.kaiser.cx> References: <20210727062813.32619-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210727062813.32619-1-manivannan.sadhasivam@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Sender: Martin Kaiser Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mani and all, Thus wrote Manivannan Sadhasivam (manivannan.sadhasivam@linaro.org): > Due to 14f97f0b8e2b, the rawnand platforms without "secure-regions" > property defined in DT fails to probe. The issue is, > of_get_nand_secure_regions() errors out if > of_property_count_elems_of_size() returns a negative error code. > If the "secure-regions" property is not present in DT, then also we'll > get -EINVAL from of_property_count_elems_of_size() but it should not > be treated as an error for platforms not declaring "secure-regions" > in DT. > So fix this behaviour by checking for the existence of that property in > DT and return 0 if it is not present. > Fixes: 14f97f0b8e2b ("mtd: rawnand: Add a check in of_get_nand_secure_regions()") > Reported-by: Martin Kaiser > Signed-off-by: Manivannan Sadhasivam > --- > drivers/mtd/nand/raw/nand_base.c | 6 ++++++ > 1 file changed, 6 insertions(+) > diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c > index cbba46432e39..3d6c6e880520 100644 > --- a/drivers/mtd/nand/raw/nand_base.c > +++ b/drivers/mtd/nand/raw/nand_base.c > @@ -5228,8 +5228,14 @@ static bool of_get_nand_on_flash_bbt(struct device_node *np) > static int of_get_nand_secure_regions(struct nand_chip *chip) > { > struct device_node *dn = nand_get_flash_node(chip); > + struct property *prop; > int nr_elem, i, j; > + /* Only proceed if the "secure-regions" property is present in DT */ > + prop = of_find_property(dn, "secure-regions", NULL); > + if (!prop) > + return 0; > + > nr_elem = of_property_count_elems_of_size(dn, "secure-regions", sizeof(u64)); > if (nr_elem <= 0) > return nr_elem; > -- > 2.25.1 not surprisingly, this fixes the issue for me. Reviewed-by: Martin Kaiser Tested-by: Martin Kaiser Still, I was wondering if the behaviour of of_property_count_elems_of_size makes sense. Without a prior check, there's no chance for the caller to distinguish between "property is absent" and "property is malformed". Thanks, Martin