Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp260971ybi; Wed, 29 May 2019 20:53:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqxf3L0YLyUNkPEzKxJSMJLLWJk9lEDwZ4qqlqiuk6VO7+AjfBW7dY2Da+/e0Uf5MOC31C0y X-Received: by 2002:a65:63cd:: with SMTP id n13mr1770886pgv.153.1559188386752; Wed, 29 May 2019 20:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559188386; cv=none; d=google.com; s=arc-20160816; b=hWR1bt+a76yQyApyT6Ma4zmTquoRVV0lzWnC7YItxKywjoeaf+UPzT74+u/xx9XOMp a0nL9hwGb3EWSYFI+glU7xgOaKaGuVO4LQWD+npQifL4vGifmKjdOsVN+VBvF49zXe+K CcPkAIb8U+wHOIoDqSGZC4G9ALAfDiNHnoliD8NnzzYiGi74jiMSsFgxr1zQySWgKjWC YfV3/Hl/4yoyQgkGJkMizPTRGe1XnrzFZcIO+1Q/e78Xr6qVL1BDy/e7OGCQMjY1HPsZ AmIWMsp1v89UJ3SAFA/Hjtr4WEymoHkyG1EmSnMfnLtCBiZJeIChs6S8N75jsKnlcviA BOcg== 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=Gp9DQPXMN03amnQWjNYzVkLzad2J/s48V2l/hhEbW5E=; b=0/PBixNuWei0uLFo5NPbQoqKq+odOTxywzfXppya0PHrChPeKCqbloE3Dz5T4oIql+ zwHPZWxP22w/luIIS0oDYLHVeXlGKcKFRJxJ/0ixIJspso0e+VHORhqyI9no17HoKtuQ 6WWqFwxAs7oq1Oxc9BXUh+/h5KO0NbA9xdliRwUPzXBhxQPlTUeYo2OEdP+OrSuMkFro ANO5sn4IUlCJeu4WSmzrsMvjg39RxiCTtRdui0IcATDTOlQOcc393qypLQXjBhl6JQMi m4NG8JkkIpaBU/nRygVU0dPkC70MoPKtD6oFqNwtqjl92De0Yb6rVVC1IPWjAyNaiS6y taYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tvqr2LqE; 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 m13si1486475pjr.102.2019.05.29.20.52.50; Wed, 29 May 2019 20:53:06 -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=tvqr2LqE; 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 S2387449AbfE3DvA (ORCPT + 99 others); Wed, 29 May 2019 23:51:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:56488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732050AbfE3DTv (ORCPT ); Wed, 29 May 2019 23:19:51 -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 7C631248E3; Thu, 30 May 2019 03:19:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186390; bh=m8QEM/pFxCfxTcHSKNahObBFJDwpB5U9Z7VT3abzRP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tvqr2LqEfjg072xKSPqQ3ns8k48hr3QTxybWikBFlX8vQeG1fubZkSR/k7kmEyXAp aA+PltccC0IRHoONHTV6ocoydnioayBY+gzx5VDRsmAUoGl2+h7kuVkqHfvbgX88LX tNToXhJzQzQF03t3i6INX2ZzeNmaiObYnMpaFdWI= 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.14 161/193] HID: logitech-hidpp: change low battery level threshold from 31 to 30 percent Date: Wed, 29 May 2019 20:06:55 -0700 Message-Id: <20190530030510.483197958@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030446.953835040@linuxfoundation.org> References: <20190530030446.953835040@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 d209b12057d59..b705cbb58ca6b 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