mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-30 08:02:30 +00:00
habanalabs: modify the return values of hl_read/write routines
The hl read and write routines implement the hwmon_ops read and write interface routines respectively. These routines are expected to return a completion status when called, which was not the case until this commit. This commit modifies these routines to return 0 upon success and a negative error value upon failure. Signed-off-by: Moti Haimovski <mhaimovski@habana.ai> Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
This commit is contained in:
parent
5557b138dc
commit
d57b83c3df
2 changed files with 43 additions and 37 deletions
|
@ -1609,13 +1609,18 @@ int hl_pci_set_dma_mask(struct hl_device *hdev, u8 dma_mask);
|
||||||
|
|
||||||
long hl_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr);
|
long hl_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr);
|
||||||
void hl_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq);
|
void hl_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq);
|
||||||
long hl_get_temperature(struct hl_device *hdev, int sensor_index, u32 attr);
|
int hl_get_temperature(struct hl_device *hdev,
|
||||||
|
int sensor_index, u32 attr, long *value);
|
||||||
int hl_set_temperature(struct hl_device *hdev,
|
int hl_set_temperature(struct hl_device *hdev,
|
||||||
int sensor_index, u32 attr, long value);
|
int sensor_index, u32 attr, long value);
|
||||||
long hl_get_voltage(struct hl_device *hdev, int sensor_index, u32 attr);
|
int hl_get_voltage(struct hl_device *hdev,
|
||||||
long hl_get_current(struct hl_device *hdev, int sensor_index, u32 attr);
|
int sensor_index, u32 attr, long *value);
|
||||||
long hl_get_fan_speed(struct hl_device *hdev, int sensor_index, u32 attr);
|
int hl_get_current(struct hl_device *hdev,
|
||||||
long hl_get_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr);
|
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);
|
||||||
void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr,
|
void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr,
|
||||||
long value);
|
long value);
|
||||||
u64 hl_get_max_power(struct hl_device *hdev);
|
u64 hl_get_max_power(struct hl_device *hdev);
|
||||||
|
|
|
@ -113,6 +113,7 @@ static int hl_read(struct device *dev, enum hwmon_sensor_types type,
|
||||||
u32 attr, int channel, long *val)
|
u32 attr, int channel, long *val)
|
||||||
{
|
{
|
||||||
struct hl_device *hdev = dev_get_drvdata(dev);
|
struct hl_device *hdev = dev_get_drvdata(dev);
|
||||||
|
int rc;
|
||||||
|
|
||||||
if (hl_device_disabled_or_in_reset(hdev))
|
if (hl_device_disabled_or_in_reset(hdev))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
@ -131,7 +132,7 @@ static int hl_read(struct device *dev, enum hwmon_sensor_types type,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*val = hl_get_temperature(hdev, channel, attr);
|
rc = hl_get_temperature(hdev, channel, attr, val);
|
||||||
break;
|
break;
|
||||||
case hwmon_in:
|
case hwmon_in:
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
|
@ -143,7 +144,7 @@ static int hl_read(struct device *dev, enum hwmon_sensor_types type,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*val = hl_get_voltage(hdev, channel, attr);
|
rc = hl_get_voltage(hdev, channel, attr, val);
|
||||||
break;
|
break;
|
||||||
case hwmon_curr:
|
case hwmon_curr:
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
|
@ -155,7 +156,7 @@ static int hl_read(struct device *dev, enum hwmon_sensor_types type,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*val = hl_get_current(hdev, channel, attr);
|
rc = hl_get_current(hdev, channel, attr, val);
|
||||||
break;
|
break;
|
||||||
case hwmon_fan:
|
case hwmon_fan:
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
|
@ -166,7 +167,7 @@ static int hl_read(struct device *dev, enum hwmon_sensor_types type,
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
*val = hl_get_fan_speed(hdev, channel, attr);
|
rc = hl_get_fan_speed(hdev, channel, attr, val);
|
||||||
break;
|
break;
|
||||||
case hwmon_pwm:
|
case hwmon_pwm:
|
||||||
switch (attr) {
|
switch (attr) {
|
||||||
|
@ -176,12 +177,12 @@ static int hl_read(struct device *dev, enum hwmon_sensor_types type,
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
*val = hl_get_pwm_info(hdev, channel, attr);
|
rc = hl_get_pwm_info(hdev, channel, attr, val);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
return 0;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int hl_write(struct device *dev, enum hwmon_sensor_types type,
|
static int hl_write(struct device *dev, enum hwmon_sensor_types type,
|
||||||
|
@ -277,10 +278,10 @@ static const struct hwmon_ops hl_hwmon_ops = {
|
||||||
.write = hl_write
|
.write = hl_write
|
||||||
};
|
};
|
||||||
|
|
||||||
long hl_get_temperature(struct hl_device *hdev, int sensor_index, u32 attr)
|
int hl_get_temperature(struct hl_device *hdev,
|
||||||
|
int sensor_index, u32 attr, long *value)
|
||||||
{
|
{
|
||||||
struct armcp_packet pkt;
|
struct armcp_packet pkt;
|
||||||
long result;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
memset(&pkt, 0, sizeof(pkt));
|
memset(&pkt, 0, sizeof(pkt));
|
||||||
|
@ -291,16 +292,16 @@ long hl_get_temperature(struct hl_device *hdev, int sensor_index, u32 attr)
|
||||||
pkt.type = __cpu_to_le16(attr);
|
pkt.type = __cpu_to_le16(attr);
|
||||||
|
|
||||||
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
|
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
|
||||||
SENSORS_PKT_TIMEOUT, &result);
|
SENSORS_PKT_TIMEOUT, value);
|
||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(hdev->dev,
|
dev_err(hdev->dev,
|
||||||
"Failed to get temperature from sensor %d, error %d\n",
|
"Failed to get temperature from sensor %d, error %d\n",
|
||||||
sensor_index, rc);
|
sensor_index, rc);
|
||||||
result = 0;
|
*value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hl_set_temperature(struct hl_device *hdev,
|
int hl_set_temperature(struct hl_device *hdev,
|
||||||
|
@ -328,10 +329,10 @@ int hl_set_temperature(struct hl_device *hdev,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
long hl_get_voltage(struct hl_device *hdev, int sensor_index, u32 attr)
|
int hl_get_voltage(struct hl_device *hdev,
|
||||||
|
int sensor_index, u32 attr, long *value)
|
||||||
{
|
{
|
||||||
struct armcp_packet pkt;
|
struct armcp_packet pkt;
|
||||||
long result;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
memset(&pkt, 0, sizeof(pkt));
|
memset(&pkt, 0, sizeof(pkt));
|
||||||
|
@ -342,22 +343,22 @@ long hl_get_voltage(struct hl_device *hdev, int sensor_index, u32 attr)
|
||||||
pkt.type = __cpu_to_le16(attr);
|
pkt.type = __cpu_to_le16(attr);
|
||||||
|
|
||||||
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
|
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
|
||||||
SENSORS_PKT_TIMEOUT, &result);
|
SENSORS_PKT_TIMEOUT, value);
|
||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(hdev->dev,
|
dev_err(hdev->dev,
|
||||||
"Failed to get voltage from sensor %d, error %d\n",
|
"Failed to get voltage from sensor %d, error %d\n",
|
||||||
sensor_index, rc);
|
sensor_index, rc);
|
||||||
result = 0;
|
*value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
long hl_get_current(struct hl_device *hdev, int sensor_index, u32 attr)
|
int hl_get_current(struct hl_device *hdev,
|
||||||
|
int sensor_index, u32 attr, long *value)
|
||||||
{
|
{
|
||||||
struct armcp_packet pkt;
|
struct armcp_packet pkt;
|
||||||
long result;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
memset(&pkt, 0, sizeof(pkt));
|
memset(&pkt, 0, sizeof(pkt));
|
||||||
|
@ -368,22 +369,22 @@ long hl_get_current(struct hl_device *hdev, int sensor_index, u32 attr)
|
||||||
pkt.type = __cpu_to_le16(attr);
|
pkt.type = __cpu_to_le16(attr);
|
||||||
|
|
||||||
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
|
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
|
||||||
SENSORS_PKT_TIMEOUT, &result);
|
SENSORS_PKT_TIMEOUT, value);
|
||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(hdev->dev,
|
dev_err(hdev->dev,
|
||||||
"Failed to get current from sensor %d, error %d\n",
|
"Failed to get current from sensor %d, error %d\n",
|
||||||
sensor_index, rc);
|
sensor_index, rc);
|
||||||
result = 0;
|
*value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
long hl_get_fan_speed(struct hl_device *hdev, int sensor_index, u32 attr)
|
int hl_get_fan_speed(struct hl_device *hdev,
|
||||||
|
int sensor_index, u32 attr, long *value)
|
||||||
{
|
{
|
||||||
struct armcp_packet pkt;
|
struct armcp_packet pkt;
|
||||||
long result;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
memset(&pkt, 0, sizeof(pkt));
|
memset(&pkt, 0, sizeof(pkt));
|
||||||
|
@ -394,22 +395,22 @@ long hl_get_fan_speed(struct hl_device *hdev, int sensor_index, u32 attr)
|
||||||
pkt.type = __cpu_to_le16(attr);
|
pkt.type = __cpu_to_le16(attr);
|
||||||
|
|
||||||
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
|
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
|
||||||
SENSORS_PKT_TIMEOUT, &result);
|
SENSORS_PKT_TIMEOUT, value);
|
||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(hdev->dev,
|
dev_err(hdev->dev,
|
||||||
"Failed to get fan speed from sensor %d, error %d\n",
|
"Failed to get fan speed from sensor %d, error %d\n",
|
||||||
sensor_index, rc);
|
sensor_index, rc);
|
||||||
result = 0;
|
*value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
long hl_get_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr)
|
int hl_get_pwm_info(struct hl_device *hdev,
|
||||||
|
int sensor_index, u32 attr, long *value)
|
||||||
{
|
{
|
||||||
struct armcp_packet pkt;
|
struct armcp_packet pkt;
|
||||||
long result;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
memset(&pkt, 0, sizeof(pkt));
|
memset(&pkt, 0, sizeof(pkt));
|
||||||
|
@ -420,16 +421,16 @@ long hl_get_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr)
|
||||||
pkt.type = __cpu_to_le16(attr);
|
pkt.type = __cpu_to_le16(attr);
|
||||||
|
|
||||||
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
|
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
|
||||||
SENSORS_PKT_TIMEOUT, &result);
|
SENSORS_PKT_TIMEOUT, value);
|
||||||
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(hdev->dev,
|
dev_err(hdev->dev,
|
||||||
"Failed to get pwm info from sensor %d, error %d\n",
|
"Failed to get pwm info from sensor %d, error %d\n",
|
||||||
sensor_index, rc);
|
sensor_index, rc);
|
||||||
result = 0;
|
*value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr,
|
void hl_set_pwm_info(struct hl_device *hdev, int sensor_index, u32 attr,
|
||||||
|
|
Loading…
Reference in a new issue