mirror of
https://gitlab.freedesktop.org/upower/power-profiles-daemon.git
synced 2026-05-09 04:48:08 +02:00
main: Namespace ProbeResult
And add PpdProbeResult to the API documentation.
This commit is contained in:
parent
07dbe8e8da
commit
86d087fb30
7 changed files with 45 additions and 33 deletions
|
|
@ -12,6 +12,7 @@ PPD_TYPE_ACTION
|
|||
<TITLE>Profile Drivers</TITLE>
|
||||
PpdDriverClass
|
||||
PpdDriver
|
||||
PpdProbeResult
|
||||
<SUBSECTION Private>
|
||||
PPD_TYPE_DRIVER
|
||||
</SECTION>
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ start_profile_drivers (PpdApp *data)
|
|||
if (PPD_IS_DRIVER (object)) {
|
||||
PpdDriver *driver = PPD_DRIVER (object);
|
||||
PpdProfile profiles;
|
||||
ProbeResult result;
|
||||
PpdProbeResult result;
|
||||
|
||||
g_debug ("Handling driver '%s'", ppd_driver_get_driver_name (driver));
|
||||
|
||||
|
|
@ -511,12 +511,12 @@ start_profile_drivers (PpdApp *data)
|
|||
}
|
||||
|
||||
result = ppd_driver_probe (driver);
|
||||
if (result == PROBE_RESULT_FAIL) {
|
||||
if (result == PPD_PROBE_RESULT_FAIL) {
|
||||
g_debug ("probe() failed for driver %s, skipping",
|
||||
ppd_driver_get_driver_name (driver));
|
||||
g_object_unref (object);
|
||||
continue;
|
||||
} else if (result == PROBE_RESULT_DEFER) {
|
||||
} else if (result == PPD_PROBE_RESULT_DEFER) {
|
||||
g_signal_connect (G_OBJECT (driver), "probe-request",
|
||||
G_CALLBACK (driver_probe_request_cb), data);
|
||||
g_ptr_array_add (data->probed_drivers, driver);
|
||||
|
|
|
|||
|
|
@ -141,20 +141,20 @@ envvar_set (const char *key)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static ProbeResult
|
||||
static PpdProbeResult
|
||||
ppd_driver_fake_probe (PpdDriver *driver)
|
||||
{
|
||||
PpdDriverFake *fake;
|
||||
|
||||
if (!envvar_set ("POWER_PROFILE_DAEMON_FAKE_DRIVER"))
|
||||
return PROBE_RESULT_FAIL;
|
||||
return PPD_PROBE_RESULT_FAIL;
|
||||
|
||||
fake = PPD_DRIVER_FAKE (driver);
|
||||
if (!setup_keyboard (fake))
|
||||
return PROBE_RESULT_FAIL;
|
||||
return PPD_PROBE_RESULT_FAIL;
|
||||
keyboard_usage ();
|
||||
|
||||
return PROBE_RESULT_SUCCESS;
|
||||
return PPD_PROBE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ ppd_driver_intel_pstate_probe (PpdDriver *driver)
|
|||
g_autoptr(GDir) dir = NULL;
|
||||
g_autofree char *policy_dir = NULL;
|
||||
const char *dirname;
|
||||
ProbeResult ret = PROBE_RESULT_FAIL;
|
||||
PpdProbeResult ret = PPD_PROBE_RESULT_FAIL;
|
||||
|
||||
dir = open_policy_dir ();
|
||||
if (!dir)
|
||||
|
|
@ -153,10 +153,10 @@ ppd_driver_intel_pstate_probe (PpdDriver *driver)
|
|||
continue;
|
||||
|
||||
pstate->devices = g_list_prepend (pstate->devices, g_steal_pointer (&path));
|
||||
ret = PROBE_RESULT_SUCCESS;
|
||||
ret = PPD_PROBE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
if (ret != PROBE_RESULT_SUCCESS)
|
||||
if (ret != PPD_PROBE_RESULT_SUCCESS)
|
||||
goto out;
|
||||
|
||||
pstate->client = up_client_new ();
|
||||
|
|
@ -177,7 +177,7 @@ ppd_driver_intel_pstate_probe (PpdDriver *driver)
|
|||
|
||||
out:
|
||||
g_debug ("%s p-state settings",
|
||||
ret == PROBE_RESULT_SUCCESS ? "Found" : "Didn't find");
|
||||
ret == PPD_PROBE_RESULT_SUCCESS ? "Found" : "Didn't find");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ struct _PpdDriverPlatformProfile
|
|||
{
|
||||
PpdDriver parent_instance;
|
||||
|
||||
ProbeResult probe_result;
|
||||
PpdProbeResult probe_result;
|
||||
GUdevDevice *device;
|
||||
gboolean lapmode;
|
||||
PpdProfile acpi_platform_profile;
|
||||
|
|
@ -87,7 +87,7 @@ acpi_platform_profile_value_to_profile (const char *str)
|
|||
return PPD_PROFILE_UNSET;
|
||||
}
|
||||
|
||||
static ProbeResult
|
||||
static PpdProbeResult
|
||||
verify_acpi_platform_profile_choices (void)
|
||||
{
|
||||
g_autofree char *choices_str = NULL;
|
||||
|
|
@ -98,15 +98,15 @@ verify_acpi_platform_profile_choices (void)
|
|||
platform_profile_choices_path = ppd_utils_get_sysfs_path (ACPI_PLATFORM_PROFILE_CHOICES_PATH);
|
||||
if (!g_file_get_contents (platform_profile_choices_path,
|
||||
&choices_str, NULL, NULL)) {
|
||||
return PROBE_RESULT_FAIL;
|
||||
return PPD_PROBE_RESULT_FAIL;
|
||||
}
|
||||
|
||||
choices = g_strsplit (choices_str, "\n", -1);
|
||||
if (g_strv_contains ((const char * const*) choices, "low-power") &&
|
||||
g_strv_contains ((const char * const*) choices, "balanced") &&
|
||||
g_strv_contains ((const char * const*) choices, "performance"))
|
||||
return PROBE_RESULT_SUCCESS;
|
||||
return PROBE_RESULT_DEFER;
|
||||
return PPD_PROBE_RESULT_SUCCESS;
|
||||
return PPD_PROBE_RESULT_DEFER;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -177,7 +177,7 @@ acpi_platform_profile_changed (GFileMonitor *monitor,
|
|||
{
|
||||
PpdDriverPlatformProfile *self = user_data;
|
||||
g_debug (ACPI_PLATFORM_PROFILE_PATH " changed");
|
||||
if (self->probe_result == PROBE_RESULT_DEFER) {
|
||||
if (self->probe_result == PPD_PROBE_RESULT_DEFER) {
|
||||
g_signal_emit_by_name (G_OBJECT (self), "probe-request", 0);
|
||||
return;
|
||||
}
|
||||
|
|
@ -234,23 +234,23 @@ find_dytc (GUdevDevice *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static ProbeResult
|
||||
static PpdProbeResult
|
||||
ppd_driver_platform_profile_probe (PpdDriver *driver)
|
||||
{
|
||||
PpdDriverPlatformProfile *self = PPD_DRIVER_PLATFORM_PROFILE (driver);
|
||||
g_autoptr(GFile) acpi_platform_profile = NULL;
|
||||
g_autofree char *platform_profile_path = NULL;
|
||||
|
||||
g_return_val_if_fail (self->probe_result == PROBE_RESULT_UNSET, PROBE_RESULT_FAIL);
|
||||
g_return_val_if_fail (self->probe_result == PPD_PROBE_RESULT_UNSET, PPD_PROBE_RESULT_FAIL);
|
||||
|
||||
/* Profile interface */
|
||||
platform_profile_path = ppd_utils_get_sysfs_path (ACPI_PLATFORM_PROFILE_PATH);
|
||||
if (!g_file_test (platform_profile_path, G_FILE_TEST_EXISTS)) {
|
||||
g_debug ("No platform_profile sysfs file");
|
||||
return PROBE_RESULT_FAIL;
|
||||
return PPD_PROBE_RESULT_FAIL;
|
||||
}
|
||||
self->probe_result = verify_acpi_platform_profile_choices ();
|
||||
if (self->probe_result == PROBE_RESULT_FAIL) {
|
||||
if (self->probe_result == PPD_PROBE_RESULT_FAIL) {
|
||||
g_debug ("No supported platform_profile choices");
|
||||
return self->probe_result;
|
||||
}
|
||||
|
|
@ -263,7 +263,7 @@ ppd_driver_platform_profile_probe (PpdDriver *driver)
|
|||
self->acpi_platform_profile_changed_id =
|
||||
g_signal_connect (G_OBJECT (self->acpi_platform_profile_mon), "changed",
|
||||
G_CALLBACK (acpi_platform_profile_changed), self);
|
||||
if (self->probe_result == PROBE_RESULT_DEFER) {
|
||||
if (self->probe_result == PPD_PROBE_RESULT_DEFER) {
|
||||
g_debug ("Monitoring platform_profile sysfs file");
|
||||
return self->probe_result;
|
||||
}
|
||||
|
|
@ -287,7 +287,7 @@ out:
|
|||
|
||||
g_debug ("%s a dytc_lapmode sysfs attribute to thinkpad_acpi",
|
||||
self->device ? "Found" : "Didn't find");
|
||||
return PROBE_RESULT_SUCCESS;
|
||||
return PPD_PROBE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -320,5 +320,5 @@ ppd_driver_platform_profile_class_init (PpdDriverPlatformProfileClass *klass)
|
|||
static void
|
||||
ppd_driver_platform_profile_init (PpdDriverPlatformProfile *self)
|
||||
{
|
||||
self->probe_result = PROBE_RESULT_UNSET;
|
||||
self->probe_result = PPD_PROBE_RESULT_UNSET;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,13 +215,13 @@ ppd_driver_init (PpdDriver *self)
|
|||
{
|
||||
}
|
||||
|
||||
ProbeResult
|
||||
PpdProbeResult
|
||||
ppd_driver_probe (PpdDriver *driver)
|
||||
{
|
||||
g_return_val_if_fail (PPD_IS_DRIVER (driver), FALSE);
|
||||
|
||||
if (!PPD_DRIVER_GET_CLASS (driver)->probe)
|
||||
return PROBE_RESULT_SUCCESS;
|
||||
return PPD_PROBE_RESULT_SUCCESS;
|
||||
|
||||
return PPD_DRIVER_GET_CLASS (driver)->probe (driver);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,23 @@
|
|||
#define PPD_TYPE_DRIVER (ppd_driver_get_type())
|
||||
G_DECLARE_DERIVABLE_TYPE(PpdDriver, ppd_driver, PPD, DRIVER, GObject)
|
||||
|
||||
/**
|
||||
* PpdProbeResult:
|
||||
* @PPD_PROBE_RESULT_UNSET: unset
|
||||
* @PPD_PROBE_RESULT_DEFER: driver should be kept alive, as kernel
|
||||
* support might appear.
|
||||
* @PPD_PROBE_RESULT_FAIL: driver failed to load.
|
||||
* @PPD_PROBE_RESULT_SUCCESS: driver successfully loaded.
|
||||
*
|
||||
* Those are the three possible values returned by a driver probe,
|
||||
* along with an unset value for convenience.
|
||||
*/
|
||||
typedef enum {
|
||||
PROBE_RESULT_UNSET = -2,
|
||||
PROBE_RESULT_DEFER = -1,
|
||||
PROBE_RESULT_FAIL = 0,
|
||||
PROBE_RESULT_SUCCESS = 1
|
||||
} ProbeResult;
|
||||
PPD_PROBE_RESULT_UNSET = -2,
|
||||
PPD_PROBE_RESULT_DEFER = -1,
|
||||
PPD_PROBE_RESULT_FAIL = 0,
|
||||
PPD_PROBE_RESULT_SUCCESS = 1
|
||||
} PpdProbeResult;
|
||||
|
||||
/**
|
||||
* PpdDriverClass:
|
||||
|
|
@ -35,14 +46,14 @@ struct _PpdDriverClass
|
|||
{
|
||||
GObjectClass parent_class;
|
||||
|
||||
ProbeResult (* probe) (PpdDriver *driver);
|
||||
PpdProbeResult (* probe) (PpdDriver *driver);
|
||||
gboolean (* activate_profile) (PpdDriver *driver,
|
||||
PpdProfile profile,
|
||||
GError **error);
|
||||
};
|
||||
|
||||
#ifndef __GTK_DOC_IGNORE__
|
||||
ProbeResult ppd_driver_probe (PpdDriver *driver);
|
||||
PpdProbeResult ppd_driver_probe (PpdDriver *driver);
|
||||
gboolean ppd_driver_activate_profile (PpdDriver *driver, PpdProfile profile, GError **error);
|
||||
const char *ppd_driver_get_driver_name (PpdDriver *driver);
|
||||
PpdProfile ppd_driver_get_profiles (PpdDriver *driver);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue