LinuxTV Patchwork usb: dvb: check status of mxl111sf_read_reg

login
register
mail settings
Submitter Kangjie Lu
Date Dec. 26, 2018, 5:58 a.m.
Message ID <20181226055809.74979-1-kjlu@umn.edu>
Download mbox | patch
Permalink /patch/53649/
State New
Delegated to: Sean Young
Headers show

Comments

Kangjie Lu - Dec. 26, 2018, 5:58 a.m.
When mxl111sf_read_reg fails, we shouldn't use "mode". The fix checks
its return value using mxl_fail

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Michael Krufky - Dec. 27, 2018, 3:47 a.m.
Kangjie,

On Wed, Dec 26, 2018 at 12:59 AM Kangjie Lu <kjlu@umn.edu> wrote:
>
> When mxl111sf_read_reg fails, we shouldn't use "mode". The fix checks
> its return value using mxl_fail
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
>  drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c
> index ffb6e7c72f57..aecc3d02fc1e 100644
> --- a/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c
> +++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c
> @@ -130,7 +130,8 @@ int mxl111sf_config_mpeg_in(struct mxl111sf_state *state,
>         mxl_fail(ret);
>
>         /* Configure MPEG Clock phase */
> -       mxl111sf_read_reg(state, V6_MPEG_IN_CLK_INV_REG, &mode);
> +       ret = mxl111sf_read_reg(state, V6_MPEG_IN_CLK_INV_REG, &mode);
> +       mxl_fail(ret);
>
>         if (clock_phase == TSIF_NORMAL)
>                 mode &= ~V6_INVERTED_CLK_PHASE;
> --
> 2.17.2 (Apple Git-113)

It *looks* correct, however....

If I recall correctly, this chip will often fail when reading
registers.   Notice, `mode` is initialized to zero at first, and not
again touched before being passed to the readreg function - this is on
purpose.   The value remains untouched if the read fails. ....and the
read _wil_ fail.  Maybe not always, but sometimes.

When you run with the patch applied, does it just spew errors?

-Mike

Patch

diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c b/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c
index ffb6e7c72f57..aecc3d02fc1e 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf-phy.c
@@ -130,7 +130,8 @@  int mxl111sf_config_mpeg_in(struct mxl111sf_state *state,
 	mxl_fail(ret);
 
 	/* Configure MPEG Clock phase */
-	mxl111sf_read_reg(state, V6_MPEG_IN_CLK_INV_REG, &mode);
+	ret = mxl111sf_read_reg(state, V6_MPEG_IN_CLK_INV_REG, &mode);
+	mxl_fail(ret);
 
 	if (clock_phase == TSIF_NORMAL)
 		mode &= ~V6_INVERTED_CLK_PHASE;

Privacy Policy