Commit d3138769 authored by Carlo Caione's avatar Carlo Caione Committed by Darren Hart (VMware)

platform/x86: hp-wmi: Do not shadow error values

All the helper functions (i.e. hp_wmi_dock_state, hp_wmi_tablet_state,
...) using hp_wmi_perform_query to perform an HP WMI query shadow the
returned value in case of error.

We return -EINVAL only when the HP WMI query returns a positive value
(the specific error code) to not mix this up with the actual value
returned by the helper function.
Suggested-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarCarlo Caione <carlo@endlessm.com>
Signed-off-by: default avatarDarren Hart (VMware) <dvhart@infradead.org>
parent d1c7073b
...@@ -248,7 +248,7 @@ static int hp_wmi_display_state(void) ...@@ -248,7 +248,7 @@ static int hp_wmi_display_state(void)
int ret = hp_wmi_perform_query(HPWMI_DISPLAY_QUERY, 0, &state, int ret = hp_wmi_perform_query(HPWMI_DISPLAY_QUERY, 0, &state,
sizeof(state), sizeof(state)); sizeof(state), sizeof(state));
if (ret) if (ret)
return -EINVAL; return ret < 0 ? ret : -EINVAL;
return state; return state;
} }
...@@ -258,7 +258,7 @@ static int hp_wmi_hddtemp_state(void) ...@@ -258,7 +258,7 @@ static int hp_wmi_hddtemp_state(void)
int ret = hp_wmi_perform_query(HPWMI_HDDTEMP_QUERY, 0, &state, int ret = hp_wmi_perform_query(HPWMI_HDDTEMP_QUERY, 0, &state,
sizeof(state), sizeof(state)); sizeof(state), sizeof(state));
if (ret) if (ret)
return -EINVAL; return ret < 0 ? ret : -EINVAL;
return state; return state;
} }
...@@ -268,7 +268,7 @@ static int hp_wmi_als_state(void) ...@@ -268,7 +268,7 @@ static int hp_wmi_als_state(void)
int ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, 0, &state, int ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, 0, &state,
sizeof(state), sizeof(state)); sizeof(state), sizeof(state));
if (ret) if (ret)
return -EINVAL; return ret < 0 ? ret : -EINVAL;
return state; return state;
} }
...@@ -279,7 +279,7 @@ static int hp_wmi_dock_state(void) ...@@ -279,7 +279,7 @@ static int hp_wmi_dock_state(void)
sizeof(state), sizeof(state)); sizeof(state), sizeof(state));
if (ret) if (ret)
return -EINVAL; return ret < 0 ? ret : -EINVAL;
return state & 0x1; return state & 0x1;
} }
...@@ -290,7 +290,7 @@ static int hp_wmi_tablet_state(void) ...@@ -290,7 +290,7 @@ static int hp_wmi_tablet_state(void)
int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state, int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state,
sizeof(state), sizeof(state)); sizeof(state), sizeof(state));
if (ret) if (ret)
return -EINVAL; return ret < 0 ? ret : -EINVAL;
return (state & 0x4) ? 1 : 0; return (state & 0x4) ? 1 : 0;
} }
...@@ -323,7 +323,7 @@ static int __init hp_wmi_enable_hotkeys(void) ...@@ -323,7 +323,7 @@ static int __init hp_wmi_enable_hotkeys(void)
int ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &value, int ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &value,
sizeof(value), 0); sizeof(value), 0);
if (ret) if (ret)
return -EINVAL; return ret < 0 ? ret : -EINVAL;
return 0; return 0;
} }
...@@ -336,7 +336,7 @@ static int hp_wmi_set_block(void *data, bool blocked) ...@@ -336,7 +336,7 @@ static int hp_wmi_set_block(void *data, bool blocked)
ret = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1, ret = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1,
&query, sizeof(query), 0); &query, sizeof(query), 0);
if (ret) if (ret)
return -EINVAL; return ret < 0 ? ret : -EINVAL;
return 0; return 0;
} }
...@@ -428,7 +428,7 @@ static int hp_wmi_post_code_state(void) ...@@ -428,7 +428,7 @@ static int hp_wmi_post_code_state(void)
int ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, 0, &state, int ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, 0, &state,
sizeof(state), sizeof(state)); sizeof(state), sizeof(state));
if (ret) if (ret)
return -EINVAL; return ret < 0 ? ret : -EINVAL;
return state; return state;
} }
...@@ -494,7 +494,7 @@ static ssize_t set_als(struct device *dev, struct device_attribute *attr, ...@@ -494,7 +494,7 @@ static ssize_t set_als(struct device *dev, struct device_attribute *attr,
int ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, 1, &tmp, int ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, 1, &tmp,
sizeof(tmp), sizeof(tmp)); sizeof(tmp), sizeof(tmp));
if (ret) if (ret)
return -EINVAL; return ret < 0 ? ret : -EINVAL;
return count; return count;
} }
...@@ -515,7 +515,7 @@ static ssize_t set_postcode(struct device *dev, struct device_attribute *attr, ...@@ -515,7 +515,7 @@ static ssize_t set_postcode(struct device *dev, struct device_attribute *attr,
ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, 1, &tmp, ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, 1, &tmp,
sizeof(tmp), sizeof(tmp)); sizeof(tmp), sizeof(tmp));
if (ret) if (ret)
return -EINVAL; return ret < 0 ? ret : -EINVAL;
return count; return count;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment