From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dy1-f180.google.com (mail-dy1-f180.google.com [74.125.82.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 522C7317173 for ; Fri, 27 Mar 2026 15:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774626152; cv=none; b=tRSbZ1D79LjbvXnlS49ifqaDl2lXvKt6Nb6n1XOQsWJiBz+irrMXIaFcWybThTFYYXh1rUlb4h88JonjFOrCqPApJV4F1yB7CpgMqmvYBCHCspmEzAsiGfQRwthGUaU39+jHRnzDwoF6k6o64UvHbPowb+4s7iMtRadjdO1QZQc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774626152; c=relaxed/simple; bh=wHClqSYMk00dSTT8QPLbIwzBEr1/LNNGBDfrcYSBl74=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bg6Vw3ToJdy/D24fPCMriN+TJNqgVIEkQPJruNGiXFLiAVofoPYDhXZZ5IPSG3DuBJDrMPeJlqGbgEuritauW90hmOsana9NBrTCBIFIusX3AZLbB6GUmuYD6h9SODxgrKV/2/EEFnvsjooFDAfK+C6U/nyVK0yYgmRB6+ydnNU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=B21bnswd; arc=none smtp.client-ip=74.125.82.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B21bnswd" Received: by mail-dy1-f180.google.com with SMTP id 5a478bee46e88-2bdd40d3c61so1928064eec.1 for ; Fri, 27 Mar 2026 08:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774626149; x=1775230949; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:from:to:cc:subject:date:message-id:reply-to; bh=PlGnbqGG5xeLchwn0WE7eEoM2zOVzOibg54QmCQ/Nyk=; b=B21bnswdivCVyVZjfuDW5pI+VrLIn1g6YXXzknxP1FOdntNiZGtvUPzB6zDjPI8KWv YJ+7S2r9dNmn79QzcxT9lFcVyjFNaK9cwGiFarMZuYSEpl+0+jFCdw+etuqbB22dJJ4B stohiSw7T60bf/AGYTkNk+ZKeDgcVEW5G+QStD0FH1/zwO7kNzInZ+Vg/yQPznDkFEgD vEQBvaglPl4+U2Tapmws4CFsIpsu4y9FpM2qDqcQjWLEtFHMIUqHlmWg8xHRbc2AMcqZ wX6x6owiblfzwvicHuSsFR5hdqjLcj2jIccGdqAvusErOa8buhy6cECbX9zFvVcIaTxZ zubg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774626149; x=1775230949; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PlGnbqGG5xeLchwn0WE7eEoM2zOVzOibg54QmCQ/Nyk=; b=AW+UlRlFd/4Rpf2FRqVdtv/zrikhKODMs2aZaZDIO+bhw89q8r8PgCEBU4iePCrLQa Q7uTz2aZPLxVCa/hF6D+joVjEfysc+UwzSQLygMbLfay7tmyMKy14WFKcidw+pcJCMJr g7ts8zpin3VEVsUQWEtzOBK6wpnwmBU+f53Ihg8le2Rg3BuPPAndz7ilaD6cKpSbvfck 7xq+hbZKoPTiWVxmexglj5rxi1MpEdHUzb/UOMR7mC1d5ZZX55LHFx6Yj8I+AQgOL8hA yZ8SqaMiiPtlu//+G5adlHrDIBnd3A8AS+UqF4q0rjKzrjrot3hLmHuD7L7E4/Up7Qmx NAlg== X-Forwarded-Encrypted: i=1; AJvYcCWgC1wiiWXplGR+TeTf52R/CSKrdz8bQMg+ChUrjl54Ectn8ThJYAle0xV27ccQSxlJrmFvjl4UVucjXGw=@vger.kernel.org X-Gm-Message-State: AOJu0YyinEkAkSv+EPm47ON7OOkGBMybgHoDHD8ppiuqYyMhmvWPlOcM PSQmcifXBMBPCrCNjE3Tv7ClspocNZ9rahEc4xYnhC3h1QGguAaPk0eX X-Gm-Gg: ATEYQzxMTAYQPpz1DSqEAFchkUSMB3Z0NbyaRTGUNOmR1BwG9N8DSeYMUXdEJRSK+C/ ub9qUA/ydCwwZByXjye3S+072UWspM3KKELpvVM/8tKZclq01sHl9dBCqJVuXcE2Ci0pQapxK8z pRSFn2d/tVXMIAaXPyvMhOIo91QVn3ShuSve7xdMVsPm7kmG5URSJXIhKC11ht55hOGR1v2r9Zl 4U79H4hZxR31YvPFPsfGDbrpggd4aQC1j9QVRa9eQ+QndApKIYFdqUHtuHz4k/LxjP/IBS8w/jO EqYzbGfFX2Ay7wYGvxEhbuX4nKc4ctjzscFaBFu2j4+zfoL97U1raWkR0SyaWsPY9KKHJWBaQ8I 6UlsqiYeG5E/ZPmzBHP1EiC6I3UssSB5xNwhP3157P+t5SauQo31787jfbUNkjsNx150ih9xQUA bPjbfWyq4iGbPwGT60ApKBUMSfxLE+pjkMkwAXbU33xnBRvKHKLur05HVXiY/apR1PZRKuML/P X-Received: by 2002:a05:7300:ac8a:b0:2c0:c754:cd86 with SMTP id 5a478bee46e88-2c185a762c8mr1592883eec.0.1774626149202; Fri, 27 Mar 2026 08:42:29 -0700 (PDT) Received: from ?IPV6:2600:1700:e321:62f0:da43:aeff:fecc:bfd5? ([2600:1700:e321:62f0:da43:aeff:fecc:bfd5]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2c16ea7bde3sm5316665eec.0.2026.03.27.08.42.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Mar 2026 08:42:28 -0700 (PDT) Sender: Guenter Roeck Message-ID: Date: Fri, 27 Mar 2026 08:42:26 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/4] hwmon: Add WITRN USB tester driver To: Rong Zhang , Jonathan Corbet , Shuah Khan Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org References: <20260327-b4-hwmon-witrn-v1-0-8d2f1896c045@rong.moe> <5ee967a8a4dca6f70e50c7fac382d4f91b6620aa.camel@rong.moe> Content-Language: en-US From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1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6CcFd6j72kRfxklOqXw zvy+2NEcXyziiLXp84130yxAKXfluax9sZhhrhKT6VrD45S6N3HxJpXQ/RY/EX35neH2/F7B RgSloce2+zWfpELyS1qRkCUTt1tlGV2p+y2BPfXzrHn2vxvbhEn1QpQ6t+85FKN8YEhJEygJ F0WaMvQMNrk9UAUziVcUkLU52NS9SXqpVg8vgrO0JKx97IXFPcNh0DWsSj/0Y8HO/RDkGXYn FDMj7fZSPKyPQPmEHg+W/KzxSSfdgWIHF2QaQ0b2q1wOSec4Rti52ohmNSY+KNIW/zODhugJ np3900V20aS7eD9K8GTU0TGC1pyz6IVJwIE= In-Reply-To: <5ee967a8a4dca6f70e50c7fac382d4f91b6620aa.camel@rong.moe> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/27/26 05:01, Rong Zhang wrote: > Hi Guenter, > > Thanks a lot for your review and applying patch 1 :-) > > On Thu, 2026-03-26 at 17:05 -0700, Guenter Roeck wrote: >> On 3/26/26 12:19, Rong Zhang wrote: >>> WITRN produces a series of devices to monitor power characteristics of >>> USB connections and display those on a on-device display. Most of them >>> contain an additional port which exposes the measurements via USB HID. >>> >>> These devices report sensor values in IEEE-754 float (binary32) format. >>> The driver must perform floating-point number to integer conversions to >>> provide hwmon channels. Meanwhile, they also report accumulative float >>> values, and simple division or multiplication turns them into useful >>> hwmon channels. >>> >>> Patch 1 adds label support for 64-bit energy attributes, as the driver >>> needs it. >>> >>> Patch 2 adds a helper module for floating-point to integer conversions, >>> so that the conversion, multification and division methods can be used >>> in this driver as well as other drivers (I am also working on another >>> USB tester driver that needs it). >>> >>> Patch 3 adds a barebone HID driver for WITRN K2. >>> >>> Patch 4 adds hwmon channels and attributes to the driver. >>> >>> Signed-off-by: Rong Zhang >>> --- >>> Rong Zhang (4): >>> hwmon: Add label support for 64-bit energy attributes >>> hwmon: New helper module for floating-point to integer conversions >> >> Nack. This is not a hwmon problem and should reside in a driver or in lib/ >> (if it is needed by multiple drivers). > > Makes sense. I will try. > >> >>> hwmon: Add barebone HID driver for WITRN >> >> Nack. This is the wrong place for such a driver. It should reside somewhere >> in drivers/usb, or maybe in drivers/misc/. > > Hmm, I decided to place it here because: > > - It's not a hid_ll_driver but a dumb hid_driver, i.e., does no low > level things but just receives hid event from the HID core. It doesn't > even send any HID report to the device. > > - There has been numerous hid_driver in drivers/hwmon/. > > - There has been a similar USB tester driver in drivers/hwmon/, i.e., > powerz. That's the major reason of my decision. > powerz is a pure hwmon driver, nothing else. It does not claim to be a "pure hid driver". If your driver _only_ provides a hwmon ABI, it would be acceptable. But then this and the next patch should be one patch, and it should only provide the hwmon ABI, nothing else (except maybe debugfs entries or sysfs entries attached directly to the HID device to display information such as serial number etc). Reading ROM/RAM addresses, as mentioned below, would be outside that scope. The entire powerz driver is 269 lines of code. Your driver has well above 1,000 LOC. Your code has separate source files plus an include file. That suggests that it does more than just reporting hardware monitoring attributes. I have not looked further into the code itself. My response is based purely on the subjects and code organization, which suggests that this is a HID driver with attached hardware monitoring. I am not sure I understand what all that would have to do with UCSI. UCSI support is implemented in drivers/usb/typec/ucsi. Anything associated with that protocol should be implemented there if it is part of the protocol. > Could you kindly explain what kinds of driver can be accepted into > drivers/hwmon/? > >> >>> hwmon: (witrn) Add monitoring support >> >> This should be implemented as auxiliary driver. > > Could you kindly elaborate? Did you mean that if the device supports > multiple functionalities they should be implemented as multiple > auxiliary drivers in different subsystems? > Correct. Your series suggests that this would be the case. > FYI, the USB tester doesn't provide any other meaningful feature that > fits other subsystems. The tester only provides two features through USB > HID: power measurements (this series), and raw PD packets sniffing. > Again, support for raw PD packets sniffing would be outside the scope of the hardware monitoring subsystem. Thanks, Guenter > As for the latter, the USB tester can sniff raw PD packets between the > source and sink if enabled in the device menu. It doesn't provide the > parsed result for packets, and the PC cannot ask the tester to send PD > packets. This doesn't fit UCSI at all, as a UCSI device operates at a > higher level and must accept commands. AFAIK such a dumb sniffer won't > fit any subsystem in the kernel. Hence, the only thing fits a subsystem > is its power measurements. > > All measurements supported by the official utility for Windows can be > found in `struct witrn_sensor'. Other than that, all extra features > provided by the utility are implemented in software and I didn't see any > extra USB packets other than querying the serial number [1] when I was > randomly messing around with the utility [2]. > > I separated patch 3 and 4 just for easier review. If you are not in > favor of such a style, I will squash them. > > [1]: In fact, the utility directly asks the device to return the content > on several specific ROM/RAM addresses, and then the utility calculates > the serial number with an unknown algorithm. Reading a ROM/RAM address > seems to be the only command that the device accepts from the USB host. > > [2]: Yeah, their utility does not support PD packet capturing or > parsing. It seems that the manufacturer provides the PD sniffing feature > as is and expects users to capture it via hidraw or libusb and parse it > themselves. > >> >> Sashiko has a lot of feedback that you might want to address before >> resubmitting. >> >> https://sashiko.dev/#/patchset/20260327-b4-hwmon-witrn-v1-0-8d2f1896c045%40rong.moe > > Sashiko's feedback helps a lot. Thanks. > > Thanks, > Rong > >> >> Thanks, >> Guenter >> >>> >>> Documentation/hwmon/index.rst | 1 + >>> Documentation/hwmon/witrn.rst | 53 ++++ >>> MAINTAINERS | 7 + >>> drivers/hwmon/Kconfig | 14 + >>> drivers/hwmon/Makefile | 2 + >>> drivers/hwmon/hwmon-fp.c | 262 ++++++++++++++++ >>> drivers/hwmon/hwmon-fp.h | 212 +++++++++++++ >>> drivers/hwmon/hwmon.c | 1 + >>> drivers/hwmon/witrn.c | 691 ++++++++++++++++++++++++++++++++++++++++++ >>> 9 files changed, 1243 insertions(+) >>> --- >>> base-commit: 0138af2472dfdef0d56fc4697416eaa0ff2589bd >>> change-id: 20260327-b4-hwmon-witrn-a629b9040250 >>> >>> Thanks, >>> Rong >>>