Re: [PATCH] 2.5.10 IDE 42

Martin Dalecki
2002-04-26T23:28:23Z

>>Somewhat agreed. Also, the above is just not the right way to do
>>printouts.
>>
>>I'd suggest rewriting the whole big mess as something like
>>
>> #define STAT_STR(x,s) \
>> ((stat & x ##_STAT) ? s " " : "")
>>
>> ...
>>
>> printf("IDE: %s%s%s%s%s%s..\n"
>> STAT_STR(READY, "DriveReady"),
>> STAT_STR(WERR, "DeviceFault"),
>> ...
>
>
> I'd go even further and suggest that pulling the mapping from a mask or
> key to string out into a table and looping through it is preferable for
> this sort of thing. You win later if you decide you need the same mapping
> elsewhere or if you want to format your messages differently, add bits to
> it, etc. Tables are generally easier to inspect for errors than code,
> although Linus' version is very nearly a table.
>
> Maintaining tables as code is a pain and is generally only a win for
> small or sparse state machines.

Once could have a look at the ll_rw_blk.c file. There is
a function there, which is dissecting the differnt request
attributes, which are stored as bitfields there.