diff options
-rw-r--r-- | drivers/media/radio/si470x/radio-si470x-common.c | 40 | ||||
-rw-r--r-- | drivers/media/radio/si470x/radio-si470x-usb.c | 17 | ||||
-rw-r--r-- | drivers/media/radio/si470x/radio-si470x.h | 1 |
3 files changed, 37 insertions, 21 deletions
diff --git a/drivers/media/radio/si470x/radio-si470x-common.c b/drivers/media/radio/si470x/radio-si470x-common.c index fd9fc4aa8fb0..9f9a417caf93 100644 --- a/drivers/media/radio/si470x/radio-si470x-common.c +++ b/drivers/media/radio/si470x/radio-si470x-common.c | |||
@@ -475,10 +475,9 @@ static int si470x_vidioc_g_ctrl(struct file *file, void *priv, | |||
475 | int retval = 0; | 475 | int retval = 0; |
476 | 476 | ||
477 | /* safety checks */ | 477 | /* safety checks */ |
478 | if (radio->disconnected) { | 478 | retval = si470x_disconnect_check(radio); |
479 | retval = -EIO; | 479 | if (retval) |
480 | goto done; | 480 | goto done; |
481 | } | ||
482 | 481 | ||
483 | switch (ctrl->id) { | 482 | switch (ctrl->id) { |
484 | case V4L2_CID_AUDIO_VOLUME: | 483 | case V4L2_CID_AUDIO_VOLUME: |
@@ -511,10 +510,9 @@ static int si470x_vidioc_s_ctrl(struct file *file, void *priv, | |||
511 | int retval = 0; | 510 | int retval = 0; |
512 | 511 | ||
513 | /* safety checks */ | 512 | /* safety checks */ |
514 | if (radio->disconnected) { | 513 | retval = si470x_disconnect_check(radio); |
515 | retval = -EIO; | 514 | if (retval) |
516 | goto done; | 515 | goto done; |
517 | } | ||
518 | 516 | ||
519 | switch (ctrl->id) { | 517 | switch (ctrl->id) { |
520 | case V4L2_CID_AUDIO_VOLUME: | 518 | case V4L2_CID_AUDIO_VOLUME: |
@@ -567,10 +565,10 @@ static int si470x_vidioc_g_tuner(struct file *file, void *priv, | |||
567 | int retval = 0; | 565 | int retval = 0; |
568 | 566 | ||
569 | /* safety checks */ | 567 | /* safety checks */ |
570 | if (radio->disconnected) { | 568 | retval = si470x_disconnect_check(radio); |
571 | retval = -EIO; | 569 | if (retval) |
572 | goto done; | 570 | goto done; |
573 | } | 571 | |
574 | if (tuner->index != 0) { | 572 | if (tuner->index != 0) { |
575 | retval = -EINVAL; | 573 | retval = -EINVAL; |
576 | goto done; | 574 | goto done; |
@@ -649,10 +647,10 @@ static int si470x_vidioc_s_tuner(struct file *file, void *priv, | |||
649 | int retval = -EINVAL; | 647 | int retval = -EINVAL; |
650 | 648 | ||
651 | /* safety checks */ | 649 | /* safety checks */ |
652 | if (radio->disconnected) { | 650 | retval = si470x_disconnect_check(radio); |
653 | retval = -EIO; | 651 | if (retval) |
654 | goto done; | 652 | goto done; |
655 | } | 653 | |
656 | if (tuner->index != 0) | 654 | if (tuner->index != 0) |
657 | goto done; | 655 | goto done; |
658 | 656 | ||
@@ -688,10 +686,10 @@ static int si470x_vidioc_g_frequency(struct file *file, void *priv, | |||
688 | int retval = 0; | 686 | int retval = 0; |
689 | 687 | ||
690 | /* safety checks */ | 688 | /* safety checks */ |
691 | if (radio->disconnected) { | 689 | retval = si470x_disconnect_check(radio); |
692 | retval = -EIO; | 690 | if (retval) |
693 | goto done; | 691 | goto done; |
694 | } | 692 | |
695 | if (freq->tuner != 0) { | 693 | if (freq->tuner != 0) { |
696 | retval = -EINVAL; | 694 | retval = -EINVAL; |
697 | goto done; | 695 | goto done; |
@@ -718,10 +716,10 @@ static int si470x_vidioc_s_frequency(struct file *file, void *priv, | |||
718 | int retval = 0; | 716 | int retval = 0; |
719 | 717 | ||
720 | /* safety checks */ | 718 | /* safety checks */ |
721 | if (radio->disconnected) { | 719 | retval = si470x_disconnect_check(radio); |
722 | retval = -EIO; | 720 | if (retval) |
723 | goto done; | 721 | goto done; |
724 | } | 722 | |
725 | if (freq->tuner != 0) { | 723 | if (freq->tuner != 0) { |
726 | retval = -EINVAL; | 724 | retval = -EINVAL; |
727 | goto done; | 725 | goto done; |
@@ -747,10 +745,10 @@ static int si470x_vidioc_s_hw_freq_seek(struct file *file, void *priv, | |||
747 | int retval = 0; | 745 | int retval = 0; |
748 | 746 | ||
749 | /* safety checks */ | 747 | /* safety checks */ |
750 | if (radio->disconnected) { | 748 | retval = si470x_disconnect_check(radio); |
751 | retval = -EIO; | 749 | if (retval) |
752 | goto done; | 750 | goto done; |
753 | } | 751 | |
754 | if (seek->tuner != 0) { | 752 | if (seek->tuner != 0) { |
755 | retval = -EINVAL; | 753 | retval = -EINVAL; |
756 | goto done; | 754 | goto done; |
diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c index 6508161401f7..2f5cf6c7234d 100644 --- a/drivers/media/radio/si470x/radio-si470x-usb.c +++ b/drivers/media/radio/si470x/radio-si470x-usb.c | |||
@@ -371,6 +371,23 @@ static int si470x_get_scratch_page_versions(struct si470x_device *radio) | |||
371 | 371 | ||
372 | 372 | ||
373 | /************************************************************************** | 373 | /************************************************************************** |
374 | * General Driver Functions - DISCONNECT_CHECK | ||
375 | **************************************************************************/ | ||
376 | |||
377 | /* | ||
378 | * si470x_disconnect_check - check whether radio disconnects | ||
379 | */ | ||
380 | int si470x_disconnect_check(struct si470x_device *radio) | ||
381 | { | ||
382 | if (radio->disconnected) | ||
383 | return -EIO; | ||
384 | else | ||
385 | return 0; | ||
386 | } | ||
387 | |||
388 | |||
389 | |||
390 | /************************************************************************** | ||
374 | * RDS Driver Functions | 391 | * RDS Driver Functions |
375 | **************************************************************************/ | 392 | **************************************************************************/ |
376 | 393 | ||
diff --git a/drivers/media/radio/si470x/radio-si470x.h b/drivers/media/radio/si470x/radio-si470x.h index dd71985c4113..d24829b04eb2 100644 --- a/drivers/media/radio/si470x/radio-si470x.h +++ b/drivers/media/radio/si470x/radio-si470x.h | |||
@@ -193,6 +193,7 @@ extern const struct v4l2_file_operations si470x_fops; | |||
193 | extern struct video_device si470x_viddev_template; | 193 | extern struct video_device si470x_viddev_template; |
194 | int si470x_get_register(struct si470x_device *radio, int regnr); | 194 | int si470x_get_register(struct si470x_device *radio, int regnr); |
195 | int si470x_set_register(struct si470x_device *radio, int regnr); | 195 | int si470x_set_register(struct si470x_device *radio, int regnr); |
196 | int si470x_disconnect_check(struct si470x_device *radio); | ||
196 | int si470x_set_freq(struct si470x_device *radio, unsigned int freq); | 197 | int si470x_set_freq(struct si470x_device *radio, unsigned int freq); |
197 | int si470x_start(struct si470x_device *radio); | 198 | int si470x_start(struct si470x_device *radio); |
198 | int si470x_stop(struct si470x_device *radio); | 199 | int si470x_stop(struct si470x_device *radio); |