Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp271760ybi; Wed, 29 May 2019 21:06:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdh5PEe5/ONAE2TW5dUw0pqtVf8Gn99FsIMJBVRgb2s5bc3NDKyT6Sr2z8XoGi9W+R303i X-Received: by 2002:a63:7146:: with SMTP id b6mr1920626pgn.426.1559189180935; Wed, 29 May 2019 21:06:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189180; cv=none; d=google.com; s=arc-20160816; b=ia6IFjxvGw628TopID0B59PDn2kzGzAhaOY4RbwaIW1JxKFJ3tm0OiAeulUNFHAwGC WiD9lPhQaPZpgG+ckaTKmeIyXOmrVen2WpsXCQKVnfObo0TWb5LHrZ9VUTB4aQiQn7Nt yS6jXlJkvaFOpnlnXGnMTaiVMIkBDa4xRJw6hhwHBPkIEH/0tHXeC3qVeCJEFP4hSZSQ cC2L6YxsjasrwLlwaVu/nmgXTS0GjakCXbG2Nhc7F6GN9JNauxThFkyfghrlcSWaaUAL nvl3m/IB3mjdSGAy67duIfsxrKrm0BdNFSDTT1BsfqeZaL+C2BZFAEPOCh7QM3AW1Aax vmBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UE1e3++DDq9pg3ngEqocnk34sSnrM2OQsyrK0+XrqjI=; b=mjFoeay8zHv1b7PeHtvSyXJeQgoyGh+OahoAme0lz9vsJJ+sRFk+0hdXxjlYSt+HHy AQFvONIniB7uqGkQMc0qKaiabf+BCEHsd/nCBJpe+QMA9CsYiGva/eyjBFkJBSskgKEX 4DX/+rrU1N/MzBbFCp5uidiAkYv+E9YBEL5GTLEvfHmbgEUUy1iRCysB0PuXAEt+BTOp 4fqFfhO36dIbetr7JLguk6kd2s7PliOmSoHFOia12R2lRzXeYX0zfGBDVhaSPVAukz+8 pjlH3ZzrLVzOxKMK6t6ZLkx3Tv+OKIj9AuREoGFwFgzbzpwu0chxhqBHJftbHOpmnlL+ 1dAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QQJG4Fh+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w19si1855410pgj.121.2019.05.29.21.06.04; Wed, 29 May 2019 21:06:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QQJG4Fh+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731761AbfE3EDi (ORCPT + 99 others); Thu, 30 May 2019 00:03:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:49208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731342AbfE3DRz (ORCPT ); Wed, 29 May 2019 23:17:55 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 42A25246F8; Thu, 30 May 2019 03:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186275; bh=+PorWUz6CDXhB4e4HZl+SYRrjgo07gaT0uiZuYhzznw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QQJG4Fh+iFDoyEUuLG0LMD6N8IOZEVckhUX7Cj0Qrf/s12fPy1JW5EqM3bxnW7pRN QktszfUnuTMoTHtaTk1Z+25nW0OAUkkA8/pcDSYUtomm+JdHphQjr/tKL2f0OWnqFN IsEaVPQn4A+N5tdOQ5j6gfQ+bo8GhQ/N9jGE8ub4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans de Goede , Jiri Kosina , Sasha Levin Subject: [PATCH 4.19 217/276] HID: logitech-hidpp: change low battery level threshold from 31 to 30 percent Date: Wed, 29 May 2019 20:06:15 -0700 Message-Id: <20190530030538.701024774@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 1f87b0cd32b3456d7efdfb017fcf74d0bfe3ec29 ] According to hidpp20_batterylevel_get_battery_info my Logitech K270 keyboard reports only 2 battery levels. This matches with what I've seen after testing with batteries at varying level of fullness, it always reports either 5% or 30%. Windows reports "battery good" for the 30% level. I've captured an USB trace of Windows reading the battery and it is getting the same info as the Linux hidpp code gets. Now that Linux handles these devices as hidpp devices, it reports the battery as being low as it treats anything under 31% as low, this leads to the user constantly getting a "Keyboard battery is low" warning from GNOME3, which is very annoying. This commit fixes this by changing the low threshold to anything under 30%, which I assume is what Windows does. Signed-off-by: Hans de Goede Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-logitech-hidpp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index edf224ad13369..e642cfaf303b4 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -910,7 +910,11 @@ static int hidpp_map_battery_level(int capacity) { if (capacity < 11) return POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL; - else if (capacity < 31) + /* + * The spec says this should be < 31 but some devices report 30 + * with brand new batteries and Windows reports 30 as "Good". + */ + else if (capacity < 30) return POWER_SUPPLY_CAPACITY_LEVEL_LOW; else if (capacity < 81) return POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; -- 2.20.1