summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarren Hart (VMware) <dvhart@infradead.org>2017-04-20 03:00:01 +0200
committerDarren Hart (VMware) <dvhart@infradead.org>2017-04-20 22:26:15 +0200
commitc7ef144c12033052c956ca9d80b2dfc19c73d939 (patch)
treec64a013ae377f7c1a7c213728dbb0777019bd514
parentplatform/x86: hp-wmi: Refactor redundant HPWMI_READ functions (diff)
downloadlinux-c7ef144c12033052c956ca9d80b2dfc19c73d939.tar.xz
linux-c7ef144c12033052c956ca9d80b2dfc19c73d939.zip
platform/x86: hp-wmi: Cleanup wireless get_(hw|sw)state functions
Use the new hp_wmi_read_int() function and add a WARN_ONCE() to the TBD regarding passing the error through. These are used in a null return function unfortunately. Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org> Tested-by: Carlo Caione <carlo@endlessm.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
-rw-r--r--drivers/platform/x86/hp-wmi.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index eb6d0a0e1392..577805987d35 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -343,33 +343,25 @@ static const struct rfkill_ops hp_wmi_rfkill_ops = {
static bool hp_wmi_get_sw_state(enum hp_wmi_radio r)
{
int mask = 0x200 << (r * 8);
- int wireless = 0;
- hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, HPWMI_READ,
- &wireless, sizeof(wireless),
- sizeof(wireless));
+ int wireless = hp_wmi_read_int(HPWMI_WIRELESS_QUERY);
+
/* TBD: Pass error */
+ WARN_ONCE(wireless < 0, "error executing HPWMI_WIRELESS_QUERY");
- if (wireless & mask)
- return false;
- else
- return true;
+ return !(wireless & mask);
}
static bool hp_wmi_get_hw_state(enum hp_wmi_radio r)
{
int mask = 0x800 << (r * 8);
- int wireless = 0;
- hp_wmi_perform_query(HPWMI_WIRELESS_QUERY, HPWMI_READ,
- &wireless, sizeof(wireless),
- sizeof(wireless));
+ int wireless = hp_wmi_read_int(HPWMI_WIRELESS_QUERY);
+
/* TBD: Pass error */
+ WARN_ONCE(wireless < 0, "error executing HPWMI_WIRELESS_QUERY");
- if (wireless & mask)
- return false;
- else
- return true;
+ return !(wireless & mask);
}
static int hp_wmi_rfkill2_set_block(void *data, bool blocked)