Skip to content

Commit 44e0e2b

Browse files
Carlo Caionegregkh
authored andcommitted
platform/x86: hp-wmi: Do not shadow error values
commit d313876925f3e7a480a02773fd333bcab9202d5e upstream. 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 <andriy.shevchenko@linux.intel.com> Signed-off-by: Carlo Caione <carlo@endlessm.com> Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org> Cc: Philip Müller <philm@manjaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ce93b66 commit 44e0e2b

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

drivers/platform/x86/hp-wmi.c

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

@@ -259,7 +259,7 @@ static int hp_wmi_hddtemp_state(void)
259259
int ret = hp_wmi_perform_query(HPWMI_HDDTEMP_QUERY, 0, &state,
260260
sizeof(state), sizeof(state));
261261
if (ret)
262-
return -EINVAL;
262+
return ret < 0 ? ret : -EINVAL;
263263
return state;
264264
}
265265

@@ -269,7 +269,7 @@ static int hp_wmi_als_state(void)
269269
int ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, 0, &state,
270270
sizeof(state), sizeof(state));
271271
if (ret)
272-
return -EINVAL;
272+
return ret < 0 ? ret : -EINVAL;
273273
return state;
274274
}
275275

@@ -280,7 +280,7 @@ static int hp_wmi_dock_state(void)
280280
sizeof(state), sizeof(state));
281281

282282
if (ret)
283-
return -EINVAL;
283+
return ret < 0 ? ret : -EINVAL;
284284

285285
return state & 0x1;
286286
}
@@ -291,7 +291,7 @@ static int hp_wmi_tablet_state(void)
291291
int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state,
292292
sizeof(state), sizeof(state));
293293
if (ret)
294-
return -EINVAL;
294+
return ret < 0 ? ret : -EINVAL;
295295

296296
return (state & 0x4) ? 1 : 0;
297297
}
@@ -324,7 +324,7 @@ static int __init hp_wmi_enable_hotkeys(void)
324324
int ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &value,
325325
sizeof(value), 0);
326326
if (ret)
327-
return -EINVAL;
327+
return ret < 0 ? ret : -EINVAL;
328328
return 0;
329329
}
330330

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

@@ -429,7 +429,7 @@ static int hp_wmi_post_code_state(void)
429429
int ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, 0, &state,
430430
sizeof(state), sizeof(state));
431431
if (ret)
432-
return -EINVAL;
432+
return ret < 0 ? ret : -EINVAL;
433433
return state;
434434
}
435435

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

500500
return count;
501501
}
@@ -516,7 +516,7 @@ static ssize_t set_postcode(struct device *dev, struct device_attribute *attr,
516516
ret = hp_wmi_perform_query(HPWMI_POSTCODEERROR_QUERY, 1, &tmp,
517517
sizeof(tmp), sizeof(tmp));
518518
if (ret)
519-
return -EINVAL;
519+
return ret < 0 ? ret : -EINVAL;
520520

521521
return count;
522522
}

0 commit comments

Comments
 (0)