Browse files

Merge remote branch 'debian/master'

  • Loading branch information...
2 parents 79ee4a1 + 4eb9827 commit a7fc045475ab8de9ff9e1441958115ed930114d7 @radekp committed Jan 18, 2011
Showing with 45 additions and 10 deletions.
  1. +15 −0 debian/changelog
  2. +27 −9 hooks/omhacks.c
  3. +3 −1 omhacks/resumereason.h
View
15 debian/changelog
@@ -14,6 +14,21 @@ omhacks (0.12-0~fso1) unstable; urgency=low
-- Timo Jyrinki <timo@debian.org> Mon, 11 Oct 2010 18:33:45 +0300
+omhacks (0.11-2) unstable; urgency=low
+
+ [ Timo Juhani Lindfors ]
+ * Avoid crash in omhacks.so when it is run under a kernel that does not
+ support resume_reason. Closes: #601321
+
+ [ Enrico Zini ]
+ * Also check error code when reading led status. There was no known bug
+ about it, but it was an unchecked error code found during a code review
+ for other unchecked error codes after #601321
+ * Use detected maximum brightness value instead of an arbitrary hardcoded
+ one
+
+ -- Enrico Zini <enrico@debian.org> Mon, 25 Oct 2010 22:53:13 +0200
+
omhacks (0.11-1) unstable; urgency=low
* New upstream release
View
36 hooks/omhacks.c
@@ -21,15 +21,21 @@ static int hook_00_status_led(int argc, const char* argv[])
if (strcmp(argv[1], "suspend") == 0)
{
// Save blue led state and turn it on
- om_led_get(&status_led_saved);
- status_led.brightness = 255;
- om_led_set(&status_led);
+ if (om_led_get(&status_led_saved) < 0)
+ {
+ perror("reading blue led status");
+ status_led.brightness = -1;
+ } else {
+ status_led.brightness = 255;
+ om_led_set(&status_led);
+ }
return 0;
}
else if (strcmp(argv[1], "resume") == 0)
{
// Restore blue led state
- om_led_set(&status_led_saved);
+ if (status_led.brightness != -1)
+ om_led_set(&status_led_saved);
return 0;
}
@@ -43,15 +49,21 @@ static int hook_99_status_led(int argc, const char* argv[])
if (strcmp(argv[1], "suspend") == 0)
{
// Turn off blue state before suspend
- status_led.brightness = 0;
- om_led_set(&status_led);
+ if (status_led.brightness != -1)
+ {
+ status_led.brightness = 0;
+ om_led_set(&status_led);
+ }
return 0;
}
else if (strcmp(argv[1], "resume") == 0)
{
// Turn on blue led after resume
- status_led.brightness = 255;
- om_led_set(&status_led);
+ if (status_led.brightness != -1)
+ {
+ status_led.brightness = 255;
+ om_led_set(&status_led);
+ }
return 0;
}
@@ -75,7 +87,7 @@ static int hook_screen(int argc, const char* argv[])
// Save current backlight brightness and turn it off
screen_brightness_saved = om_screen_brightness_swap(0);
if (screen_brightness_saved < 0)
- screen_brightness_saved = 255;
+ screen_brightness_saved = om_screen_brightness_get_max();
return 0;
}
else if (strcmp(argv[1], "resume") == 0)
@@ -103,13 +115,19 @@ static int hook_cancel_on_usb_disconnect(int argc, const char* argv[])
if (strcmp(argv[1], "resume") == 0)
{
const char** resume_reason = om_resume_reason();
+ if (resume_reason == NULL)
+ {
+ perror("getting resume reason");
+ return 254;
+ }
for ( ; *resume_reason != NULL; ++resume_reason)
if (strcmp(*resume_reason, "EINT09_PMU:usb_disconnect") == 0)
return 250;
return 0;
}
return 254;
}
+
void init()
{
if (om_led_init(&status_led, "gta02-power:blue") == 0
View
4 omhacks/resumereason.h
@@ -22,7 +22,9 @@
*/
/*
- * Return a NULL-terminated string array with the reasons for the last resume.
+ * Return a NULL-terminated string array with the reasons for the last
+ * resume or NULL if there was an error while trying to determine
+ * resume reason.
*
* Note that the strings are in a statically allocated buffer that is rewritten
* at every invocation.

0 comments on commit a7fc045

Please sign in to comment.