[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221113040108.68249-4-mailhol.vincent@wanadoo.fr>
Date: Sun, 13 Nov 2022 13:01:08 +0900
From: Vincent Mailhol <mailhol.vincent@...adoo.fr>
To: Marc Kleine-Budde <mkl@...gutronix.de>, linux-can@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
linux-usb@...r.kernel.org,
Vincent Mailhol <mailhol.vincent@...adoo.fr>
Subject: [PATCH v3 3/3] can: etas_es58x: report firmware-version through ethtool
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 <mailhol.vincent@...adoo.fr>
---
*N.B.* Drivers had to also fill ethtool_drvinfo::driver and
ethtool_drvinfo::bus_info. Starting this week, 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 c5109117f8e6..a048e0d40c97 100644
--- a/drivers/net/can/usb/etas_es58x/es58x_core.c
+++ b/drivers/net/can/usb/etas_es58x/es58x_core.c
@@ -1978,7 +1978,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 (fw_ver->major || fw_ver->minor || fw_ver->revision)
+ 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,
};
--
2.37.4
Powered by blists - more mailing lists