lkml.org 
[lkml]   [2023]   [Feb]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 4/5] platform/x86/intel/ifs: Implement Array BIST test
From
On 2/1/23 11:43, Luck, Tony wrote:
>> Why bother with a bitfield? Just do:
> How much "bother" is a bitfield?
>
>> union ifs_array {
>> u64 data;
>> struct {
>> u32 array_bitmask;
>> u16 array_bank;
>> u16 flags;
>> };
>> };
>>
>> Then you only need to mask 'ctrl_result' out of flags. You don't need
>> any crazy macros.
> "only need" to special case this one field ... but that's extra
> code for humans to read (and humans aren't good at that)
> rather than the computer (compiler) which is really good at
> doing this.

I don't follow.

If you have:

struct foo {
u16 rsvd :15;
u16 ctrl_result :1;
};

versus:

struct bar {
u16 flags;
};

and you do:

if (foo->ctrl_result)
something();

versus:

if (bar->flags & CTRL_RESULT_MASK)
something();

I think both of those are quite readable. I'd argue that humans will be
less _surprised_ by 'bar'. I also like to write portable code even if
it's going to be x86 only. It helps people who are used to reading
portable generic code read and find bugs in x86 only code.

\
 
 \ /
  Last update: 2023-03-27 00:06    [W:0.080 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site