From patchwork Fri Apr 28 16:25:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gerecke, Jason" X-Patchwork-Id: 9705087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F2743602BE for ; Fri, 28 Apr 2017 16:25:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4B172866A for ; Fri, 28 Apr 2017 16:25:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D914A2866F; Fri, 28 Apr 2017 16:25:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 736412866A for ; Fri, 28 Apr 2017 16:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756803AbdD1QZ4 (ORCPT ); Fri, 28 Apr 2017 12:25:56 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:33153 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756801AbdD1QZz (ORCPT ); Fri, 28 Apr 2017 12:25:55 -0400 Received: by mail-qk0-f194.google.com with SMTP id o85so9596856qkh.0 for ; Fri, 28 Apr 2017 09:25:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=b6Tagel72i6eRMy2LqDw/acsw5t63xgTeZd55Zwfgnw=; b=pwzasz5iO/g4SOwmBEkYDdc5C6Gv/I4jfGQTHoZswQH0Ab+ayU3kjkCLMR5FsCTJvu 8jm/NZaGWFJDISLQxYlHMc96viMCDtbwS5AMmr2O8KJ3Hmz3ZdOUDHf8h42Y0w6ghdE4 g9e2OfAwlxrZwYsaxqhlcxyH3MyhToRtPePFbBXtbmHdgRcKxVh1nFeB2iLCZC6DeG49 +gVmDMnug/iBlXCNErDy8LtuQCJ/d8aplM7IZ6omN+65NtJqgNbj4OpnrBq99evQvSew LY0vc2vvXCrMDhIA6vse4paaI4SXL0eLjqqSQb0TTHKa9vXrYrOS2xDOisgk2J1xKzvT vayg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=b6Tagel72i6eRMy2LqDw/acsw5t63xgTeZd55Zwfgnw=; b=nILczj5vlNhcZCE4e+Tmd32BrVdu1SuwKvzo4ctjXwyGusoqdZtG/AmD/ViQVxvEX6 ZVyJxo/zPLWwHxJBsiK3ldqDbvWv+KzZoyKr3AgC/XVLKlTWIMuFNZ24q209wFLopaDx +8H7QXlntHXIcboiShOHdQHFzrUf1EZNTXAPUiuVn47NqFxooXYPUux+YeytKrGTjnw+ Jfa2rjNnUPet58ONNEq2e/MCO4AIsxWwhXsTIQ8gRiwvzXSkol1Hq8zwa8BljyGACiNK t2jgJljPGn0xUkXfyUnDRR43bnvgCsiaixJVxhG1JoiOJCGL1mLgokL0s5/vARQSVQoB A3+A== X-Gm-Message-State: AN3rC/7bOwdzxCCSKldHlqPhSudd3ngFly8DgF0aW84Gw4igYcAKfSRR I23iL7Wl4Lzm4w== X-Received: by 10.55.46.198 with SMTP id u189mr10154265qkh.20.1493396755054; Fri, 28 Apr 2017 09:25:55 -0700 (PDT) Received: from wacom-arch2.corp.onewacom.com ([50.225.60.4]) by smtp.gmail.com with ESMTPSA id a76sm2688288qkj.42.2017.04.28.09.25.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Apr 2017 09:25:54 -0700 (PDT) From: Jason Gerecke To: linux-input@vger.kernel.org Cc: Jiri Kosina , Benjamin Tissoires , Ping Cheng , Aaron Skomra , Jason Gerecke , Jason Gerecke Subject: [PATCH 2/5] HID: wacom: generic: Ignore HID_DG_BATTERYSTRENTH == 0 Date: Fri, 28 Apr 2017 09:25:31 -0700 Message-Id: <20170428162534.3051-2-killertofu@gmail.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170428162534.3051-1-killertofu@gmail.com> References: <20170428162534.3051-1-killertofu@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP AES sensors use the value 0 to indicate "not available" rather than "completely dead". Such values are often sent for dozens of reports while the pen is being brought into proximity and can cause userspace to get the wrong impression about the actual battery state. Signed-off-by: Jason Gerecke --- drivers/hid/wacom_wac.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c index 1878da3321f8..c3f8fe152e48 100644 --- a/drivers/hid/wacom_wac.c +++ b/drivers/hid/wacom_wac.c @@ -2034,6 +2034,8 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field wacom_wac->hid_data.sense_state = value; return; case HID_DG_BATTERYSTRENGTH: + if (value == 0) /* "not available" */ + break; value = value * 100 / (field->logical_maximum - field->logical_minimum); wacom_wac->hid_data.battery_capacity = value; wacom_wac->hid_data.bat_connected = 1;