Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp3390787rwl; Sat, 5 Nov 2022 22:44:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6UmoNRpb7jFObGusB4wvLe633mLyC6Rhi6HivEdEKCUAg/vThoFFUqWk50ik9s4zT/OdSo X-Received: by 2002:a05:6402:4d9:b0:462:e787:3bf8 with SMTP id n25-20020a05640204d900b00462e7873bf8mr43648097edw.195.1667713447129; Sat, 05 Nov 2022 22:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667713447; cv=none; d=google.com; s=arc-20160816; b=AlmDI8nfOnQCsIRagGeZPYMt0Xcbok94esMlp+FKXnQnQkkZ7lxFmMiroUOVo3b5Kx 7NwBiOcnZGdr67WVssHCjK3ggZSw9rF6Mo0cwnrcoAbeFb+vcAv1per1qXYxkSgMl5vX q3bABFbRBpwpq1TL0QTv8eRly+qCfq+EbMyiz6pyWhvmAZm0Z2QSToSZ65ArRfTpCKdr aZTmoJi/boXPP+90neTnRIXUKqqsyXg9GY/+54F1oiSUUCfXTzq1Fy6e3JS+IuT/rlow 1J3/gevuj+1DiCaWUiGSBPAVRWOsK1QGWttKUzubLYEjZDGjdFO12Xs+DHxaXuT6EaSG tckw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=KdcHygyluxlSKZYhnOmBthfqKtj/GWkjEK+v9KvjztY=; b=x2wJ4FmVcVmn/Q6y+2Bb0iJ3LBYYqsTHQQ0x6HEZijp4I/WlqlZWaVQVhhXUsORvk3 ucfxa694/e3go1jUDh6CMqaBuR40NVK7w93x8hBCUlMPLZsprzwNr7v9hhD+eMhBGASH 049wiTioVXQ8fN3V5rsADCz2nYMTKWbFKzNFANsrdxPJGjOxstKnBQ/ueCSZc87u1x3t ZdNeBZ0B+bcLtQyzQgkET5M3mWMmESSsfzagj9tnadb6CgEKxEu3kku65jBuim0NEkN3 i7w82sykAidsy8JPAn/y6xamqeHN6J9BsDW+aG3EB9p7yQxAeVFclscMOn2W+7/q/wWE SAuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa42-20020a17090786aa00b0073fc8e72882si4997977ejc.28.2022.11.05.22.43.28; Sat, 05 Nov 2022 22:44:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229551AbiKFFfT (ORCPT + 98 others); Sun, 6 Nov 2022 01:35:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229464AbiKFFfP (ORCPT ); Sun, 6 Nov 2022 01:35:15 -0400 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9F6F62E1; Sat, 5 Nov 2022 22:35:10 -0700 (PDT) Received: by mail-pf1-f172.google.com with SMTP id g62so7892680pfb.10; Sat, 05 Nov 2022 22:35:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KdcHygyluxlSKZYhnOmBthfqKtj/GWkjEK+v9KvjztY=; b=fW6UwGe8o/Ye2VvIC4G/mRQYZUqUzC3TICxqAIhCgigDzUlNKtzQZ3DWpWaSIS7Dx0 Lj0mYdsFtfLSb/VXvUGMe4G1U3O09R1Ialntx4TNGj/8wU+QOBn6ivqyvZOZDScyOwG/ +1vyZUR+7Zq/qBzjZ/d4bWsCRCPY2MgR+/H16B30r3F1N9jqhH0FP4LeeYisW9MQe6Cw k8oS33/VpzLXjqnQzuYp1JXwCciUAyDfC1npGZheSNYzNBI2yjI8yLse6raoOV7DJnPe qq1dpVRxoLoQD+6fWi+XU6L41P0fWEfijhddktjTZEr8l8jBLzBK3KjzLRsBKIam7FOw 00TA== X-Gm-Message-State: ACrzQf1XqOlAZRrRq/8j5rrQFF5XpJZbN31Jccf9VS2pWG1iom/dp3/y jmfxdJ8Lqus9pt9JPPqzdZ6rd8CUQIRBWrgYlFyPD4Ic28UlSQ== X-Received: by 2002:a65:6894:0:b0:470:76d:6f4a with SMTP id e20-20020a656894000000b00470076d6f4amr19455046pgt.457.1667712910263; Sat, 05 Nov 2022 22:35:10 -0700 (PDT) MIME-Version: 1.0 References: <20221104073659.414147-1-mailhol.vincent@wanadoo.fr> <20221104171604.24052-1-mailhol.vincent@wanadoo.fr> <20221104171604.24052-4-mailhol.vincent@wanadoo.fr> In-Reply-To: From: Vincent MAILHOL Date: Sun, 6 Nov 2022 14:34:58 +0900 Message-ID: Subject: Re: [PATCH v2 3/3] can: etas_es58x: report the firmware version through ethtool To: Alan Stern Cc: Greg Kroah-Hartman , linux-can@vger.kernel.org, Marc Kleine-Budde , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun. 6 Nov. 2022 at 09:48, Alan Stern wrote: > On Sat, Nov 05, 2022 at 06:38:35PM +0100, Greg Kroah-Hartman wrote: > > On Sun, Nov 06, 2022 at 02:21:11AM +0900, Vincent MAILHOL wrote: > > > On Sat. 5 Nov. 2022 at 18:27, Vincent MAILHOL > > > wrote: > > > > On Sat. 5 Nov. 2022 at 17:36, Greg Kroah-Hartman > > > > wrote: > > It's late right now, and I can't remember the whole USB spec, but I > > think the device provides a list of the string ids that are valid for > > it. If so, we can add that to sysfs for any USB device out there, no > > matter the string descriptor number. > > No, there is no such list. > > > If not, maybe we can just iterate the 255 values and populate sysfs > > files if they are present? I'll dig up the USB spec tomorrow... > > Yes, we could do that. But the filename would have to be the string > id, which is not meaningful. We wouldn't be able to have labels like > "product-info" unless somehow a driver could provide the label. My shot on this would be like this: diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 549590e9c644..d0a4fc3ffe07 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -77,6 +77,19 @@ struct ieee1394_device_id { * Use the flag values to control which fields are compared. */ +/** + * struct custom_string - information of custom string and their indexes + * @idx: Index of the custom string descriptor. + * @label: Mnemotechnic, will be used as a filename for the sysfs entry. + * + * USB devices might expose some information in some customs strings. Drivers + * can use this structure to inform the USB core of where to find these. + */ +struct custom_string { + __u8 idx; + const char *label; +}; + /** * struct usb_device_id - identifies USB devices for probing and hotplugging * @match_flags: Bit mask controlling which of the other fields are used to @@ -110,6 +123,9 @@ struct ieee1394_device_id { * @driver_info: Holds information used by the driver. Usually it holds * a pointer to a descriptor understood by the driver, or perhaps * device flags. + * @customs_strings_table: devices using customs strings can use this table to + * inform the USB core of how to retrieve them. If used, must contained an + * empty terminating entry. * * In most cases, drivers will create a table of device IDs by using * USB_DEVICE(), or similar macros designed for that purpose. @@ -150,6 +166,7 @@ struct usb_device_id { /* not matched against */ kernel_ulong_t driver_info __attribute__((aligned(sizeof(kernel_ulong_t)))); + const struct custom_string *custom_strings_table; }; /* Some useful macros to use to create struct usb_device_id */ Then the driver would declare its custom stings like this: static const struct custom_string es58x_custom_strings_table[] = { { .idx = 6, .label = "product_info" }, { /* Terminating entry */ } }; Finally, the USB core can iterate through it and populate the sysfs entries using the provided label. > Also, there's the matter of language. Devices can have string > descriptors in multiple languages; which one should we show in sysfs? > All of them? Right now we use just the default language for the strings > that we put in sysfs. I do not have the knowledge to comment on the multiple languages issue. FYI, the device which I maintain does not have multiple languages. > > I say do this at the USB core level, that way it works for any USB > > device, and you don't have a device-specific sysfs file and custom > > userspace code just for this. > > This is unavoidable to some extent. Without device-specific information > or userspace code, there is no way to know which string descriptor > contains the data you want. ACK. I also do not want any userspace code for that. Users should not need to know a magic number to retrieve the thing. > Alan Stern > > > Sound reasonable? > > > > greg k-h