From: "José Expósito" <jose.exposito89@gmail.com>
To: 卢国宏 <luguohong@xiaomi.com>
Cc: "jikos@kernel.org" <jikos@kernel.org>,
"bentiss@kernel.org" <bentiss@kernel.org>,
"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
"torvalds@linux-foundation.org" <torvalds@linux-foundation.org>,
"linus@linuxfoundation.org" <linus@linuxfoundation.org>,
"jkosina@suse.cz" <jkosina@suse.cz>
Subject: Re: 转发: commit?a608dc1c06397dc50ab773498433432fb5938f92 (patch) has a bug
Date: Sat, 2 Aug 2025 18:30:26 +0200 [thread overview]
Message-ID: <aI49Im0sGb6fpgc8@fedora> (raw)
In-Reply-To: <b3cf760898054fb1adb4285e84f4a702@xiaomi.com>
Hi 卢国宏,
Thanks a lot for reporting this issue.
On Sat, Aug 02, 2025 at 12:23:54PM +0000, 卢国宏 wrote:
> Hello, José and Jiri!
> I've discovered that the patch you submitted to the Linux community,
> "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-6.3.y&id=a608dc1c06397dc50ab773498433432fb5938f92"
> contains a bug. Even with your patch, the charging status of HID
> devices is still not reported to upper layers in a timely manner.
> The reasons are as follows:
>
> [...]
>
> if function hidinput_set_battery_charge_status() return true, That is,
> the charging status of the HID device has changed,This charging status
> will not be reported,Because, only when handled is false,
> "hid input update battery(hid, value);" will be called.
I wrote this patch a while ago and I can't remember the exact reason
why hidinput_update_battery() is only called by hidinput_hid_event()
when hidinput_set_battery_charge_status() returns false.
The devices I have change their status, for example, discharging to
charging, when they are connected via Bluetooth and I switch them to
USB. This reconnection reports the status to user-space, so there is
no need for additional synchronization.
Does your device work in the same manner?
However, before we try to fix the problem, it would be nice if you
could provide a reproducer.
What device is affected by this bug?
By using "sudo hid-recorder" and selecting your device, you will be
able to capture and replay (with "hid-replay") the HID events sent
by your device.
Could you share a recording of your device changing from the charging
to discharging status and back to charging so we can reproduce the
issue, please?
If the recording is too long, please upload it to a server.
> Therefore, the function "hidinput set battery charge status" can be
> changed to the following:
>
> static bool hidinput_set_battery_charge_status(struct hid_device *dev,
> + unsigned int usage, int value)
> +{
> + switch (usage) {
> + case HID_BAT_CHARGING:
> + dev->battery_charge_status = value ?
> + POWER_SUPPLY_STATUS_CHARGING :
> + POWER_SUPPLY_STATUS_DISCHARGING;
> + power_supply_changed(dev->battery);
> + return true;
> + }
> +
> + return false;
> +}
Could you test if this patch also solves your problem, please?
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 9d80635a91eb..bce580beb5c6 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -1515,11 +1515,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
return;
if (usage->type == EV_PWR) {
- bool handled = hidinput_set_battery_charge_status(hid, usage->hid, value);
-
- if (!handled)
- hidinput_update_battery(hid, value);
-
+ hidinput_set_battery_charge_status(hid, usage->hid, value);
+ hidinput_update_battery(hid, value);
return;
}
Thanks a lot in advance,
José Expósito
> Because we have encountered this problem in our project, and this
> method can solve it.
> I hope you can solve this problem as soon as possible, otherwise,
> we will encounter this problem again in our future projects.
>
> Thank you so much!
next parent reply other threads:[~2025-08-02 16:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <51055c7ae10e40319473938f831d0af8@xiaomi.com>
[not found] ` <b3cf760898054fb1adb4285e84f4a702@xiaomi.com>
2025-08-02 16:30 ` José Expósito [this message]
[not found] ` <db380722eb484dedbf77ec6304c6ca7c@xiaomi.com>
2025-08-04 9:20 ` 答复: [External Mail]Re: 转发: commit?a608dc1c06397dc50ab773498433432fb5938f92 (patch) has a bug José Expósito
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aI49Im0sGb6fpgc8@fedora \
--to=jose.exposito89@gmail.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=jkosina@suse.cz \
--cc=linus@linuxfoundation.org \
--cc=linux-input@vger.kernel.org \
--cc=luguohong@xiaomi.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).