[pvrusb2] bitmask cleanup / new patch / newer..

Mike Isely isely at isely.net
Fri Jan 6 19:25:49 CST 2006


On Sat, 7 Jan 2006, Ingo Flaschberger wrote:

> Hey..
>
> Seems to be my good day...
>
> version 3 works now.
>
> But in file driver/pvrusb2-hdw.h I have no idea why I can't replace
> #define PVR2_SUBSYS_ENC_FIRMWARE        0x00000001
> #define PVR2_SUBSYS_ENC_CFG             0x00004000
> #define PVR2_SUBSYS_DIGITIZER_RUN       0x00008000
> #define PVR2_SUBSYS_USBSTREAM_RUN       0x00010000
> #define PVR2_SUBSYS_ENC_RUN             0x00020000
>
> with:
> #define PVR2_SUBSYS_ENC_FIRMWARE        1 << 0
> #define PVR2_SUBSYS_ENC_CFG             1 << 14
> #define PVR2_SUBSYS_DIGITIZER_RUN       1 << 15
> #define PVR2_SUBSYS_USBSTREAM_RUN       1 << 16
> #define PVR2_SUBSYS_ENC_RUN             1 << 17
>
>
> It just does not work. Also ((unsigned long) 1) << 0 casts does not help.
> Strange...

Surround them with parantheses, like this:

#define PVR2_SUBSYS_ENC_FIRMWARE        (1 << 0)

In fact, the debug masks (or anything that expands in a preproc macro) 
should do this too.  You're replacing a constant with an expression (a 
constant expression, but still an expression) thus you expose yourself to 
problems involving associativity and commutativity in expression 
evaluation.

   -Mike


-- 
                         |         Mike Isely          |     PGP fingerprint
      Spammers Die!!     |                             | 03 54 43 4D 75 E5 CC 92
                         |   isely @ pobox (dot) com   | 71 16 01 E2 B5 F5 C1 E8
                         |                             |


More information about the pvrusb2 mailing list