Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp575589lqs; Tue, 5 Mar 2024 09:56:25 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWIBIBT+tPPYhVPGIzkiQPI9wrlmSx30nBlPZ2QkdOhYM+0eyTxM4CC0zirt79EDe2adWk9XTHa+ghzI7AeMkcfVXHljPUnFq3xuo1Stw== X-Google-Smtp-Source: AGHT+IEJhXozQeMkBYSIPFwvwK/6Xcl6A+Uy7QmiYZJBIQ2hMKMhmi0tUG7UNkDPCn8i+RquWlHL X-Received: by 2002:a05:6a00:844:b0:6e6:21b2:fac2 with SMTP id q4-20020a056a00084400b006e621b2fac2mr4564878pfk.13.1709661385107; Tue, 05 Mar 2024 09:56:25 -0800 (PST) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s187-20020a6377c4000000b005d8bf42e02dsi10341004pgc.544.2024.03.05.09.56.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 09:56:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92794-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=GhGrdjr3; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-92794-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92794-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C5E25282036 for ; Tue, 5 Mar 2024 17:56:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60E2717BB4; Tue, 5 Mar 2024 17:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GhGrdjr3" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 80E97BE4D; Tue, 5 Mar 2024 17:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709661380; cv=none; b=J1rz4sZjd7iGXr6VlAIkzUo1QIpJsWSn5lPFMB1xuN1mz1oJlsDxwLHnvYng1KDaYk3k6Gq2YdzNpnXLxUOXf9uPF1Bd1lIlc+1y0YWYPOADWp2P24U+ztdJb3UbqKCwoLrfBS1QxnbNO5p+KpiZXPle8/JDj1kJdDYe+NuSKzs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709661380; c=relaxed/simple; bh=2bQynvk86aY7tc8jimbDs5P3dMauTJFDjIC5JF3c/tU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=mWXbbDAQLECvrA2e1ey2XmQOnCRc7gUqShP5RZAhVTS050md5juVvWjG2vjIZJJNpfWgVdt/s75yXig9PMQxqYZBDX6HFbXBowxba2CYgZc3ZPoqZO8+h2oojagfoOLInY/tZdJ3oaNvgST8s0BpJQFLaoVKCQQSzQLPORE5r9g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GhGrdjr3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00F4DC433C7; Tue, 5 Mar 2024 17:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709661380; bh=2bQynvk86aY7tc8jimbDs5P3dMauTJFDjIC5JF3c/tU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=GhGrdjr31yTnSPEOKXTJqZjjZWLkuTUkn80SdQpOfQ1E65gl7jCO6O8AA5gOwYD+7 +Glftl3+g702P0WksUK+yCK+1mr2rIzYSjN3yDXi0WmWAoMdz2g6Q8piM5zIym0eoI AaTmSZVHcualb1zcLIPH883CqoEQPtYzAB3GsZ07Joo6HIhF/BKy+gD1V9VszSFY7S VbaNNdmtfvpMubriE5+V/6+X36VNcS0vj65RGSCN2uOgcJeSLgvdmMJpQKfOkAKu5p 2gzVqL9KZDgLP7/Hrc2jaiQDKv1lN3R665GIdfi9WWon1tQenYIqIs+Y8f+97bxXrI ECeUegWPOezWw== Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2d109e82bd0so72960281fa.3; Tue, 05 Mar 2024 09:56:19 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCUjqdP2vIbjOt9RSNIJCwTVIxJ4bXLiTHpy+yu+NM7MaGUBziznpW5Mw72CU4jkObn/IYdgTVDFT1vbiIMMxqoZLvgLcLRe+Jg9hOr2oS589lpJVHTQ4vyxVwDMmE+fDvfCq940uOE7NA== X-Gm-Message-State: AOJu0Yw8GGkZef1l7oohNGBVOSide/aZ7BWu38872Tlj1fs7VJ1QtvQZ r3cn80HFCcaK1nB35sN9fzuO7b/H6sIlfZhLLruYdQ0wiG5aal7U4R69MXlnxX1bHy4b8SW/ExK vGQczH9L7d9NqvTVOCLMNmZf8VQ== X-Received: by 2002:a2e:bc23:0:b0:2d2:3392:8c0b with SMTP id b35-20020a2ebc23000000b002d233928c0bmr1959443ljf.51.1709661378081; Tue, 05 Mar 2024 09:56:18 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240303104853.31511-1-brgl@bgdev.pl> In-Reply-To: From: Rob Herring Date: Tue, 5 Mar 2024 11:56:04 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] of: make for_each_property_of_node() available to to !OF To: Geert Uytterhoeven Cc: Bartosz Golaszewski , Frank Rowand , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Mar 5, 2024 at 2:32=E2=80=AFAM Geert Uytterhoeven wrote: > > Hi Bartosz, > > On Sun, Mar 3, 2024 at 11:49=E2=80=AFAM Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > for_each_property_of_node() is a macro and so doesn't have a stub inlin= e > > function for !OF. Move it out of the relevant #ifdef to make it availab= le > > to all users. > > Thanks for your patch, which is now commit ad8ee969d7e34dd3 ("of: make > for_each_property_of_node() available to to !OF") in dt-rh/for-next > > > Fixes: 611cad720148 ("dt: add of_alias_scan and of_alias_get_id") > > How is this related? > > > Signed-off-by: Bartosz Golaszewski > > --- > > I have an upcoming driver that will use this but which can also be buil= t > > on non-DT systems. I'd like to get that in as a fix to avoid inter-tree > > dependencies later. > > Do you have a link? > > > --- a/include/linux/of.h > > +++ b/include/linux/of.h > > @@ -362,9 +362,6 @@ extern struct device_node *of_get_cpu_state_node(st= ruct device_node *cpu_node, > > int index); > > extern u64 of_get_cpu_hwid(struct device_node *cpun, unsigned int thre= ad); > > > > -#define for_each_property_of_node(dn, pp) \ > > - for (pp =3D dn->properties; pp !=3D NULL; pp =3D pp->next) > > - > > extern int of_n_addr_cells(struct device_node *np); > > extern int of_n_size_cells(struct device_node *np); > > extern const struct of_device_id *of_match_node( > > @@ -892,6 +889,9 @@ static inline int of_prop_val_eq(struct property *p= 1, struct property *p2) > > !memcmp(p1->value, p2->value, (size_t)p1->length); > > } > > > > +#define for_each_property_of_node(dn, pp) \ > > + for (pp =3D dn->properties; pp !=3D NULL; pp =3D pp->next) > > Is this safe if !OF? Can dn be NULL? Good point. I would say running code shouldn't reach this though. Also, it should be written in a way it gets optimized away if !OF is valid. Long term, I want to make struct device_node opaque. So if we really want to fix this, I think we'd want to convert this to use an iterator function. Though I guess any user would be mucking with struct property too, so the whole loop would need to be reworked. So in conclusion, don't use for_each_property_of_node(). :) Shrug. Rob