All of lore.kernel.org
 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 1/4] drm: Put platform driver registration/unregistration loops in core.
Date: Thu, 17 Sep 2015 10:57:55 -0400	[thread overview]
Message-ID: <1442501878-9037-1-git-send-email-eric@anholt.net> (raw)

This is mostly just a move of the code from exynos, with a slight
reformat.  I wanted to do a similar thing for vc4, and msm looks like
a good candidate as well.

Signed-off-by: Eric Anholt <eric@anholt.net>
---

v2: Move to the KMS helper config flag, and add our kerneldoc to
    drm.tmpl (under the "Driver Initialization" section), as requested
    by danvet.  Move to drm_platform_helper.c instead of _helpers.c to
    be consistent with other files.

 Documentation/DocBook/drm.tmpl          |  4 +++
 drivers/gpu/drm/Makefile                |  3 +-
 drivers/gpu/drm/drm_platform_helper.c   | 53 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 38 ++++-------------------
 include/drm/drmP.h                      |  4 +++
 5 files changed, 69 insertions(+), 33 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_platform_helper.c

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 9ddf8c6..1678d8f 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -465,6 +465,10 @@ char *date;</synopsis>
         </para>
       </sect3>
     </sect2>
+    <sect2>
+      <title>Platform Helper Functions Reference</title>
+!Edrivers/gpu/drm/drm_platform_helper.c
+    </sect2>
   </sect1>
 
   <!-- Internals: memory management -->
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 45e7719..8e3f251 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -21,7 +21,8 @@ drm-$(CONFIG_DRM_PANEL) += drm_panel.o
 drm-$(CONFIG_OF) += drm_of.o
 
 drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
-		drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o
+		drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
+		drm_platform_helper.o
 drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
 drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
 drm_kms_helper-$(CONFIG_DRM_KMS_CMA_HELPER) += drm_fb_cma_helper.o
