Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/xe/hwmon: Use scope-based runtime PM

Use scope-based runtime power management in the hwmon code for
consistency with other parts of the driver.

v2:
- Drop unnecessary 'ret' variables. (Gustavo)

Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>
Link: https://patch.msgid.link/20251118164338.3572146-52-matthew.d.roper@intel.com
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>

+14 -38
+14 -38
drivers/gpu/drm/xe/xe_hwmon.c
··· 502 502 503 503 int ret = 0; 504 504 505 - xe_pm_runtime_get(hwmon->xe); 505 + guard(xe_pm_runtime)(hwmon->xe); 506 506 507 507 mutex_lock(&hwmon->hwmon_lock); 508 508 ··· 520 520 } 521 521 522 522 mutex_unlock(&hwmon->hwmon_lock); 523 - 524 - xe_pm_runtime_put(hwmon->xe); 525 523 526 524 x = REG_FIELD_GET(PWR_LIM_TIME_X, reg_val); 527 525 y = REG_FIELD_GET(PWR_LIM_TIME_Y, reg_val); ··· 602 604 rxy = REG_FIELD_PREP(PWR_LIM_TIME_X, x) | 603 605 REG_FIELD_PREP(PWR_LIM_TIME_Y, y); 604 606 605 - xe_pm_runtime_get(hwmon->xe); 607 + guard(xe_pm_runtime)(hwmon->xe); 606 608 607 609 mutex_lock(&hwmon->hwmon_lock); 608 610 ··· 613 615 PWR_LIM_TIME, rxy); 614 616 615 617 mutex_unlock(&hwmon->hwmon_lock); 616 - 617 - xe_pm_runtime_put(hwmon->xe); 618 618 619 619 return count; 620 620 } ··· 1120 1124 int channel, long *val) 1121 1125 { 1122 1126 struct xe_hwmon *hwmon = dev_get_drvdata(dev); 1123 - int ret; 1124 1127 1125 - xe_pm_runtime_get(hwmon->xe); 1128 + guard(xe_pm_runtime)(hwmon->xe); 1126 1129 1127 1130 switch (type) { 1128 1131 case hwmon_temp: 1129 - ret = xe_hwmon_temp_read(hwmon, attr, channel, val); 1130 - break; 1132 + return xe_hwmon_temp_read(hwmon, attr, channel, val); 1131 1133 case hwmon_power: 1132 - ret = xe_hwmon_power_read(hwmon, attr, channel, val); 1133 - break; 1134 + return xe_hwmon_power_read(hwmon, attr, channel, val); 1134 1135 case hwmon_curr: 1135 - ret = xe_hwmon_curr_read(hwmon, attr, channel, val); 1136 - break; 1136 + return xe_hwmon_curr_read(hwmon, attr, channel, val); 1137 1137 case hwmon_in: 1138 - ret = xe_hwmon_in_read(hwmon, attr, channel, val); 1139 - break; 1138 + return xe_hwmon_in_read(hwmon, attr, channel, val); 1140 1139 case hwmon_energy: 1141 - ret = xe_hwmon_energy_read(hwmon, attr, channel, val); 1142 - break; 1140 + return xe_hwmon_energy_read(hwmon, attr, channel, val); 1143 1141 case hwmon_fan: 1144 - ret = xe_hwmon_fan_read(hwmon, attr, channel, val); 1145 - break; 1142 + return xe_hwmon_fan_read(hwmon, attr, channel, val); 1146 1143 default: 1147 - ret = -EOPNOTSUPP; 1148 - break; 1144 + return -EOPNOTSUPP; 1149 1145 } 1150 - 1151 - xe_pm_runtime_put(hwmon->xe); 1152 - 1153 - return ret; 1154 1146 } 1155 1147 1156 1148 static int ··· 1146 1162 int channel, long val) 1147 1163 { 1148 1164 struct xe_hwmon *hwmon = dev_get_drvdata(dev); 1149 - int ret; 1150 1165 1151 - xe_pm_runtime_get(hwmon->xe); 1166 + guard(xe_pm_runtime)(hwmon->xe); 1152 1167 1153 1168 switch (type) { 1154 1169 case hwmon_power: 1155 - ret = xe_hwmon_power_write(hwmon, attr, channel, val); 1156 - break; 1170 + return xe_hwmon_power_write(hwmon, attr, channel, val); 1157 1171 case hwmon_curr: 1158 - ret = xe_hwmon_curr_write(hwmon, attr, channel, val); 1159 - break; 1172 + return xe_hwmon_curr_write(hwmon, attr, channel, val); 1160 1173 default: 1161 - ret = -EOPNOTSUPP; 1162 - break; 1174 + return -EOPNOTSUPP; 1163 1175 } 1164 - 1165 - xe_pm_runtime_put(hwmon->xe); 1166 - 1167 - return ret; 1168 1176 } 1169 1177 1170 1178 static int xe_hwmon_read_label(struct device *dev,