msm: camera: Clean up during open failure.

This commit is contained in:
tytung 2011-08-19 00:48:31 +08:00
parent e04e3db5d9
commit f6c36f2d66

View File

@ -2330,9 +2330,10 @@ static struct msm_vfe_callback msm_vfe_s = {
.vfe_free = msm_vfe_sync_free,
};
static int __msm_open(struct msm_sync *sync, const char *const apps_id)
static int __msm_open(struct msm_device *pmsm, const char *const apps_id)
{
int rc = 0;
struct msm_sync *sync = pmsm->sync;
mutex_lock(&sync->lock);
if (sync->apps_id && strcmp(sync->apps_id, apps_id)) {
@ -2358,19 +2359,19 @@ static int __msm_open(struct msm_sync *sync, const char *const apps_id)
if (rc < 0) {
pr_err("%s: vfe_init failed at %d\n",
__func__, rc);
goto msm_open_done;
goto msm_open_err;
}
rc = sync->sctrl.s_init(sync->sdata);
if (rc < 0) {
pr_err("%s: sensor init failed: %d\n",
__func__, rc);
sync->vfefn.vfe_release(sync->pdev);
goto msm_open_done;
goto msm_open_err;
}
} else {
pr_err("%s: no sensor init func\n", __func__);
rc = -ENODEV;
goto msm_open_done;
goto msm_open_err;
}
if (rc >= 0) {
@ -2384,6 +2385,11 @@ static int __msm_open(struct msm_sync *sync, const char *const apps_id)
msm_open_done:
mutex_unlock(&sync->lock);
return rc;
msm_open_err:
atomic_set(&pmsm->opened, 0);
mutex_unlock(&sync->lock);
return rc;
}
static int msm_open_common(struct inode *inode, struct file *filep,
@ -2408,7 +2414,7 @@ static int msm_open_common(struct inode *inode, struct file *filep,
return rc;
}
rc = __msm_open(pmsm->sync, MSM_APPS_ID_PROP);
rc = __msm_open(pmsm, MSM_APPS_ID_PROP);
if (rc < 0)
return rc;