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

[media] ti-vpe: get rid of some smatch warnings

When compiled on i386, it produces several warnings:

./arch/x86/include/asm/bitops.h:457:22: warning: asm output is not an lvalue
./arch/x86/include/asm/bitops.h:457:22: warning: asm output is not an lvalue
./arch/x86/include/asm/bitops.h:457:22: warning: asm output is not an lvalue
./arch/x86/include/asm/bitops.h:457:22: warning: asm output is not an lvalue
./arch/x86/include/asm/bitops.h:457:22: warning: asm output is not an lvalue
./arch/x86/include/asm/bitops.h:457:22: warning: asm output is not an lvalue

I suspect that some gcc optimization could be causing the asm code to be
incorrectly generated. Splitting it into two macro calls fix the issues
and gets us rid of 6 smatch warnings, with is a good thing. As it should
not cause any troubles, as we're basically doing the same thing, let's
apply such change to vpe.c.

Cc: Benoit Parrot <bparrot@ti.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

+15 -3
+15 -3
drivers/media/platform/ti-vpe/vpe.c
··· 1615 1615 */ 1616 1616 depth_bytes = depth >> 3; 1617 1617 1618 - if (depth_bytes == 3) 1618 + if (depth_bytes == 3) { 1619 1619 /* 1620 1620 * if bpp is 3(as in some RGB formats), the pixel width doesn't 1621 1621 * really help in ensuring line stride is 16 byte aligned 1622 1622 */ 1623 1623 w_align = 4; 1624 - else 1624 + } else { 1625 1625 /* 1626 1626 * for the remainder bpp(4, 2 and 1), the pixel width alignment 1627 1627 * can ensure a line stride alignment of 16 bytes. For example, 1628 1628 * if bpp is 2, then the line stride can be 16 byte aligned if 1629 1629 * the width is 8 byte aligned 1630 1630 */ 1631 - w_align = order_base_2(VPDMA_DESC_ALIGN / depth_bytes); 1631 + 1632 + /* 1633 + * HACK: using order_base_2() here causes lots of asm output 1634 + * errors with smatch, on i386: 1635 + * ./arch/x86/include/asm/bitops.h:457:22: 1636 + * warning: asm output is not an lvalue 1637 + * Perhaps some gcc optimization is doing the wrong thing 1638 + * there. 1639 + * Let's get rid of them by doing the calculus on two steps 1640 + */ 1641 + w_align = roundup_pow_of_two(VPDMA_DESC_ALIGN / depth_bytes); 1642 + w_align = ilog2(w_align); 1643 + } 1632 1644 1633 1645 v4l_bound_align_image(&pix->width, MIN_W, MAX_W, w_align, 1634 1646 &pix->height, MIN_H, MAX_H, H_ALIGN,