- neutrino: avoid some ifdef's; prioritize proc filesystem

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2017-11-13 21:17:36 +01:00
committed by Thilo Graf
parent 98e4d453be
commit 456c12dfb3

View File

@@ -2178,20 +2178,23 @@ void wake_up(bool &wakeup)
close(fd); close(fd);
} }
#endif #endif
#if HAVE_ARM_HARDWARE /* prioritize proc filesystem */
FILE *f = fopen("/proc/stb/fp/was_timer_wakeup", "r"); if (access("/proc/stb/fp/was_timer_wakeup", F_OK) == 0)
if (f)
{ {
unsigned int tmp; FILE *f = fopen("/proc/stb/fp/was_timer_wakeup", "r");
if (fscanf(f, "%u", &tmp) != 1) if (f)
printf("[neutrino] read /proc/stb/fp/was_timer_wakeup failed: %m\n"); {
else unsigned int tmp;
wakeup = (tmp > 0); if (fscanf(f, "%u", &tmp) != 1)
fclose(f); printf("[neutrino] read /proc/stb/fp/was_timer_wakeup failed: %m\n");
else
wakeup = (tmp > 0);
fclose(f);
}
} }
#endif // HAVE_ARM_HARDWARE
/* not platform specific - this is created by the init process */ /* not platform specific - this is created by the init process */
if (access("/tmp/.timer_wakeup", F_OK) == 0) { else if (access("/tmp/.timer_wakeup", F_OK) == 0)
{
wakeup = 1; wakeup = 1;
unlink("/tmp/.timer_wakeup"); unlink("/tmp/.timer_wakeup");
} }
@@ -3949,33 +3952,38 @@ void CNeutrinoApp::ExitRun(int can_shutdown)
#endif #endif
if (timer_minutes || leds) if (timer_minutes || leds)
{ {
#if HAVE_ARM_HARDWARE /* prioritize proc filesystem */
FILE *f = fopen("/proc/stb/fp/wakeup_time","w"); if (access("/proc/stb/fp/was_timer_wakeup", F_OK) == 0)
if (f)
{ {
time_t t = timer_minutes * 60; FILE *f = fopen("/proc/stb/fp/wakeup_time","w");
struct tm *tm = localtime(&t); if (f)
char date[30]; {
strftime(date, sizeof(date), "%c", tm); time_t t = timer_minutes * 60;
fprintf(stderr, "timer_wakeup: %s (%ld)\n", date, timer_minutes * 60); struct tm *tm = localtime(&t);
fprintf(f, "%ld\n", timer_minutes * 60); char date[30];
fclose(f); strftime(date, sizeof(date), "%c", tm);
fprintf(stderr, "timer_wakeup: %s (%ld)\n", date, timer_minutes * 60);
fprintf(f, "%ld\n", timer_minutes * 60);
fclose(f);
}
else
perror("fopen /proc/stb/fp/wakeup_time");
} }
/* not platform specific */
else else
perror("fopen /proc/stb/fp/wakeup_time");
#else
FILE *f = fopen("/tmp/.timer", "w");
if (f)
{ {
fprintf(stderr, "timer_wakeup: %ld\n", timer_minutes * 60); FILE *f = fopen("/tmp/.timer", "w");
fprintf(f, "%ld\n", timer_minutes * 60); if (f)
fprintf(f, "%d\n", leds); {
fprintf(f, "%d\n", bright); fprintf(stderr, "timer_wakeup: %ld\n", timer_minutes * 60);
fclose(f); fprintf(f, "%ld\n", timer_minutes * 60);
fprintf(f, "%d\n", leds);
fprintf(f, "%d\n", bright);
fclose(f);
}
else
perror("fopen /tmp/.timer");
} }
else
perror("fopen /tmp/.timer");
#endif
} }
delete g_RCInput; delete g_RCInput;