From patchwork Thu Sep 2 09:02:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 505729 Delivered-To: patches@linaro.org Received: by 2002:a02:8629:0:0:0:0:0 with SMTP id e38csp1031950jai; Thu, 2 Sep 2021 02:02:33 -0700 (PDT) X-Received: by 2002:a05:651c:28f:: with SMTP id b15mr1693924ljo.186.1630573353123; Thu, 02 Sep 2021 02:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630573353; cv=none; d=google.com; s=arc-20160816; b=tnJL1Pf9wspWnHL18DOLDgl7uzGxZXSAZwCR2I1UVJef1IrGuMkDjt4Y1abgnyrlFJ whjayLz5cVe20u0KXUDXOmj7jL01/nLRSyM41V5qIkC/NZdrqQyMptdSrt5IXn7uepxL p08uL6nNW3HrDSGjYWHppxRH3HBOECOKjcfPONU5ukzk063LRWZ735bgPR1tUVFi8DFx wG6ECXt9z9oWT6kwZDJmuJNUuP9QiYjO7eABxO4Gaav6NPp6H7Kurlo88S7n6MjJPWMO aGPSzu7cLzlaEEl3BirKVfCGI/rOlQH/y9TycQPaicnwtq/XR8e3WRDbMZyH1lxuYlVo d8OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=qZWfMSX8wMAWulFpFk0yumlnd8aLSAYEODrPThO+hW0=; b=c/xJ8iQwHlnsyYugJ26xPbxXCkIZuplkIAsBBJHGhXO/c8Rzs18K0tULbslAFOF7Gy 6ZiXTW+4hGp4WaVAQqLYWQtVxccCZ8YCN223w1yF5VZ0Qq6/29tbTMBVn3qKCRqVhUhX degmf03fbG4d1NMoEZ3H2uTEL4bC9pggyiFzfC8WWFqpCLNeLC1isR+skUmYAmns1YIe 7NEUA4q9/w/SQcSg5vSpZgwNY+AGFP0Exew1hlRZRq4e7BBaECIJtrrCq8RrZq6I1Ice kst7QmrdD3bMT1KSgOOpCC2/PDAZ4RohlqSjqe5U1JuvHREsxVr4dO6hpbivbjkeNq8I 2stw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ctOuK49c; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id g20sor640427ljj.69.2021.09.02.02.02.32 for (Google Transport Security); Thu, 02 Sep 2021 02:02:33 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ctOuK49c; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.41 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qZWfMSX8wMAWulFpFk0yumlnd8aLSAYEODrPThO+hW0=; b=ctOuK49ceAh0izIbXBGFKtYK3umKm395+zOvmxODultMDVBXDumAtSV4us9u/GtX8f zANgiH/F6HpXzEI54iHJz4+6o81Tqbowx0vFtPdwIbsbxurzrmN98UtGkPvwzBJ5FZ6c D4bf4vWVBQ0627tlmzlA58vLbGHFkFaive6GSlEgpviV1Z7EV5KUA0E34ApzxZ2rFbVN caeS38SXdDtGfXwxIjgy3R05Puo8i+PM065QlF082mTQuOCrfs5HhJFBaaY3jX6WR8lP +qKhF7Xonfed3APeeUfUusSkR3Wq/1kpbkEshbAlBfoqg9ZfG0wUSp06dXM/RyrlO1wt jQuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qZWfMSX8wMAWulFpFk0yumlnd8aLSAYEODrPThO+hW0=; b=R3/jUmoWq+xcNEQwlJHxwcdKiTaxFyXvvuBM/ggbXQ2kbX0R+UNW7Teh4ncaxnIjpy pFBaX66hs7xVgAp6/tkXaLDBDk5cMxSSQSwjiY71tecLdtafEAafANleappukJsofoLW /7eRvM+jP80fZEAn5U/KcJ24HMCfLZSL8ceL5NVn2RbPHM385jB1cSp/n+A6yJgR8bsN GcP/SmjbmpW4CeUI12qj/qbo4CZAUo67MELwdJHBsmE0+ggRprALBPYl1GGdrVNirdVr iNrKgWtt7tD1PqvbUmZl//zP5R3I1dasJFg5qDXqIj4LTT9QRoaUxQS1ivaE2Y5kKNZF o/gg== X-Gm-Message-State: AOAM530ej4ExdtjU0C2lnX3P4rAbcLJ0QkH8BF5Q4fh7wFqR6PjMOkio Gw3S35ijOEPdTDFJAiNi3FqXl+eyUMax/7sfaTQ= X-Google-Smtp-Source: ABdhPJxC9FL/CE2Uc0dvquHeUzF6/9Ta3W9YEHISvKYopat1t+96pMvVAuHGdEZ6lz4F1h2PDEdjFw== X-Received: by 2002:a2e:86ce:: with SMTP id n14mr1588757ljj.421.1630573352628; Thu, 02 Sep 2021 02:02:32 -0700 (PDT) Return-Path: Received: from localhost.localdomain (h-155-4-129-146.NA.cust.bahnhof.se. [155.4.129.146]) by smtp.gmail.com with ESMTPSA id t12sm137590lfg.151.2021.09.02.02.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Sep 2021 02:02:31 -0700 (PDT) From: Ulf Hansson To: Saravana Kannan , Rob Herring , devicetree@vger.kernel.org Cc: "Rafael J . Wysocki" , Stephen Boyd , Dmitry Osipenko , Ulf Hansson , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] of: property: fw_devlink: Fixup behaviour when 'node_not_dev' is set Date: Thu, 2 Sep 2021 11:02:21 +0200 Message-Id: <20210902090221.820254-1-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 In the struct supplier_bindings the member 'node_not_dev' is described as "The consumer node containing the property is never a device.", but that is inconsistent with the behaviour of the code in of_link_property(), as it calls of_get_compat_node() that starts parsing for a compatible property from the node it gets passed to it. The proper behaviour is to start at the node's parent, so let's do that. While at it, let's take the opportunity to update the description of the 'node_not_dev' flag, as to clarify its purpose. Signed-off-by: Ulf Hansson Reviewed-by: Saravana Kannan --- drivers/of/property.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/drivers/of/property.c b/drivers/of/property.c index 6c028632f425..a94d007be416 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1075,6 +1075,17 @@ static struct device_node *of_get_compat_node(struct device_node *np) return np; } +static struct device_node *of_get_compat_node_parent(struct device_node *np) +{ + struct device_node *parent, *node; + + parent = of_get_parent(np); + node = of_get_compat_node(parent); + of_node_put(parent); + + return node; +} + /** * of_link_to_phandle - Add fwnode link to supplier from supplier phandle * @con_np: consumer device tree node @@ -1249,7 +1260,9 @@ static struct device_node *parse_##fname(struct device_node *np, \ * @parse_prop.index: For properties holding a list of phandles, this is the * index into the list * @optional: Describes whether a supplier is mandatory or not - * @node_not_dev: The consumer node containing the property is never a device. + * @node_not_dev: The consumer node containing the property is never converted + * to a struct device. Instead, parse ancestor nodes for the + * compatible property to find a node corresponding to a device. * * Returns: * parse_prop() return values are @@ -1416,7 +1429,7 @@ static int of_link_property(struct device_node *con_np, const char *prop_name) struct device_node *con_dev_np; con_dev_np = s->node_not_dev - ? of_get_compat_node(con_np) + ? of_get_compat_node_parent(con_np) : of_node_get(con_np); matched = true; i++;