lkml.org 
[lkml]   [2009]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: Input: add MAX7359 key switch controller driver
On Sat, May 9, 2009 at 12:36 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> Hi Kim,
>
> On Friday 08 May 2009 18:58:45 Kim Kyuwon wrote:
>> By the way, can I ask the same question which I ask to Trilok.
>> Even though I guard suspend/resume with #ifdef CONFIG_PM in the new
>> patch, Could I know the good reason for this protection? Because
>> '/Documentation/SubmittingPatches' says "ifdefs are ugly"
>
> If kernel is compiled without CONFIG_PM then these functions would
> be just dead weight. Generally speaking, #ifdefs are considered ugly
> if they are in the middle of function code, affecting logic. But to
> to compile out unneeded functionality they are OK. That's why you
> often see in the kernel
>
> #ifdef CONFIG_BAZ
> void do_baz()
> {
> .. real code ..
> }
> #else
> void do_baz()
> {
> }
> #endif
>
> and then...
>
> int foo()
> {
> bar1();
> bar2();
> do_baz();
> bar3();
> }
>
>
> As you can see, foo()'s logic stays the same, there are no #ifdefs
> cluttering it, but baz code either executed or not.
>
> Hope this helps.

Thank you for your kind explanation. It is very helpful to me and my colleagues.

Kyuwon


\
 
 \ /
  Last update: 2009-05-09 05:59    [W:0.047 / U:0.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site