Skip to content

Commit

Permalink
V4L/DVB: lgs8gxx: Use shifts rather than multiply/divide when possible
Browse files Browse the repository at this point in the history
If val is a u64, then following:

	val *= (u64)1 << 32;
	val /= (u64)1 << 32;

should surely be better represented as:

	val <<= 32;
	val >>= 32;

Especially as, for the division, the compiler might want to actually do a
division:

drivers/built-in.o: In function `lgs8gxx_get_afc_phase':
drivers/media/dvb/frontends/lgs8gxx.c:250: undefined reference to `__udivdi3'

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
David Howells authored and Mauro Carvalho Chehab committed Dec 16, 2009
1 parent 5bf5834 commit 3ab1b9c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/media/dvb/frontends/lgs8gxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ static int lgs8gxx_set_if_freq(struct lgs8gxx_state *priv, u32 freq /*in kHz*/)

val = freq;
if (freq != 0) {
val *= (u64)1 << 32;
val <<= 32;
if (if_clk != 0)
do_div(val, if_clk);
v32 = val & 0xFFFFFFFF;
Expand Down Expand Up @@ -246,7 +246,7 @@ static int lgs8gxx_get_afc_phase(struct lgs8gxx_state *priv)

val = v32;
val *= priv->config->if_clk_freq;
val /= (u64)1 << 32;
val >>= 32;
dprintk("AFC = %u kHz\n", (u32)val);
return 0;
}
Expand Down

0 comments on commit 3ab1b9c

Please sign in to comment.