From patchwork Fri Sep 11 15:40:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyle Evans X-Patchwork-Id: 7162391 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 EACC69F326 for ; Fri, 11 Sep 2015 15:40:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 13763207B7 for ; Fri, 11 Sep 2015 15:40:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16600207AA for ; Fri, 11 Sep 2015 15:40:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752406AbbIKPka (ORCPT ); Fri, 11 Sep 2015 11:40:30 -0400 Received: from mail-ig0-f172.google.com ([209.85.213.172]:33850 "EHLO mail-ig0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752114AbbIKPka (ORCPT ); Fri, 11 Sep 2015 11:40:30 -0400 Received: by igcpb10 with SMTP id pb10so47786220igc.1 for ; Fri, 11 Sep 2015 08:40:29 -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=YmqxklEyqwCjEtkcncnAe30kIFTzBrvO8em86Swd3wg=; b=PkYBkuvZNkcg+EMMm+xWtOQGY+JEnAEMJT5ITLcSDi3C2/Q+qVD2zm85ZcDUNa/PpN 3o9V4CS777eQxKNsVJFGrMIPhfodYrdTqhTVCEzFmEFvQMGW++T0oyOlvHFeLGi+qYro WMmuFDIEM8iWrTKk3Xfz1GJyekJQJYMxqHTXc+oa1MXvHI80A+WSIT8P+De8rTaqPee9 WPWdhUekQbvGUN7cOb8qTFSX/s4YxOx3YXq6/DcodV2Llvp5+DGAyk2pkcKzTQxrkUnQ CgxVunQzgMsaJ1TgCGZsJJcTYhyietTZqb9k6NLx8TJ28igHziDc4EAMO9qi9SlyM5Ah Hgog== X-Received: by 10.50.32.34 with SMTP id f2mr16523010igi.44.1441986029515; Fri, 11 Sep 2015 08:40:29 -0700 (PDT) Received: from localhost.localdomain ([208.78.206.26]) by smtp.gmail.com with ESMTPSA id m25sm419547iod.32.2015.09.11.08.40.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 08:40:28 -0700 (PDT) From: Kyle Evans To: dvhart@infradead.org Cc: platform-driver-x86@vger.kernel.org, rjw@rjwysocki.net, Kyle Evans Subject: [PATCHv5] hp-wmi: limit hotkey enable Date: Fri, 11 Sep 2015 10:40:17 -0500 Message-Id: <1441986017-1680-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. Add missing __init tag. 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. Since v4: - Fix "bios" typo. - Add __init tag. 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..fb4dd7b 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 __init 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_bios_2008_later()) hp_wmi_enable_hotkeys(); status = wmi_install_notify_handler(HPWMI_EVENT_GUID, hp_wmi_notify, NULL);