Skip to content

Commit

Permalink
msm: camera: Allow driver file to be opend only once.
Browse files Browse the repository at this point in the history
Use proper synchronization to ensure driver file is opened
only once.

FPIIM-1557

CRs-Fixed: 2023513
Change-Id: I71e55e2d487fe561d3f596590b3e8102c5e921b5
Signed-off-by: Trishansh Bhardwaj <[email protected]>
Signed-off-by: Francisco Franco <[email protected]>
  • Loading branch information
Trishansh Bhardwaj authored and franciscofranco committed Sep 16, 2017
1 parent 6a80416 commit d0eec9c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/media/platform/msm/camera_v2/msm.c
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,9 @@ static int msm_open(struct file *filep)
BUG_ON(!pvdev);

/* !!! only ONE open is allowed !!! */
if (atomic_read(&pvdev->opened))
if (atomic_cmpxchg(&pvdev->opened, 0, 1))
return -EBUSY;

atomic_set(&pvdev->opened, 1);

spin_lock_irqsave(&msm_pid_lock, flags);
msm_pid = get_pid(task_pid(current));
spin_unlock_irqrestore(&msm_pid_lock, flags);
Expand Down

0 comments on commit d0eec9c

Please sign in to comment.