Skip to content

Commit b71e819

Browse files
committed
fuel_gauge: composite: fix unreleased PM constraint
Fix the PM constraint not being released when the sample fetch API call fails. Signed-off-by: Jordan Yates <[email protected]>
1 parent 4ef1163 commit b71e819

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/fuel_gauge/composite/fuel_gauge_composite.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@ struct composite_data {
2828

2929
static int composite_fetch(const struct device *dev)
3030
{
31-
int rc;
31+
int rc, rc2;
3232

3333
rc = pm_device_runtime_get(dev);
3434
if (rc < 0) {
3535
return rc;
3636
}
3737
rc = sensor_sample_fetch(dev);
38-
if (rc < 0) {
39-
return rc;
38+
/* Uncondionally release the PM constraint */
39+
rc2 = pm_device_runtime_put(dev);
40+
if (rc == 0) {
41+
rc = rc2;
4042
}
41-
return pm_device_runtime_put(dev);
43+
return rc;
4244
}
4345

4446
static int composite_channel_get(const struct device *dev, enum sensor_channel chan,

0 commit comments

Comments
 (0)