forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/gpu/drm/nouveau/nouveau_hwmon.c
....@@ -29,8 +29,6 @@
2929 #include <linux/hwmon.h>
3030 #include <linux/hwmon-sysfs.h>
3131
32
-#include <drm/drmP.h>
33
-
3432 #include "nouveau_drv.h"
3533 #include "nouveau_hwmon.h"
3634
....@@ -428,6 +426,8 @@
428426
429427 switch (attr) {
430428 case hwmon_temp_input:
429
+ if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)
430
+ return -EINVAL;
431431 ret = nvkm_therm_temp_get(therm);
432432 *val = ret < 0 ? ret : (ret * 1000);
433433 break;
....@@ -474,6 +474,8 @@
474474
475475 switch (attr) {
476476 case hwmon_fan_input:
477
+ if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)
478
+ return -EINVAL;
477479 *val = nvkm_therm_fan_sense(therm);
478480 break;
479481 default:
....@@ -496,6 +498,8 @@
496498
497499 switch (attr) {
498500 case hwmon_in_input:
501
+ if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)
502
+ return -EINVAL;
499503 ret = nvkm_volt_get(volt);
500504 *val = ret < 0 ? ret : (ret / 1000);
501505 break;
....@@ -527,6 +531,8 @@
527531 *val = therm->attr_get(therm, NVKM_THERM_ATTR_FAN_MODE);
528532 break;
529533 case hwmon_pwm_input:
534
+ if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)
535
+ return -EINVAL;
530536 *val = therm->fan_get(therm);
531537 break;
532538 default:
....@@ -548,6 +554,8 @@
548554
549555 switch (attr) {
550556 case hwmon_power_input:
557
+ if (drm_dev->switch_power_state != DRM_SWITCH_POWER_ON)
558
+ return -EINVAL;
551559 *val = nvkm_iccsense_read_all(iccsense);
552560 break;
553561 case hwmon_power_max:
....@@ -733,7 +741,7 @@
733741 special_groups[i++] = &pwm_fan_sensor_group;
734742 }
735743
736
- special_groups[i] = 0;
744
+ special_groups[i] = NULL;
737745 hwmon_dev = hwmon_device_register_with_info(dev->dev, "nouveau", dev,
738746 &nouveau_chip_info,
739747 special_groups);