msm: camera: Return correct code when camera open fails

There can be situations when opening camera will fail, not
due to an error but due to the fact that the current hardware
configuration can only support either the front or back camera
and can't support opening another the camera at the moment.

In such cases, rather than returning -EFAULT to user space, camera
should return -EBUSY so as to distinguish between a genuine failure
to open the camera and a failure due to current configuration which
precludes from opening another instance of the camera.

So, correct the return code in the camera open failure handling code.

Change-Id: Ib99ed919be44b40a1b0270a3d2a8a1794a0373cb
Signed-off-by: Seemanta Dutta <seemanta@codeaurora.org>
This commit is contained in:
Seemanta Dutta 2015-05-20 17:58:06 -07:00 committed by Gerrit - the friendly Code Review server
parent 46840b97d0
commit 7cda08880a
2 changed files with 11 additions and 1 deletions

View File

@ -69,7 +69,16 @@ static int camera_check_event_status(struct v4l2_event *event)
__func__);
pr_err("%s : Line %d event_data->status 0X%x\n",
__func__, __LINE__, event_data->status);
return -EFAULT;
switch (event_data->status) {
case MSM_CAMERA_ERR_CMD_FAIL:
case MSM_CAMERA_ERR_MAPPING:
return -EFAULT;
case MSM_CAMERA_ERR_DEVICE_BUSY:
return -EBUSY;
default:
return -EFAULT;
}
}
return 0;

View File

@ -126,6 +126,7 @@
#define MSM_CAMERA_ERR_EVT_BASE 0x00010000
#define MSM_CAMERA_ERR_CMD_FAIL (MSM_CAMERA_ERR_EVT_BASE + 1)
#define MSM_CAMERA_ERR_MAPPING (MSM_CAMERA_ERR_EVT_BASE + 2)
#define MSM_CAMERA_ERR_DEVICE_BUSY (MSM_CAMERA_ERR_EVT_BASE + 3)
/* The msm_v4l2_event_data structure should match the
* v4l2_event.u.data field.