aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-05-05 11:30:01 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-05-19 11:59:16 -0400
commit64561a38838c66de1af059e7f4c14bbaa7dd3d54 (patch)
treef80efbbca61c8d5055d4be26d9295fb3fee564b6 /drivers
parente36309f54a6196792fce74100356ebdeaecabd56 (diff)
V4L/DVB: Fix unlock logic at medusa_video_init
As reported by Dan Carpenter: > This was my patch: "cx25821: fix double unlock in medusa_video_init()" > > It accidentally got merged two times. The version from the staging tree > is not correct. Please can you revert it: > 7a02f549fcc30fe6be0c0024beae9a3db22e1af6 "Staging: cx25821: fix double > unlock in medusa_video_init()" After reviewing the logic at the function, instead of just adding a patch to revert the wrong one, the better is to apply a different logic: add a goto that will always unlock and return the error. This simplifies the code a little bit, and, instead of just return -EINVAL, it will return the error condition reported by the called functions. This patch is folded with another patch from Dan that added one missing goto. Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/cx25821/cx25821-medusa-video.c53
1 files changed, 21 insertions, 32 deletions
diff --git a/drivers/staging/cx25821/cx25821-medusa-video.c b/drivers/staging/cx25821/cx25821-medusa-video.c
index 0bb33ba7e99d..34616dc507f9 100644
--- a/drivers/staging/cx25821/cx25821-medusa-video.c
+++ b/drivers/staging/cx25821/cx25821-medusa-video.c
@@ -778,9 +778,9 @@ int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int decoder)
778 778
779int medusa_video_init(struct cx25821_dev *dev) 779int medusa_video_init(struct cx25821_dev *dev)
780{ 780{
781 u32 value = 0, tmp = 0; 781 u32 value, tmp = 0;
782 int ret_val = 0; 782 int ret_val;
783 int i = 0; 783 int i;
784 784
785 mutex_lock(&dev->lock); 785 mutex_lock(&dev->lock);
786 786
@@ -790,18 +790,15 @@ int medusa_video_init(struct cx25821_dev *dev)
790 value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp); 790 value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp);
791 value &= 0xFFFFF0FF; 791 value &= 0xFFFFF0FF;
792 ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value); 792 ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value);
793 if (ret_val < 0)
794 goto error;
793 795
794 if (ret_val < 0) {
795 mutex_unlock(&dev->lock);
796 return -EINVAL;
797 }
798 /* Turn off Master source switch enable */ 796 /* Turn off Master source switch enable */
799 value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp); 797 value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp);
800 value &= 0xFFFFFFDF; 798 value &= 0xFFFFFFDF;
801 ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value); 799 ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value);
802
803 if (ret_val < 0) 800 if (ret_val < 0)
804 return -EINVAL; 801 goto error;
805 802
806 mutex_unlock(&dev->lock); 803 mutex_unlock(&dev->lock);
807 804
@@ -815,31 +812,25 @@ int medusa_video_init(struct cx25821_dev *dev)
815 value &= 0xFF70FF70; 812 value &= 0xFF70FF70;
816 value |= 0x00090008; /* set en_active */ 813 value |= 0x00090008; /* set en_active */
817 ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_AB_CTRL, value); 814 ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_AB_CTRL, value);
815 if (ret_val < 0)
816 goto error;
818 817
819 if (ret_val < 0) {
820 mutex_unlock(&dev->lock);
821 return -EINVAL;
822 }
823 /* enable input is VIP/656 */ 818 /* enable input is VIP/656 */
824 value = cx25821_i2c_read(&dev->i2c_bus[0], BYP_AB_CTRL, &tmp); 819 value = cx25821_i2c_read(&dev->i2c_bus[0], BYP_AB_CTRL, &tmp);
825 value |= 0x00040100; /* enable VIP */ 820 value |= 0x00040100; /* enable VIP */
826 ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value); 821 ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value);
827 822
828 if (ret_val < 0) { 823 if (ret_val < 0)
829 mutex_unlock(&dev->lock); 824 goto error;
830 return -EINVAL; 825
831 }
832 /* select AFE clock to output mode */ 826 /* select AFE clock to output mode */
833 value = cx25821_i2c_read(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, &tmp); 827 value = cx25821_i2c_read(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, &tmp);
834 value &= 0x83FFFFFF; 828 value &= 0x83FFFFFF;
835 ret_val = 829 ret_val = cx25821_i2c_write(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL,
836 cx25821_i2c_write(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, 830 value | 0x10000000);
837 value | 0x10000000); 831 if (ret_val < 0)
832 goto error;
838 833
839 if (ret_val < 0) {
840 mutex_unlock(&dev->lock);
841 return -EINVAL;
842 }
843 /* Turn on all of the data out and control output pins. */ 834 /* Turn on all of the data out and control output pins. */
844 value = cx25821_i2c_read(&dev->i2c_bus[0], PIN_OE_CTRL, &tmp); 835 value = cx25821_i2c_read(&dev->i2c_bus[0], PIN_OE_CTRL, &tmp);
845 value &= 0xFEF0FE00; 836 value &= 0xFEF0FE00;
@@ -858,17 +849,15 @@ int medusa_video_init(struct cx25821_dev *dev)
858 849
859 value |= 7; 850 value |= 7;
860 ret_val = cx25821_i2c_write(&dev->i2c_bus[0], PIN_OE_CTRL, value); 851 ret_val = cx25821_i2c_write(&dev->i2c_bus[0], PIN_OE_CTRL, value);
861 if (ret_val < 0) { 852 if (ret_val < 0)
862 mutex_unlock(&dev->lock); 853 goto error;
863 return -EINVAL;
864 }
865 854
866 mutex_unlock(&dev->lock); 855 mutex_unlock(&dev->lock);
867 856
868 ret_val = medusa_set_videostandard(dev); 857 ret_val = medusa_set_videostandard(dev);
858 return ret_val;
869 859
870 if (ret_val < 0) 860error:
871 return -EINVAL; 861 mutex_unlock(&dev->lock);
872 862 return ret_val;
873 return 1;
874} 863}