From patchwork Fri Nov 4 17:16:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 622043 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5729BC4167B for ; Fri, 4 Nov 2022 17:16:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231642AbiKDRQs (ORCPT ); Fri, 4 Nov 2022 13:16:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231580AbiKDRQm (ORCPT ); Fri, 4 Nov 2022 13:16:42 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4D253E0AF; Fri, 4 Nov 2022 10:16:39 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id v3so4910785pgh.4; Fri, 04 Nov 2022 10:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=c6xstQC+oWBeL9AwJF0jL3DBXjH1eGPpeBG49uXCkMc=; b=Ghil2qaj38t6smkETB1K9BXz0DmrVNVi9yXIXDoDSKDnadi3OpTbUWhA7SK69bzEwI DR13bjWvIrDDunwYvpDndcJqX7us7Kr1TeZeh1zQZ5aZgturlor6ik/JoKO21iKmjMCe xlUXwuCJwGXHUdW7ZiGS+Xtc9pjxejTiHp7Lhc7aarG4zyDLcgnzR3OO7WN6pn3H8O1s a9sVNJnXL7zLxoQUf72YMUa+TzZUF6KiE/UcuNuB0Kn7mRZ8taOImBLNBrDYCj53epsn hLuD39Mn1iMLo1eucyN7gX9AgKga2QLoLYEag4Pk7i24p3MglepXq9Dis1lmh5DxFRCb Y/vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=c6xstQC+oWBeL9AwJF0jL3DBXjH1eGPpeBG49uXCkMc=; b=FcdbP5DPviT+OcczJwUUiClLh8vz9FkZW+GRNCjzlDjo1rSfY/aF16oDDM8mDzhzUU OWhidvy+MjlYIXGASluGrLUjhe5sokJ+gJscPukd0M+5nR2aMVX0oUS3yOVjmyx2bKDF kHEzXz166j+ZfVHvOoNUPpoqH+7dWIXBe4lruSuVJ83OsXfPF7COVUpVEHzoPyVKN6RY FQUxqqtClcWXaxm4WGnEzvj/NpwcgBw3tSelpeFhp0afaPh3khZDAejQ6TiZM/mLrXO8 wxswWdY1T4O17h4GwM2GikWgpdo0a7LMd8QAIa5IwLDLn/JF4ZtoKh8spzSNigHCheQp ES2A== X-Gm-Message-State: ACrzQf310acscScZ/DOIQOvh7dGDv8eMq+W7jz+TG0KzVEgEBUqX6fRp Z4RxZausvr+ea0BN5mhAvvWPo1m5ISY= X-Google-Smtp-Source: AMsMyM5sTalN9uMJUZEgasHiM/dXo/Fo6ANaOopl9ap2qtuUp9Yc6AD73GpyzPRE5DF5UvOKz1YyKQ== X-Received: by 2002:a63:1303:0:b0:46f:b44b:3519 with SMTP id i3-20020a631303000000b0046fb44b3519mr25169879pgl.278.1667582199111; Fri, 04 Nov 2022 10:16:39 -0700 (PDT) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id u15-20020a17090a450f00b00212c27abcaesm1917655pjg.17.2022.11.04.10.16.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 10:16:38 -0700 (PDT) Sender: Vincent Mailhol From: Vincent Mailhol To: linux-can@vger.kernel.org Cc: Marc Kleine-Budde , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Vincent Mailhol Subject: [PATCH v2 1/3] USB: core: export usb_cache_string() Date: Sat, 5 Nov 2022 02:16:02 +0900 Message-Id: <20221104171604.24052-2-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221104171604.24052-1-mailhol.vincent@wanadoo.fr> References: <20221104073659.414147-1-mailhol.vincent@wanadoo.fr> <20221104171604.24052-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org usb_cache_string() can also be useful for the drivers so export it. Signed-off-by: Vincent Mailhol --- drivers/usb/core/message.c | 1 + drivers/usb/core/usb.h | 1 - include/linux/usb.h | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 4d59d927ae3e..127fac1af676 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -1037,6 +1037,7 @@ char *usb_cache_string(struct usb_device *udev, int index) } return smallbuf; } +EXPORT_SYMBOL_GPL(usb_cache_string); /* * usb_get_device_descriptor - (re)reads the device descriptor (usbcore) diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 82538daac8b8..0eac7d4285d1 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h @@ -47,7 +47,6 @@ extern int usb_get_device_descriptor(struct usb_device *dev, extern int usb_set_isoch_delay(struct usb_device *dev); extern int usb_get_bos_descriptor(struct usb_device *dev); extern void usb_release_bos_descriptor(struct usb_device *dev); -extern char *usb_cache_string(struct usb_device *udev, int index); extern int usb_set_configuration(struct usb_device *dev, int configuration); extern int usb_choose_configuration(struct usb_device *udev); extern int usb_generic_driver_probe(struct usb_device *udev); diff --git a/include/linux/usb.h b/include/linux/usb.h index 9ff1ad4dfad1..d2d2f41052c0 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1829,6 +1829,7 @@ static inline int usb_get_ptm_status(struct usb_device *dev, void *data) extern int usb_string(struct usb_device *dev, int index, char *buf, size_t size); +extern char *usb_cache_string(struct usb_device *udev, int index); /* wrappers that also update important state inside usbcore */ extern int usb_clear_halt(struct usb_device *dev, int pipe); From patchwork Fri Nov 4 17:16:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 621688 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08EECC43219 for ; Fri, 4 Nov 2022 17:16:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231361AbiKDRQq (ORCPT ); Fri, 4 Nov 2022 13:16:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231539AbiKDRQo (ORCPT ); Fri, 4 Nov 2022 13:16:44 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D52B32BA7; Fri, 4 Nov 2022 10:16:42 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id z26so5082329pff.1; Fri, 04 Nov 2022 10:16:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=Xz0y0NUNkUf+PsJYRPU+aqv8faUzWDQk/DO9G90XRKo=; b=Z3ID3+fUilwpptQbakP1Bw3RkXXb6Z6uBwK9oPN9nqBEAh1/6XDg03a6BlcSasoJh9 gYa4XkYDTSIm4NCKqnkv41e7VwaffKXipVy4PsCcn+xtKt4XM8yg0TSG8/JkUaio/0ND ldix8oj7sZQDc3y7Z8qdwu92XziPcWSMdfJWwmadqK3F0ngSiAAOgXGoaPhh41RW8W8y xyete8ujLnU9jve0QgEtnHjRoEfDnLBv3BBDB0dAyBOwDkNWs+q27BbHYc1rb2HJ8Epd 3+8yHxzdRRwsLZjt6DJWoL0BVuTj7zSU0P6Z/8GkXSjUVTxfbmgDuouyKPpHVtMw5vqg lrkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Xz0y0NUNkUf+PsJYRPU+aqv8faUzWDQk/DO9G90XRKo=; b=uP1bi2Eptrr7q0NS8zMrrQDJeAuyAEsbqeN7w/Az0XNFQFNvQP/g+qYFgFaZIACYyF w1l0+F9S6sXaiP6x/ch658gLtLUwKqS1tkYOdny/Y8rRxXT4F3KcCkaziegb0/SnQyOq /yko1escrKAP1rV/rSWGikpQAZU+Zfo/cXJy5sG650DO4ekXLzDMqg25pXyn79w8lP9v URz1dEpfWDLHZK9VYuRr6Oo8PCnKjR0oZBQQYTOepKeGJO6W39hnkX9uiUloCCknJef5 mWjn2kGVsBcSrcTVzqGuCO9FIimBdRiTCFngkGKA71nRQpWQ4IXTa4OToMbSyj+X78/h sWHg== X-Gm-Message-State: ACrzQf3N4eWcq158xXthjP4rgW52/Ukeos3TC6n5TVFXhVRXpZHqt+70 bZwWbpbNJ6zWDTVAgaHKKuTXrSm1Ijw= X-Google-Smtp-Source: AMsMyM5d/ovbRY9EV1vKTdycQP8C9Q3zhLDFha9/KS6ksS9Lysb3v+4Os2GQdL22ju5cT9yitMbRdA== X-Received: by 2002:a63:e348:0:b0:46f:25cc:d554 with SMTP id o8-20020a63e348000000b0046f25ccd554mr32095610pgj.598.1667582201901; Fri, 04 Nov 2022 10:16:41 -0700 (PDT) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id u15-20020a17090a450f00b00212c27abcaesm1917655pjg.17.2022.11.04.10.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 10:16:41 -0700 (PDT) Sender: Vincent Mailhol From: Vincent Mailhol To: linux-can@vger.kernel.org Cc: Marc Kleine-Budde , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Vincent Mailhol Subject: [PATCH v2 2/3] can: etas_es58x: use usb_cache_string() to retrieve the product info string Date: Sat, 5 Nov 2022 02:16:03 +0900 Message-Id: <20221104171604.24052-3-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221104171604.24052-1-mailhol.vincent@wanadoo.fr> References: <20221104073659.414147-1-mailhol.vincent@wanadoo.fr> <20221104171604.24052-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Instead of allocating memory ourselves and doing all the error handling, rely on usb_cache_string(). This results in simpler code. Make es58x_get_product_info() return void. The reason is double: 1/ by using usb_cache_string() we do not know anymore the root cause (is it an allocation issue or input/output issue?) 2/ Failling to get the product info is not critical. So it is OK to continue. Signed-off-by: Vincent Mailhol --- drivers/net/can/usb/etas_es58x/es58x_core.c | 33 +++------------------ drivers/net/can/usb/etas_es58x/es58x_core.h | 3 ++ 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c index 51294b717040..1a17aadfc1dc 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_core.c +++ b/drivers/net/can/usb/etas_es58x/es58x_core.c @@ -2124,41 +2124,18 @@ static void es58x_free_netdevs(struct es58x_device *es58x_dev) * @es58x_dev: ES58X device. * * Do a synchronous call to get the product information. - * - * Return: zero on success, errno when any error occurs. */ -static int es58x_get_product_info(struct es58x_device *es58x_dev) +static void es58x_get_product_info(struct es58x_device *es58x_dev) { - struct usb_device *udev = es58x_dev->udev; - const int es58x_prod_info_idx = 6; - /* Empirical tests show a prod_info length of maximum 83, - * below should be more than enough. - */ - const size_t prod_info_len = 127; char *prod_info; - int ret; - prod_info = kmalloc(prod_info_len, GFP_KERNEL); + prod_info = usb_cache_string(es58x_dev->udev, ES58X_PROD_INFO_IDX); if (!prod_info) - return -ENOMEM; + return; - ret = usb_string(udev, es58x_prod_info_idx, prod_info, prod_info_len); - if (ret < 0) { - dev_err(es58x_dev->dev, - "%s: Could not read the product info: %pe\n", - __func__, ERR_PTR(ret)); - goto out_free; - } - if (ret >= prod_info_len - 1) { - dev_warn(es58x_dev->dev, - "%s: Buffer is too small, result might be truncated\n", - __func__); - } dev_info(es58x_dev->dev, "Product info: %s\n", prod_info); - out_free: kfree(prod_info); - return ret < 0 ? ret : 0; } /** @@ -2243,9 +2220,7 @@ static int es58x_probe(struct usb_interface *intf, if (IS_ERR(es58x_dev)) return PTR_ERR(es58x_dev); - ret = es58x_get_product_info(es58x_dev); - if (ret) - return ret; + es58x_get_product_info(es58x_dev); for (ch_idx = 0; ch_idx < es58x_dev->num_can_ch; ch_idx++) { ret = es58x_init_netdev(es58x_dev, ch_idx); diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.h b/drivers/net/can/usb/etas_es58x/es58x_core.h index 640fe0a1df63..9a5a616df783 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_core.h +++ b/drivers/net/can/usb/etas_es58x/es58x_core.h @@ -49,6 +49,9 @@ /* A magic number sent by the ES581.4 to inform it is alive. */ #define ES58X_HEARTBEAT 0x11 +/* USB descriptor index containing the product information string. */ +#define ES58X_PROD_INFO_IDX 6 + /** * enum es58x_driver_info - Quirks of the device. * @ES58X_DUAL_CHANNEL: Device has two CAN channels. If this flag is From patchwork Fri Nov 4 17:16:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 622042 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09394C4332F for ; Fri, 4 Nov 2022 17:16:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231674AbiKDRQu (ORCPT ); Fri, 4 Nov 2022 13:16:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231621AbiKDRQq (ORCPT ); Fri, 4 Nov 2022 13:16:46 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CC883E09D; Fri, 4 Nov 2022 10:16:45 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id v17so5500464plo.1; Fri, 04 Nov 2022 10:16:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=e0ErP+orkk4G4ShNSRoAumyTCOdV2yHLSVRR3eTBZqY=; b=pnM3I45GlSkO+51EPfO/sMnc4irB4Km6/IANDutMalaLXhM0IbxCwbXK1vNBWmD4Cx IaEbe+6qSuyiP+ff+zgSY7A2g6unUQt2J3/kHEciXxbQvFNkLY7qKNeBSfS42DU/Gzm8 4/hOoI/3YQwf2XbCC5lPNk65PRLQESclwUb5kQeFA2K0dIUhLRQeeAl4oExZrO5jwfSo fJd73x2t2uAjgAT0X88cufrQbA+2qnKVn1SqECkojZfFmMtqn3tEc843RIY8b8WgK00r BuY+JKPIaY09w6d4/iMfLl99dklAQ4QKx7a6htaodAdv8DjWmfSxoCErE4l28o1XN0sU ZtEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=e0ErP+orkk4G4ShNSRoAumyTCOdV2yHLSVRR3eTBZqY=; b=pjbhcPRfoak/KUVrwcC6pJp9HzxEFQeZqxbKDGGtzrUryzsHRNFvIANjU3xsBxH4ez X5s+4sDCJF/eCrnrTxYf+mE2Ncrbp+IP40EvhMnU803ePfeE+rcsloAiocsGUi4Pnxpd 8gJyCcL4s6rOr1eBopcDuJVVB45AK4Zs1sffvAWTISer0L80iQP5A86QOiwnCxxt6FFy odbmL7Ft1V7R+LlAZBLYEir+IuqK08MFNxQV4RB/GvC4GL1SM9TrkPNLa1MKRsqOPliB NNFrl0wcgdDfIXt93YaaOvxSq/incJStLPV9AfSQ+zmjwA15xYF/GzhJd806eBpuX26S kKJQ== X-Gm-Message-State: ACrzQf04cyEkWTMVqy5BXZ7VAZ3CpKomwLfSvBuxiF/Z/zMnhjaVEuKG IGlVUsapz73mM/BvMTVwodpDvZR8No4= X-Google-Smtp-Source: AMsMyM7hdEM7xNTxTC+b/SLA3tmCuWd+pXY/ru1M14fvtoxF7YucqgvNa7u/+yapLO6Ua1M7ev1b+w== X-Received: by 2002:a17:903:2308:b0:186:f608:c509 with SMTP id d8-20020a170903230800b00186f608c509mr36996999plh.154.1667582204511; Fri, 04 Nov 2022 10:16:44 -0700 (PDT) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id u15-20020a17090a450f00b00212c27abcaesm1917655pjg.17.2022.11.04.10.16.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 10:16:44 -0700 (PDT) Sender: Vincent Mailhol From: Vincent Mailhol To: linux-can@vger.kernel.org Cc: Marc Kleine-Budde , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Vincent Mailhol Subject: [PATCH v2 3/3] can: etas_es58x: report the firmware version through ethtool Date: Sat, 5 Nov 2022 02:16:04 +0900 Message-Id: <20221104171604.24052-4-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221104171604.24052-1-mailhol.vincent@wanadoo.fr> References: <20221104073659.414147-1-mailhol.vincent@wanadoo.fr> <20221104171604.24052-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org ES58x devices report below information in their usb product info string: * the firmware version * the bootloader version * the hardware revision Report the firmware version through ethtool_drvinfo::fw_version. Because struct ethtool_drvinfo has no fields to report the boatloader version nor the hardware revision, continue to print these in the kernel log (c.f. es58x_get_product_info()). While doing so, bump up copyright year of each modified files. Signed-off-by: Vincent Mailhol --- drivers/net/can/usb/etas_es58x/es581_4.c | 5 ++- drivers/net/can/usb/etas_es58x/es58x_core.c | 42 ++++++++++++++++++++- drivers/net/can/usb/etas_es58x/es58x_core.h | 5 ++- drivers/net/can/usb/etas_es58x/es58x_fd.c | 5 ++- 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/usb/etas_es58x/es581_4.c b/drivers/net/can/usb/etas_es58x/es581_4.c index 1bcdcece5ec7..29c03c8b3f07 100644 --- a/drivers/net/can/usb/etas_es58x/es581_4.c +++ b/drivers/net/can/usb/etas_es58x/es581_4.c @@ -6,7 +6,7 @@ * * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved. * Copyright (c) 2020 ETAS K.K.. All rights reserved. - * Copyright (c) 2020, 2021 Vincent Mailhol + * Copyright (c) 2020-2022 Vincent Mailhol */ #include @@ -492,7 +492,8 @@ const struct es58x_parameters es581_4_param = { .tx_bulk_max = ES581_4_TX_BULK_MAX, .urb_cmd_header_len = ES581_4_URB_CMD_HEADER_LEN, .rx_urb_max = ES58X_RX_URBS_MAX, - .tx_urb_max = ES58X_TX_URBS_MAX + .tx_urb_max = ES58X_TX_URBS_MAX, + .prod_info_delim = ',', }; const struct es58x_operators es581_4_ops = { diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c index 1a17aadfc1dc..72a60f5f92c8 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_core.c +++ b/drivers/net/can/usb/etas_es58x/es58x_core.c @@ -7,7 +7,7 @@ * * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved. * Copyright (c) 2020 ETAS K.K.. All rights reserved. - * Copyright (c) 2020, 2021 Vincent Mailhol + * Copyright (c) 2020-2022 Vincent Mailhol */ #include @@ -1978,7 +1978,47 @@ static const struct net_device_ops es58x_netdev_ops = { .ndo_eth_ioctl = can_eth_ioctl_hwts, }; +/** + * es58x_get_drvinfo() - Get the driver name and firmware version. + * @netdev: CAN network device. + * @drvinfo: Driver information. + * + * Populate @drvinfo with the driver name and the firmware version. + */ +static void es58x_get_drvinfo(struct net_device *netdev, + struct ethtool_drvinfo *drvinfo) +{ + struct es58x_device *es58x_dev = es58x_priv(netdev)->es58x_dev; + char *prod_info, *start, *end; + + strscpy(drvinfo->driver, KBUILD_MODNAME, sizeof(drvinfo->driver)); + + prod_info = usb_cache_string(es58x_dev->udev, ES58X_PROD_INFO_IDX); + if (!prod_info) + return; + + /* The firmware prefix is either "FW_V" or "FW:" */ + start = strstr(prod_info, "FW"); + if (!start) + goto free_prod_info; + /* Go to first digit */ + while (!isdigit(*start)) { + start++; + if (!*start) + goto free_prod_info; + } + end = strchr(start, es58x_dev->param->prod_info_delim); + if (!end || end - start >= sizeof(drvinfo->fw_version)) + goto free_prod_info; + + strncpy(drvinfo->fw_version, start, end - start); + + free_prod_info: + kfree(prod_info); +} + static const struct ethtool_ops es58x_ethtool_ops = { + .get_drvinfo = es58x_get_drvinfo, .get_ts_info = can_ethtool_op_get_ts_info_hwts, }; diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.h b/drivers/net/can/usb/etas_es58x/es58x_core.h index 9a5a616df783..9c2cdb57f34a 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_core.h +++ b/drivers/net/can/usb/etas_es58x/es58x_core.h @@ -6,7 +6,7 @@ * * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved. * Copyright (c) 2020 ETAS K.K.. All rights reserved. - * Copyright (c) 2020, 2021 Vincent Mailhol + * Copyright (c) 2020-2022 Vincent Mailhol */ #ifndef __ES58X_COMMON_H__ @@ -309,6 +309,8 @@ struct es58x_priv { * @urb_cmd_header_len: Length of the URB command header. * @rx_urb_max: Number of RX URB to be allocated during device probe. * @tx_urb_max: Number of TX URB to be allocated during device probe. + * @prod_info_delim: delimiter of the different fields in the USB + * product information string. */ struct es58x_parameters { const struct can_bittiming_const *bittiming_const; @@ -327,6 +329,7 @@ struct es58x_parameters { u8 urb_cmd_header_len; u8 rx_urb_max; u8 tx_urb_max; + char prod_info_delim; }; /** diff --git a/drivers/net/can/usb/etas_es58x/es58x_fd.c b/drivers/net/can/usb/etas_es58x/es58x_fd.c index c97ffa71fd75..aa7a4866f870 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_fd.c +++ b/drivers/net/can/usb/etas_es58x/es58x_fd.c @@ -8,7 +8,7 @@ * * Copyright (c) 2019 Robert Bosch Engineering and Business Solutions. All rights reserved. * Copyright (c) 2020 ETAS K.K.. All rights reserved. - * Copyright (c) 2020, 2021 Vincent Mailhol + * Copyright (c) 2020-2022 Vincent Mailhol */ #include @@ -550,7 +550,8 @@ const struct es58x_parameters es58x_fd_param = { .tx_bulk_max = ES58X_FD_TX_BULK_MAX, .urb_cmd_header_len = ES58X_FD_URB_CMD_HEADER_LEN, .rx_urb_max = ES58X_RX_URBS_MAX, - .tx_urb_max = ES58X_TX_URBS_MAX + .tx_urb_max = ES58X_TX_URBS_MAX, + .prod_info_delim = '-', }; const struct es58x_operators es58x_fd_ops = { From patchwork Sat Nov 26 16:22:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 628861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3B8FC46467 for ; Sat, 26 Nov 2022 16:23:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229754AbiKZQXT (ORCPT ); Sat, 26 Nov 2022 11:23:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbiKZQWu (ORCPT ); Sat, 26 Nov 2022 11:22:50 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DF1416588; Sat, 26 Nov 2022 08:22:47 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id 3-20020a17090a098300b00219041dcbe9so5472187pjo.3; Sat, 26 Nov 2022 08:22:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=qpk5NRZGXT6wrXMKM9BCDiOE6+iPJ0S6rC3xQ1EVYCc=; b=PcvQ7SBhzOJybY6+jatfIAbtpni76oCLbPDJ5hc5isiyOAtuRnAnCarpbJ4tzisVXU kdpFTPOsDcn7G66NXoCUgX9Ht3adGoFzCIWmpfGcvQPlNKESUlH04lsTPrAzSu0lLIvn +osLHYK6J9SMA28fYLX4pq4o8nWJhKgMGQvrlditRvMF9zPohPHuzxpKKIRD9xd4P6s2 GN0dOAYE+dGPIiQG2L5he9dMtncbAC6vlC+87U5JO5EDukE9KQ096D++5+nRDjMFZpg1 kzXzMHAFfuTc1O1a5DaCOhhPfHWVXQn3n2uBTgvdlo7auSBEMArpt+/sXy974twJEzqg yzxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=qpk5NRZGXT6wrXMKM9BCDiOE6+iPJ0S6rC3xQ1EVYCc=; b=0UqHK3XmLeqUaRRCeNhaDD1x70XrGo3LUUnlPUTiwNgB47/OEK/AeFC8ElxpKg3/zA uOa4L0nxXcL6Dkr9nxV3/msT0PyEFz9LamW1PzCHE+IyTKgMKVB4HHlb43hp3TqRF/Xr zJPrK2eA/JVBJ+7WfkrtRQUtJpCdK06BoKz/bwsyCv5b7MnvK4asKxacXoqAIr/qMq1F v1tpELmCN00YseJuma6WcjSSqV7Dr7TokdrP4E4xU8LJJJPXia/rQpAcJwJ6a1ub/z0/ AXE5ZepMPYWR3xPkO0qS3W12b/K0TcRh1DPLGPOklWPcexawf7os1o2BZat6BzVg1JfM 5img== X-Gm-Message-State: ANoB5pnIkRA6FvsBUuMSCIgvmhDXFQsmo75/Ox85pdhylgjZ5AWSB8LY mpnWN5z5kS21KYd+7+3wUtWFg1JzVvfpJw== X-Google-Smtp-Source: AA0mqf4halsh85pz1Q+OGUUHUQMqK2ByYwfdWQSW1PvJE4KBID1RYyl0RKhK1cWpAGU6sxw7irqu3w== X-Received: by 2002:a17:902:d191:b0:189:1d93:1435 with SMTP id m17-20020a170902d19100b001891d931435mr24457444plb.105.1669479766928; Sat, 26 Nov 2022 08:22:46 -0800 (PST) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id y14-20020a63e24e000000b00460ea630c1bsm4169601pgj.46.2022.11.26.08.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Nov 2022 08:22:46 -0800 (PST) Sender: Vincent Mailhol From: Vincent Mailhol To: linux-can@vger.kernel.org Cc: Marc Kleine-Budde , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , netdev@vger.kernel.org, linux-usb@vger.kernel.org, Saeed Mahameed , Andrew Lunn , Jiri Pirko , Lukas Magel , Vincent Mailhol Subject: [PATCH v4 5/6] can: etas_es58x: report the firmware version through ethtool Date: Sun, 27 Nov 2022 01:22:10 +0900 Message-Id: <20221126162211.93322-6-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221126162211.93322-1-mailhol.vincent@wanadoo.fr> References: <20221104073659.414147-1-mailhol.vincent@wanadoo.fr> <20221126162211.93322-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Implement ethtool_ops::get_drvinfo() in order to report the firmware version. Firmware version 0.0.0 has a special meaning and just means that we could not parse the product information string. In such case, do nothing (i.e. leave the .fw_version string empty). Signed-off-by: Vincent Mailhol Reviewed-by: Andrew Lunn --- *N.B.* Drivers had to also fill ethtool_drvinfo::driver and ethtool_drvinfo::bus_info. Starting this month, this is not needed anymore because of commit edaf5df22cb8 ("ethtool: ethtool_get_drvinfo: populate drvinfo fields even if callback exits"). https://git.kernel.org/netdev/net-next/c/edaf5df22cb8 --- drivers/net/can/usb/etas_es58x/es58x_core.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c index e81ef23d8698..12968aef41af 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_core.c +++ b/drivers/net/can/usb/etas_es58x/es58x_core.c @@ -1979,7 +1979,28 @@ static const struct net_device_ops es58x_netdev_ops = { .ndo_eth_ioctl = can_eth_ioctl_hwts, }; +/** + * es58x_get_drvinfo() - Get the firmware version. + * @netdev: CAN network device. + * @drvinfo: Driver information. + * + * Populate @drvinfo with the firmware version. The core will populate + * the rest. + */ +static void es58x_get_drvinfo(struct net_device *netdev, + struct ethtool_drvinfo *drvinfo) +{ + struct es58x_device *es58x_dev = es58x_priv(netdev)->es58x_dev; + struct es58x_sw_version *fw_ver = &es58x_dev->firmware_version; + + if (es58x_sw_version_is_set(fw_ver)) + snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), + "%02u.%02u.%02u", + fw_ver->major, fw_ver->minor, fw_ver->revision); +} + static const struct ethtool_ops es58x_ethtool_ops = { + .get_drvinfo = es58x_get_drvinfo, .get_ts_info = can_ethtool_op_get_ts_info_hwts, }; From patchwork Wed Nov 30 17:46:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 629839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72A91C352A1 for ; Wed, 30 Nov 2022 17:48:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230131AbiK3Rse (ORCPT ); Wed, 30 Nov 2022 12:48:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbiK3RsI (ORCPT ); Wed, 30 Nov 2022 12:48:08 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C359DF8; Wed, 30 Nov 2022 09:47:32 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id r18so16736778pgr.12; Wed, 30 Nov 2022 09:47:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=cBWVgR+RLUqkJ8KuTZNticMrWH5FaJ887K/c4/dMWdA=; b=WsjXgGWo66TTf4k4CxDjO+Yxift66oL1FoKPNxBbihKtuoOA6A11uvbDG1PwudCgXQ w2Ti5aXY8NPBiYPRx1hyWUXPmCkOESo3MEfV2IflpG7PcWR5dtjp0WF24VSI2s/8jqEl u0Zs46TlIevVudlrikGM7pRi4OV7QB008WyTpDuAw4c5SX+SWGbr7y10DFDAgzZ+CEnd +07OmOj6ViR0TZqXMuxH+nduGu3vUSf9+2P3pSXh/Z8SIDh1Zyl8nMfCKI49nfag8N7p x6YY/OHtrnAAu/wR7sapVecrlvjsHAfYrOtnVtWdTb2qLKrbft82Y93QZwMsWIzWv9tf kTCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cBWVgR+RLUqkJ8KuTZNticMrWH5FaJ887K/c4/dMWdA=; b=fW70i49ADstA59XQ8pgtgeVJfjFfOKyuYCcEUi3VkErUxEBOE45uRiM9PeeZ2iPutT NihDMKpVYvRELdg2xw8opexIiKvI5CwuR4ekkBZgLY/V/+B3/0XUGJos/IIY1607+p5d Mx2Srcr3MGMTMSGEnO6FE60a/QfyldRhI8LG/vjfzZ0K48O6gvYy55B8NlEnnYCjmpPs vbN2PV2yCGOeVq4Q/x/jbmfS4WdbQNnmWYaT5DfkRIpwdbg9Bzrc6LGrkCti5RZdh14h 161Gl2fbbFCG99+rA3DLYzlSjGcDjSBbu06xzvGZF3EGd/RZLbXTMMz7gwevlv5PhtDN 09Gg== X-Gm-Message-State: ANoB5plzxDzBqMAmOlEPSUJ4PM1X9VYrTGq5bvZgwAJ6sjQ+Sr6/B0xi 1lnh+YMYnZB2L6PZ7TzLwFDuKF+tjikdew== X-Google-Smtp-Source: AA0mqf6+iAYcgK40TW/F0ayXJMs5DDcd7U+Q10WoXb0OwWhIMHR8WWRiUQOxMJTsUAUBjvY3o6NNAQ== X-Received: by 2002:a63:1345:0:b0:476:f92f:69f0 with SMTP id 5-20020a631345000000b00476f92f69f0mr55727855pgt.463.1669830451644; Wed, 30 Nov 2022 09:47:31 -0800 (PST) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id p3-20020aa79e83000000b00574cdb63f03sm1714505pfq.144.2022.11.30.09.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Nov 2022 09:47:31 -0800 (PST) Sender: Vincent Mailhol From: Vincent Mailhol To: linux-can@vger.kernel.org Cc: Marc Kleine-Budde , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , netdev@vger.kernel.org, linux-usb@vger.kernel.org, Saeed Mahameed , Andrew Lunn , Jiri Pirko , Lukas Magel , Jakub Kicinski , Vincent Mailhol Subject: [PATCH v5 7/7] Documentation: devlink: add devlink documentation for the etas_es58x driver Date: Thu, 1 Dec 2022 02:46:58 +0900 Message-Id: <20221130174658.29282-8-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221130174658.29282-1-mailhol.vincent@wanadoo.fr> References: <20221104073659.414147-1-mailhol.vincent@wanadoo.fr> <20221130174658.29282-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org List all the version information reported by the etas_es58x driver through devlink. Also, update MAINTAINERS with the newly created file. Signed-off-by: Vincent Mailhol --- .../networking/devlink/etas_es58x.rst | 36 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 37 insertions(+) create mode 100644 Documentation/networking/devlink/etas_es58x.rst diff --git a/Documentation/networking/devlink/etas_es58x.rst b/Documentation/networking/devlink/etas_es58x.rst new file mode 100644 index 000000000000..9893e57b625a --- /dev/null +++ b/Documentation/networking/devlink/etas_es58x.rst @@ -0,0 +1,36 @@ +.. SPDX-License-Identifier: GPL-2.0 + +========================== +etas_es58x devlink support +========================== + +This document describes the devlink features implemented by the +``etas_es58x`` device driver. + +Info versions +============= + +The ``etas_es58x`` driver reports the following versions + +.. list-table:: devlink info versions implemented + :widths: 5 5 90 + + * - Name + - Type + - Description + * - ``fw`` + - running + - Version of the firmware running on the device. Also available + through ``ethtool -i`` as the first member of the + ``firmware-version``. + * - ``bl`` + - running + - Version of the bootloader running on the device. Also available + through ``ethtool -i`` as the second member of the + ``firmware-version``. + * - ``board.rev`` + - fixed + - The hardware revision of the device. + * - ``serial_number`` + - fixed + - The USB serial number. Also available through ``lsusb -v``. diff --git a/MAINTAINERS b/MAINTAINERS index 955c1be1efb2..71f4f8776779 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7682,6 +7682,7 @@ ETAS ES58X CAN/USB DRIVER M: Vincent Mailhol L: linux-can@vger.kernel.org S: Maintained +F: Documentation/networking/devlink/etas_es58x.rst F: drivers/net/can/usb/etas_es58x/ ETHERNET BRIDGE