From: Carlo Caione <carlo@caione.org> To: dvhart@infradead.org, andy@infradead.org, andy.shevchenko@gmail.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, linux@endlessm.com Cc: Carlo Caione <carlo@endlessm.com> Subject: [PATCH v2 1/2] hp-wmi: Do not shadow error values Date: Wed, 19 Apr 2017 19:41:53 +0200 [thread overview] Message-ID: <20170419174154.16518-2-carlo@caione.org> (raw) In-Reply-To: <20170419174154.16518-1-carlo@caione.org> From: Carlo Caione <carlo@endlessm.com> 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. Signed-off-by: Carlo Caione <carlo@endlessm.com> --- drivers/platform/x86/hp-wmi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index 96ffda4..8c7773a 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -248,7 +248,7 @@ static int hp_wmi_display_state(void) int ret = hp_wmi_perform_query(HPWMI_DISPLAY_QUERY, 0, &state, sizeof(state), sizeof(state)); if (ret) - return -EINVAL; + return ret < 0 ? ret : -EINVAL; return state; } @@ -258,7 +258,7 @@ static int hp_wmi_hddtemp_state(void) int ret = hp_wmi_perform_query(HPWMI_HDDTEMP_QUERY, 0, &state, sizeof(state), sizeof(state)); if (ret) - return -EINVAL; + return ret < 0 ? ret : -EINVAL; return state; } @@ -268,7 +268,7 @@ static int hp_wmi_als_state(void) int ret = hp_wmi_perform_query(HPWMI_ALS_QUERY, 0, &state, sizeof(state), sizeof(state)); if (ret) - return -EINVAL; + return ret < 0 ? ret : -EINVAL; return state; } @@ -279,7 +279,7 @@ static int hp_wmi_dock_state(void) sizeof(state), sizeof(state)); if (ret) - return -EINVAL; + return ret < 0 ? ret : -EINVAL; return state & 0x1; } @@ -290,7 +290,7 @@ static int hp_wmi_tablet_state(void) int ret = hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, 0, &state, sizeof(state), sizeof(state)); if (ret) - return ret; + return ret < 0 ? ret : -EINVAL; return (state & 0x4) ? 1 : 0; } @@ -323,7 +323,7 @@ static int __init hp_wmi_enable_hotkeys(void) int ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &value, sizeof(value), 0); if (ret) - return -EINVAL; + return ret < 0 ? ret : -EINVAL; return 0; } -- 2.9.3
next prev parent reply other threads:[~2017-04-19 17:42 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-04-19 17:41 [PATCH v2 0/2] hp-wmi: Fix dock status and tablet mode reporting Carlo Caione 2017-04-19 17:41 ` Carlo Caione [this message] 2017-04-19 20:11 ` [PATCH v2 1/2] hp-wmi: Do not shadow error values Darren Hart 2017-04-19 20:25 ` Carlo Caione 2017-04-19 17:41 ` [PATCH v2 2/2] hp-wmi: Fix detection for dock and tablet mode Carlo Caione
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20170419174154.16518-2-carlo@caione.org \ --to=carlo@caione.org \ --cc=andy.shevchenko@gmail.com \ --cc=andy@infradead.org \ --cc=carlo@endlessm.com \ --cc=dvhart@infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux@endlessm.com \ --cc=platform-driver-x86@vger.kernel.org \ --subject='Re: [PATCH v2 1/2] hp-wmi: Do not shadow error values' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).