diff mbox

[1/2] staging: tidspbridge: convert dmm_map_lock to sema

Message ID 1292855134-14374-2-git-send-email-felipe.contreras@nokia.com (mailing list archive)
State New, archived
Delegated to:
Headers show

Commit Message

Felipe Contreras Dec. 20, 2010, 2:25 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/staging/tidspbridge/include/dspbridge/drv.h b/drivers/staging/tidspbridge/include/dspbridge/drv.h
index c1f363e..217c918 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/drv.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/drv.h
@@ -163,7 +163,7 @@  struct process_context {
 
 	/* DMM mapped memory resources */
 	struct list_head dmm_map_list;
-	spinlock_t dmm_map_lock;
+	struct semaphore dmm_map_sema;
 
 	/* DMM reserved memory resources */
 	struct list_head dmm_rsv_list;
diff --git a/drivers/staging/tidspbridge/rmgr/drv_interface.c b/drivers/staging/tidspbridge/rmgr/drv_interface.c
index 324fcdf..82c25c6 100644
--- a/drivers/staging/tidspbridge/rmgr/drv_interface.c
+++ b/drivers/staging/tidspbridge/rmgr/drv_interface.c
@@ -507,7 +507,7 @@  static int bridge_open(struct inode *ip, struct file *filp)
 	pr_ctxt = kzalloc(sizeof(struct process_context), GFP_KERNEL);
 	if (pr_ctxt) {
 		pr_ctxt->res_state = PROC_RES_ALLOCATED;
-		spin_lock_init(&pr_ctxt->dmm_map_lock);
+		sema_init(&pr_ctxt->dmm_map_sema, 1);
 		INIT_LIST_HEAD(&pr_ctxt->dmm_map_list);
 		spin_lock_init(&pr_ctxt->dmm_rsv_lock);
 		INIT_LIST_HEAD(&pr_ctxt->dmm_rsv_list);
diff --git a/drivers/staging/tidspbridge/rmgr/proc.c b/drivers/staging/tidspbridge/rmgr/proc.c
index b47d7aa..77ab5f5 100644
--- a/drivers/staging/tidspbridge/rmgr/proc.c
+++ b/drivers/staging/tidspbridge/rmgr/proc.c
@@ -144,9 +144,9 @@  static struct dmm_map_object *add_mapping_info(struct process_context *pr_ctxt,
 	map_obj->size = size;
 	map_obj->num_usr_pgs = num_usr_pgs;
 
-	spin_lock(&pr_ctxt->dmm_map_lock);
+	down(&pr_ctxt->dmm_map_sema);
 	list_add(&map_obj->link, &pr_ctxt->dmm_map_list);
-	spin_unlock(&pr_ctxt->dmm_map_lock);
+	up(&pr_ctxt->dmm_map_sema);
 
 	return map_obj;
 }
@@ -170,7 +170,7 @@  static void remove_mapping_information(struct process_context *pr_ctxt,
 	pr_debug("%s: looking for virt 0x%x size 0x%x\n", __func__,
 							dsp_addr, size);
 
-	spin_lock(&pr_ctxt->dmm_map_lock);
+	down(&pr_ctxt->dmm_map_sema);
 	list_for_each_entry(map_obj, &pr_ctxt->dmm_map_list, link) {
 		pr_debug("%s: candidate: mpu_addr 0x%x virt 0x%x size 0x%x\n",
 							__func__,
@@ -191,7 +191,7 @@  static void remove_mapping_information(struct process_context *pr_ctxt,
 
 	pr_err("%s: failed to find given map info\n", __func__);
 out:
-	spin_unlock(&pr_ctxt->dmm_map_lock);
+	up(&pr_ctxt->dmm_map_sema);
 }
 
 static int match_containing_map_obj(struct dmm_map_object *map_obj,
@@ -211,7 +211,7 @@  static struct dmm_map_object *find_containing_mapping(
 	pr_debug("%s: looking for mpu_addr 0x%x size 0x%x\n", __func__,
 						mpu_addr, size);
 
-	spin_lock(&pr_ctxt->dmm_map_lock);
+	down(&pr_ctxt->dmm_map_sema);
 	list_for_each_entry(map_obj, &pr_ctxt->dmm_map_list, link) {
 		pr_debug("%s: candidate: mpu_addr 0x%x virt 0x%x size 0x%x\n",
 						__func__,
@@ -228,7 +228,7 @@  static struct dmm_map_object *find_containing_mapping(
 
 	map_obj = NULL;
 out:
-	spin_unlock(&pr_ctxt->dmm_map_lock);
+	up(&pr_ctxt->dmm_map_sema);
 	return map_obj;
 }