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:
> 7a02f549fc
"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>
This commit is contained in:
Родитель
e36309f54a
Коммит
64561a3883
|
@ -778,9 +778,9 @@ int medusa_set_saturation(struct cx25821_dev *dev, int saturation, int decoder)
|
|||
|
||||
int medusa_video_init(struct cx25821_dev *dev)
|
||||
{
|
||||
u32 value = 0, tmp = 0;
|
||||
int ret_val = 0;
|
||||
int i = 0;
|
||||
u32 value, tmp = 0;
|
||||
int ret_val;
|
||||
int i;
|
||||
|
||||
mutex_lock(&dev->lock);
|
||||
|
||||
|
@ -790,18 +790,15 @@ int medusa_video_init(struct cx25821_dev *dev)
|
|||
value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp);
|
||||
value &= 0xFFFFF0FF;
|
||||
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value);
|
||||
if (ret_val < 0)
|
||||
goto error;
|
||||
|
||||
if (ret_val < 0) {
|
||||
mutex_unlock(&dev->lock);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* Turn off Master source switch enable */
|
||||
value = cx25821_i2c_read(&dev->i2c_bus[0], MON_A_CTRL, &tmp);
|
||||
value &= 0xFFFFFFDF;
|
||||
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], MON_A_CTRL, value);
|
||||
|
||||
if (ret_val < 0)
|
||||
return -EINVAL;
|
||||
goto error;
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
|
||||
|
@ -815,31 +812,25 @@ int medusa_video_init(struct cx25821_dev *dev)
|
|||
value &= 0xFF70FF70;
|
||||
value |= 0x00090008; /* set en_active */
|
||||
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], DENC_AB_CTRL, value);
|
||||
if (ret_val < 0)
|
||||
goto error;
|
||||
|
||||
if (ret_val < 0) {
|
||||
mutex_unlock(&dev->lock);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* enable input is VIP/656 */
|
||||
value = cx25821_i2c_read(&dev->i2c_bus[0], BYP_AB_CTRL, &tmp);
|
||||
value |= 0x00040100; /* enable VIP */
|
||||
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], BYP_AB_CTRL, value);
|
||||
|
||||
if (ret_val < 0) {
|
||||
mutex_unlock(&dev->lock);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (ret_val < 0)
|
||||
goto error;
|
||||
|
||||
/* select AFE clock to output mode */
|
||||
value = cx25821_i2c_read(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, &tmp);
|
||||
value &= 0x83FFFFFF;
|
||||
ret_val =
|
||||
cx25821_i2c_write(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL,
|
||||
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL,
|
||||
value | 0x10000000);
|
||||
if (ret_val < 0)
|
||||
goto error;
|
||||
|
||||
if (ret_val < 0) {
|
||||
mutex_unlock(&dev->lock);
|
||||
return -EINVAL;
|
||||
}
|
||||
/* Turn on all of the data out and control output pins. */
|
||||
value = cx25821_i2c_read(&dev->i2c_bus[0], PIN_OE_CTRL, &tmp);
|
||||
value &= 0xFEF0FE00;
|
||||
|
@ -858,17 +849,15 @@ int medusa_video_init(struct cx25821_dev *dev)
|
|||
|
||||
value |= 7;
|
||||
ret_val = cx25821_i2c_write(&dev->i2c_bus[0], PIN_OE_CTRL, value);
|
||||
if (ret_val < 0) {
|
||||
mutex_unlock(&dev->lock);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (ret_val < 0)
|
||||
goto error;
|
||||
|
||||
mutex_unlock(&dev->lock);
|
||||
|
||||
ret_val = medusa_set_videostandard(dev);
|
||||
return ret_val;
|
||||
|
||||
if (ret_val < 0)
|
||||
return -EINVAL;
|
||||
|
||||
return 1;
|
||||
error:
|
||||
mutex_unlock(&dev->lock);
|
||||
return ret_val;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче