static int nouveau_power_read(struct device *dev, u32 attr, int channel, long *val) { struct drm_device *drm_dev = dev_get_drvdata(dev); struct nouveau_drm *drm = nouveau_drm(drm_dev); struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->client.device); if (!iccsense) return -EOPNOTSUPP; switch (attr) { case hwmon_power_input: *val = nvkm_iccsense_read_all(iccsense); break; case hwmon_power_max: *val = iccsense->power_w_max; break; case hwmon_power_crit: *val = iccsense->power_w_crit; break; default: return -EOPNOTSUPP; } return 0; }
static ssize_t nouveau_hwmon_get_power1_input(struct device *d, struct device_attribute *a, char *buf) { struct drm_device *dev = dev_get_drvdata(d); struct nouveau_drm *drm = nouveau_drm(dev); struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->device); int result = nvkm_iccsense_read_all(iccsense); if (result < 0) return result; return sprintf(buf, "%i\n", result); }