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:
@@ -2780,7 +2780,7 @@ void hl_fw_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq)
|
|||||||
used_pll_idx, rc);
|
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;
|
struct cpucp_packet pkt;
|
||||||
u64 result;
|
u64 result;
|
||||||
@@ -2794,7 +2794,7 @@ u64 hl_fw_get_max_power(struct hl_device *hdev)
|
|||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(hdev->dev, "Failed to get max power, error %d\n", rc);
|
dev_err(hdev->dev, "Failed to get max power, error %d\n", rc);
|
||||||
return (u64) rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@@ -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_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);
|
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);
|
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);
|
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_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);
|
int hl_set_current(struct hl_device *hdev, int sensor_index, u32 attr, long value);
|
||||||
|
@@ -304,6 +304,8 @@ static ssize_t max_power_show(struct device *dev, struct device_attribute *attr,
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
val = hl_fw_get_max_power(hdev);
|
val = hl_fw_get_max_power(hdev);
|
||||||
|
if (val < 0)
|
||||||
|
return val;
|
||||||
|
|
||||||
return sprintf(buf, "%lu\n", val);
|
return sprintf(buf, "%lu\n", val);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user