[PATCH 05/12] drm: use drm_get_platform_dev and drop drm_platform_init/exit

Sascha Hauer s.hauer at pengutronix.de
Thu Feb 2 03:57:57 PST 2012


drm_platform_init is modelled after the legacy pci probe
support. It initializes a device_list, but this list will
only ever have a single entry as it is specific to a single
platform device instance. Simplify this by calling
drm_get_platform_dev directly from the driver.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/gpu/drm/drm_platform.c          |   39 +++---------------------------
 drivers/gpu/drm/exynos/exynos_drm_drv.c |    6 +++-
 include/drm/drmP.h                      |    3 --
 3 files changed, 8 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index 453da2d..7153508 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -28,6 +28,8 @@
 #include <linux/export.h>
 #include "drmP.h"
 
+static struct drm_bus drm_platform_bus;
+
 /**
  * Register.
  *
@@ -53,6 +55,8 @@ int drm_get_platform_dev(struct platform_device *platdev,
 
 	dev->dev = &platdev->dev;
 
+	driver->bus = &drm_platform_bus;
+
 	mutex_lock(&drm_global_mutex);
 
 	ret = drm_fill_in_dev(dev, NULL, driver);
@@ -87,8 +91,6 @@ int drm_get_platform_dev(struct platform_device *platdev,
 			goto err_g3;
 	}
 
-	list_add_tail(&dev->driver_item, &driver->device_list);
-
 	mutex_unlock(&drm_global_mutex);
 
 	DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
@@ -165,36 +167,3 @@ static struct drm_bus drm_platform_bus = {
 	.get_name = drm_platform_get_name,
 	.set_busid = drm_platform_set_busid,
 };
-
-/**
- * Platform device initialization. Called direct from modules.
- *
- * \return zero on success or a negative number on failure.
- *
- * Initializes a drm_device structures,registering the
- * stubs
- *
- * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and
- * after the initialization for driver customization.
- */
-
-int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device)
-{
-	DRM_DEBUG("\n");
-
-	driver->bus = &drm_platform_bus;
-	INIT_LIST_HEAD(&driver->device_list);
-	return drm_get_platform_dev(platform_device, driver);
-}
-EXPORT_SYMBOL(drm_platform_init);
-
-void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device)
-{
-	struct drm_device *dev, *tmp;
-	DRM_DEBUG("\n");
-
-	list_for_each_entry_safe(dev, tmp, &driver->device_list, driver_item)
-		drm_put_dev(dev);
-	DRM_INFO("Module unloaded\n");
-}
-EXPORT_SYMBOL(drm_platform_exit);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 35889ca..17a100c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -219,14 +219,16 @@ static int exynos_drm_platform_probe(struct platform_device *pdev)
 
 	exynos_drm_driver.num_ioctls = DRM_ARRAY_SIZE(exynos_ioctls);
 
-	return drm_platform_init(&exynos_drm_driver, pdev);
+	return drm_get_platform_dev(pdev, &exynos_drm_driver);
 }
 
 static int exynos_drm_platform_remove(struct platform_device *pdev)
 {
+	struct drm_device *dev = platform_get_drvdata(pdev);
+
 	DRM_DEBUG_DRIVER("%s\n", __FILE__);
 
-	drm_platform_exit(&exynos_drm_driver, pdev);
+	drm_put_dev(dev);
 
 	return 0;
 }
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 3d1ce03..d14c23a 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1678,9 +1678,6 @@ extern int drm_get_pci_dev(struct pci_dev *pdev,
 
 
 /* platform section */
-extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device);
-extern void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device);
-
 extern int drm_get_platform_dev(struct platform_device *pdev,
 				struct drm_driver *driver);
 
-- 
1.7.8.3



More information about the dri-devel mailing list