Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] iguanair: simplify calculation of carrier delay cycles

Simplify the logic that calculates the carrier, and removes a warning
on avr32 arch:
drivers/media/rc/iguanair.c: In function 'iguanair_set_tx_carrier':
drivers/media/rc/iguanair.c:304: warning: 'sevens' may be used uninitialized in this function

Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>

authored by

Sean Young and committed by
Mauro Carvalho Chehab
9bd766b7 5f27ca41

+6 -16
+6 -16
drivers/media/rc/iguanair.c
··· 308 308 cycles = DIV_ROUND_CLOSEST(24000000, carrier * 2) - 309 309 ir->cycle_overhead; 310 310 311 - /* make up the the remainer of 4-cycle blocks */ 312 - switch (cycles & 3) { 313 - case 0: 314 - sevens = 0; 315 - break; 316 - case 1: 317 - sevens = 3; 318 - break; 319 - case 2: 320 - sevens = 2; 321 - break; 322 - case 3: 323 - sevens = 1; 324 - break; 325 - } 326 - 311 + /* 312 + * Calculate minimum number of 7 cycles needed so 313 + * we are left with a multiple of 4; so we want to have 314 + * (sevens * 7) & 3 == cycles & 3 315 + */ 316 + sevens = (4 - cycles) & 3; 327 317 fours = (cycles - sevens * 7) / 4; 328 318 329 319 /* magic happens here */