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

Mike Isely isely at isely.net
Sat Jan 7 11:31:30 CST 2006


On Sat, 7 Jan 2006, Frans Meulenbroeks wrote:

> Exactly what I wanted to say.
>
> Reason for posting this anyway, is that personally I'm
> in favor for the old bitmasks (I consider them to be
> better readable and it is instantaneously clear which
> bit is involved whereas the shift mechanism requires
> more thinking).
>
> My suggestion would be to keep the old masks...

I don't have a strong preference either way.  In these particular cases 
only one bit is ever set per defined token, and the assignments themselves 
are largely arbitrary.  I've habitually always coded bit masks directly 
unless there was a specific reason to do otherwise in a particular case.

Given that I don't have a strong preference, I was going to commit these 
patches (with parantheses added of course), since at least one person here 
wants them.  Maybe I'll flip a coin :-)

   -Mike


>
> Frans.
>
> --- Mike Isely <isely at isely.net> wrote:
>
>> 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
>>                          |
>>   |
>> _______________________________________________
>> pvrusb2 mailing list
>> pvrusb2 at isely.net
>>
> http://www.isely.net/cgi-bin/mailman/listinfo/pvrusb2
>>
>
>
>
>
> __________________________________________
> Yahoo! DSL – Something to write home about.
> Just $16.99/mo. or less.
> dsl.yahoo.com
>
> _______________________________________________
> pvrusb2 mailing list
> pvrusb2 at isely.net
> http://www.isely.net/cgi-bin/mailman/listinfo/pvrusb2
>

-- 
                         |         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