dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Eric Anholt <eric@anholt.net>
To: dri-devel@lists.freedesktop.org
Cc: linux-arm-msm@vger.kernel.org,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	linux-kernel@vger.kernel.org,
	Kyungmin Park <kyungmin.park@samsung.com>
Subject: [PATCH v2 4/4] drm/msm: Use exynos's model for handling component driver matching.
Date: Thu, 17 Sep 2015 10:57:58 -0400	[thread overview]
Message-ID: <1442501878-9037-4-git-send-email-eric@anholt.net> (raw)
In-Reply-To: <1442501878-9037-1-git-send-email-eric@anholt.net>

This eliminates the need for the "connectors" and "gpus" nodes in the
devicetree, which we were doing nothing connector- or gpu-specific
with.

Signed-off-by: Eric Anholt <eric@anholt.net>
---
 drivers/gpu/drm/msm/msm_drv.c | 65 +++++++++++++++++--------------------------
 include/drm/drmP.h            |  2 +-
 2 files changed, 27 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index a9b0573..4e1263b 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -1039,34 +1039,7 @@ static const struct dev_pm_ops msm_pm_ops = {
  * Componentized driver support:
  */
 
-#ifdef CONFIG_OF
-/* NOTE: the CONFIG_OF case duplicates the same code as exynos or imx
- * (or probably any other).. so probably some room for some helpers
- */
-static int compare_of(struct device *dev, void *data)
-{
-	return dev->of_node == data;
-}
-
-static int add_components(struct device *dev, struct component_match **matchptr,
-		const char *name)
-{
-	struct device_node *np = dev->of_node;
-	unsigned i;
-
-	for (i = 0; ; i++) {
-		struct device_node *node;
-
-		node = of_parse_phandle(np, name, i);
-		if (!node)
-			break;
-
-		component_match_add(dev, matchptr, compare_of, node);
-	}
-
-	return 0;
-}
-#else
+#ifndef CONFIG_OF
 static int compare_dev(struct device *dev, void *data)
 {
 	return dev == data;
@@ -1088,6 +1061,20 @@ static const struct component_master_ops msm_drm_ops = {
 	.unbind = msm_drm_unbind,
 };
 
+static struct platform_driver *const noncomponent_drivers[] = {
+#if IS_ENABLED(CONFIG_DRM_MSM_DSI)
+	&msm_dsi_phy_driver,
+#endif
+};
+
+static struct platform_driver *const component_drivers[] = {
+#if IS_ENABLED(CONFIG_DRM_MSM_DSI)
+	&msm_dsi_driver,
+#endif
+	&msm_hdmi_driver,
+	&adreno_driver,
+};
+
 /*
  * Platform driver:
  */
@@ -1096,8 +1083,9 @@ static int msm_pdev_probe(struct platform_device *pdev)
 {
 	struct component_match *match = NULL;
 #ifdef CONFIG_OF
-	add_components(&pdev->dev, &match, "connectors");
-	add_components(&pdev->dev, &match, "gpus");
+	drm_platform_component_match_add_drivers(&pdev->dev, &match,
+						 component_drivers,
+						 ARRAY_SIZE(component_drivers));
 #else
 	/* For non-DT case, it kinda sucks.  We don't actually have a way
 	 * to know whether or not we are waiting for certain devices (or if
@@ -1159,20 +1147,17 @@ static struct platform_driver msm_platform_driver = {
 	.id_table   = msm_id,
 };
 
-static struct platform_driver *const component_drivers[] = {
-#if IS_ENABLED(CONFIG_DRM_MSM_DSI)
-	&msm_dsi_phy_driver,
-	&msm_dsi_driver,
-#endif
-	&msm_hdmi_driver,
-	&adreno_driver,
-};
-
 static int __init msm_drm_register(void)
 {
 	int ret;
 
 	DBG("init");
+
+	ret = drm_platform_register_drivers(noncomponent_drivers,
+					    ARRAY_SIZE(noncomponent_drivers));
+	if (ret)
+		return ret;
+
 	ret = drm_platform_register_drivers(component_drivers,
 					    ARRAY_SIZE(component_drivers));
 	if (ret)
@@ -1187,6 +1172,8 @@ static void __exit msm_drm_unregister(void)
 	platform_driver_unregister(&msm_platform_driver);
 	drm_platform_unregister_drivers(component_drivers,
 					ARRAY_SIZE(component_drivers));
+	drm_platform_unregister_drivers(noncomponent_drivers,
+					ARRAY_SIZE(noncomponent_drivers));
 }
 
 module_init(msm_drm_register);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index b65d886..0da8599 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1094,7 +1094,7 @@ void drm_platform_unregister_drivers(struct platform_driver *const *drv,
 				     int count);
 void drm_platform_component_match_add_drivers(struct device *dev,
 					      struct component_match **match,
-					      struct platform_driver **drivers,
+					      struct platform_driver *const *drivers,
 					      int count);
 
 /* returns true if currently okay to sleep */
-- 
2.1.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2015-09-17 14:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-17 14:57 [PATCH v2 1/4] drm: Put platform driver registration/unregistration loops in core Eric Anholt
2015-09-17 14:57 ` [PATCH v2 2/4] drm/msm: Use drm_platform_register/unregister_drivers() Eric Anholt
2015-09-17 14:57 ` [PATCH v2 3/4] drm: Move exynos "match_add all devices matching my drivers" to core Eric Anholt
2015-09-17 14:57 ` Eric Anholt [this message]
2015-09-17 19:19   ` [PATCH v2 4/4] drm/msm: Use exynos's model for handling component driver matching Rob Clark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1442501878-9037-4-git-send-email-eric@anholt.net \
    --to=eric@anholt.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sw0312.kim@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).