[PATCH r128 2/6] Get entity without code duplication

Connor Behan connor.behan at gmail.com
Wed Jul 16 18:34:53 PDT 2014


This fixes the parts of the code that were not using the helper function
to find the entity.

Signed-off-by: Connor Behan <connor.behan at gmail.com>
---
 src/r128_accel.c  |  8 ++------
 src/r128_driver.c | 34 ++++++----------------------------
 2 files changed, 8 insertions(+), 34 deletions(-)

diff --git a/src/r128_accel.c b/src/r128_accel.c
index 7ffd15f..4d666c7 100644
--- a/src/r128_accel.c
+++ b/src/r128_accel.c
@@ -1853,12 +1853,8 @@ static void R128MMIOAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a)
 
     if(xf86IsEntityShared(pScrn->entityList[0]))
     {
-        DevUnion* pPriv;
-        R128EntPtr pR128Ent;
-        pPriv = xf86GetEntityPrivate(pScrn->entityList[0],
-                getR128EntityIndex());
-        pR128Ent = pPriv->ptr;
-        
+        R128EntPtr pR128Ent = R128EntPriv(pScrn);
+
         /*if there are more than one devices sharing this entity, we
           have to assign this call back, otherwise the XAA will be
           disabled */
diff --git a/src/r128_driver.c b/src/r128_driver.c
index 4c03060..c62a1af 100644
--- a/src/r128_driver.c
+++ b/src/r128_driver.c
@@ -241,9 +241,7 @@ static Bool R128MapMMIO(ScrnInfoPtr pScrn)
         /* If the primary screen has already mapped the MMIO region,
            use its pointer instead of mapping it a second time. */
         if (info->IsSecondary) {
-            DevUnion* pPriv = xf86GetEntityPrivate(pScrn->entityList[0], 
-                                                   getR128EntityIndex());
-            R128EntPtr pR128Ent = pPriv->ptr;
+            R128EntPtr pR128Ent = R128EntPriv(pScrn);
             R128InfoPtr info0 = R128PTR(pR128Ent->pPrimaryScrn);
             info->MMIO=info0->MMIO;
             if (info->MMIO) return TRUE;
@@ -482,11 +480,7 @@ static Bool R128GetBIOSParameters(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10)
 
                  if(info->DisplayType > MT_NONE)
                  {
-                     DevUnion* pPriv;
-                     R128EntPtr pR128Ent;
-                     pPriv = xf86GetEntityPrivate(pScrn->entityList[0], 
-                         getR128EntityIndex());
-                     pR128Ent = pPriv->ptr;
+                     R128EntPtr pR128Ent = R128EntPriv(pScrn);
                      pR128Ent->HasSecondary = TRUE;
 
                  }
@@ -506,11 +500,7 @@ static Bool R128GetBIOSParameters(ScrnInfoPtr pScrn, xf86Int10InfoPtr pInt10)
                      If something on CRT port, treat it as primary*/
                      if(xf86IsEntityShared(pScrn->entityList[0]))
                      {
-                         DevUnion* pPriv;
-                         R128EntPtr pR128Ent;
-                         pPriv = xf86GetEntityPrivate(pScrn->entityList[0], 
-                             getR128EntityIndex());
-                         pR128Ent = pPriv->ptr;
+                         R128EntPtr pR128Ent = R128EntPriv(pScrn);
                          pR128Ent->BypassSecondary = TRUE;
                      }
 
@@ -1427,24 +1417,16 @@ Bool R128PreInit(ScrnInfoPtr pScrn, int flags)
     {
         if(xf86IsPrimInitDone(pScrn->entityList[0]))
         {
-            DevUnion* pPriv;
-            R128EntPtr pR128Ent;
+            R128EntPtr pR128Ent = R128EntPriv(pScrn);
             info->IsSecondary = TRUE;
-            pPriv = xf86GetEntityPrivate(pScrn->entityList[0], 
-                    getR128EntityIndex());
-            pR128Ent = pPriv->ptr;
             if(pR128Ent->BypassSecondary) return FALSE;
             pR128Ent->pSecondaryScrn = pScrn;
         }
         else
         {
-            DevUnion* pPriv;
-            R128EntPtr pR128Ent;
+            R128EntPtr pR128Ent = R128EntPriv(pScrn);
 	    info->IsPrimary = TRUE;
             xf86SetPrimInitDone(pScrn->entityList[0]);
-            pPriv = xf86GetEntityPrivate(pScrn->entityList[0], 
-                    getR128EntityIndex());
-            pR128Ent = pPriv->ptr;
             pR128Ent->pPrimaryScrn = pScrn;
             pR128Ent->IsDRIEnabled = FALSE;
             pR128Ent->BypassSecondary = FALSE;
@@ -1894,11 +1876,7 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DECL)
                     R128DRIScreenInit(pScreen);
                 if(xf86IsEntityShared(pScrn->entityList[0]))
                 {
-                    DevUnion* pPriv;
-                    R128EntPtr pR128Ent;
-                    pPriv = xf86GetEntityPrivate(pScrn->entityList[0], 
-                        getR128EntityIndex());
-                    pR128Ent = pPriv->ptr;
+                    R128EntPtr pR128Ent = R128EntPriv(pScrn);
                     pR128Ent->IsDRIEnabled = info->directRenderingEnabled;
                 }
             }
-- 
2.0.0



More information about the xorg-driver-ati mailing list