Skip to content

Commit d313876

Browse files
Carlo Caionedvhart
authored andcommitted
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: Andy Shevchenko <[email protected]> Signed-off-by: Carlo Caione <[email protected]> Signed-off-by: Darren Hart (VMware) <[email protected]>
1 parent d1c7073 commit d313876

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/platform/x86/hp-wmi.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static int hp_wmi_display_state(void)
248248
int ret = hp_wmi_perform_query(HPWMI_DISPLAY_QUERY, 0, &state,
249249
sizeof(state), sizeof(state));
250250
if (ret)
251-
return -EINVAL;
251+
return ret < 0 ? ret : -EINVAL;
252252
return state;
253253
}
254254

@@ -258,7 +258,7 @@ static int hp_wmi_hddtemp_state(void)
258258
int ret = hp_wmi_perform_query(HPWMI_HDDTEMP_QUERY, 0, &state,
259259
sizeof(state), sizeof(state));
260260
if (ret)
261-
return -EINVAL;
261+
return ret < 0 ? ret : -EINVAL;
262262
return state;
263263
}
264264

@@ -268,7 +268,7 @@ static int hp_wmi_als_state(void)
268268
int ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, 0, &state,
269269
sizeof(state), sizeof(state));
270270
if (ret)
271-
return -EINVAL;
271+
return ret < 0 ? ret : -EINVAL;
272272
return state;
273273
}
274274

@@ -279,7 +279,7 @@ static int hp_wmi_dock_state(void)
279279
sizeof(state), sizeof(state));
280280

281281
if (ret)
282-
return -EINVAL;
282+
return ret < 0 ? ret : -EINVAL;
283283

284284
return state & 0x1;
285285
}
@@ -290,7 +290,7 @@ static int hp_wmi_tablet_state(void)
290290
int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state,
291291
sizeof(state), sizeof(state));
292292
if (ret)
293-
return -EINVAL;
293+
return ret < 0 ? ret : -EINVAL;
294294

295295
return (state & 0x4) ? 1 : 0;
296296
}
@@ -323,7 +323,7 @@ static int __init hp_wmi_enable_hotkeys(void)
323323
int ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &value,
324324
sizeof(value), 0);
325325
if (ret)
326-
return -EINVAL;
326+
return ret < 0 ? ret : -EINVAL;
327327
return 0;
328328
}
329329

@@ -336,7 +336,7 @@ static int hp_wmi_set_block(void *data, bool blocked)
336336
ret = hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, 1,
337337
&query, sizeof(query), 0);
338338
if (ret)
339-
return -EINVAL;
339+
return ret < 0 ? ret : -EINVAL;
340340
return 0;
341341
}
342342

@@ -428,7 +428,7 @@ static int hp_wmi_post_code_state(void)
428428
int ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, 0, &state,
429429
sizeof(state), sizeof(state));
430430
if (ret)
431-
return -EINVAL;
431+
return ret < 0 ? ret : -EINVAL;
432432
return state;
433433
}
434434

@@ -494,7 +494,7 @@ static ssize_t set_als(struct device *dev, struct device_attribute *attr,
494494
int ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, 1, &tmp,
495495
sizeof(tmp), sizeof(tmp));
496496
if (ret)
497-
return -EINVAL;
497+
return ret < 0 ? ret : -EINVAL;
498498

499499
return count;
500500
}
@@ -515,7 +515,7 @@ static ssize_t set_postcode(struct device *dev, struct device_attribute *attr,
515515
ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, 1, &tmp,
516516
sizeof(tmp), sizeof(tmp));
517517
if (ret)
518-
return -EINVAL;
518+
return ret < 0 ? ret : -EINVAL;
519519

520520
return count;
521521
}

0 commit comments

Comments
 (0)