[U-Boot] [PATCH] Davinci I2C code cleanup

ksi at koi8.net ksi at koi8.net
Mon Feb 23 00:11:33 CET 2009


On Sun, 22 Feb 2009, Wolfgang Denk wrote:

> Dear ksi at koi8.net,
> 
> In message <Pine.LNX.4.64ksi.0902221346290.5031 at home-gw.koi8.net> you wrote:
> >
> > > I suggest that "tmp" gets passed as argument to the macro.
> > 
> > It is _NOT_ a macro working on some variable. It is simply repeating
> 
> Oh yes, of course it is. It references the variable "tmp", and this is
> nasty as it is not clear to the reader of the code.
> 
> If I think it would be better to rename "tmp" into "foo" the code will
> magically break.

It won't magically break, it will fail to compile. It is totally different
case.

This macro does not come from some header file, it is in the same relatively
small source file so it is easy to trace if compilation broke. Also it is
not used anywhere else so there is no risk it could break anything else. And
there is absolutely no reason to rename tmp to foo.

> > _LITERAL_ text that not only accesses a local variable tmp but even
> > performs a function return with an error if condition is not met. That is,
> 
> You are right. That's even worse.

Yep. That's if we are to follow those dogmas to the letter, blindly. But we
don't have to.

> > why, BTW, it should not be made into an inline function because it would
> > require additional checking of its return code where it is used (lot of
> > places in Davinci I2C driver) that, in turn, would've added a lot of
> > unnecessary overhead for local variable, register loads, second conditional
> > checking etc.
> 
> I am sure you could come up with an efficient *and* clean solution - if
> you really wanted to try.

There is no way you can avoid that very same code repeated several times (7
or so? didn't count them) -- that is how the driver works.

> > It is _NOT_ supposed to be any function-like macro. It is just a fragment of
> > _LITERAL_ text.
> 
> The code as is is not acceptable and needs to be cleaned up.

Why not? What is wrong with that code?

---
******************************************************************
*  KSI at home    KOI8 Net  < >  The impossible we do immediately.  *
*  Las Vegas   NV, USA   < >  Miracles require 24-hour notice.   *
******************************************************************


More information about the U-Boot mailing list