From patchwork Thu Sep 10 17:45:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Evans X-Patchwork-Id: 7155291 Return-Path: X-Original-To: patchwork-platform-driver-x86@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7512E9F326 for ; Thu, 10 Sep 2015 17:45:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 95FEF20632 for ; Thu, 10 Sep 2015 17:45:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB61420629 for ; Thu, 10 Sep 2015 17:45:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752209AbbIJRp5 (ORCPT ); Thu, 10 Sep 2015 13:45:57 -0400 Received: from mail-ig0-f169.google.com ([209.85.213.169]:33971 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750970AbbIJRp4 (ORCPT ); Thu, 10 Sep 2015 13:45:56 -0400 Received: by igcpb10 with SMTP id pb10so26070054igc.1 for ; Thu, 10 Sep 2015 10:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MB/TsH/JLIoGCw1RRCmbENGQ/g58cS1S5Z7w+9YGVSw=; b=RX6JAfuAXycsaQ1t3aimBXQ/GuZ3qSyNGf8QDwASRHgVQFf49ajJFuYGabWFtQ0SZW JdGXpMWfcmv9hyeoY/Lu/LrALIc1ObqGvJ0Vg+Za7YN/dHWcac9sT0mpmTizU3vKiqHE q0WjBjiNioisiMS9SCxmKVAIpjY+qu753A9yd6m/k5FjDlMjhU0ZW/HkTE9ScMkIgQGh Q1+6kgx5Q76CfWX8FvWgYz9pzaqHKanaWx1d1yr16VoNdHvw8vfYXWcsNmb1qHlu/8OH ZM0X1mO6E6iGmYug45E211XW2i1Z0muF70vROP/5BHyrzp/nQ8sssm+OPIokpvHOpyo8 hvyQ== X-Received: by 10.50.142.37 with SMTP id rt5mr8633183igb.88.1441907156347; Thu, 10 Sep 2015 10:45:56 -0700 (PDT) Received: from localhost.localdomain ([208.78.206.26]) by smtp.gmail.com with ESMTPSA id kb10sm4647340igb.4.2015.09.10.10.45.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2015 10:45:55 -0700 (PDT) From: Kyle Evans To: dvhart@infradead.org Cc: platform-driver-x86@vger.kernel.org, rjw@rjwysocki.net, Kyle Evans Subject: [PATCHv4] hp-wmi: limit hotkey enable Date: Thu, 10 Sep 2015 12:45:00 -0500 Message-Id: <1441907100-4141-1-git-send-email-kvans32@gmail.com> X-Mailer: git-send-email 1.8.5.5 In-Reply-To: <20150910030330.GE90062@vmdeb7> References: <20150910030330.GE90062@vmdeb7> Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Do not write initialize magic on systems that do not have feature query 0xb. Fixes Bug #82451. Redefine FEATURE_QUERY to align with 0xb and FEATURE2 with 0xd for code clearity. Add a new test function, hp_wmi_bios_2008_later() & simplify hp_wmi_bios_2009_later(), which fixes a bug in cases where an improper value is returned. Probably also fixes Bug #69131. Signed-off-by: Kyle Evans --- Since v1: - Refactored feature query 0xb into separate function - Redefine FEATURE_QUERY to align with 0xb and FEATURE2 with 0xd Since v2: - Simplify hp_wmi_bios_200x_later functions. No longer returns true (4) when the test fails. However, if state is somehow useful, that is lost. Since v3: - Fix whitespace, email client reformatting. drivers/platform/x86/hp-wmi.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c index 0669731..45a9eaa 100644 --- a/drivers/platform/x86/hp-wmi.c +++ b/drivers/platform/x86/hp-wmi.c @@ -54,8 +54,9 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4"); #define HPWMI_HARDWARE_QUERY 0x4 #define HPWMI_WIRELESS_QUERY 0x5 #define HPWMI_BIOS_QUERY 0x9 +#define HPWMI_FEATURE_QUERY 0xb #define HPWMI_HOTKEY_QUERY 0xc -#define HPWMI_FEATURE_QUERY 0xd +#define HPWMI_FEATURE2_QUERY 0xd #define HPWMI_WIRELESS2_QUERY 0x1b #define HPWMI_POSTCODEERROR_QUERY 0x2a @@ -295,25 +296,33 @@ static int hp_wmi_tablet_state(void) return (state & 0x4) ? 1 : 0; } -static int __init hp_wmi_bios_2009_later(void) +static int __init hp_wmi_bios_2008_later(void) { int state = 0; int ret = hp_wmi_perform_query(HPWMI_FEATURE_QUERY, 0, &state, sizeof(state), sizeof(state)); - if (ret) - return ret; + if (!ret) + return 1; - return (state & 0x10) ? 1 : 0; + return (ret == HPWMI_RET_UNKNOWN_CMDTYPE) ? 0 : -ENXIO; } -static int hp_wmi_enable_hotkeys(void) +static int __init hp_wmi_bios_2009_later(void) { - int ret; - int query = 0x6e; + int state = 0; + int ret = hp_wmi_perform_query(HPWMI_FEATURE2_QUERY, 0, &state, + sizeof(state), sizeof(state)); + if (!ret) + return 1; - ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &query, sizeof(query), - 0); + return (ret == HPWMI_RET_UNKNOWN_CMDTYPE) ? 0 : -ENXIO; +} +static int hp_wmi_enable_hotkeys(void) +{ + int value = 0x6e; + int ret = hp_wmi_perform_query(HPWMI_BIOS_QUERY, 1, &value, + sizeof(value), 0); if (ret) return -EINVAL; return 0; @@ -663,7 +672,7 @@ static int __init hp_wmi_input_setup(void) hp_wmi_tablet_state()); input_sync(hp_wmi_input_dev); - if (hp_wmi_bios_2009_later() == 4) + if (!hp_wmi_bios_2009_later() && hp_wmi_2008_later()) hp_wmi_enable_hotkeys(); status = wmi_install_notify_handler(HPWMI_EVENT_GUID, hp_wmi_notify, NULL);