Skip to contentSkip to conversation

gma500: Add proper use of the variable ret for the function, psb_mmu_inset_pfn_sequence

PATCH New Bastien Philbert 1 participant 2 messages Apr 5, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 gma500: Add proper use of the variable ret for the function, psb_mmu_inset_pfn_sequence

This adds proper use of the variable ret by returning it at the end of the function, psb_mmu_inset_pfn_sequence for indicating to callers when an error has occurred. Further more remove the unneeded double setting of ret to the error code, -ENOMEM after checking if a call to the function,

---
 drivers/gpu/drm/gma500/mmu.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/gma500/mmu.c +2 -3
index 0eaf11c..b832397 100644
@@ -677,10 +677,9 @@ int psb_mmu_insert_pfn_sequence(struct psb_mmu_pd *pd, uint32_t start_pfn,
 	do {
 		next = psb_pd_addr_end(addr, end);
 		pt = psb_mmu_pt_alloc_map_lock(pd, addr);
-		if (!pt) {
-			ret = -ENOMEM;
+		if (!pt)
 			goto out;
-		}
+
 		do {
 			pte = psb_mmu_mask_pte(start_pfn++, type);
 			psb_mmu_set_pte(pt, addr, pte);
Signature · 1 line
2.5.0
#1 lore raw

PATCH 2/2 gma500: Add new error checking for the function, psb_driver_load

This adds new error checking to the function, psb_driver_load for when the function, psb_mmu_inset_pfn_sequence fails to grab memory for the internal function call to psb_pd_addr_end. In addition we now implement this by checking for a error code return value from the internal call to the function, psb_mmu_inset_pfn_sequence for the function, psb_driver_load. If a error code is returned we must jump to a new label, unlock_err in order to deallocate our usage count by one for the usage of the semaphore, sem before unloading

---
 drivers/gpu/drm/gma500/psb_drv.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/gma500/psb_drv.c +5 -0
index 4e1c685..52651fb 100644
@@ -343,7 +343,10 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
 					  dev_priv->stolen_base >> PAGE_SHIFT,
 					  pg->gatt_start,
 					  pg->stolen_size >> PAGE_SHIFT, 0);
+	if (ret)
+		goto unlock_err;
 	up_read(&pg->sem);
+
 
 	psb_mmu_set_pd_context(psb_mmu_get_default_pd(dev_priv->mmu), 0);
 	psb_mmu_set_pd_context(dev_priv->pf_pd, 1);
@@ -405,6 +408,8 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
 #endif
 	/* Intel drm driver load is done, continue doing pvr load */
 	return 0;
+unlock_err:
+	up_read(&pg->sem);
 out_err:
 	psb_driver_unload(dev);
 	return ret;
Signature · 1 line
2.5.0