msm: camera: Allow driver file to be opend only once.

Use proper synchronization to ensure driver file is opened
only once.

CRs-Fixed: 2023513
Change-Id: I71e55e2d487fe561d3f596590b3e8102c5e921b5
Signed-off-by: Trishansh Bhardwaj <tbhardwa@codeaurora.org>
(cherry picked from commit 84f8c42e5d848b1d04f49d253f98296e8c2280b9)
This commit is contained in:
Trishansh Bhardwaj 2017-04-07 11:16:29 +05:30 committed by Sean McCreary
parent aaab8b2495
commit 20ffd0b6f0

View file

@ -753,11 +753,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);