diff --git a/drivers/gpu/drm/drm_platform_helper.c b/drivers/gpu/drm/drm_platform_helper.c
new file mode 100644
index 0000000..450846f
--- /dev/null
+++ b/drivers/gpu/drm/drm_platform_helper.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <drm/drmP.h>
+
+/**
+ * drm_platform_register_drivers - Helper to register an array of
+ * struct platform_drivers wth platform_driver_register().
+ * @drv:   array of platform drivers to register
+ * @count: number of drivers in the array
+ *
+ * Use drm_platform_unregister_drivers() to undo this.
+ *
+ * Return: 0 on success, -errno value from the last
+ * platform_driver_register otherwise.
+ */
+int drm_platform_register_drivers(struct platform_driver *const *drv,
+				  int count)
+{
+	int i, ret;
+
+	for (i = 0; i < count; ++i) {
+		ret = platform_driver_register(drv[i]);
+		if (ret) {
+			while (--i >= 0)
+				platform_driver_unregister(drv[i]);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(drm_platform_register_drivers);
+
+/**
+ * drm_platform_unregister_drivers - Helper to unregister an array of
+ * struct platform_drivers.
+ * @drv:   array of platform drivers to unregister
+ * @count: number of drivers in the array
+ */
+void drm_platform_unregister_drivers(struct platform_driver *const *drv,
+				     int count)
+{
+	while (--count >= 0)
+		platform_driver_unregister(drv[count]);
+}
+EXPORT_SYMBOL_GPL(drm_platform_unregister_drivers);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index fa5194c..83f829b 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -520,53 +520,27 @@ static int exynos_drm_register_devices(void)
 	return 0;
 }
 
-static void exynos_drm_unregister_drivers(struct platform_driver * const *drv,
-					  int count)
-{
-	while (--count >= 0)
-		platform_driver_unregister(drv[count]);
-}
-
-static int exynos_drm_register_drivers(struct platform_driver * const *drv,
-				       int count)
-{
-	int i, ret;
-
-	for (i = 0; i < count; ++i) {
-		ret = platform_driver_register(drv[i]);
-		if (!ret)
-			continue;
-
-		while (--i >= 0)
-			platform_driver_unregister(drv[i]);
-
-		return ret;
-	}
-
-	return 0;
-}
-
 static inline int exynos_drm_register_kms_drivers(void)
 {
-	return exynos_drm_register_drivers(exynos_drm_kms_drivers,
-					ARRAY_SIZE(exynos_drm_kms_drivers));
+	return drm_platform_register_drivers(exynos_drm_kms_drivers,
+					     ARRAY_SIZE(exynos_drm_kms_drivers));
 }
 
 static inline int exynos_drm_register_non_kms_drivers(void)
 {
-	return exynos_drm_register_drivers(exynos_drm_non_kms_drivers,
-					ARRAY_SIZE(exynos_drm_non_kms_drivers));
+	return drm_platform_register_drivers(exynos_drm_non_kms_drivers,
+					     ARRAY_SIZE(exynos_drm_non_kms_drivers));
 }
 
 static inline void exynos_drm_unregister_kms_drivers(void)
 {
-	exynos_drm_unregister_drivers(exynos_drm_kms_drivers,
+	drm_platform_unregister_drivers(exynos_drm_kms_drivers,
 					ARRAY_SIZE(exynos_drm_kms_drivers));
 }
 
 static inline void exynos_drm_unregister_non_kms_drivers(void)
 {
-	exynos_drm_unregister_drivers(exynos_drm_non_kms_drivers,
+	drm_platform_unregister_drivers(exynos_drm_non_kms_drivers,
 					ARRAY_SIZE(exynos_drm_non_kms_drivers));
 }
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8b5ce7c..a774574 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1087,6 +1087,10 @@ extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
 /* platform section */
 extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
 extern int drm_platform_set_busid(struct drm_device *d, struct drm_master *m);
+int drm_platform_register_drivers(struct platform_driver *const *drv,
+				  int count);
+void drm_platform_unregister_drivers(struct platform_driver *const *drv,
+				     int count);
 
 /* returns true if currently okay to sleep */
 static __inline__ bool drm_can_sleep(void)
-- 
2.1.4

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

WARNING: multiple messages have this Message-ID (diff)
From: Eric Anholt <eric@anholt.net>
To: dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org, David Airlie <airlied@linux.ie>,
	Inki Dae <inki.dae@samsung.com>,
	Joonyoung Shim <jy0922.shim@samsung.com>,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	linux-arm-msm@vger.kernel.org, Rob Clark <robdclark@gmail.com>,
	Eric Anholt <eric@anholt.net>
Subject: [PATCH v2 1/4] drm: Put platform driver registration/unregistration loops in core.
Date: Thu, 17 Sep 2015 10:57:55 -0400	[thread overview]
Message-ID: <1442501878-9037-1-git-send-email-eric@anholt.net> (raw)

This is mostly just a move of the code from exynos, with a slight
reformat.  I wanted to do a similar thing for vc4, and msm looks like
a good candidate as well.

Signed-off-by: Eric Anholt <eric@anholt.net>
---

v2: Move to the KMS helper config flag, and add our kerneldoc to
    drm.tmpl (under the "Driver Initialization" section), as requested
    by danvet.  Move to drm_platform_helper.c instead of _helpers.c to
    be consistent with other files.

 Documentation/DocBook/drm.tmpl          |  4 +++
 drivers/gpu/drm/Makefile                |  3 +-
 drivers/gpu/drm/drm_platform_helper.c   | 53 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 38 ++++-------------------
 include/drm/drmP.h                      |  4 +++
 5 files changed, 69 insertions(+), 33 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_platform_helper.c

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 9ddf8c6..1678d8f 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -465,6 +465,10 @@ char *date;</synopsis>
         </para>
       </sect3>
     </sect2>
+    <sect2>
+      <title>Platform Helper Functions Reference</title>
+!Edrivers/gpu/drm/drm_platform_helper.c
+    </sect2>
   </sect1>
 
   <!-- Internals: memory management -->
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 45e7719..8e3f251 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -21,7 +21,8 @@ drm-$(CONFIG_DRM_PANEL) += drm_panel.o
 drm-$(CONFIG_OF) += drm_of.o
 
 drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
-		drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o
+		drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
+		drm_platform_helper.o
 drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
 drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
 drm_kms_helper-$(CONFIG_DRM_KMS_CMA_HELPER) += drm_fb_cma_helper.o
diff --git a/drivers/gpu/drm/drm_platform_helper.c b/drivers/gpu/drm/drm_platform_helper.c
new file mode 100644
index 0000000..450846f
--- /dev/null
+++ b/drivers/gpu/drm/drm_platform_helper.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <drm/drmP.h>
+
+/**
+ * drm_platform_register_drivers - Helper to register an array of
+ * struct platform_drivers wth platform_driver_register().
+ * @drv:   array of platform drivers to register
+ * @count: number of drivers in the array
+ *
+ * Use drm_platform_unregister_drivers() to undo this.
+ *
+ * Return: 0 on success, -errno value from the last
+ * platform_driver_register otherwise.
+ */
+int drm_platform_register_drivers(struct platform_driver *const *drv,
+				  int count)
+{
+	int i, ret;
+
+	for (i = 0; i < count; ++i) {
+		ret = platform_driver_register(drv[i]);
+		if (ret) {
+			while (--i >= 0)
+				platform_driver_unregister(drv[i]);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(drm_platform_register_drivers);
+
+/**
+ * drm_platform_unregister_drivers - Helper to unregister an array of
+ * struct platform_drivers.
+ * @drv:   array of platform drivers to unregister
+ * @count: number of drivers in the array
+ */
+void drm_platform_unregister_drivers(struct platform_driver *const *drv,
+				     int count)
+{
+	while (--count >= 0)
+		platform_driver_unregister(drv[count]);
+}
+EXPORT_SYMBOL_GPL(drm_platform_unregister_drivers);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index fa5194c..83f829b 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -520,53 +520,27 @@ static int exynos_drm_register_devices(void)
 	return 0;
 }
 
-static void exynos_drm_unregister_drivers(struct platform_driver * const *drv,
-					  int count)
-{
-	while (--count >= 0)
-		platform_driver_unregister(drv[count]);
-}
-
-static int exynos_drm_register_drivers(struct platform_driver * const *drv,
-				       int count)
-{
-	int i, ret;
-
-	for (i = 0; i < count; ++i) {
-		ret = platform_driver_register(drv[i]);
-		if (!ret)
-			continue;
-
-		while (--i >= 0)
-			platform_driver_unregister(drv[i]);
-
-		return ret;
-	}
-
-	return 0;
-}
-
 static inline int exynos_drm_register_kms_drivers(void)
 {
-	return exynos_drm_register_drivers(exynos_drm_kms_drivers,
-					ARRAY_SIZE(exynos_drm_kms_drivers));
+	return drm_platform_register_drivers(exynos_drm_kms_drivers,
+					     ARRAY_SIZE(exynos_drm_kms_drivers));
 }
 
 static inline int exynos_drm_register_non_kms_drivers(void)
 {
-	return exynos_drm_register_drivers(exynos_drm_non_kms_drivers,
-					ARRAY_SIZE(exynos_drm_non_kms_drivers));
+	return drm_platform_register_drivers(exynos_drm_non_kms_drivers,
+					     ARRAY_SIZE(exynos_drm_non_kms_drivers));
 }
 
 static inline void exynos_drm_unregister_kms_drivers(void)
 {
-	exynos_drm_unregister_drivers(exynos_drm_kms_drivers,
+	drm_platform_unregister_drivers(exynos_drm_kms_drivers,
 					ARRAY_SIZE(exynos_drm_kms_drivers));
 }
 
 static inline void exynos_drm_unregister_non_kms_drivers(void)
 {
-	exynos_drm_unregister_drivers(exynos_drm_non_kms_drivers,
+	drm_platform_unregister_drivers(exynos_drm_non_kms_drivers,
 					ARRAY_SIZE(exynos_drm_non_kms_drivers));
 }
 
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8b5ce7c..a774574 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1087,6 +1087,10 @@ extern int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *speed_mask);
 /* platform section */
 extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
 extern int drm_platform_set_busid(struct drm_device *d, struct drm_master *m);
+int drm_platform_register_drivers(struct platform_driver *const *drv,
+				  int count);
+void drm_platform_unregister_drivers(struct platform_driver *const *drv,
+				     int count);
 
 /* returns true if currently okay to sleep */
 static __inline__ bool drm_can_sleep(void)
-- 
2.1.4


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

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-17 14:57 Eric Anholt [this message]
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
2015-09-17 14:57 ` [PATCH v2 4/4] drm/msm: Use exynos's model for handling component driver matching Eric Anholt
2015-09-17 14:57   ` Eric Anholt
2015-09-17 19:19   ` 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-1-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.