From patchwork Fri Feb 2 10:13:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 195772 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp326774dyc; Fri, 2 Feb 2024 02:14:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IFI/pljQ1BUGVxE4GmLF3FMoq1Y9FMP7nHYlxemLfZuvfpryYSab4p4dPADDFd/70QW2RXw X-Received: by 2002:a05:6808:209c:b0:3be:3cb3:8231 with SMTP id s28-20020a056808209c00b003be3cb38231mr2221193oiw.26.1706868863271; Fri, 02 Feb 2024 02:14:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706868863; cv=pass; d=google.com; s=arc-20160816; b=usXp2UN2UHWsCg7xx1mQxP+SWM0ufGciTkROH5zH860YswAlZoIOU4M76H+QMoXfg9 NDSElIBBiy0ZXl4r8rRcaBLNDwRh+vKccNmIAR5aHVO3TMSnzvQb52pu6SMYmN8v8YpK CHHT4iOWWYzhwEQazDa6l55q9Z8tH9QexTd7GM0X+t51Q48FINo+yjzJHF3YiZOuynHk YQJhjG05j0RQBkncMW2gpXn5NkWt3R11O1h0dWyW93z4potiha+ZtUwuFg6a6sb0wece LzbOevx1BVAz/ubtovgcMtsyWvYVY3dCgcoyuLSuZt29lJaJEC+pA2rVDk+ivRbnAj0M DJcQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=PLhsSS3HwprQWBFpEcHgJ/pLquVGk4PYeCURrLCLOgI=; fh=5OQW5dPHEXoq1lCpF43sAbTI9VKyXAFBnbQ1zWdn6kk=; b=n7UfNpHAUHWgv23WH9FNOzsn/qWHx1lu5DB0Rt3yTv15TufIX1RGTm8j2tUwRoeVnH zOk2oRzxrFf+0wcVg+kLxxClmoTMAkgT8O4ZcvuyJ1w/y1JdCIpyAQ9i2N2563CIy7Cr xKrQdLyreg0fwj0lG+3blPteDIZnCWgfeUJXjjw9JXGrZ/bk3KACHHWFDSFrcolf0kgh sCrIFfg1m44xRRyTSv+RF3WPzXoCCxZ07CRmUL36OtjTpr1HSogVDxk/TqaaIuhnyptT fO6MZ+WSx0hHOAHLkr7p845j0NXus+M0JT6kok3JvihExmDqLv04/CuWTAerfH8kLJ9R Q2hQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zX6ZZATX; arc=pass (i=1 spf=pass spfdomain=flex--saravanak.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49652-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49652-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCX7ntyeTJQVBxLZCB6IAgo9VvMxgr8WJ3/DWe5CT9Kcw4E73ZuvrcIu3L271H3cq9sHdrrmwDNQaa/OJQ6gV6cZF+bB/g== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j9-20020ac85f89000000b0042bf7d9a7f1si1588306qta.591.2024.02.02.02.14.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 02:14:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49652-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zX6ZZATX; arc=pass (i=1 spf=pass spfdomain=flex--saravanak.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49652-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49652-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F094E1C2554A for ; Fri, 2 Feb 2024 10:14:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52D197E56B; Fri, 2 Feb 2024 10:13:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zX6ZZATX" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A62F57C0B3 for ; Fri, 2 Feb 2024 10:13:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706868814; cv=none; b=g+OTf3fMLvD0Tax7HLzd1as4i/JDogRfKAXKKaMKshBPPTtGE48EFx/WTTbp3n3rySWYNxsBPLe4y/YQfPTcs43NTfmLy4Ym9/6Hje7EthfTlpw/ymGt9OD6J91s4m1/OCjLJXZ5Qxe7BDxkAIdISVmknRO2nvLGzMBfP/kJlMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706868814; c=relaxed/simple; bh=zKan942Nkahudi5ozsgPLVKO5gJLw2vqAX/thHirjSw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=tj6XJSbsj5yV5LNQPWtMl06AJCL9f48Cgj52WCvGtp0MG6k76sCwTWtuw8z5J9kaYsMPgzRpckaD31ftQK7qTsNQw6ojL7JEAnO7sfBS6rYWkFSUcWjj6jy3QXAmOzIgT0tYAz+Czo7cPLRg6qdA9T8v8vyCHqUW3nW/xNxgqew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zX6ZZATX; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-604127be0a0so38595467b3.1 for ; Fri, 02 Feb 2024 02:13:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706868811; x=1707473611; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=PLhsSS3HwprQWBFpEcHgJ/pLquVGk4PYeCURrLCLOgI=; b=zX6ZZATX4AgX3HcbrldADaoVMKXUGOC/fPR9dEug/fZ9dcnBmTUY5SwC69Ez4yM4o1 qxX/0E4WJIuCBWn0ic6L5+KcwtsyHvGMVRJRJbo8Aean+bpY1PH5JYOoQGlYLGHZGFu7 c1rN9JISirQ16F6BAhcsgAHIMkkLyIcy//pxe+QARoEKiJVqpfRUpPB906uFHqzv3MRg e1maBuEtRqWabFaUlui+WoZHzySUx8xSzLlGYynEjRD5kiXG5sicoBtSyWJVB3TfYkTL WRLq7RtnTPJYMEIpYsV7CRt8aFl9YNxbzqaBQqKvAqWUUuqWs98UeN/m2IQdW90hZk9Q UDcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706868811; x=1707473611; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PLhsSS3HwprQWBFpEcHgJ/pLquVGk4PYeCURrLCLOgI=; b=JWhVBLmud1IEYjo0cyWOGSTP101UqO74aBbALO8c99vyoCMqhFaUetElz3e9SyVpt6 Aw+G5sHxLGNjzH6ckGkMkjPMgh+ckp4hfJ5eFJw0OL8FmYwc+X5+9j72BmF2ZAIij7Fr zaAxyqhi+4yK6bVK3fEjGPfsOjWdlJHpEZ8ylIFAGuyb/DQw0HyRYYatovI+x3UBkkXO SHRHzkimmDt4soYtgLYPtt3fLKPFcjTYxh6Ort0hA8TIfVXGzZkcqrk+ei+62+eWt1+O QmOg82haJEbHzKChFVGV16wZ9an5N9hnDB7V6wpGaBlXoA+D8Us7MVHGGxOOuTFu2WQw Uu8A== X-Gm-Message-State: AOJu0Yxm2GuH06fLzYXdKch1z4zpAX1Q5K7knWiAZHHl+AZsVjICkLXG EAfVpdLZ7IgD15XOqbN8L4xDXRieGmvKZMHyDZPlMYd+UazdSZZ3u88bD3H3rYI9gndgtxjNMsu ZZ5x5istt2q4sFw== X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:6f0:da10:9cb3:5b3]) (user=saravanak job=sendgmr) by 2002:a81:99c9:0:b0:602:d398:5176 with SMTP id q192-20020a8199c9000000b00602d3985176mr1632614ywg.4.1706868811768; Fri, 02 Feb 2024 02:13:31 -0800 (PST) Date: Fri, 2 Feb 2024 02:13:24 -0800 In-Reply-To: <20240202101326.876070-1-saravanak@google.com> Message-Id: <20240202101326.876070-2-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240202101326.876070-1-saravanak@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Subject: [PATCH v1 1/2] of: property: Improve finding the consumer of a remote-endpoint property From: Saravana Kannan To: Rob Herring , Frank Rowand , Greg Kroah-Hartman , Saravana Kannan Cc: kernel-team@android.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789781725187351005 X-GMAIL-MSGID: 1789781725187351005 We have a more accurate function to find the right consumer of a remote-endpoint property instead of searching for a parent with compatible string property. So, use that instead. While at it, make the code to find the consumer a bit more flexible and based on the property being parsed. Fixes: f7514a663016 ("of: property: fw_devlink: Add support for remote-endpoint") Signed-off-by: Saravana Kannan --- drivers/of/property.c | 52 +++++++++++++------------------------------ 1 file changed, 15 insertions(+), 37 deletions(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index 641a40cf5cf3..ba374a1f2072 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1063,36 +1063,6 @@ of_fwnode_device_get_match_data(const struct fwnode_handle *fwnode, return of_device_get_match_data(dev); } -static struct device_node *of_get_compat_node(struct device_node *np) -{ - of_node_get(np); - - while (np) { - if (!of_device_is_available(np)) { - of_node_put(np); - np = NULL; - } - - if (of_property_present(np, "compatible")) - break; - - np = of_get_next_parent(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; -} - static void of_link_to_phandle(struct device_node *con_np, struct device_node *sup_np) { @@ -1222,10 +1192,10 @@ static struct device_node *parse_##fname(struct device_node *np, \ * parse_prop.prop_name: Name of property holding a phandle value * parse_prop.index: For properties holding a list of phandles, this is the * index into the list + * @get_con_dev: If the consumer node containing the property is never converted + * to a struct device, implement this ops so fw_devlink can use it + * to find the true consumer. * @optional: Describes whether a supplier is mandatory or not - * @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 @@ -1236,8 +1206,8 @@ static struct device_node *parse_##fname(struct device_node *np, \ struct supplier_bindings { struct device_node *(*parse_prop)(struct device_node *np, const char *prop_name, int index); + struct device_node *(*get_con_dev)(struct device_node *np); bool optional; - bool node_not_dev; }; DEFINE_SIMPLE_PROP(clocks, "clocks", "#clock-cells") @@ -1328,6 +1298,11 @@ static struct device_node *parse_interrupts(struct device_node *np, return of_irq_parse_one(np, index, &sup_args) ? NULL : sup_args.np; } +static struct device_node *get_remote_endpoint_dev(struct device_node *np) +{ + return to_of_node(fwnode_graph_get_port_parent(of_fwnode_handle(np))); +} + static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_clocks, }, { .parse_prop = parse_interconnects, }, @@ -1352,7 +1327,10 @@ static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_pinctrl6, }, { .parse_prop = parse_pinctrl7, }, { .parse_prop = parse_pinctrl8, }, - { .parse_prop = parse_remote_endpoint, .node_not_dev = true, }, + { + .parse_prop = parse_remote_endpoint, + .get_con_dev = get_remote_endpoint_dev, + }, { .parse_prop = parse_pwms, }, { .parse_prop = parse_resets, }, { .parse_prop = parse_leds, }, @@ -1403,8 +1381,8 @@ static int of_link_property(struct device_node *con_np, const char *prop_name) while ((phandle = s->parse_prop(con_np, prop_name, i))) { struct device_node *con_dev_np; - con_dev_np = s->node_not_dev - ? of_get_compat_node_parent(con_np) + con_dev_np = s->get_con_dev + ? s->get_con_dev(con_np) : of_node_get(con_np); matched = true; i++; From patchwork Fri Feb 2 10:13:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 195789 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp337264dyc; Fri, 2 Feb 2024 02:40:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDvcOCJZNlYwKZGlkBiDup9MLMjh+B414EwbhwFSEKsLbk1CkYv/EVATmOcrF4ammE/zfL X-Received: by 2002:a17:902:d4d2:b0:1d9:11c8:b3c8 with SMTP id o18-20020a170902d4d200b001d911c8b3c8mr7157067plg.64.1706870430688; Fri, 02 Feb 2024 02:40:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706870430; cv=pass; d=google.com; s=arc-20160816; b=sfHXz9QFSrdfPK85d7AtKoEcRtiXG0Z4WpMCMaS2XZvHtFHNEMTzO977bSoGqZaq1U Y8hhWLJ6xlaZSo3LPcZK01SoWSq0289aBcdRgh11FgVFKAodVFHnFCmuB8NtBZf9MgAr +wo2tyAHOQUcDuK3Ai+vu2vhDKypjxv6+vGRcWMoLGfkWNWshzOtQu9rUJfUN1yyBGGB /bWTiFAhl4ydZbzvcGXNIht+7jg8cNu+g5/HPvHOAXuisor8aObwbaz00B38wRuR2fVU eIpVJ+q0uZCAFynUj3yqaahW0o6ge51diPwqGFSeiRlabSPE5XIoqtu9gdq+Lk9yRTDI YShA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=MmGh++VKQQZ2V54BTT2UNO9KFpQjbrHNRiYoSPHg+q4=; fh=kZ95Qy3y8kDFEIiNPX/FY+zYISTtD0aINVC98SPh+6o=; b=Mm1pNH7IdPoLTxPYInRwk9hQAbmAXamzkXT/ndl71UX6EldsfhPauLiVIwzKvZ0icx o0yCaW3VuoA5uWB6uvAdc5WKOSIS4JpbeZ+8pmcx0OUOhDw9KWaK7s/nyllTaYIGbLN7 tI2U52T257QlxXiMQwdHEqFtDyO0iXeyyTh/q/XZ3NXhRay73kfi5AAiP/wt6Yoobl+i Zx+I6qNGuH+aOj80nNgsW9F34rzx8xwFnNistk++iqNkmYGVCiFXui6uib2+m4omSSOU xqyo1aFEqzfAv6SHU/ACnbPKpizziuWdL36LvVxRtD+CW23rStYUOvveC7/BsNAPo5jq wIrg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qhf7tuAb; arc=pass (i=1 spf=pass spfdomain=flex--saravanak.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49653-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49653-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCVi3i0euDRsoo1bQ8ggUf/uSLMKGuYi+8xKr4PIid7ksNVORHVMb+JJqUkX+wazhOotmE/OXXQwQyo6hrfPkucd8E7NSQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p17-20020a170902ead100b001d94a0871e4si1416768pld.554.2024.02.02.02.40.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 02:40:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49653-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=qhf7tuAb; arc=pass (i=1 spf=pass spfdomain=flex--saravanak.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-49653-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49653-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 15185B2A52D for ; Fri, 2 Feb 2024 10:14:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F9E67E590; Fri, 2 Feb 2024 10:13:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qhf7tuAb" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E93777F2A for ; Fri, 2 Feb 2024 10:13:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706868816; cv=none; b=NkZ1qpXvo/Znf841gp3yjNxHcuafBNbccOXznCmgNaSCB1d3QHN9djv4ybJ/jEvec8tEXln2P8qn2E/JKnTUNqYIUEa/CBaPkjHuTPqqsLfcGuBSnziTN+V/TypI7SbhXh9Nb9IIraMYNpFNBmnjLGd1aBM/yK2sO0N+Kmg5kGE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706868816; c=relaxed/simple; bh=PJHamj29rRPnmcKigV5i/g/eYFjHdot+aXYjPD55b9A=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=u2Jb9iqzuckYqoSI0Cr1LcqI4lXkJedw0yfHt+G3ouw2/ouw8qchdWitXhDQ0ZMJHehEfvyTyvYr9L7rwyCxQlBu1FIhqb5O/XFW3CMsRt2IXj1iQaklh1C+N5orvByF/PplZzGgh1xVgwg3oWkI6fBilGQwr1m8Kv3+/Wng5y0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=qhf7tuAb; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--saravanak.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6b9f4a513so2947291276.3 for ; Fri, 02 Feb 2024 02:13:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706868814; x=1707473614; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=MmGh++VKQQZ2V54BTT2UNO9KFpQjbrHNRiYoSPHg+q4=; b=qhf7tuAbPqa3DyhMI7DqkdD5a3vJEYC79d27UG3soDoQiQAw+i7tvlDRE2rgGV+wzQ Bu+hKBbsBjgV1JlcFmrBXzUYh4CP9LeuZrS8ckkdwjCE3xanE/UBGpAHTti3oaweX6S5 pDaqrtJoagKqPnom/3w4Hi7XutGVtCfujLWYpiVofqpaD2PizNszOgI7TPz2Nfd4P8Dl d4Wx0zcNpnOte0RDFxjodsq/DmnSOu+arLt7wiULjp1awrqlSjmv3UG1K8HiyggzR6Qu mD570K2VB8Zp/ISAC4kGngiGqe6T9PTmjrt9R6U2CsyhzFKnPnoNIU1DIFOkRlbaWtLc duUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706868814; x=1707473614; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MmGh++VKQQZ2V54BTT2UNO9KFpQjbrHNRiYoSPHg+q4=; b=ANjZpKlZvTw2JZngqhH/k5YnI9WcbWi3PzzStQ8QxT7dU4D7Rwn862rZHiAJH2peCP kOJoGmaAeXmvSEgf9vdRy9rJTiSnUFKJn/Ouav3QmtzVGJIBgYmsWtsubo4hSoZ+E++K UPxB3R7cZ2ilRZWJdSt/Ug6YNcazfWhV3AZ3fkCBDpIj97cRut/9ZIWc+w46nTje5GBY ANKEMNmb6H1ojnqTsMnN2S3hLB41wLeA4IpzJCz+L+Pbsn+vzalx25UXTzwSvmQHTLkS GxTFX1NA7FWWReKaXlE41VHQEk/Jp3hK8PoaAXBDCD07cjQbHLvJ5Shn1tFJMdhxDzlg jrOQ== X-Gm-Message-State: AOJu0Yz4Sv9fgVzuJRYQ4/N0hXfaFEagsAhN8TtUcLg2FRa4N4pgCcdA OoBx1bGg3yZsHApOpddyoVSyG4MUk+6p14tiFkSHUdg9oYAwacof1gee5c/8tGZDe52nocADMwU YQ7s4lld4YEIjxA== X-Received: from saravanak.san.corp.google.com ([2620:15c:2d:3:6f0:da10:9cb3:5b3]) (user=saravanak job=sendgmr) by 2002:a05:6902:2186:b0:dc2:466a:23c4 with SMTP id dl6-20020a056902218600b00dc2466a23c4mr499035ybb.4.1706868814499; Fri, 02 Feb 2024 02:13:34 -0800 (PST) Date: Fri, 2 Feb 2024 02:13:25 -0800 In-Reply-To: <20240202101326.876070-1-saravanak@google.com> Message-Id: <20240202101326.876070-3-saravanak@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240202101326.876070-1-saravanak@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Subject: [PATCH v1 2/2] of: property: Improve finding the supplier of a remote-endpoint property From: Saravana Kannan To: Rob Herring , Frank Rowand , Greg Kroah-Hartman , Saravana Kannan Cc: kernel-team@android.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789783368737676298 X-GMAIL-MSGID: 1789783368737676298 After commit 4a032827daa8 ("of: property: Simplify of_link_to_phandle()"), remote-endpoint properties created a fwnode link from the consumer device to the supplier endpoint. This is a tiny bit inefficient (not buggy) when trying to create device links or detecting cycles. So, improve this the same way we improved finding the consumer of a remote-endpoint property. Fixes: 4a032827daa8 ("of: property: Simplify of_link_to_phandle()") Signed-off-by: Saravana Kannan --- drivers/of/property.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index ba374a1f2072..6c168446b647 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1232,7 +1232,6 @@ DEFINE_SIMPLE_PROP(pinctrl5, "pinctrl-5", NULL) DEFINE_SIMPLE_PROP(pinctrl6, "pinctrl-6", NULL) DEFINE_SIMPLE_PROP(pinctrl7, "pinctrl-7", NULL) DEFINE_SIMPLE_PROP(pinctrl8, "pinctrl-8", NULL) -DEFINE_SIMPLE_PROP(remote_endpoint, "remote-endpoint", NULL) DEFINE_SIMPLE_PROP(pwms, "pwms", "#pwm-cells") DEFINE_SIMPLE_PROP(resets, "resets", "#reset-cells") DEFINE_SIMPLE_PROP(leds, "leds", NULL) @@ -1303,6 +1302,24 @@ static struct device_node *get_remote_endpoint_dev(struct device_node *np) return to_of_node(fwnode_graph_get_port_parent(of_fwnode_handle(np))); } +static struct device_node *parse_remote_endpoint(struct device_node *np, + const char *prop_name, + int index) +{ + struct device_node *endpoint, *sup; + + if (strcmp(prop_name, "remote-endpoint")) + return NULL; + + endpoint = of_parse_phandle(np, prop_name, index); + if (!endpoint) + return NULL; + + sup = get_remote_endpoint_dev(endpoint); + of_node_put(endpoint); + return sup; +} + static const struct supplier_bindings of_supplier_bindings[] = { { .parse_prop = parse_clocks, }, { .parse_prop = parse_interconnects, },