From patchwork Sat Nov 26 16:22:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 26272 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4718621wrr; Sat, 26 Nov 2022 08:24:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf69p64w1yB6t/6+TU0bpE9pjLK6eeQJRNgyQDJ3eKSNzzTg7HS0mKlsYcRzYGe8hy7caZ/2 X-Received: by 2002:aa7:c6da:0:b0:469:172:1f38 with SMTP id b26-20020aa7c6da000000b0046901721f38mr38745011eds.195.1669479894619; Sat, 26 Nov 2022 08:24:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669479894; cv=none; d=google.com; s=arc-20160816; b=aNL2hu0c1eocSTT2QfqRK5uN7FC+gyMCMFOVXymnM1Cuv3SB9wzzLHNP8/wTILYoLU VDfGtKY8QBQjZX2h9J3XVzPTzl+BmYRxzMQ01R8BtlWwSxMMDEn59aaDTfflQhlFWSDg qmjo9dMTU0B54T0L69qI7s50KIkg5yc5oevYH55cJtuOaMHfPRAxBeBwMxZMtzlycQT9 /KW/lcWsXz22C9x/9dgwp9Cvcy0k4czY0Y4QROFq/jI3IghBen6br6vm1sQ8f1jBZzqa pzXg+9wKu4vDCOPedHz3BrH/45+Ftub29b3jroJWC23yUmQX50Y9VCpQ1AJUqzTYX613 WW8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=vkA/imn3R47+/xWfnmkBBzHVEaOv5ORTLT0XDNYcHEQ=; b=WuqMjA3w0q+OvG4uH9pHtpwFEmm2s6cAw6QaXw+Z5TviLWi6HQ9h3U4zjbVKD9LyCT ubo9GPTqMb8hI8hmXdjZgCvQ/j0E6/9z+fLT1YuhygLd2rtTQhN9dqmP2aQG5ZVNbPyg Kcx0mUdyerYuKrD5AxLGXueH0REZZGSiigyZEch6Pc+z9wiwzhr1C3dztzMpVa721T5I RStTVqrez7uD/2hlHfBA1Fbaj2d2/Yw0TGT8XG1Avh8tLjutuaK0jen2z0j/jsFK0IR8 PjaBSeaueP57hHbSW88wvudX3Tz95gYwKKM/ktVridECJE8bOnHWEVXCaoJ12eQVamx2 AOdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="ON/gRuzS"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sc14-20020a1709078a0e00b0078d9db99f5esi6609290ejc.39.2022.11.26.08.24.31; Sat, 26 Nov 2022 08:24:54 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b="ON/gRuzS"; 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 S229686AbiKZQWn (ORCPT + 99 others); Sat, 26 Nov 2022 11:22:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229623AbiKZQWi (ORCPT ); Sat, 26 Nov 2022 11:22:38 -0500 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 251F5E02C; Sat, 26 Nov 2022 08:22:37 -0800 (PST) Received: by mail-pg1-x52e.google.com with SMTP id f9so6266574pgf.7; Sat, 26 Nov 2022 08:22:37 -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=vkA/imn3R47+/xWfnmkBBzHVEaOv5ORTLT0XDNYcHEQ=; b=ON/gRuzSyPH7S6hT2zLZ5P/N1rDVq2AAs/J1IG1Q4wK//8xSZJmYCo3ea9cghVmONi AkbwjnPARZ+CkiUZ1LcufjhMuu5TCWGFytab6j4pCw09Pe+EsD0sklq1HTHm7PBws6Iz +ugY8jxmIC6aMemQ0OQnE0iQaY7+iFXo8633ASE+Oq3HJ2I88uE+/E05poH811GWXP1P TPO56OLkdAIcW1kRz/IcXL4WtzrQrIzs1NTFxpiXF/m1QfGdHdMrDmTGW2vtdskJx4WF bFEM0wwUHW5zPbQ24ozWVwi8RORyqG2XoP6tWmb7GLESbClu5TvNTvz4EV0fnivfvbJ7 wyDg== 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=vkA/imn3R47+/xWfnmkBBzHVEaOv5ORTLT0XDNYcHEQ=; b=QizfY/Mr4EAamKhov6itfyASzG37bg+1l4kBJ6BxM+xljSuuRSxf2/TefHgc4evp+9 iJSwS46q6U8+N1hA0A2mlrGybZbOGmc79inHlyf24VHRsHbZqK+RJ7LopgKaIXxi03Qv /AH4sOgDGOg47scG4A1wyZtpD4oWi6nkkq3bbtioWIyMHLq70qTi743C1ovsGTRa8KzW 7oo7JHkFr603ZBMwwDIsEU1BDNqCG8okDrXCHQJg/X+EQ26uJQ7Wi0yT/RHiZx4qxtuV fWGbVEm9tUD6qYKxyabdb/NYJQoSQ5Ss5sGCGnz+vEVANOfE67tPzIPxDL8+xHvWfxqQ US9Q== X-Gm-Message-State: ANoB5pkjOJ8/B8lFlostNkH8kjbqr7Gn06K1uQ6a4r8T8meJ+RPBmJlO mZE7fc81KCp1ce5iflJxG2xooIiNb6QfRA== X-Received: by 2002:a65:4948:0:b0:46e:be03:d9b5 with SMTP id q8-20020a654948000000b0046ebe03d9b5mr19928275pgs.495.1669479756374; Sat, 26 Nov 2022 08:22:36 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Nov 2022 08:22:36 -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 1/6] USB: core: export usb_cache_string() Date: Sun, 27 Nov 2022 01:22:06 +0900 Message-Id: <20221126162211.93322-2-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 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748586761916897891?= X-GMAIL-MSGID: =?utf-8?q?1750576550099392229?= usb_cache_string() can also be useful for the drivers so export it. Signed-off-by: Vincent Mailhol Acked-by: Greg Kroah-Hartman --- For reference, acked by Greg here: https://lore.kernel.org/linux-usb/Y3zyCz5HbGdsxmRT@kroah.com/ --- 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 Sat Nov 26 16:22:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 26275 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4718877wrr; Sat, 26 Nov 2022 08:25:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf6c3QIObth6fQSbu+TjE2CRDQeHIMzNsnSfbRJNMkwdiEcr4zMz7SzFNHbxYogki7rwFLc+ X-Received: by 2002:aa7:db4b:0:b0:46a:c6d3:a237 with SMTP id n11-20020aa7db4b000000b0046ac6d3a237mr7536483edt.132.1669479936831; Sat, 26 Nov 2022 08:25:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669479936; cv=none; d=google.com; s=arc-20160816; b=GGxLHBh9/ZfanI4wrY8iyzUjD0oFLbOnPsnhyryCReBmOc4wUEWptdtvX/Q+bE7JnZ DWPdAzxSfNXGnS0VVv21EGiFsU+DV3+/oGrM+emrVNaDA0NQ7lLXGlD+YoQ325fAjEID FxKVO4i/2XqT5CITgig4h1Tz2yByL5vLuTD5FjYCbFn94CeCuHZKqbO9T+dUtcwPxywO nNwKqoW5wzwgc2w6ROYel/LLUV9lRfvDc6aMKDZy0UdZrgwUOcEP9Q8kbWDfNXPj/dFt iiqnWTpOiQTXUxK6iA+AgNYGQEVjAfH19f6Nd252fJcNE2I50tFLr8p1yJ6l+4XfxduH ljrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=FmB9Jwaiin8tKBRiu/35E9rAp2jafIlqnhIKGIJ7dMk=; b=d3Lk/IvOxHFPeARAucw00CmnBPXdzRdtNNuXkqRtClGxQnk3QS0kt4nFyJ/UpndwXk mQsO6rfa5KlpWalh/V9kelZnS9gJ9vruv1uN1WHE8lWHZcED4KVHF5vB2yxLj4HvcTSk KXZeV6MC3IjWDk62Q556wHNhvmjH638481eFf4s3yqLeiCEyugZN5dVMDoM2DkGxBOSf SdYC0AESoBqKA5mmmUlxwHeilNplQAV+H1FGVsIBJNXLfkmzcwlSmmngC72v6ayCez96 vAsKjvgSxLTu8BcN1udebq8cFfP372Ats9cPZu6igfEgvgnzS6DXKmhFbyQE6mYQPhw1 qHbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=khULKVn7; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v5-20020a50d585000000b00467c3cbab04si5940505edi.66.2022.11.26.08.25.13; Sat, 26 Nov 2022 08:25:36 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=khULKVn7; 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 S229661AbiKZQWs (ORCPT + 99 others); Sat, 26 Nov 2022 11:22:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229514AbiKZQWl (ORCPT ); Sat, 26 Nov 2022 11:22:41 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5017D133; Sat, 26 Nov 2022 08:22:39 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id z17so1849424pff.1; Sat, 26 Nov 2022 08:22:39 -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=FmB9Jwaiin8tKBRiu/35E9rAp2jafIlqnhIKGIJ7dMk=; b=khULKVn7mhBorIgJ9/uSv1GtI9gWeAf7IdoCqRohNUR3WBjwfEG8IRQpjhUFMcy/pF bZUfl5luaKyGxgWulR/VhNJE06b6pbsTiAcTuWh2zfW7cBzfeQBnyllksrnct6RuRZbs 4YejzBFsRwKBoUC8ir9dG4ru0k8JluVmTAqU/ZbCPGwzdPGccBSn+wZNcxsDGhM7lQZG k+PbJtI0sAUGEBZsMCTP6WaSfg7Vbkl4umo6qg8T7mEz9QkwpvT1PWDyfkwycKKLOTh/ MjJqiibil70zUkopTYedSZ7NMce7bCMAFfPTkiA7JQ4guX5sFdEcB4GQ/kspK0PkWaZ5 JwvA== 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=FmB9Jwaiin8tKBRiu/35E9rAp2jafIlqnhIKGIJ7dMk=; b=1EOziRpsfVc7Cr3G+akDuRslHTKyyYDmQYrYgzu2OY3c3PbZVuQ8ma4SUgiD1c5A3i lRU4gMFmmtAM4m5k52FF6Yn/wZxJHlrNTn9mixzLJ6yr8zN8d4bYIHQUs1dt1nKlO71b v8B7C65XknCtOQHPu1WMd45aCDY2Z/11vMiImElDd4JdLHmH4qibnarqZBgDczgSjQ/V s3+9IzgLDiL4bTMv5MCAUJEGhD8ft21z99VDZQzVjW931o3CBE3xrzk4QWa9RypbC9Xq AbPjY0SFuE06PRNQShLL5KrbBPFTwi+XzdhpNmFUzmTxAORVMULFSFcOrvY4aHEVE4bS okUA== X-Gm-Message-State: ANoB5pl6voL9R3Z7EW5stRWpdivMddQlOrmQCGlxs3Zaepq/zjf3adEI WGCrP5dSA/3w0i1eISZ9ayQvjDGOF+REdw== X-Received: by 2002:a63:1f63:0:b0:460:ec46:3645 with SMTP id q35-20020a631f63000000b00460ec463645mr40054183pgm.92.1669479758992; Sat, 26 Nov 2022 08:22:38 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Nov 2022 08:22:38 -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 2/6] can: etas_es58x: add devlink support Date: Sun, 27 Nov 2022 01:22:07 +0900 Message-Id: <20221126162211.93322-3-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 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750576593978685394?= X-GMAIL-MSGID: =?utf-8?q?1750576593978685394?= Add basic support for devlink. The callbacks of struct devlink_ops will be implemented next. Signed-off-by: Vincent Mailhol --- drivers/net/can/usb/Kconfig | 1 + drivers/net/can/usb/etas_es58x/Makefile | 2 +- drivers/net/can/usb/etas_es58x/es58x_core.c | 13 ++++++++++--- drivers/net/can/usb/etas_es58x/es58x_core.h | 6 ++++++ drivers/net/can/usb/etas_es58x/es58x_devlink.c | 13 +++++++++++++ 5 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 drivers/net/can/usb/etas_es58x/es58x_devlink.c diff --git a/drivers/net/can/usb/Kconfig b/drivers/net/can/usb/Kconfig index 8c6fea661530..445504ababce 100644 --- a/drivers/net/can/usb/Kconfig +++ b/drivers/net/can/usb/Kconfig @@ -30,6 +30,7 @@ config CAN_ESD_USB config CAN_ETAS_ES58X tristate "ETAS ES58X CAN/USB interfaces" select CRC16 + select NET_DEVLINK help This driver supports the ES581.4, ES582.1 and ES584.1 interfaces from ETAS GmbH (https://www.etas.com/en/products/es58x.php). diff --git a/drivers/net/can/usb/etas_es58x/Makefile b/drivers/net/can/usb/etas_es58x/Makefile index a129b4aa0215..d6667ebe259f 100644 --- a/drivers/net/can/usb/etas_es58x/Makefile +++ b/drivers/net/can/usb/etas_es58x/Makefile @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_CAN_ETAS_ES58X) += etas_es58x.o -etas_es58x-y = es58x_core.o es581_4.o es58x_fd.o +etas_es58x-y = es58x_core.o es58x_devlink.o es581_4.o es58x_fd.o diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c index 4c97102202bf..c6e598e4800c 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_core.c +++ b/drivers/net/can/usb/etas_es58x/es58x_core.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "es58x_core.h" @@ -2174,6 +2175,7 @@ static struct es58x_device *es58x_init_es58x_dev(struct usb_interface *intf, { struct device *dev = &intf->dev; struct es58x_device *es58x_dev; + struct devlink *devlink; const struct es58x_parameters *param; const struct es58x_operators *ops; struct usb_device *udev = interface_to_usbdev(intf); @@ -2196,11 +2198,12 @@ static struct es58x_device *es58x_init_es58x_dev(struct usb_interface *intf, ops = &es581_4_ops; } - es58x_dev = devm_kzalloc(dev, es58x_sizeof_es58x_device(param), - GFP_KERNEL); - if (!es58x_dev) + devlink = devlink_alloc(&es58x_dl_ops, es58x_sizeof_es58x_device(param), + dev); + if (!devlink) return ERR_PTR(-ENOMEM); + es58x_dev = devlink_priv(devlink); es58x_dev->param = param; es58x_dev->ops = ops; es58x_dev->dev = dev; @@ -2247,6 +2250,8 @@ static int es58x_probe(struct usb_interface *intf, if (ret) return ret; + devlink_register(priv_to_devlink(es58x_dev)); + for (ch_idx = 0; ch_idx < es58x_dev->num_can_ch; ch_idx++) { ret = es58x_init_netdev(es58x_dev, ch_idx); if (ret) { @@ -2272,8 +2277,10 @@ static void es58x_disconnect(struct usb_interface *intf) dev_info(&intf->dev, "Disconnecting %s %s\n", es58x_dev->udev->manufacturer, es58x_dev->udev->product); + devlink_unregister(priv_to_devlink(es58x_dev)); es58x_free_netdevs(es58x_dev); es58x_free_urbs(es58x_dev); + devlink_free(priv_to_devlink(es58x_dev)); usb_set_intfdata(intf, NULL); } diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.h b/drivers/net/can/usb/etas_es58x/es58x_core.h index 4a082fd69e6f..bf24375580e5 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_core.h +++ b/drivers/net/can/usb/etas_es58x/es58x_core.h @@ -674,6 +674,7 @@ static inline enum es58x_flag es58x_get_flags(const struct sk_buff *skb) return es58x_flags; } +/* es58x_core.c. */ int es58x_can_get_echo_skb(struct net_device *netdev, u32 packet_idx, u64 *tstamps, unsigned int pkts); int es58x_tx_ack_msg(struct net_device *netdev, u16 tx_free_entries, @@ -691,9 +692,14 @@ int es58x_rx_cmd_ret_u32(struct net_device *netdev, int es58x_send_msg(struct es58x_device *es58x_dev, u8 cmd_type, u8 cmd_id, const void *msg, u16 cmd_len, int channel_idx); +/* es58x_devlink.c. */ +extern const struct devlink_ops es58x_dl_ops; + +/* es581_4.c. */ extern const struct es58x_parameters es581_4_param; extern const struct es58x_operators es581_4_ops; +/* es58x_fd.c. */ extern const struct es58x_parameters es58x_fd_param; extern const struct es58x_operators es58x_fd_ops; diff --git a/drivers/net/can/usb/etas_es58x/es58x_devlink.c b/drivers/net/can/usb/etas_es58x/es58x_devlink.c new file mode 100644 index 000000000000..af6ca7ada23f --- /dev/null +++ b/drivers/net/can/usb/etas_es58x/es58x_devlink.c @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* Driver for ETAS GmbH ES58X USB CAN(-FD) Bus Interfaces. + * + * File es58x_devlink.c: report the product information using devlink. + * + * Copyright (c) 2022 Vincent Mailhol + */ + +#include + +const struct devlink_ops es58x_dl_ops = { +}; From patchwork Sat Nov 26 16:22:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 26273 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4718802wrr; Sat, 26 Nov 2022 08:25:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf70Zqt3nu3xYsbv8yccK825SO2DS4kWpX5Y6wFFqOTGZrEddLnkIYcTVbuGuLOrG7TTfWdj X-Received: by 2002:a17:906:444b:b0:7ad:dd43:5d53 with SMTP id i11-20020a170906444b00b007addd435d53mr19356524ejp.376.1669479924004; Sat, 26 Nov 2022 08:25:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669479923; cv=none; d=google.com; s=arc-20160816; b=d741TkvbgFsKQxBq3zpxaUYhBArDXRLrn7lr5DmBgv3/LS7h5JM3tdsVjp9IpH8hdi MyJKPqOOWjfvDyRGIfTPZdXB6cytRjz0iZtvsDa4RZ+W+WaG/zKptqHQb4h1PcYWt18w PA8DHyQ02sMa6ljvR9+3Q5b7AZqZaskA2Yjal6B/dvP/w4xd5ykh9YK/cQn8Duvj6giL o5tQAhE9wjrxM9bg+xWP/r7i951xfdCxxEWeioAT8+b7hQ6uqleADnqtQuWAALGBAqdD WXXvaiLy1pVUtc7IewwkVk2+EkZrk7nd5ZXQob6+h1d178E0sM8vsHB018FNL6l2QGML /Ymg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=xN3ydGNmt/NIkyDnxS01qJwZNhn0e4E8fz0G/KiL0Cs=; b=CMjb8SnFVrHJfUtmR9b2sNo7p77Wsu0gaeki6YOtMXxdbY23KQRV60fQ8didVs8OfO SDcNU+BlVJECzHsWFSwNIaD24KtNSLjD7AjHxeT1ols+zBW6HjlNZJi+TTeRHcs6oVWd govouiTK7w3lnZ8L56+9VB2taE3b+1FlpalrNZdXcMB7iSqR7xJcdokn9muZdWDsa9PV kHLmnQQ4tGizHZOtpqBb1tbABcLFXllgTaq0qXqeA6TeRBDlW+DYlfJbM1cQRVBiK9Nf cHosGLfSliahdymX80v83wAHgqnGhMEJZMnWpJsAYIisa010rB5rFwzRQlcImGoNfURU vHKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mMFp9jNq; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b20-20020a056402279400b0045d4a88c735si7511671ede.220.2022.11.26.08.25.00; Sat, 26 Nov 2022 08:25:23 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mMFp9jNq; 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 S229722AbiKZQWx (ORCPT + 99 others); Sat, 26 Nov 2022 11:22:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbiKZQWn (ORCPT ); Sat, 26 Nov 2022 11:22:43 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BCD326A; Sat, 26 Nov 2022 08:22:42 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id 9so6637602pfx.11; Sat, 26 Nov 2022 08:22:42 -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=xN3ydGNmt/NIkyDnxS01qJwZNhn0e4E8fz0G/KiL0Cs=; b=mMFp9jNqoQmZDOo5IFAg0tIYHe/kgkCWuwfLlikHbCI7u+xPrH3Y8ZwQrsuYgJC7D8 0aNVwrTKqV/ZT1k5ebhirDDgAePTk6t4BaGGGoHbHeUmli58hf3jhB64AbSs9IYLsLXq BAAlmTZ8fGPPmHBqIOPxb7WGvtfITVb7UhkOBRVMX6CKLIIJxHz8wNQmMYF+rHGol/qs fZ+W+GuoO8hAD/04WErVZ37dlMYmIre/0TMkr7ULtWBDh7wd/lyfKxiKqvIoxy/VSdR6 JV4Ctvs9MfazyvUQrPvzF/iToznlIFHAzTwkn//xvV6IyemqIOsXZQtmXxzCy9k4OiLK fxBw== 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=xN3ydGNmt/NIkyDnxS01qJwZNhn0e4E8fz0G/KiL0Cs=; b=zhZcrL2uSvaH66CnHGingTlca7CMXw2RNyDOyXMwXePIf8ANuz2YG5lgdOCPjwlcdw JheichDHtIZW0EwN4GzrtUjx1au740Q9ZKaYO9bRQDuVfJoWb0OCHgLEFubqutCTcPj8 r2/8eQzu9WYYiIk0Ujxjfa7sEbt2JU2nSxFgkpe33ubHBt1a9q3XMxa+l2Ur9jXfb/gm Zc9YLOmFVAjAOZISKV3ayEdSLnCuzDCYWDO53Mf8wZ2B6LQ1B5qCBRfuEWK+cHRHMB2e tv9Smnf+u+0bbor9qpfz/hGjBH17sBirNnr3ZDoxfxhv/2borJPQcwWAzirtndrtRB3v HOaA== X-Gm-Message-State: ANoB5pnCHuNAYyIHzzeMTAqehugzsRH20sM8BEM3fx0zyxLNtVgs/U2X wmvWuENtOXvY2pf5WjwK4Bt/6Qhbhwecpw== X-Received: by 2002:a63:2310:0:b0:457:a1a5:3ce with SMTP id j16-20020a632310000000b00457a1a503cemr20611837pgj.416.1669479761623; Sat, 26 Nov 2022 08:22:41 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Nov 2022 08:22:41 -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 3/6] can: etas_es58x: export product information through devlink_ops::info_get() Date: Sun, 27 Nov 2022 01:22:08 +0900 Message-Id: <20221126162211.93322-4-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 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750576580790628629?= X-GMAIL-MSGID: =?utf-8?q?1750576580790628629?= ES58x devices report below product information through a custom usb string: * the firmware version * the bootloader version * the hardware revision Parse this string, store the results in struct es58x_dev, export the firmware version through devlink's "fw" name and the hardware revision through devlink's "board.rev" name. devlink does not yet have a name suited for the bootloader and so this last piece of information is exposed to the userland for through a custom name: "bl". Those devlink entries are not critical to use the device, if parsing fails, print an informative log message and continue to probe the device. In addition to that, report the device serial number which is available in usb_device::serial. Signed-off-by: Vincent Mailhol Reviewed-by: Andrew Lunn --- drivers/net/can/usb/etas_es58x/es58x_core.c | 1 + drivers/net/can/usb/etas_es58x/es58x_core.h | 67 ++++++ .../net/can/usb/etas_es58x/es58x_devlink.c | 194 ++++++++++++++++++ 3 files changed, 262 insertions(+) diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c index c6e598e4800c..d29c1bf90d73 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_core.c +++ b/drivers/net/can/usb/etas_es58x/es58x_core.c @@ -2250,6 +2250,7 @@ static int es58x_probe(struct usb_interface *intf, if (ret) return ret; + es58x_parse_product_info(es58x_dev); devlink_register(priv_to_devlink(es58x_dev)); for (ch_idx = 0; ch_idx < es58x_dev->num_can_ch; 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 bf24375580e5..9481f0764131 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_core.h +++ b/drivers/net/can/usb/etas_es58x/es58x_core.h @@ -356,6 +356,39 @@ struct es58x_operators { int (*get_timestamp)(struct es58x_device *es58x_dev); }; +/** + * struct es58x_sw_version - Version number of the firmware or the + * bootloader. + * @major: Version major number, represented on two digits. + * @minor: Version minor number, represented on two digits. + * @revision: Version revision number, represented on two digits. + * + * The firmware and the bootloader share the same format: "xx.xx.xx" + * where 'x' is a digit. Both can be retrieved from the product + * information string. + */ +struct es58x_sw_version { + u8 major; + u8 minor; + u8 revision; +}; + +/** + * struct es58x_hw_revision - Hardware revision number. + * @letter: Revision letter. + * @major: Version major number, represented on three digits. + * @minor: Version minor number, represented on three digits. + * + * The hardware revision uses its own format: "axxx/xxx" where 'a' is + * a letter and 'x' a digit. It can be retrieved from the product + * information string. + */ +struct es58x_hw_revision { + char letter; + u16 major; + u16 minor; +}; + /** * struct es58x_device - All information specific to an ES58X device. * @dev: Device information. @@ -373,6 +406,9 @@ struct es58x_operators { * queue wake/stop logic should prevent this URB from getting * empty. Please refer to es58x_get_tx_urb() for more details. * @tx_urbs_idle_cnt: number of urbs in @tx_urbs_idle. + * @firmware_version: The firmware version number. + * @bootloader_version: The bootloader version number. + * @hardware_revision: The hardware revision number. * @ktime_req_ns: kernel timestamp when es58x_set_realtime_diff_ns() * was called. * @realtime_diff_ns: difference in nanoseconds between the clocks of @@ -408,6 +444,10 @@ struct es58x_device { struct usb_anchor tx_urbs_idle; atomic_t tx_urbs_idle_cnt; + struct es58x_sw_version firmware_version; + struct es58x_sw_version bootloader_version; + struct es58x_hw_revision hardware_revision; + u64 ktime_req_ns; s64 realtime_diff_ns; @@ -420,6 +460,32 @@ struct es58x_device { union es58x_urb_cmd rx_cmd_buf; }; +/** + * es58x_sw_version_is_set() - Check if the version is a valid number. + * @sw_ver: Version number of either the firmware or the bootloader. + * + * If &es58x_sw_version.major, &es58x_sw_version.minor and + * &es58x_sw_version.revision are all zero, the product string could + * not be parsed and the version number is invalid. + */ +static inline bool es58x_sw_version_is_set(struct es58x_sw_version *sw_ver) +{ + return sw_ver->major || sw_ver->minor || sw_ver->revision; +} + +/** + * es58x_hw_revision_is_set() - Check if the revision is a valid number. + * @hw_rev: Revision number of the hardware. + * + * If &es58x_hw_revision.letter, &es58x_hw_revision.major and + * &es58x_hw_revision.minor are all zero, the product string could not + * be parsed and the hardware revision number is invalid. + */ +static inline bool es58x_hw_revision_is_set(struct es58x_hw_revision *hw_rev) +{ + return hw_rev->letter || hw_rev->major || hw_rev->minor; +} + /** * es58x_sizeof_es58x_device() - Calculate the maximum length of * struct es58x_device. @@ -693,6 +759,7 @@ int es58x_send_msg(struct es58x_device *es58x_dev, u8 cmd_type, u8 cmd_id, const void *msg, u16 cmd_len, int channel_idx); /* es58x_devlink.c. */ +void es58x_parse_product_info(struct es58x_device *es58x_dev); extern const struct devlink_ops es58x_dl_ops; /* es581_4.c. */ diff --git a/drivers/net/can/usb/etas_es58x/es58x_devlink.c b/drivers/net/can/usb/etas_es58x/es58x_devlink.c index af6ca7ada23f..7b67682b952e 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_devlink.c +++ b/drivers/net/can/usb/etas_es58x/es58x_devlink.c @@ -7,7 +7,201 @@ * Copyright (c) 2022 Vincent Mailhol */ +#include +#include +#include #include +#include "es58x_core.h" + +/* USB descriptor index containing the product information string. */ +#define ES58X_PROD_INFO_IDX 6 + +/** + * es58x_parse_sw_version() - Extract boot loader or firmware version. + * @es58x_dev: ES58X device. + * @prod_info: USB custom string returned by the device. + * @prefix: Select which information should be parsed. Set it to "FW" + * to parse the firmware version or to "BL" to parse the + * bootloader version. + * + * The @prod_info string contains the firmware and the bootloader + * version number all prefixed by a magic string and concatenated with + * other numbers. Depending on the device, the firmware (bootloader) + * format is either "FW_Vxx.xx.xx" ("BL_Vxx.xx.xx") or "FW:xx.xx.xx" + * ("BL:xx.xx.xx") where 'x' represents a digit. @prod_info must + * contains the common part of those prefixes: "FW" or "BL". + * + * Parse @prod_info and store the version number in + * &es58x_dev.firmware_version or &es58x_dev.bootloader_version + * according to @prefix value. + * + * Return: zero on success, -EINVAL if @prefix contains an invalid + * value and -EBADMSG if @prod_info could not be parsed. + */ +static int es58x_parse_sw_version(struct es58x_device *es58x_dev, + const char *prod_info, const char *prefix) +{ + struct es58x_sw_version *version; + int major, minor, revision; + + if (!strcmp(prefix, "FW")) + version = &es58x_dev->firmware_version; + else if (!strcmp(prefix, "BL")) + version = &es58x_dev->bootloader_version; + else + return -EINVAL; + + /* Go to prefix */ + prod_info = strstr(prod_info, prefix); + if (!prod_info) + return -EBADMSG; + /* Go to beginning of the version number */ + while (!isdigit(*prod_info)) { + prod_info++; + if (!*prod_info) + return -EBADMSG; + } + + if (sscanf(prod_info, "%2u.%2u.%2u", &major, &minor, &revision) != 3) + return -EBADMSG; + + version->major = major; + version->minor = minor; + version->revision = revision; + + return 0; +} + +/** + * es58x_parse_hw_rev() - Extract hardware revision number. + * @es58x_dev: ES58X device. + * @prod_info: USB custom string returned by the device. + * + * @prod_info contains the hardware revision prefixed by a magic + * string and conquenated together with other numbers. Depending on + * the device, the hardware revision format is either + * "HW_VER:axxx/xxx" or "HR:axxx/xxx" where 'a' represents a letter + * and 'x' a digit. + * + * Parse @prod_info and store the hardware revision number in + * &es58x_dev.hardware_revision. + * + * Return: zero on success, -EBADMSG if @prod_info could not be + * parsed. + */ +static int es58x_parse_hw_rev(struct es58x_device *es58x_dev, + const char *prod_info) +{ + char letter; + int major, minor; + + /* The only occurrence of 'H' is in the hardware revision prefix. */ + prod_info = strchr(prod_info, 'H'); + if (!prod_info) + return -EBADMSG; + /* Go to beginning of the hardware revision */ + prod_info = strchr(prod_info, ':'); + if (!prod_info) + return -EBADMSG; + prod_info++; + + if (sscanf(prod_info, "%c%3u/%3u", &letter, &major, &minor) != 3) + return -EBADMSG; + + es58x_dev->hardware_revision.letter = letter; + es58x_dev->hardware_revision.major = major; + es58x_dev->hardware_revision.minor = minor; + + return 0; +} + +/** + * es58x_parse_product_info() - Parse the ES58x product information + * string. + * @es58x_dev: ES58X device. + * + * Retrieve the product information string and parse it to extract the + * firmware version, the bootloader version and the hardware + * revision. + * + * If the function fails, simply emit a log message and continue + * because product information is not critical for the driver to + * operate. + */ +void es58x_parse_product_info(struct es58x_device *es58x_dev) +{ + char *prod_info; + + prod_info = usb_cache_string(es58x_dev->udev, ES58X_PROD_INFO_IDX); + if (!prod_info) { + dev_warn(es58x_dev->dev, + "could not retrieve the product info string\n"); + return; + } + + if (es58x_parse_sw_version(es58x_dev, prod_info, "FW") || + es58x_parse_sw_version(es58x_dev, prod_info, "BL") || + es58x_parse_hw_rev(es58x_dev, prod_info)) + dev_info(es58x_dev->dev, + "could not parse product info: '%s'\n", prod_info); + + kfree(prod_info); +} + +/** + * es58x_devlink_info_get() - Report the product information. + * @devlink: Devlink. + * @req: skb wrapper where to put requested information. + * @extack: Unused. + * + * Report the firmware version, the bootloader version, the hardware + * revision and the serial number through netlink. + * + * Return: zero on success, errno when any error occurs. + */ +static int es58x_devlink_info_get(struct devlink *devlink, + struct devlink_info_req *req, + struct netlink_ext_ack *extack) +{ + struct es58x_device *es58x_dev = devlink_priv(devlink); + struct es58x_sw_version *fw_ver = &es58x_dev->firmware_version; + struct es58x_sw_version *bl_ver = &es58x_dev->bootloader_version; + struct es58x_hw_revision *hw_rev = &es58x_dev->hardware_revision; + char buf[max(sizeof("xx.xx.xx"), sizeof("axxx/xxx"))]; + int ret = 0; + + if (es58x_sw_version_is_set(fw_ver)) { + snprintf(buf, sizeof(buf), "%02u.%02u.%02u", + fw_ver->major, fw_ver->minor, fw_ver->revision); + ret = devlink_info_version_running_put(req, + DEVLINK_INFO_VERSION_GENERIC_FW, + buf); + if (ret) + return ret; + } + + if (es58x_sw_version_is_set(bl_ver)) { + snprintf(buf, sizeof(buf), "%02u.%02u.%02u", + bl_ver->major, bl_ver->minor, bl_ver->revision); + ret = devlink_info_version_running_put(req, "bl", buf); + if (ret) + return ret; + } + + if (es58x_hw_revision_is_set(hw_rev)) { + snprintf(buf, sizeof(buf), "%c%03u/%03u", + hw_rev->letter, hw_rev->major, hw_rev->minor); + ret = devlink_info_version_fixed_put(req, + DEVLINK_INFO_VERSION_GENERIC_BOARD_REV, + buf); + if (ret) + return ret; + } + + return devlink_info_serial_number_put(req, es58x_dev->udev->serial); +} + const struct devlink_ops es58x_dl_ops = { + .info_get = es58x_devlink_info_get, }; From patchwork Sat Nov 26 16:22:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 26274 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4718847wrr; Sat, 26 Nov 2022 08:25:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf6+sSuzHRK4ksaPwrjSSKfz+0yI+MEPnn5SF9pCMW9gFowb6QOcIej8sFcdotBSPVY0qV3a X-Received: by 2002:a17:907:8d03:b0:7ae:1d34:4da5 with SMTP id tc3-20020a1709078d0300b007ae1d344da5mr33214892ejc.340.1669479931583; Sat, 26 Nov 2022 08:25:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669479931; cv=none; d=google.com; s=arc-20160816; b=qVhFLCCRpxB4tTlXys/7YRi2nhmkU92MEaKIkaxddHHvTFjxDh3Rv/QV1TLQQDle3v VpzdXPOj9zdFeNWChDV8Jfbpn8zq/n/fszPjaJxrtiGcetGTtQteO8T9T7sdf76YDVYN evKPIOzrvZrzzS3GINz1+1VrYFFhAs4GX74WBfRpvaPofIH6HQyCznqJ4h4T0AHgsgfD AcfbNnVw2fxwONdH3fXKIzE9XDt9pwrUpmIJYfnEFfzW3qODti/z+Y/yhKzpKhx9iLNs RzgM0Vk85a8ORmFPkgVuM8Q6aGFZ57p4DcLZNlzdwnZJJFd16tH89BkqWRGfTQdf/h8c w6ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=FqxbdWmkDaYh64fn5vJKWcy9PbC9sFK7pSd5yFtHB2A=; b=NW9XYo6WofG9SGL7nsPZfeqpfy6PMIUL3D4Pf4R83EpzCPKd8JdVWDQL/11AlEMYtM rs76uqyCxeSQO7xC/xLDbs2fU0htED3g9tjap1Wi74SUTlOsNX6laEJYwj+Xvqd1pVUY 1+sKo9kqpUlY2uem4z8pkkX8EFiM65wItnhgX0AdsIuRMArQMJjawI1jZQvPc22WAGL4 A43mu4rNoQNaUJPJqXkvWb7smv8iYAMfO1nv5z4N/Mn5mcb+/mSPZnscTuvQojeS8Pdj PWabV8modERNzxZR4lHrA0uQ4QGgaYtKpSmdfuXZ+JZqm298pDv9XF5iRSqmGs+fZgPl 11jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Vbr686uQ; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n13-20020a05640205cd00b00461d2ed78acsi6850028edx.378.2022.11.26.08.25.08; Sat, 26 Nov 2022 08:25:31 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Vbr686uQ; 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 S229711AbiKZQW4 (ORCPT + 99 others); Sat, 26 Nov 2022 11:22:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbiKZQWq (ORCPT ); Sat, 26 Nov 2022 11:22:46 -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 90A0813D25; Sat, 26 Nov 2022 08:22:44 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id 3-20020a17090a098300b00219041dcbe9so5472142pjo.3; Sat, 26 Nov 2022 08:22:44 -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=FqxbdWmkDaYh64fn5vJKWcy9PbC9sFK7pSd5yFtHB2A=; b=Vbr686uQefXtARICYQMOWq68c10KROWIUykAqWE3v/K6+O3EKosQse7pUL4xetrAXJ miZraXXF9B+zQkT/2QY5dbRShtbaJ2KD0F9FYYlGjzvI95DULAKbw9edrf36TrQ80dT7 xBgJ/K2iYOBtPHqOtckAUfKSoU6iRClkcJBoFrkKvCCKzB4KFlUPwvHADR8yQYkhVWl9 7EmGQzaeN5QXnbxbhJORYWFcq8hk4beQ5fiCQfXFsFlAWMFagyWpT1i34IWM1kK6T76c B9aGkenxsIgmOtY6895/RgKu4+5IDXFV8ZVYYtQFeEy3emyqbFNTCxvl48oPiWj+Jy5m v+KQ== 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=FqxbdWmkDaYh64fn5vJKWcy9PbC9sFK7pSd5yFtHB2A=; b=IXxA1vyGr0TnXRnz0P56ISx1Q0mG/q+xpinDWmEtdBf94+sTMQcX8IUW4/pwVHRXIj +2iLr9Cqni/W5qNA0jdGnB1gj/+dgx5kjtp7tuGD3l2Oj1+ewuYmCIE2YIsTgZi5VxCp iQ632qOG6kK8opXLFuBkQTzqn9KjC+DU2v5X6VDufciJAhfWaCrW7X36LSRt60DUDaV1 I0TO876hmoyjO2Uky8BJqL5bp+ftHibkrW01PJxILWmM6xyUkxld7wbgMlMuefnoLqUP WrRLl1QYiu+SZLtV5fHxSaUrU7HBn9fzHuIcjOxad63Hz/AMckD1WkQE9le9SbNejvp3 tNkw== X-Gm-Message-State: ANoB5pkdo/pJ/1pVrDePbOVWfw2PVuATNloa2p6RnDhel6JIS4Y2kITX PvkWxo/GGiFydvp4jvWVXHXNaHypZx+6Kw== X-Received: by 2002:a17:902:9881:b0:188:62b8:2278 with SMTP id s1-20020a170902988100b0018862b82278mr29895394plp.96.1669479764254; Sat, 26 Nov 2022 08:22:44 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Nov 2022 08:22:44 -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 4/6] can: etas_es58x: remove es58x_get_product_info() Date: Sun, 27 Nov 2022 01:22:09 +0900 Message-Id: <20221126162211.93322-5-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 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750576588839389451?= X-GMAIL-MSGID: =?utf-8?q?1750576588839389451?= Now that the product information is available under devlink, no more need to print them in the kernel log. Remove es58x_get_product_info(). Signed-off-by: Vincent Mailhol Reviewed-by: Andrew Lunn --- drivers/net/can/usb/etas_es58x/es58x_core.c | 52 ++------------------- 1 file changed, 3 insertions(+), 49 deletions(-) diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c index d29c1bf90d73..e81ef23d8698 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_core.c +++ b/drivers/net/can/usb/etas_es58x/es58x_core.c @@ -2120,48 +2120,6 @@ static void es58x_free_netdevs(struct es58x_device *es58x_dev) } } -/** - * es58x_get_product_info() - Get the product information and print them. - * @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) -{ - 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); - if (!prod_info) - return -ENOMEM; - - 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; -} - /** * es58x_init_es58x_dev() - Initialize the ES58X device. * @intf: USB interface. @@ -2240,28 +2198,24 @@ static int es58x_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct es58x_device *es58x_dev; - int ch_idx, ret; + int ch_idx; es58x_dev = es58x_init_es58x_dev(intf, id->driver_info); if (IS_ERR(es58x_dev)) return PTR_ERR(es58x_dev); - ret = es58x_get_product_info(es58x_dev); - if (ret) - return ret; - es58x_parse_product_info(es58x_dev); devlink_register(priv_to_devlink(es58x_dev)); for (ch_idx = 0; ch_idx < es58x_dev->num_can_ch; ch_idx++) { - ret = es58x_init_netdev(es58x_dev, ch_idx); + int ret = es58x_init_netdev(es58x_dev, ch_idx); if (ret) { es58x_free_netdevs(es58x_dev); return ret; } } - return ret; + return 0; } /** 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: 26276 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4718928wrr; Sat, 26 Nov 2022 08:25:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf63S40ym7feyu1rCtGH3byJogvtO4Km82rjs+LABm9p8fEdkjQIsyHg+VM/pIdW4eczT4XW X-Received: by 2002:a17:907:d006:b0:7bc:ad2d:879d with SMTP id va6-20020a170907d00600b007bcad2d879dmr7044435ejc.603.1669479945713; Sat, 26 Nov 2022 08:25:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669479945; cv=none; d=google.com; s=arc-20160816; b=An2ngjBkauVI5Hse4IEOroy3HJoRPHvfT/W0S0x1oOOyQOLixYDMPPO3RKqk0EmpZm uFzPXOKuDQdkol9PNiwXn8UV59Bee4R7XpE75IOlcb+7upIWuV9FMgbgVJcjEy6oFbPd yAmntT9eJX2tOt/Cv0AsPpXRyUwCh2ZfU32Lp8S06kMdNOEjM44bnbCIXyt8ZINxxH2L oIAVX7ftqDt1YCCFYNeiDVe8LalqNpckhgDkcLfuB7xF9L7OKaxYH6cSj8ZupXSogqNS aGtVXIVpL0jDZqsdL3+vmBI4iWhhgvi4wcdbEXUC48GKo5N3GrqAcLUQQf73gbefNLyK 5F3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=qpk5NRZGXT6wrXMKM9BCDiOE6+iPJ0S6rC3xQ1EVYCc=; b=j3RmURKexAHLyV7fWE1QF+VKTn/zbJeUC1kWtnuqbsgvElMvOKcZ/xQjN4QwrQi9XR McBvcmQy6q31HXIRiNvYFXEIireS3zFr6CQ0Auw52kjqqwFrPQVCv2mCC1mKdToVxBXL YB2F8wctOzokajsQSPXdwUgh4PTCcSRO6lUJhV9cETFq+ZF1zo2Vuf8HJlnOBABa5gY2 JkPT8/53+xGIQ6m3FmCDTcdUgfePlV8PzVH4uyfCbSLCERGZl1bYVwxmWC44PDS4vsaM tEHK2NAhF1bnRQ0yFwf9zo6Xm5uhQZl99muigflDRULLS/C9C0rOQmZli5HRUkfINuYW Rwvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PcvQ7SBh; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id di13-20020a170906730d00b007abafd4d7d0si7204533ejc.702.2022.11.26.08.25.22; Sat, 26 Nov 2022 08:25:45 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PcvQ7SBh; 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 S229607AbiKZQXV (ORCPT + 99 others); Sat, 26 Nov 2022 11:23:21 -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-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 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748551562710711621?= X-GMAIL-MSGID: =?utf-8?q?1750576603322582890?= 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 Sat Nov 26 16:22:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 26277 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4719030wrr; Sat, 26 Nov 2022 08:26:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf40hEY1B9TYjrFkPA2jF2BfmTgqepKti75afDzqw1RSx6YvAySWxEZKrZr0pD4jXFl+BGi+ X-Received: by 2002:a17:906:d977:b0:7ad:934e:b67f with SMTP id rp23-20020a170906d97700b007ad934eb67fmr23738511ejb.238.1669479962204; Sat, 26 Nov 2022 08:26:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669479962; cv=none; d=google.com; s=arc-20160816; b=w88t0LzxW+vP2M+o5F5VkzMM2to+EIQwHJoAGxGHFOYIj8IGrf5/PjWw2P88e/9jRb iuuKc0AlDyutDETqRq6NNM5aDXBkjLOqq8hJVi1gOY7KxvES1yKlrwRRgAbgLF/q5hrF kQQYXTuqzPjzAUxnm6RyoLVkkjgMcc5Xp/S1seC200Qe3ie5x6Wx/f2XKcJ1szKMCrhL 2QysYtoud7EzUB4IJ1kLW8iZapEPVFQySlAQrjkySwG7FhKHHtjlin257PhWJGd6om7/ EymfqA++xWidzoTv5YwrZBe2u5tSg69YWg1AwBs8YsU6AdUNjGS5YmggKevn9iO/oxh/ 5bYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=Vp+9zaIiM6o3AbLJPzloleeAqXF3PPreHB77EhGVkH4=; b=IXnxp756yPoyEugZ128+a2a0mXdIdoCKZJt8X1wbUNa6tZlPc89BAeTX+94tJyYKF8 /yxmQjLIF3Ojwcyeew5i23NAqM0+ZRSAekYhon66naPP0oXUaIlG3s07lTukmd9rCUNP f/UDdr4ggnEM2ZH+3ssuvBtkuJ8m0RKDBrrRpYGkc/T+ts4LKBTuviREah7qLI23Mmug 920DAcWhrPBqoPAjslChmtpy/xeLQF8fJKRlbbbZ02gtprDXlVgt3vdZPe62L2mHATe/ vQmPeA+Ld2QY0N8U+wu7xFC7oLVupUHpsvH6uQok+X/PnD0b259ygbHLP2CngPUzkpUf G5fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="jJzS/vl3"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz20-20020a1709077d9400b0078de44dd61fsi6234298ejc.990.2022.11.26.08.25.38; Sat, 26 Nov 2022 08:26:02 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20210112 header.b="jJzS/vl3"; 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 S229564AbiKZQXZ (ORCPT + 99 others); Sat, 26 Nov 2022 11:23:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229600AbiKZQXM (ORCPT ); Sat, 26 Nov 2022 11:23:12 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AE92167D3; Sat, 26 Nov 2022 08:22:50 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id w79so6670287pfc.2; Sat, 26 Nov 2022 08:22:50 -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=Vp+9zaIiM6o3AbLJPzloleeAqXF3PPreHB77EhGVkH4=; b=jJzS/vl3K9wBJJWaAASEZ3VJpJbW41iogkAB78k8y3rZDNrO95YRSR6teWO4S6INPI hAqkUqoINYo6VJ2+xfNyyDSDi4Seb1cOkiFIizhP/kzkyMSTyrY/gpQCwNFs1Ao7ARjR 33v5YAET2nyB/AuntWUIFM0TNygUSDU5YH2pKoZJWtFNc60U+q3lAfPX+p3lanXz6L+/ H4Z6Opw0/95H2FUUCwLTvoVmaYnMAqqUm9DsGa66nEawNVZ6UjbF6y9KVm8sRqo2SrEx 0i9JVwA4BWl1i5mXq/t0tB9Kckd2VEtzsh+QzHAonCd9H8yV7Nx9h1hwo4YoYV3DqilO mwGQ== 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=Vp+9zaIiM6o3AbLJPzloleeAqXF3PPreHB77EhGVkH4=; b=pok2hTFbbGKzyqi346K2KEpZ1bCCIuoGxJQCI0Bf3Ns911vFWBQxKn26GYn/bCSqb1 6nZn2c+EvIaVtcwhadaiGwmzYuDOG4E4NlAktINVd8DywcrqCa0lsZJaIW9ETifzgHbt qklt9ApFfi6O2d9Gx/fPXITeU0PTHtLESYCWw9jpywn9NloJYPTFjLN1TUijVOx2z8fH 4PvqqmU8zzDLYTBHYVyjY2o0A1iYtCg/QjmgoGZSyLIO28ZMKZ8f3kyakNeNt1AQuHa7 QJ0J+VzFYuvwLE1v9eERV6SgEPRPCZ1I+ymczx+lT81mUis3nrClYIxc/6Q7GiUJFpxR RDEA== X-Gm-Message-State: ANoB5pkLco4xXIB7wuv5YEZ2vE2bxW3IwUCGrVb5Jo476oM4aitArDHF vylX/pg369ZMV9EGk/A/BTxu/dZ5VGcFkg== X-Received: by 2002:a62:e80f:0:b0:574:cc3d:a23f with SMTP id c15-20020a62e80f000000b00574cc3da23fmr6887091pfi.53.1669479769553; Sat, 26 Nov 2022 08:22:49 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Nov 2022 08:22:49 -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 6/6] Documentation: devlink: add devlink documentation for the etas_es58x driver Date: Sun, 27 Nov 2022 01:22:11 +0900 Message-Id: <20221126162211.93322-7-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 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750576621064523703?= X-GMAIL-MSGID: =?utf-8?q?1750576621064523703?= List all the version information reported by the etas_es58x driver. Also, update MAINTAINERS with the newly created file. Signed-off-by: Vincent Mailhol --- .../networking/devlink/etas_es58x.rst | 33 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 34 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..83f59713eed5 --- /dev/null +++ b/Documentation/networking/devlink/etas_es58x.rst @@ -0,0 +1,33 @@ +.. 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 firmware running on the device. Also available + through ``ethtool -i``. + * - ``bl`` + - running + - Version of the bootloader running on the device. + * - ``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 61fe86968111..d95642683fc4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7686,6 +7686,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