[POC 11/16] drm/img-rogue: replace call to obsolete drm_platform_init()

Ulrich Hecht ulrich.hecht+renesas at gmail.com
Wed Nov 15 07:24:18 PST 2017


Use drm_dev_alloc(), drm_dev_register() and remove the .load and .unload
methods from drm_driver.

Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas at gmail.com>
---
 drivers/gpu/drm/img-rogue/1.6/mt8173/mtk_module.c | 14 +++++++++++--
 drivers/gpu/drm/img-rogue/1.6/pvr_drm.c           | 24 +----------------------
 2 files changed, 13 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/img-rogue/1.6/mt8173/mtk_module.c b/drivers/gpu/drm/img-rogue/1.6/mt8173/mtk_module.c
index 5df3a15..1ef75bb 100644
--- a/drivers/gpu/drm/img-rogue/1.6/mt8173/mtk_module.c
+++ b/drivers/gpu/drm/img-rogue/1.6/mt8173/mtk_module.c
@@ -109,7 +109,7 @@ static struct platform_driver powervr_driver = {
 *****************************************************************************/
 int PVRSRVSystemInit(struct drm_device *pDrmDevice)
 {
-	struct platform_device *pDevice = pDrmDevice->platformdev;
+	struct platform_device *pDevice = to_platform_device(pDrmDevice->dev);
 	PVRSRV_ERROR err;
 
 	PVR_TRACE(("%s (pDevice=%p)", __func__, pDevice));
@@ -160,8 +160,10 @@ void PVRSRVSystemDeInit(struct platform_device *pDevice)
  @Return 0 for success or <0 for an error.
 
 *****************************************************************************/
+int PVRSRVDRMLoad(struct drm_device *dev, unsigned long flags);
 static int PVRSRVDriverProbe(struct platform_device *pDevice)
 {
+	struct drm_device *drm;
 	int result;
 
 	PVR_TRACE(("%s (pDevice=%p)", __func__, pDevice));
@@ -172,13 +174,21 @@ static int PVRSRVDriverProbe(struct platform_device *pDevice)
 			return result;
 	}
 
-	result = drm_platform_init(&sPVRDRMDriver, pDevice);
+	drm = drm_dev_alloc(&sPVRDRMDriver, &pDevice->dev);
+        if (IS_ERR(drm))
+		return PTR_ERR(drm);
+
+	platform_set_drvdata(pDevice, drm);
+
+	result = PVRSRVDRMLoad(drm, 0);
 
 	dma_set_mask(&pDevice->dev, DMA_BIT_MASK(33));
 
 	if (result == 0)
 		PVRSRVDeviceInit();
 
+	result = drm_dev_register(drm, 0);
+
 	return result;
 }
 
diff --git a/drivers/gpu/drm/img-rogue/1.6/pvr_drm.c b/drivers/gpu/drm/img-rogue/1.6/pvr_drm.c
index 7439a6f..36c5a76 100644
--- a/drivers/gpu/drm/img-rogue/1.6/pvr_drm.c
+++ b/drivers/gpu/drm/img-rogue/1.6/pvr_drm.c
@@ -107,17 +107,12 @@ DECLARE_WAIT_QUEUE_HEAD(sWaitForInit);
 IMG_BOOL bInitComplete;
 IMG_BOOL bInitFailed;
 
-static int PVRSRVDRMLoad(struct drm_device *dev, unsigned long flags)
+int PVRSRVDRMLoad(struct drm_device *dev, unsigned long flags)
 {
 	int iRes;
 
 	PVR_TRACE(("PVRSRVDRMLoad"));
 
-#if defined(LDM_PLATFORM)
-	/* The equivalent is done for PCI modesetting drivers by drm_get_pci_dev() */
-	platform_set_drvdata(dev->platformdev, dev);
-#endif
-
 	/* Module initialisation */
 	iRes = PVRSRVSystemInit(dev);
 	if (iRes != 0)
@@ -141,21 +136,6 @@ static int PVRSRVDRMLoad(struct drm_device *dev, unsigned long flags)
 	return iRes;
 }
 
-static int PVRSRVDRMUnload(struct drm_device *dev)
-{
-#if defined(LDM_PLATFORM)
-	LDM_DEV *pDevice = dev->platformdev;
-#elif defined(LDM_PCI)
-	LDM_DEV *pDevice = dev->pdev;
-#endif
-
-	PVR_TRACE(("PVRSRVDRMUnload"));
-
-	PVRSRVSystemDeInit(pDevice);
-
-	return 0;
-}
-
 static int PVRSRVDRMOpen(struct drm_device *dev, struct drm_file *file)
 {
 	while (!bInitComplete)
@@ -306,8 +286,6 @@ struct drm_driver sPVRDRMDriver =
 	.driver_features	= DRIVER_MODESET | DRIVER_RENDER,
 
 	.dev_priv_size		= 0,
-	.load			= PVRSRVDRMLoad,
-	.unload			= PVRSRVDRMUnload,
 	.open			= PVRSRVDRMOpen,
 	.postclose		= PVRSRVRelease,
 
-- 
2.7.4




More information about the Linux-mediatek mailing list