All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: stv090x: fix if-else order
@ 2018-06-01 16:12 Ivan Bornyakov
  2018-07-26 19:26 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 3+ messages in thread
From: Ivan Bornyakov @ 2018-06-01 16:12 UTC (permalink / raw)
  To: mchehab; +Cc: linux-media, linux-kernel, Ivan Bornyakov

There is this code:

	if (v >= 0x20) {
		...
	} else if (v < 0x20) {
		...
	} else if (v > 0x30) {
		/* this branch is impossible */
	}

It would be sensibly for last branch to be on the top.

Signed-off-by: Ivan Bornyakov <brnkv.i1@gmail.com>
---
 drivers/media/dvb-frontends/stv090x.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb-frontends/stv090x.c b/drivers/media/dvb-frontends/stv090x.c
index 9133f65d4623..d70eb311ebaf 100644
--- a/drivers/media/dvb-frontends/stv090x.c
+++ b/drivers/media/dvb-frontends/stv090x.c
@@ -4841,7 +4841,11 @@ static int stv090x_setup(struct dvb_frontend *fe)
 	}
 
 	state->internal->dev_ver = stv090x_read_reg(state, STV090x_MID);
-	if (state->internal->dev_ver >= 0x20) {
+	if (state->internal->dev_ver > 0x30) {
+		/* we shouldn't bail out from here */
+		dprintk(FE_ERROR, 1, "INFO: Cut: 0x%02x probably incomplete support!",
+			state->internal->dev_ver);
+	} else if (state->internal->dev_ver >= 0x20) {
 		if (stv090x_write_reg(state, STV090x_TSGENERAL, 0x0c) < 0)
 			goto err;
 
@@ -4857,10 +4861,6 @@ static int stv090x_setup(struct dvb_frontend *fe)
 			state->internal->dev_ver);
 
 		goto err;
-	} else if (state->internal->dev_ver > 0x30) {
-		/* we shouldn't bail out from here */
-		dprintk(FE_ERROR, 1, "INFO: Cut: 0x%02x probably incomplete support!",
-			state->internal->dev_ver);
 	}
 
 	/* ADC1 range */
-- 
2.16.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: stv090x: fix if-else order
  2018-06-01 16:12 [PATCH] media: stv090x: fix if-else order Ivan Bornyakov
@ 2018-07-26 19:26 ` Mauro Carvalho Chehab
  2018-07-27 11:10   ` Ivan Bornyakov
  0 siblings, 1 reply; 3+ messages in thread
From: Mauro Carvalho Chehab @ 2018-07-26 19:26 UTC (permalink / raw)
  To: Ivan Bornyakov; +Cc: mchehab, linux-media, linux-kernel

Em Fri,  1 Jun 2018 19:12:21 +0300
Ivan Bornyakov <brnkv.i1@gmail.com> escreveu:

> There is this code:
> 
> 	if (v >= 0x20) {
> 		...
> 	} else if (v < 0x20) {
> 		...
> 	} else if (v > 0x30) {
> 		/* this branch is impossible */
> 	}
> 
> It would be sensibly for last branch to be on the top.

Have you tested it and check at the datasheets if dev_ver > 0x30 makes
sense?

If not, I would prefer, instead, to remove the dead code, as this
patch may cause regressions (adding a FIXME comment about this
special case).

> 
> Signed-off-by: Ivan Bornyakov <brnkv.i1@gmail.com>
> ---
>  drivers/media/dvb-frontends/stv090x.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/dvb-frontends/stv090x.c b/drivers/media/dvb-frontends/stv090x.c
> index 9133f65d4623..d70eb311ebaf 100644
> --- a/drivers/media/dvb-frontends/stv090x.c
> +++ b/drivers/media/dvb-frontends/stv090x.c
> @@ -4841,7 +4841,11 @@ static int stv090x_setup(struct dvb_frontend *fe)
>  	}
>  
>  	state->internal->dev_ver = stv090x_read_reg(state, STV090x_MID);
> -	if (state->internal->dev_ver >= 0x20) {
> +	if (state->internal->dev_ver > 0x30) {
> +		/* we shouldn't bail out from here */
> +		dprintk(FE_ERROR, 1, "INFO: Cut: 0x%02x probably incomplete support!",
> +			state->internal->dev_ver);
> +	} else if (state->internal->dev_ver >= 0x20) {
>  		if (stv090x_write_reg(state, STV090x_TSGENERAL, 0x0c) < 0)
>  			goto err;
>  
> @@ -4857,10 +4861,6 @@ static int stv090x_setup(struct dvb_frontend *fe)
>  			state->internal->dev_ver);
>  
>  		goto err;
> -	} else if (state->internal->dev_ver > 0x30) {
> -		/* we shouldn't bail out from here */
> -		dprintk(FE_ERROR, 1, "INFO: Cut: 0x%02x probably incomplete support!",
> -			state->internal->dev_ver);
>  	}
>  
>  	/* ADC1 range */



Thanks,
Mauro

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: stv090x: fix if-else order
  2018-07-26 19:26 ` Mauro Carvalho Chehab
@ 2018-07-27 11:10   ` Ivan Bornyakov
  0 siblings, 0 replies; 3+ messages in thread
From: Ivan Bornyakov @ 2018-07-27 11:10 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: mchehab, linux-media, linux-kernel

On Thu, Jul 26, 2018 at 04:26:07PM -0300, Mauro Carvalho Chehab wrote:
> Em Fri,  1 Jun 2018 19:12:21 +0300
> Ivan Bornyakov <brnkv.i1@gmail.com> escreveu:
> 
> > There is this code:
> > 
> > 	if (v >= 0x20) {
> > 		...
> > 	} else if (v < 0x20) {
> > 		...
> > 	} else if (v > 0x30) {
> > 		/* this branch is impossible */
> > 	}
> > 
> > It would be sensibly for last branch to be on the top.
> 
> Have you tested it and check at the datasheets if dev_ver > 0x30 makes
> sense?
> 
> If not, I would prefer, instead, to remove the dead code, as this
> patch may cause regressions (adding a FIXME comment about this
> special case).
> 

Hi, Mauro!

Actually, I did not test it, because I did not have the hardware.
But, in the other places of the code, the same if cases are used.

Here are a couple examples:

  static int stv090x_dvbs_track_crl(struct stv090x_state *state)
  {
          if (state->internal->dev_ver >= 0x30) {
                  ...
	  } else {
	          ...
	  }

	  ...
  }

  static u32 stv090x_srate_srch_coarse(struct stv090x_state *state)
  {
	...

	if (state->internal->dev_ver >= 0x30) {
                ...
	} else if (state->internal->dev_ver >= 0x20) {
	        ...
	}

	...
  }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-27 11:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-01 16:12 [PATCH] media: stv090x: fix if-else order Ivan Bornyakov
2018-07-26 19:26 ` Mauro Carvalho Chehab
2018-07-27 11:10   ` Ivan Bornyakov

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.