Re: [PATCH] hwmon: (corsair-psu) serialize debugfs access against hwmon

Ali Ahmet Memis <[email protected]> Tue, 4 Aug 2026 09:47:53 +0000
Newsgroups org.kernel.vger.linux-hwmon,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Tue, 04 Aug 2026 04:11:11 +0000 Wilken Gottwalt wrote:
> I was playing with the idea to (1) remove the raw HID mode completely or
> (2) make the driver switchable, raw HID or normal HID, but not both at the
> same time.

Two different things are getting mixed together here, which may be why the
answers you got do not agree with each other.

->raw_event is not the userspace side. It is how the driver receives its
replies: corsairpsu_usb_cmd() sends the report and then blocks on
wait_completion, and corsairpsu_raw_event() is what fills cmd_buffer and
completes it. Take that away and no command ever returns.

The raw HID mode you can actually drop is HID_CONNECT_HIDRAW in
hid_hw_start(), which is what creates /dev/hidrawN. That one is allowed to
go: hid_connect() only refuses a device with no listeners if the driver has
no ->raw_event, and this driver has one.

Dropping it does not fix the cmd_buffer problem though, it only removes one
way to trigger it. The window is internal: usb_cmd() times out, the reply
arrives late anyway, the next command's reinit_completion() re-arms the
guard at the top of raw_event, and that stale reply is taken as the answer
to the new command. Nothing in userspace is needed for that.

One thing worth checking before going with (1): if your libhidapi tool uses
the hidraw backend it goes through /dev/hidrawN, so removing
HID_CONNECT_HIDRAW would take that tool's access away as well.