summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothée Ravier <siosm99@gmail.com>2013-09-02 05:46:08 +0200
committerMartin Pitt <martinpitt@gnome.org>2013-09-02 05:46:08 +0200
commit12f6f4014502d41d343dcfaf39a65a3ae504ce04 (patch)
tree0c010dd9d5e22d62f0bd7f4759e3ede6dc5b4884
parent7933b0e55234fca86809dad1dee53f0d8e2b96ec (diff)
linux: Only one warning if no valid voltage found
Avoid filling the logs with repeated warning saying that no correct voltage value was found for a power device. Improves the situation with bugs https://bugzilla.redhat.com/show_bug.cgi?id=847874 and https://bugzilla.redhat.com/show_bug.cgi?id=863524 Signed-off-by: Timothée Ravier <tim@siosm.fr> Signed-off-by: Martin Pitt <martinpitt@gnome.org>
-rw-r--r--src/linux/up-device-supply.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c
index a93d16a..98536f4 100644
--- a/src/linux/up-device-supply.c
+++ b/src/linux/up-device-supply.c
@@ -60,6 +60,7 @@ struct UpDeviceSupplyPrivate
guint unknown_retries;
gboolean enable_poll;
gboolean is_power_supply;
+ gboolean shown_invalid_voltage_warning;
};
G_DEFINE_TYPE (UpDeviceSupply, up_device_supply, UP_TYPE_DEVICE)
@@ -372,7 +373,7 @@ out:
* up_device_supply_get_design_voltage:
**/
static gdouble
-up_device_supply_get_design_voltage (const gchar *native_path)
+up_device_supply_get_design_voltage (UpDeviceSupply *device, const gchar *native_path)
{
gdouble voltage;
gchar *device_type = NULL;
@@ -413,8 +414,14 @@ up_device_supply_get_design_voltage (const gchar *native_path)
goto out;
}
+ /* no valid value found; display a warning the first time for each
+ * device */
+ if (!device->priv->shown_invalid_voltage_warning) {
+ device->priv->shown_invalid_voltage_warning = TRUE;
+ g_warning ("no valid voltage value found for device %s, assuming 10V", native_path);
+ }
/* completely guess, to avoid getting zero values */
- g_warning ("no voltage values for device %s, using 10V as approximation", native_path);
+ g_debug ("no voltage values for device %s, using 10V as approximation", native_path);
voltage = 10.0f;
out:
g_free (device_type);
@@ -527,7 +534,7 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
energy = sysfs_get_double (native_path, "energy_avg") / 1000000.0;
/* used to convert A to W later */
- voltage_design = up_device_supply_get_design_voltage (native_path);
+ voltage_design = up_device_supply_get_design_voltage (supply, native_path);
/* initial values */
if (!supply->priv->has_coldplug_values ||
@@ -1018,6 +1025,8 @@ up_device_supply_init (UpDeviceSupply *supply)
supply->priv->energy_old = g_new (gdouble, UP_DEVICE_SUPPLY_ENERGY_OLD_LENGTH);
supply->priv->energy_old_timespec = g_new (GTimeVal, UP_DEVICE_SUPPLY_ENERGY_OLD_LENGTH);
supply->priv->energy_old_first = 0;
+
+ supply->priv->shown_invalid_voltage_warning = FALSE;
}
/**