habanalabs: add missing error check in sysfs max_power_show

Add a missing error check in the sysfs show function for max_power.

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
This commit is contained in:
Tomer Tayar 2022-01-12 11:40:43 +02:00 committed by Oded Gabbay
parent 15f8eb1905
commit 4ae9548de7
3 changed files with 5 additions and 3 deletions

View file

@ -2780,7 +2780,7 @@ void hl_fw_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq)
used_pll_idx, rc);
}
u64 hl_fw_get_max_power(struct hl_device *hdev)
long hl_fw_get_max_power(struct hl_device *hdev)
{
struct cpucp_packet pkt;
u64 result;
@ -2794,7 +2794,7 @@ u64 hl_fw_get_max_power(struct hl_device *hdev)
if (rc) {
dev_err(hdev->dev, "Failed to get max power, error %d\n", rc);
return (u64) rc;
return rc;
}
return result;

View file

@ -3098,7 +3098,7 @@ int hl_get_current(struct hl_device *hdev, int sensor_index, u32 attr, long *val
int hl_get_fan_speed(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
int hl_get_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr, long *value);
void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr, long value);
u64 hl_fw_get_max_power(struct hl_device *hdev);
long hl_fw_get_max_power(struct hl_device *hdev);
void hl_fw_set_max_power(struct hl_device *hdev);
int hl_set_voltage(struct hl_device *hdev, int sensor_index, u32 attr, long value);
int hl_set_current(struct hl_device *hdev, int sensor_index, u32 attr, long value);

View file

@ -304,6 +304,8 @@ static ssize_t max_power_show(struct device *dev, struct device_attribute *attr,
return -ENODEV;
val = hl_fw_get_max_power(hdev);
if (val < 0)
return val;
return sprintf(buf, "%lu\n", val);
}