From patchwork Sat Feb 4 13:30:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pin-yen Lin X-Patchwork-Id: 650690 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A1EFC636CC for ; Sat, 4 Feb 2023 13:31:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233625AbjBDNbC (ORCPT ); Sat, 4 Feb 2023 08:31:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233645AbjBDNbA (ORCPT ); Sat, 4 Feb 2023 08:31:00 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3100367E3 for ; Sat, 4 Feb 2023 05:30:57 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id 203so5552049pfx.6 for ; Sat, 04 Feb 2023 05:30:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R9iPc9yhVkUofB90tWrcvmiWB1xZN7L6aBmsKjdgh6c=; b=MmH3x/xM62zRTISXSedEvzRlaMSI+F8Qma5UmquaxSwlvv6YsPZ+8h1xP3F7M3D1Df QCXfWhoJOdvLdzh0hNXPqpam40tk12C8NpO5zRmImK/NmNXbcxJ9dSbO/w8oKgfe20ZG QRCqSAG2eCerNb0ZmsoC546f3eCSx0931M3tA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R9iPc9yhVkUofB90tWrcvmiWB1xZN7L6aBmsKjdgh6c=; b=UXx37AVIPncB3CooCYixh1Pp25dZZtpeAoe+fB0OmmcTaEWF8kIDvOYjkOKVucgGW7 5d6kfGbnpXDdYKtR0yp3iFElz/yJ1tNm36eChTUp7aEIupOsAc6K78OXxnS+ekXisn8Y aXYKN45rNfQFCTuHcITPHixlHhLLjF+AXJV5Bbnc3U6P6YS5ndSz429lxH2m0m+dg36u irH6y6JOseGbvPAK2VNxfjOBO+M0NYMOJm6QIbeK5+x2MFmJSe2UOUYqyBFNTsAm0Bw9 KyX7Q9z+sB1eBydErjs/48jBc2TpESak+FzGNSWNKMjf3Keaen75s74ZeWEnrzIJcwlt gJ3Q== X-Gm-Message-State: AO0yUKVoPBHN7x07cS5XmxFiUdWpHH8coIgwFgkTkVGWiuD/ceJmR+9O /ZW+SEwkw7Cq++fgEVm19qz7Rw== X-Google-Smtp-Source: AK7set+L0bc/md7jnlp6ucsfNCGE/z+ghrSK5N+MS4DGPqmGcMvtPY/U7zbRRON1T5JI3CoL3plPaA== X-Received: by 2002:a05:6a00:882:b0:593:96a2:d60a with SMTP id q2-20020a056a00088200b0059396a2d60amr18474657pfj.30.1675517456766; Sat, 04 Feb 2023 05:30:56 -0800 (PST) Received: from treapking.tpe.corp.google.com ([2401:fa00:1:10:c1ad:2bdc:7b5a:72e3]) by smtp.gmail.com with ESMTPSA id 144-20020a621596000000b00593ce7ebbaasm3655639pfv.184.2023.02.04.05.30.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 05:30:56 -0800 (PST) From: Pin-yen Lin To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Prashant Malani , Benson Leung , Guenter Roeck Cc: linux-kernel@vger.kernel.org, =?utf-8?q?N=C3=ADcolas_F_=2E_R_=2E_A_=2E_P?= =?utf-8?q?rado?= , Hsin-Yi Wang , devicetree@vger.kernel.org, Pin-yen Lin , Allen Chen , Lyude Paul , linux-acpi@vger.kernel.org, dri-devel@lists.freedesktop.org, Marek Vasut , Xin Ji , Stephen Boyd , AngeloGioacchino Del Regno , Thomas Zimmermann , Javier Martinez Canillas , chrome-platform@lists.linux.dev, Chen-Yu Tsai Subject: [PATCH v11 1/9] device property: Add remote endpoint to devcon matcher Date: Sat, 4 Feb 2023 21:30:32 +0800 Message-Id: <20230204133040.1236799-2-treapking@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230204133040.1236799-1-treapking@chromium.org> References: <20230204133040.1236799-1-treapking@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Prashant Malani When searching the device graph for device matches, check the remote-endpoint itself for a match. Some drivers register devices for individual endpoints. This allows the matcher code to evaluate those for a match too, instead of only looking at the remote parent devices. This is required when a device supports two mode switches in its endpoints, so we can't simply register the mode switch with the parent node. Signed-off-by: Prashant Malani Signed-off-by: Pin-yen Lin Reviewed-by: Chen-Yu Tsai Tested-by: Chen-Yu Tsai --- Changes in v11: - Added missing fwnode_handle_put in drivers/base/property.c Changes in v10: - Collected Reviewed-by and Tested-by tags Changes in v6: - New in v6 drivers/base/property.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/base/property.c b/drivers/base/property.c index 2a5a37fcd998..e6f915b72eb7 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1223,6 +1223,22 @@ static unsigned int fwnode_graph_devcon_matches(struct fwnode_handle *fwnode, break; } + /* + * Some drivers may register devices for endpoints. Check + * the remote-endpoints for matches in addition to the remote + * port parent. + */ + node = fwnode_graph_get_remote_endpoint(ep); + if (fwnode_device_is_available(node)) { + ret = match(node, con_id, data); + if (ret) { + if (matches) + matches[count] = ret; + count++; + } + } + fwnode_handle_put(node); + node = fwnode_graph_get_remote_port_parent(ep); if (!fwnode_device_is_available(node)) { fwnode_handle_put(node);