Skip to contentSkip to conversation

subdev/volt/gk104: return error when read fails

PATCH New Karol Herbst 1 participant 1 message Jul 31, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 subdev/volt/gk104: return error when read fails

While my gpu was powered off, hwmon returned 0.6V as the current voltage. If nvkm_rd32 fails for any reason, return the error.

With that sensors will display a "N/A" instead of 0.6V.

---
 drm/nouveau/nvkm/subdev/volt/gk104.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drm/nouveau/nvkm/subdev/volt/gk104.c +6 -1
index 420bd84..1821626 100644
@@ -39,10 +39,15 @@ gk104_volt_get(struct nvkm_volt *base)
 {
 	struct nvbios_volt *bios = &gk104_volt(base)->bios;
 	struct nvkm_device *device = base->subdev.device;
-	u32 div, duty;
+	int div, duty;
 
 	div  = nvkm_rd32(device, 0x20340);
+	if (div < 0)
+		return div;
+
 	duty = nvkm_rd32(device, 0x20344);
+	if (duty < 0)
+		return duty;
 
 	return bios->base + bios->pwm_range * duty / div;
 }
Signature · 6 lines
2.9.2

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau