Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp757391pxb; Fri, 28 Jan 2022 09:18:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKhdLqZ7f46A10n/eQC1wzzGB12PZmKsxQlyKrFcLAV5OP5Bjtwx3aI/wkvpsL32FxpZBL X-Received: by 2002:a17:902:b710:: with SMTP id d16mr9757231pls.130.1643390317773; Fri, 28 Jan 2022 09:18:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643390317; cv=none; d=google.com; s=arc-20160816; b=Z4KF4rf3pFRfpCDNgOb1A9KCUSpF5asw4ILzeOkqdzcPsRmJkZXASk/ynrYZQmNtZm GuB1h0rE1cuVRpvKkoFB/eyTWRqMSjsyBFLtJh7/RUI6xZIyap2Ni8UHIJj/t7AtvuIa MkbjU3rCKV89XQivQ6HvQQNw3zBQxpcMns3f7u9C2TTHtovmx+ff7ycp94HdAS5yztDd YRf4N8znHu8kJP5Y5kHAKl06bjlbHhZned8xdtM0g9rWMd9JqbL8bkFds82R7VXXUdmH c4rDUUscHrUrMk4hIdt3iDZLDDa0091oCCJGMB86rrUXaDfpKEgF42BZ2NOrIOHpSpWy K6tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VhuBKYUydW/oAiCUL39yB0AWYBKOWjvjaMBQaeNTygM=; b=gqgY9IfPBuGbZIO/TZR2mTn+vL2oqVHUsvoUb/tmbul4aW6+kleO9INFhLDTay5J4m +JdDx0wYRVS4T8/yoIqHX7UTjPq3tAZIdgvrL52SvMW76uymc7lMAZj38rITqSQSJPg9 Bk4015CnJ7eL92cllbkJyXJtCgkzcj/3nnkq2M4xS8l3GnywCv/W9le9xCodmdZAvcZU KDh5/FEOpLkRFwUgldgL2cPRxytZOJ+eMed6JnMtHVVQCtGqdYixI5WGwkAv8K8X4Hoa eb8HRowqCNJkw/Z861nR0eHJYxksSmJVe6gWRe8VmjZgeJv2R1PzzyBHm9ICquveABis 4dUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JTAhu45H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 2si5205073pli.600.2022.01.28.09.18.25; Fri, 28 Jan 2022 09:18:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JTAhu45H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343667AbiA0UCI (ORCPT + 99 others); Thu, 27 Jan 2022 15:02:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343650AbiA0UCB (ORCPT ); Thu, 27 Jan 2022 15:02:01 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED798C061747 for ; Thu, 27 Jan 2022 12:02:00 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id i1so3668237pla.9 for ; Thu, 27 Jan 2022 12:02:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VhuBKYUydW/oAiCUL39yB0AWYBKOWjvjaMBQaeNTygM=; b=JTAhu45HjLrGN1796BA+tTBKdZIZpsx5QiysdWprNrAbi58xzewJb434XsoCmY5lZo 2icc8mot+qjYU3QPcf1TCDXdsDcWFn8RD/waujc1pge5siUAzBrhPvTWqhWVDw8zYIOs pkYsKKCxqQufaYfH19vEp8rPBJlN1Oat/78Fo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VhuBKYUydW/oAiCUL39yB0AWYBKOWjvjaMBQaeNTygM=; b=4LQNNbnKbQLTcsU6zs35tkFolE+fsQNKWZtTBrxp1rxeLwfj8oB3hW6wZhFcmoWW+V 6DLMI6zBV3zMou2FEl8aQc0/YpiFW9MjZBN4cEO3pbyedYDsW8gs//aSPUlMGxdSMoJN LbTh5hbEETHFS+PSi8CRKh3OfLSWqHrAvPkbilFEfcMg8Z/P0PLrlDteRjC1wMbXhbxE asfSif5zGC4zqzVs2yFpIeT4nQC3lWA3Pp0Nq6Jcf6SlJOdlsSZvmVKutICNTpnCI7xu kIBMCnyi0o0SFfyn7jTxk5lr/XXePAjRhFijNF+EREdKaOaVZGIfFs+ziv2P9jdl3ujC 8tJw== X-Gm-Message-State: AOAM531K3B01yYri8TR/X8fqneos51t1Ug/JiCG2vGoK+TO+MfRGKMDA I0XWLih2wAAt8LWrl00iLvF2Fg== X-Received: by 2002:a17:90b:1b08:: with SMTP id nu8mr5856603pjb.82.1643313720505; Thu, 27 Jan 2022 12:02:00 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:201:9246:1838:3243:3071]) by smtp.gmail.com with ESMTPSA id k21sm6561190pff.33.2022.01.27.12.01.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 12:02:00 -0800 (PST) From: Stephen Boyd To: Greg Kroah-Hartman , Douglas Anderson Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Laurent Pinchart , Daniel Vetter , "Rafael J. Wysocki" , Rob Clark , Russell King , Saravana Kannan Subject: [PATCH v6 05/35] drm/of: Add a drm_of_aggregate_probe() API Date: Thu, 27 Jan 2022 12:01:11 -0800 Message-Id: <20220127200141.1295328-6-swboyd@chromium.org> X-Mailer: git-send-email 2.35.0.rc0.227.g00780c9af4-goog In-Reply-To: <20220127200141.1295328-1-swboyd@chromium.org> References: <20220127200141.1295328-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similar to drm_of_component_probe() but using the new API that registers a driver instead of an ops struct. This allows us to migrate the users of drm_of_component_probe() to the new way of doing things. Cc: Laurent Pinchart Cc: Daniel Vetter Cc: "Rafael J. Wysocki" Cc: Rob Clark Cc: Russell King Cc: Saravana Kannan Signed-off-by: Stephen Boyd --- drivers/gpu/drm/drm_of.c | 85 +++++++++++++++++++++++++++++++--------- include/drm/drm_of.h | 12 ++++++ 2 files changed, 78 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index 59d368ea006b..0fe822319aae 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -99,30 +99,18 @@ void drm_of_component_match_add(struct device *master, } EXPORT_SYMBOL_GPL(drm_of_component_match_add); -/** - * drm_of_component_probe - Generic probe function for a component based master - * @dev: master device containing the OF node - * @compare_of: compare function used for matching components - * @m_ops: component master ops to be used - * - * Parse the platform device OF node and bind all the components associated - * with the master. Interface ports are added before the encoders in order to - * satisfy their .bind requirements - * See Documentation/devicetree/bindings/graph.txt for the bindings. - * - * Returns zero if successful, or one of the standard error codes if it fails. - */ -int drm_of_component_probe(struct device *dev, +static int _drm_of_component_probe(struct device *dev, int (*compare_of)(struct device *, void *), - const struct component_master_ops *m_ops) + struct component_match **matchptr) { struct device_node *ep, *port, *remote; - struct component_match *match = NULL; int i; if (!dev->of_node) return -EINVAL; + *matchptr = NULL; + /* * Bind the crtc's ports first, so that drm_of_find_possible_crtcs() * called from encoder's .bind callbacks works as expected @@ -133,7 +121,7 @@ int drm_of_component_probe(struct device *dev, break; if (of_device_is_available(port->parent)) - drm_of_component_match_add(dev, &match, compare_of, + drm_of_component_match_add(dev, matchptr, compare_of, port); of_node_put(port); @@ -144,7 +132,7 @@ int drm_of_component_probe(struct device *dev, return -ENODEV; } - if (!match) { + if (!*matchptr) { dev_err(dev, "no available port\n"); return -ENODEV; } @@ -174,17 +162,76 @@ int drm_of_component_probe(struct device *dev, continue; } - drm_of_component_match_add(dev, &match, compare_of, + drm_of_component_match_add(dev, matchptr, compare_of, remote); of_node_put(remote); } of_node_put(port); } + return 0; +} + +/** + * drm_of_component_probe - Generic probe function for a component based master + * @dev: master device containing the OF node + * @compare_of: compare function used for matching components + * @m_ops: component master ops to be used + * + * Parse the platform device OF node and bind all the components associated + * with the master. Interface ports are added before the encoders in order to + * satisfy their .bind requirements + * See Documentation/devicetree/bindings/graph.txt for the bindings. + * + * Deprecated: Use drm_of_aggregate_probe() instead. + * + * Returns zero if successful, or one of the standard error codes if it fails. + */ +int drm_of_component_probe(struct device *dev, + int (*compare_of)(struct device *, void *), + const struct component_master_ops *m_ops) +{ + + struct component_match *match; + int ret; + + ret = _drm_of_component_probe(dev, compare_of, &match); + if (ret) + return ret; + return component_master_add_with_match(dev, m_ops, match); } EXPORT_SYMBOL(drm_of_component_probe); + +/** + * drm_of_aggregate_probe - Generic probe function for a component based aggregate host + * @dev: device containing the OF node + * @compare_of: compare function used for matching components + * @adrv: aggregate driver to be used + * + * Parse the platform device OF node and bind all the components associated + * with the aggregate device. Interface ports are added before the encoders in + * order to satisfy their .bind_component requirements + * See Documentation/devicetree/bindings/graph.txt for the bindings. + * + * Returns zero if successful, or one of the standard error codes if it fails. + */ +int drm_of_aggregate_probe(struct device *dev, + int (*compare_of)(struct device *, void *), + struct aggregate_driver *adrv) +{ + struct component_match *match; + int ret; + + ret = _drm_of_component_probe(dev, compare_of, &match); + if (ret) + return ret; + + return component_aggregate_register(dev, adrv, match); +} +EXPORT_SYMBOL(drm_of_aggregate_probe); + /* * drm_of_encoder_active_endpoint - return the active encoder endpoint * @node: device tree node containing encoder input ports diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h index 99f79ac8b4cd..7c7b0d8377a7 100644 --- a/include/drm/drm_of.h +++ b/include/drm/drm_of.h @@ -7,6 +7,7 @@ #include #endif +struct aggregate_driver; struct component_master_ops; struct component_match; struct device; @@ -40,6 +41,9 @@ void drm_of_component_match_add(struct device *master, int drm_of_component_probe(struct device *dev, int (*compare_of)(struct device *, void *), const struct component_master_ops *m_ops); +int drm_of_aggregate_probe(struct device *dev, + int (*compare_of)(struct device *, void *), + struct aggregate_driver *adrv); int drm_of_encoder_active_endpoint(struct device_node *node, struct drm_encoder *encoder, struct of_endpoint *endpoint); @@ -79,6 +83,14 @@ drm_of_component_probe(struct device *dev, return -EINVAL; } +static inline int +drm_of_aggregate_probe(struct device *dev, + int (*compare_of)(struct device *, void *), + struct aggregate_driver *adrv) +{ + return -EINVAL; +} + static inline int drm_of_encoder_active_endpoint(struct device_node *node, struct drm_encoder *encoder, struct of_endpoint *endpoint) -- https://chromeos.dev