From nobody Sat Feb 7 15:30:06 2026 Received: from outboundhk.mxmail.xiaomi.com (outboundhk.mxmail.xiaomi.com [118.143.206.90]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 690E11B4F0A; Fri, 10 Oct 2025 10:43:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=118.143.206.90 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760093039; cv=none; b=XH7koABUN/ELGbgKsVyQWY/xPPI36aVI+UN44m4OBupcBO+0920c3BlEDVz64LxJDYFvJ8wH5EA38wY7wDVtl9Fec6YvNoMepfqFeuKFgfWuCs7PI9rv0p7P9M0sZmp7l0c4c4weR3Taq7BdyaCXRN6MHNJhAlH0Y4wUwJBJIYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760093039; c=relaxed/simple; bh=w0UyaiAGorJJnhWsrzaZobRZhjWgzEJUC6LvbliauOY=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=HQCZ/oWaPk5sPGFQrnwEenUM5zEgGqHL+v6SCZZc3EXNWs+g17NiVNDHmtMPC/RRC+XAw6fcAfFtnKC7L888mrG1U4h85nkNH2xyK27E98+xPjxh353WQaEkaL2cHiIXOE5k3sNWteUZv7hV6KxQ5Hdl7OxnLbE92Dfo/J//4Jc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=xiaomi.com; spf=pass smtp.mailfrom=xiaomi.com; arc=none smtp.client-ip=118.143.206.90 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=xiaomi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xiaomi.com X-CSE-ConnectionGUID: sUathrCVT9aW9ipNGqGSqw== X-CSE-MsgGUID: tQUFshdUQn68vzO/1OHzxA== X-IronPort-AV: E=Sophos;i="6.19,218,1754928000"; d="scan'208";a="129069490" From: =?gb2312?B?wqy5+rrq?= To: Dmitry Torokhov , Jiri Kosina , Benjamin Tissoires CC: "kenalba@google.com" , "linux-input@vger.kernel.org" , "linux-kernel@vger.kernel.org" , =?gb2312?B?wO7F9A==?= , =?gb2312?B?y87D3MPc?= , =?gb2312?B?wqy5+rrq?= Subject: =?gb2312?B?tPC4tDogW0V4dGVybmFsIE1haWxdW1BBVENIXSBISUQ6IGhpZC1pbnB1dDog?= =?gb2312?Q?only_ignore_0_battery_events_for_digitizers?= Thread-Topic: [External Mail][PATCH] HID: hid-input: only ignore 0 battery events for digitizers Thread-Index: AQHcOazZHRANaD7djkOKShmNHYh1F7S7MO8b Date: Fri, 10 Oct 2025 10:43:55 +0000 Message-ID: <6ec0ba2fd4ba42bf91fa8c5dbfb5e1c0@xiaomi.com> References: In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Thanks, Dmitry. Hi Jiri Kosina, Benjamin Tissoires, please let me know once you've merged t= his patch into the kernel. Thanks! ________________________________________ =E5=8F=91=E4=BB=B6=E4=BA=BA: Dmitry Torokhov =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2025=E5=B9=B410=E6=9C=8810=E6=97=A5 1= 4:12 =E6=94=B6=E4=BB=B6=E4=BA=BA: Jiri Kosina; Benjamin Tissoires =E6=8A=84=E9=80=81: =E5=8D=A2=E5=9B=BD=E5=AE=8F; kenalba@google.com; linux-= input@vger.kernel.org; linux-kernel@vger.kernel.org =E4=B8=BB=E9=A2=98: [External Mail][PATCH] HID: hid-input: only ignore 0 ba= ttery events for digitizers [=E5=A4=96=E9=83=A8=E9=82=AE=E4=BB=B6] =E6=AD=A4=E9=82=AE=E4=BB=B6=E6=9D=A5= =E6=BA=90=E4=BA=8E=E5=B0=8F=E7=B1=B3=E5=85=AC=E5=8F=B8=E5=A4=96=E9=83=A8=EF= =BC=8C=E8=AF=B7=E8=B0=A8=E6=85=8E=E5=A4=84=E7=90=86=E3=80=82=E8=8B=A5=E5=AF= =B9=E9=82=AE=E4=BB=B6=E5=AE=89=E5=85=A8=E6=80=A7=E5=AD=98=E7=96=91=EF=BC=8C= =E8=AF=B7=E5=B0=86=E9=82=AE=E4=BB=B6=E8=BD=AC=E5=8F=91=E7=BB=99misec@xiaomi= .com=E8=BF=9B=E8=A1=8C=E5=8F=8D=E9=A6=88 Commit 581c4484769e ("HID: input: map digitizer battery usage") added handling of battery events for digitizers (typically for batteries presented in styli). Digitizers typically report correct battery levels only when stylus is actively touching the surface, and in other cases they may report battery level of 0. To avoid confusing consumers of the battery information the code was added to filer out reports with 0 battery levels. However there exist other kinds of devices that may legitimately report 0 battery levels. Fix this by filtering out 0-level reports only for digitizer usages, and continue reporting them for other kinds of devices (Smart Batteries, etc). Reported-by: =E5=8D=A2=E5=9B=BD=E5=AE=8F Tested-by: =E5=8D=A2=E5=9B=BD=E5=AE=8F Fixes: 581c4484769e ("HID: input: map digitizer battery usage") Signed-off-by: Dmitry Torokhov --- drivers/hid/hid-input.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index ff1784b5c2a4..ba3f6655af9e 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -595,14 +595,18 @@ static void hidinput_cleanup_battery(struct hid_devic= e *dev) dev->battery =3D NULL; } -static void hidinput_update_battery(struct hid_device *dev, int value) +static void hidinput_update_battery(struct hid_device *dev, + unsigned int usage, int value) { int capacity; if (!dev->battery) return; - if (value =3D=3D 0 || value < dev->battery_min || value > dev->batt= ery_max) + if ((usage & HID_USAGE_PAGE) =3D=3D HID_UP_DIGITIZER && value =3D= =3D 0) + return; + + if (value < dev->battery_min || value > dev->battery_max) return; capacity =3D hidinput_scale_battery_capacity(dev, value); @@ -1518,7 +1522,7 @@ void hidinput_hid_event(struct hid_device *hid, struc= t hid_field *field, struct bool handled =3D hidinput_set_battery_charge_status(hid, us= age->hid, value); if (!handled) - hidinput_update_battery(hid, value); + hidinput_update_battery(hid, usage->hid, value); return; } -- 2.51.0.740.g6adb054d12-goog -- Dmitry #/******=E6=9C=AC=E9=82=AE=E4=BB=B6=E5=8F=8A=E5=85=B6=E9=99=84=E4=BB=B6=E5= =90=AB=E6=9C=89=E5=B0=8F=E7=B1=B3=E5=85=AC=E5=8F=B8=E7=9A=84=E4=BF=9D=E5=AF= =86=E4=BF=A1=E6=81=AF=EF=BC=8C=E4=BB=85=E9=99=90=E4=BA=8E=E5=8F=91=E9=80=81= =E7=BB=99=E4=B8=8A=E9=9D=A2=E5=9C=B0=E5=9D=80=E4=B8=AD=E5=88=97=E5=87=BA=E7= =9A=84=E4=B8=AA=E4=BA=BA=E6=88=96=E7=BE=A4=E7=BB=84=E3=80=82=E7=A6=81=E6=AD= =A2=E4=BB=BB=E4=BD=95=E5=85=B6=E4=BB=96=E4=BA=BA=E4=BB=A5=E4=BB=BB=E4=BD=95= =E5=BD=A2=E5=BC=8F=E4=BD=BF=E7=94=A8=EF=BC=88=E5=8C=85=E6=8B=AC=E4=BD=86=E4= =B8=8D=E9=99=90=E4=BA=8E=E5=85=A8=E9=83=A8=E6=88=96=E9=83=A8=E5=88=86=E5=9C= =B0=E6=B3=84=E9=9C=B2=E3=80=81=E5=A4=8D=E5=88=B6=E3=80=81=E6=88=96=E6=95=A3= =E5=8F=91=EF=BC=89=E6=9C=AC=E9=82=AE=E4=BB=B6=E4=B8=AD=E7=9A=84=E4=BF=A1=E6= =81=AF=E3=80=82=E5=A6=82=E6=9E=9C=E6=82=A8=E9=94=99=E6=94=B6=E4=BA=86=E6=9C= =AC=E9=82=AE=E4=BB=B6=EF=BC=8C=E8=AF=B7=E6=82=A8=E7=AB=8B=E5=8D=B3=E7=94=B5= =E8=AF=9D=E6=88=96=E9=82=AE=E4=BB=B6=E9=80=9A=E7=9F=A5=E5=8F=91=E4=BB=B6=E4= =BA=BA=E5=B9=B6=E5=88=A0=E9=99=A4=E6=9C=AC=E9=82=AE=E4=BB=B6=EF=BC=81 This = e-mail and its attachments contain confidential information from XIAOMI, wh= ich is intended only for the person or entity whose address is listed above= . Any use of the information contained herein in any way (including, but no= t limited to, total or partial disclosure, reproduction, or dissemination) = by persons other than the intended recipient(s) is prohibited. If you recei= ve this e-mail in error, please notify the sender by phone or email immedia= tely and delete it!******/#