From patchwork Fri Aug 6 22:09:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12423957 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 A4110C4320A for ; Fri, 6 Aug 2021 22:09:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8080F611CB for ; Fri, 6 Aug 2021 22:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245442AbhHFWJd (ORCPT ); Fri, 6 Aug 2021 18:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239019AbhHFWJd (ORCPT ); Fri, 6 Aug 2021 18:09:33 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1B03C0613CF; Fri, 6 Aug 2021 15:09:16 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id n12so2749756wrr.2; Fri, 06 Aug 2021 15:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U+w3lXB2hzuJmWQKE0Bh8lOKq0x+eCrRICMF6HvQuy4=; b=AR6iq6SyCBxDMmTf+J80VgzIcoH0rrkrZrWDtEr7oMQXuIJ+Ofl109DG6vdde4pZEC /TD/npyfQ7J3ZERLxohOb8q5Ly8MCDRxCdNJWsPF6MSIzFzzapd9p2RBONjU1IT6e7kR bqLAjo3avCxF8W4b9xbvyMVzzaeTgKh+tJxFms5V01VT2cxe9/PKy/0M00fCI4Basdu6 q2wGJRCK90/hD26EynCqkn7Rx58INpWuGKn8PomMpGbPBaq0+TCP9sAivsgvsBZvfaHC CCviICmAkVm6hZPdFIhNcNVNa+KV2aADpdE/5TIp5x3sw3lBicKj4c7B3LxfyscvRpWv q26A== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=U+w3lXB2hzuJmWQKE0Bh8lOKq0x+eCrRICMF6HvQuy4=; b=Ke/cQ8UcC6b/Rlkhg703lHf3fU15q+CXR6Efr6N/VVy5NSuMwZLie9cggnJLnq4EVE z1+zTyEb/rB0kqKbdXG7NLhdB+3vmy3o5/doKD4pzYKImfNUQ5kBgWP1tCrYf6WOpjAQ IoJHqCFS1FE4FxmEpfYOMwKzuOlakLy4MV0ZqQrOp4OXOY+JW92V1usFpxSWnTCcxnKZ 27XxCuJA5zUsVWlxpBsY5EkAuGRSDPTX5rqZeZG0m/crd+VvBhQqTU9/LG0zZArPGZAQ EM00utaVMHCItGjMjs/HJ113hTZWsbhkMQ3QU21pja24UkJmtyB2X2Bcu7QPgpXrNIXn yP4A== X-Gm-Message-State: AOAM53193YPb/81pdWUUsag6KslgpE8MyGevAA2JNq/PcAO17hjpF6+V bJtR2bpxmYGghmpJujEhJpalO31rbJ8= X-Google-Smtp-Source: ABdhPJxyx0BoPYh+lrQIkpxrxXJ5e5fxiZ7vYYRbODsw8aRIDt5NVYrNLxxp9KeY7eEC/HyqIHBJ6g== X-Received: by 2002:adf:e60c:: with SMTP id p12mr13009984wrm.285.1628287755514; Fri, 06 Aug 2021 15:09:15 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id y21sm12764204wma.38.2021.08.06.15.09.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Aug 2021 15:09:15 -0700 (PDT) From: Daniel Scally To: linux-kernel@vger.kernel.org Cc: linux-acpi@vger.kernel.org, gregkh@linuxfoundation.org, rafael@kernel.org, andriy.shevchenko@linux.intel.com, laurent.pinchart@ideasonboard.com Subject: [PATCH RESEND v3 1/2] device property: Check fwnode->secondary in fwnode_graph_get_next_endpoint() Date: Fri, 6 Aug 2021 23:09:05 +0100 Message-Id: <20210806220906.326758-2-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210806220906.326758-1-djrscally@gmail.com> References: <20210806220906.326758-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Sensor drivers often check for an endpoint to make sure that they're connected to a consuming device like a CIO2 during .probe(). Some of those endpoints might be in the form of software_nodes assigned as a secondary to the device's fwnode_handle. Account for this possibility in fwnode_graph_get_next_endpoint() to avoid having to do it in the sensor drivers themselves. Reviewed-by: Andy Shevchenko Signed-off-by: Daniel Scally --- drivers/base/property.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index 1421e9548857..fb0e852dad5f 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1036,7 +1036,26 @@ struct fwnode_handle * fwnode_graph_get_next_endpoint(const struct fwnode_handle *fwnode, struct fwnode_handle *prev) { - return fwnode_call_ptr_op(fwnode, graph_get_next_endpoint, prev); + const struct fwnode_handle *parent; + struct fwnode_handle *ep; + + /* + * If this function is in a loop and the previous iteration returned + * an endpoint from fwnode->secondary, then we need to use the secondary + * as parent rather than @fwnode. + */ + if (prev) + parent = fwnode_graph_get_port_parent(prev); + else + parent = fwnode; + + ep = fwnode_call_ptr_op(parent, graph_get_next_endpoint, prev); + + if (IS_ERR_OR_NULL(ep) && + !IS_ERR_OR_NULL(parent) && !IS_ERR_OR_NULL(parent->secondary)) + ep = fwnode_graph_get_next_endpoint(parent->secondary, NULL); + + return ep; } EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint); From patchwork Fri Aug 6 22:09:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Scally X-Patchwork-Id: 12423959 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 CCF15C432BE for ; Fri, 6 Aug 2021 22:09:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F72C611C5 for ; Fri, 6 Aug 2021 22:09:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245447AbhHFWJe (ORCPT ); Fri, 6 Aug 2021 18:09:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245444AbhHFWJe (ORCPT ); Fri, 6 Aug 2021 18:09:34 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1235C0613CF; Fri, 6 Aug 2021 15:09:17 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id h14so12769403wrx.10; Fri, 06 Aug 2021 15:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HbdHuUgm9R0O8iD622sN5nUz4CxbxanIEic5v8NNLJE=; b=SuLT8uBTDrpu9O8cTw8EoHnTAMCFyuGzPjEAfgUBnzfLjrNHMfi5GCnTWT4pDq7KbX K73XknSxcL2b0lQhgySS5mPF9dT3GpYo8pvVNrY2hTtjWEXsF6x3mXed+xySyc7SzwG3 N+zyrsTxJ25lgW8VWX4ojjtQ7aMVayF+QDE0q+AQN+pn4Jf2zQqqfOzbzSewcVbv6gSu jqxrKXvRMeP24IaasGaqXj+3t0Ls1d8K5CncgStW44WsLxUB87Pt3BQCtar80b3hvL2s wLr7kHSrNg/3K6SUcmKDaryD6bG7s4kk5nuIMKHgRvzW34fyUBBDBPPzXE6z/3pUE7yh BPqQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=HbdHuUgm9R0O8iD622sN5nUz4CxbxanIEic5v8NNLJE=; b=nIve0DiIjfZkHDvvXpSMBfpkEMyImM1Q7d4EAQh2zD4T7MJq1lNP0KCuShLRdZ4bhQ qYilMYatxnqtwmzneCqH4RTzUjz5bMM9DS3mHHLX2QkuHjWU4QTI2qBSYIY0yWaJ2UNZ AcbJcm8XAM+BqlxLbpKyFnjr5hvo61C17x3QVecSyqlD1pwxe9LBtfSNhdZ6QRC+2mk5 TSaQGXIEqVqDdklKVycqa2BHE4m/wTRz3AaIexHTTR9pHfYmJqAwv+GEv8NmMqhc7zi9 tnGQ8s2Q3wPg5VfIB57IGid58mKzHjpuet0lT52+wv8OYPXlsprPZusiUCIzLfmhzmNF avew== X-Gm-Message-State: AOAM533s/BSrIBdxS3Vyco6g1tg+j6vdbQIJQfVck/n+7KFDzrSlmYCd 8zF38Ok+lKZM/Ue1xGLdM8Y2TfNL0HE= X-Google-Smtp-Source: ABdhPJxsjnEToAvjIfzMFnIo0vfMKI+o6oeBOX0DBjBZbRWHUVjqUhqntfB/c/EGvqh1q089GWkc8g== X-Received: by 2002:adf:cd02:: with SMTP id w2mr13222132wrm.68.1628287756350; Fri, 06 Aug 2021 15:09:16 -0700 (PDT) Received: from localhost.localdomain (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161]) by smtp.gmail.com with ESMTPSA id y21sm12764204wma.38.2021.08.06.15.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Aug 2021 15:09:15 -0700 (PDT) From: Daniel Scally To: linux-kernel@vger.kernel.org Cc: linux-acpi@vger.kernel.org, gregkh@linuxfoundation.org, rafael@kernel.org, andriy.shevchenko@linux.intel.com, laurent.pinchart@ideasonboard.com Subject: [PATCH RESEND v3 2/2] Revert "media: device property: Call fwnode_graph_get_endpoint_by_id() for fwnode->secondary" Date: Fri, 6 Aug 2021 23:09:06 +0100 Message-Id: <20210806220906.326758-3-djrscally@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210806220906.326758-1-djrscally@gmail.com> References: <20210806220906.326758-1-djrscally@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org This reverts commit acd418bfcfc415cf5e6414b6d1c6acfec850f290. Checking for endpoints against fwnode->secondary in fwnode_graph_get_next_endpoint() is a better way to do this since that function is also used in a bunch of other places, for instance sensor drivers checking that they do have an endpoint connected during probe. This reversion depends on the previous patch in this series, "device property: Check fwnode->secondary in fwnode_graph_get_next_endpoint()". Reviewed-by: Andy Shevchenko Signed-off-by: Daniel Scally --- Changes in v3: - specified that this patch depends on 1/2 (Greg) drivers/base/property.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index fb0e852dad5f..c6bb3d453c57 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -1234,14 +1234,7 @@ fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode, best_ep_id = fwnode_ep.id; } - if (best_ep) - return best_ep; - - if (fwnode && !IS_ERR_OR_NULL(fwnode->secondary)) - return fwnode_graph_get_endpoint_by_id(fwnode->secondary, port, - endpoint, flags); - - return NULL; + return best_ep; } EXPORT_SYMBOL_GPL(fwnode_graph_get_endpoint_by_id);