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: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Tobias Lorenz <tobias.lorenz@gmx.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/radio/si470x/radio-si470x-common.c b/drivers/media/radio/si470x/radio-si470x-common.c
index fd9fc4a..9f9a417 100644
--- a/drivers/media/radio/si470x/radio-si470x-common.c
+++ b/drivers/media/radio/si470x/radio-si470x-common.c
@@ -475,10 +475,9 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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;
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
index 6508161..2f5cf6c 100644
--- a/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -371,6 +371,23 @@
 
 
 /**************************************************************************
+ * 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
  **************************************************************************/
 
diff --git a/drivers/media/radio/si470x/radio-si470x.h b/drivers/media/radio/si470x/radio-si470x.h
index dd71985..d24829b 100644
--- a/drivers/media/radio/si470x/radio-si470x.h
+++ b/drivers/media/radio/si470x/radio-si470x.h
@@ -193,6 +193,7 @@
 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);