[E3-hacking] [PATCH v2] LEDS: Add output invertion option to backlight trigger

Ralph Corderoy ralph at inputplus.co.uk
Mon Oct 4 10:30:26 BST 2010


Hi Janusz,

>     struct led_classdev *led = n->led;
>     struct fb_event *fb_event = data;
>     int *blank = fb_event->data;
>     int new_status = *blank ? BLANK : UNBLANK;
>   
>     switch (event) {
>     case FB_EVENT_BLANK :
>         if (new_status == n->old_status)
>             break;
>   
>         if ((n->old_status == UNBLANK) ^ n->invert) {
>             n->brightness = led->brightness;
>             led_set_brightness(led, LED_OFF);
>         } else {
>             led_set_brightness(led, n->brightness);
>         }
>   
>         n->old_status = new_status;
>   
>         break;
>     }
>   
>     return 0;

This is a general question rather than a comment on the patch.  My gcc
for x86 with -O3 produces code that sets up led, blank, and new_status
before testing if event == FB_EVENT_BLANK.  Clearly, none of that work
is needed if the condition is false.

Is it assumed in kernel coding that the compiler is clever enough not to
do this, or that the extra work doesn't matter?

Cheers,
Ralph.




More information about the e3-hacking mailing list