On Tue, Nov 18, 2014 at 05:31:23PM -0500, Lennart Sorensen wrote:
> On Tue, Nov 18, 2014 at 11:05:21PM +0100, Gilles Chanteperdrix wrote:
> > From what I was told by someone who knew  someone who talked to
> > someone, this was actually actually a two step process (I do not
> > know whether this changed).
> > 
> > An team did the work that went into the kernel fork that was
> > delivered to customers, with rapid delivery date as the priority
> > goal.
> > 
> > Then in a second time, a different team started writing the code
> > that went into mainline, I am not even sure it used the code of the
> > first team.
> 
> Well there is also the question of whether it is the network group or
> automotive group doing it (sometimes even for the same chip).
> 
> It does appear that the code is getting reused from the bits I have seen
> getting mainlines, although at least some of it has needed some cleanups.
> 
> > I did that. And I prefer explicit bit numbers, because they match
> > the datasheet, which is the ultimate reference.
> > 
> > With code relying on defines, you have to trust the define names to
> > match what you think they do. And I have learned to never trust
> > identifier names, so I want to check the datasheet anyway, and the
> > defines do not help, because now instead of having just 4 fields to
> > check from the same line of code in the documentation of one
> > register, you have to find the 4 fields definitions in the
> > middle of a whole bunch of definitions in a separate header file,
> > and move back and forth.
> > 
> > So, the bottom line is, while I understand the values of defines to
> > provide the same name to the same bit, when used in several places,
> > as would be the case for software bitfield, I do not see the value
> > of it for register values.
> 
> If you don't remember which bit is which, having names for them helps you
> remember what the code does.  Or at least put a comment saying "Disabling
> idle and enabling wakeup, etc".

Ok for the comment. I trust comments even less than I trust
identifier names, but I understand other would like them when
reading the code.

> 
> Magic numbers with no explanation are terrible when reading the code.

This applies to software bitmap I agree, but having made it a
general rule and apply it indiscriminately is wrong. Register values
are magic values, whether you want it or not, the only way to
understand code writing to registers is using the datasheet.

Adding defines for register bits is just adding a layer of things
which could not do what they appear to do. Incidentally, in TI code
it already happened to me to bang my head against the wall because a
register write did not work as expected, only to find out that the
define in the header was wrong due to a cut and paste error.

-- 
                                            Gilles.

_______________________________________________
Xenomai mailing list
[email protected]
http://www.xenomai.org/mailman/listinfo/xenomai

Reply via email to