mirror of
https://github.com/libretro/RetroArch
synced 2025-04-07 13:23:32 +00:00
(platform_linux.c) Cleanups
This commit is contained in:
parent
106ab9b42b
commit
52f9084665
@ -989,20 +989,18 @@ static bool frontend_linux_powerstate_check_acpi(
|
|||||||
enum frontend_powerstate *state,
|
enum frontend_powerstate *state,
|
||||||
int *seconds, int *percent)
|
int *seconds, int *percent)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
|
||||||
struct RDIR *entry = NULL;
|
|
||||||
bool have_battery = false;
|
bool have_battery = false;
|
||||||
bool have_ac = false;
|
bool have_ac = false;
|
||||||
bool charging = false;
|
bool charging = false;
|
||||||
|
struct RDIR *entry = retro_opendir(proc_acpi_battery_path);
|
||||||
*state = FRONTEND_POWERSTATE_NONE;
|
|
||||||
|
|
||||||
entry = retro_opendir(proc_acpi_battery_path);
|
|
||||||
if (!entry)
|
if (!entry)
|
||||||
goto end;
|
return false;
|
||||||
|
|
||||||
if (retro_dirent_error(entry))
|
if (retro_dirent_error(entry))
|
||||||
goto end;
|
{
|
||||||
|
retro_closedir(entry);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
while (retro_readdir(entry))
|
while (retro_readdir(entry))
|
||||||
check_proc_acpi_battery(retro_dirent_get_name(entry),
|
check_proc_acpi_battery(retro_dirent_get_name(entry),
|
||||||
@ -1012,12 +1010,14 @@ static bool frontend_linux_powerstate_check_acpi(
|
|||||||
|
|
||||||
entry = retro_opendir(proc_acpi_ac_adapter_path);
|
entry = retro_opendir(proc_acpi_ac_adapter_path);
|
||||||
if (!entry)
|
if (!entry)
|
||||||
goto end;
|
return false;
|
||||||
|
|
||||||
while (retro_readdir(entry))
|
while (retro_readdir(entry))
|
||||||
check_proc_acpi_ac_adapter(
|
check_proc_acpi_ac_adapter(
|
||||||
retro_dirent_get_name(entry), &have_ac);
|
retro_dirent_get_name(entry), &have_ac);
|
||||||
|
|
||||||
|
retro_closedir(entry);
|
||||||
|
|
||||||
if (!have_battery)
|
if (!have_battery)
|
||||||
*state = FRONTEND_POWERSTATE_NO_SOURCE;
|
*state = FRONTEND_POWERSTATE_NO_SOURCE;
|
||||||
else if (charging)
|
else if (charging)
|
||||||
@ -1027,20 +1027,13 @@ static bool frontend_linux_powerstate_check_acpi(
|
|||||||
else
|
else
|
||||||
*state = FRONTEND_POWERSTATE_ON_POWER_SOURCE;
|
*state = FRONTEND_POWERSTATE_ON_POWER_SOURCE;
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
end:
|
|
||||||
if (entry)
|
|
||||||
retro_closedir(entry);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool frontend_linux_powerstate_check_acpi_sysfs(
|
static bool frontend_linux_powerstate_check_acpi_sysfs(
|
||||||
enum frontend_powerstate *state,
|
enum frontend_powerstate *state,
|
||||||
int *seconds, int *percent)
|
int *seconds, int *percent)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
|
||||||
bool have_battery = false;
|
bool have_battery = false;
|
||||||
bool have_ac = false;
|
bool have_ac = false;
|
||||||
bool charging = false;
|
bool charging = false;
|
||||||
@ -1118,6 +1111,8 @@ static enum frontend_powerstate frontend_linux_get_powerstate(
|
|||||||
if (frontend_linux_powerstate_check_acpi_sysfs(&ret, seconds, percent))
|
if (frontend_linux_powerstate_check_acpi_sysfs(&ret, seconds, percent))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
ret = FRONTEND_POWERSTATE_NONE;
|
||||||
|
|
||||||
if (frontend_linux_powerstate_check_acpi(&ret, seconds, percent))
|
if (frontend_linux_powerstate_check_acpi(&ret, seconds, percent))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user