V4L/DVB (12415): radio-si470x: add disconnect check function
authorJoonyoung Shim <jy0922.shim@samsung.com>
Sun, 9 Aug 2009 17:23:02 +0000 (14:23 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 12 Sep 2009 15:18:42 +0000 (12:18 -0300)
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: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Tobias Lorenz <tobias.lorenz@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/radio/si470x/radio-si470x-common.c
drivers/media/radio/si470x/radio-si470x-usb.c
drivers/media/radio/si470x/radio-si470x.h

index fd9fc4aa8fb0bd288a3084448defaa63fc64791a..9f9a417caf936454bdaa359620239e594a6899fd 100644 (file)
@@ -475,10 +475,9 @@ static int si470x_vidioc_g_ctrl(struct file *file, void *priv,
        int retval = 0;
 
        /* safety checks */
-       if (radio->disconnected) {
-               retval = -EIO;
+       retval = si470x_disconnect_check(radio);
+       if (retval)
                goto done;
-       }
 
        switch (ctrl->id) {
        case V4L2_CID_AUDIO_VOLUME:
@@ -511,10 +510,9 @@ static int si470x_vidioc_s_ctrl(struct file *file, void *priv,
        int retval = 0;
 
        /* safety checks */
-       if (radio->disconnected) {
-               retval = -EIO;
+       retval = si470x_disconnect_check(radio);
+       if (retval)
                goto done;
-       }
 
        switch (ctrl->id) {
        case V4L2_CID_AUDIO_VOLUME:
@@ -567,10 +565,10 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv,
        int retval = 0;
 
        /* safety checks */
-       if (radio->disconnected) {
-               retval = -EIO;
+       retval = si470x_disconnect_check(radio);
+       if (retval)
                goto done;
-       }
+
        if (tuner->index != 0) {
                retval = -EINVAL;
                goto done;
@@ -649,10 +647,10 @@ static int si470x_vidioc_s_tuner(struct file *file, void *priv,
        int retval = -EINVAL;
 
        /* safety checks */
-       if (radio->disconnected) {
-               retval = -EIO;
+       retval = si470x_disconnect_check(radio);
+       if (retval)
                goto done;
-       }
+
        if (tuner->index != 0)
                goto done;
 
@@ -688,10 +686,10 @@ static int si470x_vidioc_g_frequency(struct file *file, void *priv,
        int retval = 0;
 
        /* safety checks */
-       if (radio->disconnected) {
-               retval = -EIO;
+       retval = si470x_disconnect_check(radio);
+       if (retval)
                goto done;
-       }
+
        if (freq->tuner != 0) {
                retval = -EINVAL;
                goto done;
@@ -718,10 +716,10 @@ static int si470x_vidioc_s_frequency(struct file *file, void *priv,
        int retval = 0;
 
        /* safety checks */
-       if (radio->disconnected) {
-               retval = -EIO;
+       retval = si470x_disconnect_check(radio);
+       if (retval)
                goto done;
-       }
+
        if (freq->tuner != 0) {
                retval = -EINVAL;
                goto done;
@@ -747,10 +745,10 @@ static int si470x_vidioc_s_hw_freq_seek(struct file *file, void *priv,
        int retval = 0;
 
        /* safety checks */
-       if (radio->disconnected) {
-               retval = -EIO;
+       retval = si470x_disconnect_check(radio);
+       if (retval)
                goto done;
-       }
+
        if (seek->tuner != 0) {
                retval = -EINVAL;
                goto done;
index 6508161401f7029b14aa0236589037cf7874d450..2f5cf6c7234df14659940632e6f74407172a11fc 100644 (file)
@@ -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
  **************************************************************************/
index dd71985c41139d9f0941e638d12d58efe08a07e9..d24829b04eb2b40420191540866346c812719f7d 100644 (file)
@@ -193,6 +193,7 @@ extern const struct v4l2_file_operations si470x_fops;
 extern struct video_device si470x_viddev_template;
 int si470x_get_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_start(struct si470x_device *radio);
 int si470x_stop(struct si470x_device *radio);