All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joonyoung Shim <jy0922.shim@samsung.com>
To: linux-media@vger.kernel.org
Cc: mchehab@infradead.org, tobias.lorenz@gmx.net,
	kyungmin.park@samsung.com, klimov.linux@gmail.com
Subject: [PATCH v2 3/4] radio-si470x: add disconnect check function
Date: Tue, 14 Jul 2009 14:11:57 +0900	[thread overview]
Message-ID: <4A5C139D.3070409@samsung.com> (raw)

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>
---
 .../media/radio/si470x/radio-si470x-common.c       |   40 +++++++++----------
 .../drivers/media/radio/si470x/radio-si470x-usb.c  |   17 ++++++++
 linux/drivers/media/radio/si470x/radio-si470x.h    |    1 +
 3 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/linux/drivers/media/radio/si470x/radio-si470x-common.c b/linux/drivers/media/radio/si470x/radio-si470x-common.c
index 2be22bd..84cbea3 100644
--- a/linux/drivers/media/radio/si470x/radio-si470x-common.c
+++ b/linux/drivers/media/radio/si470x/radio-si470x-common.c
@@ -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;
diff --git a/linux/drivers/media/radio/si470x/radio-si470x-usb.c b/linux/drivers/media/radio/si470x/radio-si470x-usb.c
index 6508161..2f5cf6c 100644
--- a/linux/drivers/media/radio/si470x/radio-si470x-usb.c
+++ b/linux/drivers/media/radio/si470x/radio-si470x-usb.c
@@ -371,6 +371,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
  **************************************************************************/
 
diff --git a/linux/drivers/media/radio/si470x/radio-si470x.h b/linux/drivers/media/radio/si470x/radio-si470x.h
index 6b85315..6305f6b 100644
--- a/linux/drivers/media/radio/si470x/radio-si470x.h
+++ b/linux/drivers/media/radio/si470x/radio-si470x.h
@@ -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);
-- 
1.6.0.4

                 reply	other threads:[~2009-07-14  5:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A5C139D.3070409@samsung.com \
    --to=jy0922.shim@samsung.com \
    --cc=klimov.linux@gmail.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@infradead.org \
    --cc=tobias.lorenz@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.