summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dkp-csr.c15
-rw-r--r--src/dkp-device.c15
-rw-r--r--src/dkp-hid.c6
-rw-r--r--src/dkp-supply.c13
-rw-r--r--src/dkp-wup.c4
5 files changed, 38 insertions, 15 deletions
diff --git a/src/dkp-csr.c b/src/dkp-csr.c
index e8f7a52..00414e6 100644
--- a/src/dkp-csr.c
+++ b/src/dkp-csr.c
@@ -126,6 +126,8 @@ out:
/**
* dkp_csr_coldplug:
+ *
+ * Return %TRUE on success, %FALSE if we failed to get data and should be removed
**/
static gboolean
dkp_csr_coldplug (DkpDevice *device)
@@ -216,14 +218,16 @@ out:
/**
* dkp_csr_refresh:
+ *
+ * Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
static gboolean
dkp_csr_refresh (DkpDevice *device)
{
- gboolean ret = TRUE;
+ gboolean ret = FALSE;
GTimeVal time;
DkpCsr *csr = DKP_CSR (device);
- usb_dev_handle *handle;
+ usb_dev_handle *handle = NULL;
char buf[80];
unsigned int addr;
gdouble percentage;
@@ -239,14 +243,14 @@ dkp_csr_refresh (DkpDevice *device)
if (csr->priv->device == NULL) {
egg_warning ("no device!");
- return FALSE;
+ goto out;
}
/* open USB device */
handle = usb_open (csr->priv->device);
if (handle == NULL) {
egg_warning ("could not open device");
- return FALSE;
+ goto out;
}
/* get the charge */
@@ -273,7 +277,8 @@ dkp_csr_refresh (DkpDevice *device)
}
out:
- usb_close (handle);
+ if (handle != NULL)
+ usb_close (handle);
return ret;
}
diff --git a/src/dkp-device.c b/src/dkp-device.c
index 9c394d8..ef46c05 100644
--- a/src/dkp-device.c
+++ b/src/dkp-device.c
@@ -476,6 +476,8 @@ out:
/**
* dkp_device_coldplug:
+ *
+ * Return %TRUE on success, %FALSE if we failed to get data and should be removed
**/
gboolean
dkp_device_coldplug (DkpDevice *device, DkpDaemon *daemon, DevkitDevice *d)
@@ -677,6 +679,8 @@ out:
/**
* dkp_device_refresh:
+ *
+ * Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
gboolean
dkp_device_refresh (DkpDevice *device, DBusGMethodInvocation *context)
@@ -697,24 +701,23 @@ dkp_device_refresh (DkpDevice *device, DBusGMethodInvocation *context)
gboolean
dkp_device_changed (DkpDevice *device, DevkitDevice *d, gboolean synthesized)
{
- gboolean changed;
+ gboolean ret;
g_return_val_if_fail (DKP_IS_DEVICE (device), FALSE);
g_object_unref (device->priv->d);
device->priv->d = g_object_ref (d);
- changed = dkp_device_refresh_internal (device);
+ ret = dkp_device_refresh_internal (device);
- /* this 'change' event might prompt us to remove the supply */
- if (!changed)
+ /* we failed to refresh, don't emit changed */
+ if (!ret)
goto out;
/* no, it's good .. keep it */
dkp_device_emit_changed (device);
-
out:
- return changed;
+ return ret;
}
/**
diff --git a/src/dkp-hid.c b/src/dkp-hid.c
index 4e4991b..374bd3f 100644
--- a/src/dkp-hid.c
+++ b/src/dkp-hid.c
@@ -281,6 +281,8 @@ dkp_hid_get_all_data (DkpHid *hid)
/**
* dkp_hid_coldplug:
+ *
+ * Return %TRUE on success, %FALSE if we failed to get data and should be removed
**/
static gboolean
dkp_hid_coldplug (DkpDevice *device)
@@ -351,6 +353,8 @@ out:
/**
* dkp_hid_refresh:
+ *
+ * Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
static gboolean
dkp_hid_refresh (DkpDevice *device)
@@ -370,7 +374,7 @@ dkp_hid_refresh (DkpDevice *device)
/* read any data -- it's okay if there's nothing as we are non-blocking */
rd = read (hid->priv->fd, ev, sizeof (ev));
if (rd < (int) sizeof (ev[0])) {
- ret = TRUE;
+ ret = FALSE;
goto out;
}
diff --git a/src/dkp-supply.c b/src/dkp-supply.c
index bd95798..9ea76b5 100644
--- a/src/dkp-supply.c
+++ b/src/dkp-supply.c
@@ -60,6 +60,8 @@ static gboolean dkp_supply_refresh (DkpDevice *device);
/**
* dkp_supply_refresh_line_power:
+ *
+ * Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
static gboolean
dkp_supply_refresh_line_power (DkpSupply *supply)
@@ -274,7 +276,7 @@ dkp_supply_convert_device_technology (const gchar *type)
/**
* dkp_supply_refresh_battery:
*
- * Return value: TRUE if we changed
+ * Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
static gboolean
dkp_supply_refresh_battery (DkpSupply *supply)
@@ -522,11 +524,14 @@ dkp_supply_poll_battery (DkpSupply *supply)
/**
* dkp_supply_coldplug:
+ *
+ * Return %TRUE on success, %FALSE if we failed to get data and should be removed
**/
static gboolean
dkp_supply_coldplug (DkpDevice *device)
{
DkpSupply *supply = DKP_SUPPLY (device);
+ gboolean ret;
DevkitDevice *d;
const gchar *native_path;
@@ -549,9 +554,9 @@ dkp_supply_coldplug (DkpDevice *device)
}
/* coldplug values */
- dkp_supply_refresh (device);
+ ret = dkp_supply_refresh (device);
- return TRUE;
+ return ret;
}
/**
@@ -590,6 +595,8 @@ out:
/**
* dkp_supply_refresh:
+ *
+ * Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
static gboolean
dkp_supply_refresh (DkpDevice *device)
diff --git a/src/dkp-wup.c b/src/dkp-wup.c
index faf34b4..23ada77 100644
--- a/src/dkp-wup.c
+++ b/src/dkp-wup.c
@@ -291,6 +291,8 @@ out:
/**
* dkp_wup_coldplug:
+ *
+ * Return %TRUE on success, %FALSE if we failed to get data and should be removed
**/
static gboolean
dkp_wup_coldplug (DkpDevice *device)
@@ -388,6 +390,8 @@ out:
/**
* dkp_wup_refresh:
+ *
+ * Return %TRUE on success, %FALSE if we failed to refresh or no data
**/
static gboolean
dkp_wup_refresh (DkpDevice *device)