diff mbox series

[v3,3/3] usb: misc: ljca: print firmware version

Message ID 20241107073718.405208-3-stanislaw.gruszka@linux.intel.com
State Superseded
Headers show
Series [v3,1/3] usb: misc: ljca: move usb_autopm_put_interface() after wait for response | expand

Commit Message

Stanislaw Gruszka Nov. 7, 2024, 7:37 a.m. UTC
For diagnostics purposes read firmware version from device
and print it to dmesg during initialization.

Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com> # ThinkPad X1 Yoga Gen 8, ov2740
Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
---
v2: 80-chars line wrap
v3: use dev_dbg for printing the firmware version

 drivers/usb/misc/usb-ljca.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Comments

Greg KH Nov. 7, 2024, 8:37 a.m. UTC | #1
On Thu, Nov 07, 2024 at 08:37:18AM +0100, Stanislaw Gruszka wrote:
> For diagnostics purposes read firmware version from device
> and print it to dmesg during initialization.

This changelog text isn't correct anymore :(

thanks,

greg k-h
Stanislaw Gruszka Nov. 11, 2024, 11:08 a.m. UTC | #2
On Thu, Nov 07, 2024 at 10:27:29AM +0100, Stanislaw Gruszka wrote:
> On Thu, Nov 07, 2024 at 09:37:34AM +0100, Greg KH wrote:
> > On Thu, Nov 07, 2024 at 08:37:18AM +0100, Stanislaw Gruszka wrote:
> > > For diagnostics purposes read firmware version from device
> > > and print it to dmesg during initialization.
> > 
> > This changelog text isn't correct anymore :(
> 
> I'll drop this one from the set.

It was decided infernally to rewrite this patch to use
sysfs attribute for providing FW version. I'll do this and
will keep the patch in the next posting of the patchset.

Regards
Stanislaw
diff mbox series

Patch

diff --git a/drivers/usb/misc/usb-ljca.c b/drivers/usb/misc/usb-ljca.c
index d9c21f783055..9a44acc48898 100644
--- a/drivers/usb/misc/usb-ljca.c
+++ b/drivers/usb/misc/usb-ljca.c
@@ -43,6 +43,7 @@  enum ljca_client_type {
 
 /* MNG client commands */
 enum ljca_mng_cmd {
+	LJCA_MNG_GET_VERSION = 1,
 	LJCA_MNG_RESET = 2,
 	LJCA_MNG_ENUM_GPIO = 4,
 	LJCA_MNG_ENUM_I2C = 5,
@@ -68,6 +69,13 @@  struct ljca_msg {
 	u8 data[] __counted_by(len);
 } __packed;
 
+struct ljca_fw_version {
+	u8 major;
+	u8 minor;
+	__le16 patch;
+	__le16 build;
+} __packed;
+
 struct ljca_i2c_ctr_info {
 	u8 id;
 	u8 capacity;
@@ -695,6 +703,25 @@  static int ljca_reset_handshake(struct ljca_adapter *adap)
 	return 0;
 }
 
+static void ljca_print_fw_version(struct ljca_adapter *adap)
+{
+	struct ljca_fw_version version = {};
+	int ret;
+
+	ret = ljca_send(adap, LJCA_CLIENT_MNG, LJCA_MNG_GET_VERSION, NULL, 0,
+			(u8 *)&version, sizeof(version), true,
+			LJCA_WRITE_ACK_TIMEOUT_MS);
+
+	if (ret != sizeof(version)) {
+		dev_err(adap->dev, "Get version failed, ret: %d\n", ret);
+		return;
+	}
+
+	dev_dbg(adap->dev, "Firmware version: %d.%d.%d.%d\n",
+		version.major, version.minor,
+		le16_to_cpu(version.patch), le16_to_cpu(version.build));
+}
+
 static int ljca_enumerate_clients(struct ljca_adapter *adap)
 {
 	struct ljca_client *client, *next;
@@ -811,6 +838,8 @@  static int ljca_probe(struct usb_interface *interface,
 	if (ret)
 		goto err_free;
 
+	ljca_print_fw_version(adap);
+
 	/*
 	 * This works around problems with ov2740 initialization on some
 	 * Lenovo platforms. The autosuspend delay, has to be smaller than