Commit 3c7cc8d5 authored by Joonyoung Shim's avatar Joonyoung Shim Committed by Mauro Carvalho Chehab

V4L/DVB (12415): radio-si470x: add disconnect check function

The si470x_disconnect_check is function to check disconnect state of
radio in common file. The function is implemented in each interface
file.
Signed-off-by: default avatarJoonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: default avatarTobias Lorenz <tobias.lorenz@gmx.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent a9d6fd5e
...@@ -475,10 +475,9 @@ static int si470x_vidioc_g_ctrl(struct file *file, void *priv, ...@@ -475,10 +475,9 @@ static int si470x_vidioc_g_ctrl(struct file *file, void *priv,
int retval = 0; int retval = 0;
/* safety checks */ /* safety checks */
if (radio->disconnected) { retval = si470x_disconnect_check(radio);
retval = -EIO; if (retval)
goto done; goto done;
}
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME: case V4L2_CID_AUDIO_VOLUME:
...@@ -511,10 +510,9 @@ static int si470x_vidioc_s_ctrl(struct file *file, void *priv, ...@@ -511,10 +510,9 @@ static int si470x_vidioc_s_ctrl(struct file *file, void *priv,
int retval = 0; int retval = 0;
/* safety checks */ /* safety checks */
if (radio->disconnected) { retval = si470x_disconnect_check(radio);
retval = -EIO; if (retval)
goto done; goto done;
}
switch (ctrl->id) { switch (ctrl->id) {
case V4L2_CID_AUDIO_VOLUME: case V4L2_CID_AUDIO_VOLUME:
...@@ -567,10 +565,10 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv, ...@@ -567,10 +565,10 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv,
int retval = 0; int retval = 0;
/* safety checks */ /* safety checks */
if (radio->disconnected) { retval = si470x_disconnect_check(radio);
retval = -EIO; if (retval)
goto done; goto done;
}
if (tuner->index != 0) { if (tuner->index != 0) {
retval = -EINVAL; retval = -EINVAL;
goto done; goto done;
...@@ -649,10 +647,10 @@ static int si470x_vidioc_s_tuner(struct file *file, void *priv, ...@@ -649,10 +647,10 @@ static int si470x_vidioc_s_tuner(struct file *file, void *priv,
int retval = -EINVAL; int retval = -EINVAL;
/* safety checks */ /* safety checks */
if (radio->disconnected) { retval = si470x_disconnect_check(radio);
retval = -EIO; if (retval)
goto done; goto done;
}
if (tuner->index != 0) if (tuner->index != 0)
goto done; goto done;
...@@ -688,10 +686,10 @@ static int si470x_vidioc_g_frequency(struct file *file, void *priv, ...@@ -688,10 +686,10 @@ static int si470x_vidioc_g_frequency(struct file *file, void *priv,
int retval = 0; int retval = 0;
/* safety checks */ /* safety checks */
if (radio->disconnected) { retval = si470x_disconnect_check(radio);
retval = -EIO; if (retval)
goto done; goto done;
}
if (freq->tuner != 0) { if (freq->tuner != 0) {
retval = -EINVAL; retval = -EINVAL;
goto done; goto done;
...@@ -718,10 +716,10 @@ static int si470x_vidioc_s_frequency(struct file *file, void *priv, ...@@ -718,10 +716,10 @@ static int si470x_vidioc_s_frequency(struct file *file, void *priv,
int retval = 0; int retval = 0;
/* safety checks */ /* safety checks */
if (radio->disconnected) { retval = si470x_disconnect_check(radio);
retval = -EIO; if (retval)
goto done; goto done;
}
if (freq->tuner != 0) { if (freq->tuner != 0) {
retval = -EINVAL; retval = -EINVAL;
goto done; goto done;
...@@ -747,10 +745,10 @@ static int si470x_vidioc_s_hw_freq_seek(struct file *file, void *priv, ...@@ -747,10 +745,10 @@ static int si470x_vidioc_s_hw_freq_seek(struct file *file, void *priv,
int retval = 0; int retval = 0;
/* safety checks */ /* safety checks */
if (radio->disconnected) { retval = si470x_disconnect_check(radio);
retval = -EIO; if (retval)
goto done; goto done;
}
if (seek->tuner != 0) { if (seek->tuner != 0) {
retval = -EINVAL; retval = -EINVAL;
goto done; goto done;
......
...@@ -370,6 +370,23 @@ static int si470x_get_scratch_page_versions(struct si470x_device *radio) ...@@ -370,6 +370,23 @@ static int si470x_get_scratch_page_versions(struct si470x_device *radio)
/**************************************************************************
* General Driver Functions - DISCONNECT_CHECK
**************************************************************************/
/*
* si470x_disconnect_check - check whether radio disconnects
*/
int si470x_disconnect_check(struct si470x_device *radio)
{
if (radio->disconnected)
return -EIO;
else
return 0;
}
/************************************************************************** /**************************************************************************
* RDS Driver Functions * RDS Driver Functions
**************************************************************************/ **************************************************************************/
......
...@@ -193,6 +193,7 @@ extern const struct v4l2_file_operations si470x_fops; ...@@ -193,6 +193,7 @@ extern const struct v4l2_file_operations si470x_fops;
extern struct video_device si470x_viddev_template; extern struct video_device si470x_viddev_template;
int si470x_get_register(struct si470x_device *radio, int regnr); int si470x_get_register(struct si470x_device *radio, int regnr);
int si470x_set_register(struct si470x_device *radio, int regnr); int si470x_set_register(struct si470x_device *radio, int regnr);
int si470x_disconnect_check(struct si470x_device *radio);
int si470x_set_freq(struct si470x_device *radio, unsigned int freq); int si470x_set_freq(struct si470x_device *radio, unsigned int freq);
int si470x_start(struct si470x_device *radio); int si470x_start(struct si470x_device *radio);
int si470x_stop(struct si470x_device *radio); int si470x_stop(struct si470x_device *radio);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment