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: 12471069 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB683C432BE for ; Thu, 2 Sep 2021 09:05:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7AEE061051 for ; Thu, 2 Sep 2021 09:05:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7AEE061051 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=+nqFfpP2atE2wF2vSXKIMElWC59ulhBy/EQ8u9BrtmA=; b=gRjApDjGjk7AnY EYwwZATZVxvB1smJIIx/8hxQuqy7EaFkEFujo4krR50QOPDMOeN5sjcOJqLGLq3x+2TSRz2dgGmmC 2hxAZ7QLBbShpNGfzuO6TkSMryRePZGrzD+CN3HLBZZodBaKoGJ3lZ2J+91zErsN5xWFM9FLfLfE3 gmpSUEdC3vVLj6vX52w3NE2CUsrW6ZPuv6FADPdJewoPtZylmNda4oGGGoTO2c2OT/zRiqDr3iYbo 8J17UZmiIdY7n2551KAgq5T6zjBY3ReJYUk2D3w/FD2mOP9DdinloL6zspchvsc4VnP11QBJl82H7 PvsPaa/mo1/8G1tk1B5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLicM-0092Mn-Da; Thu, 02 Sep 2021 09:02:42 +0000 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLicF-0092LT-NQ for linux-arm-kernel@lists.infradead.org; Thu, 02 Sep 2021 09:02:39 +0000 Received: by mail-lj1-x236.google.com with SMTP id g14so2232629ljk.5 for ; Thu, 02 Sep 2021 02:02:33 -0700 (PDT) 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=smkCmy3WO+LY2HdaSWpXqXxSFUFXkyd09W18JO/a2hn6G6mwJh2CVJtY1UdG0xISI/ 5Cs5pr8xflvJT8z2EbyVSATLSbabNHgEDPwVhyVl9pBls7h7qhdGP5ld3mfDkdYh9qen yhrjj28tCUpiJOcm3NoE0j1ig+UWthmDV/zgi/hEDLRo7AK3AqFdOITJC3r1tedLgO4G l18ZKJSLi2FhsL5rTi2UJilfHedGafzVI/EXNgbgm6805w7BPchXcRzxASXqdQo+yMRA 9v128XrCnI96MKZABJYUS0ZoOcdfxZw8dLRYdKcgJO/gFpJbiI04Gj/4161ZP3HywIPK b5iA== X-Gm-Message-State: AOAM531E4lTgJt52DdFmdJfceYJz2RmmwJWAVf6Itf2h8OQqv2uxhaTd YneW24XZzO6fjEC+wQ4jezln5A== 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) 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210902_020235_864231_85602607 X-CRM114-Status: GOOD ( 16.40 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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(-) 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++;