Skip to contentSkip to conversation

hwmon: (corsair-cpro) Add firmware and bootloader information

PATCH Superseded Marius Zachmann 2 participants 2 messages May 13, 2024

Subsystems (3)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Marius Zachmann

author maintainer
#0 lore raw

PATCH v4 1/1 hwmon: (corsair-cpro) Add firmware and bootloader information

Add support for reporting firmware and bootloader version using debugfs. Update documentation accordingly.

---
Changes in v4:
- split get_fw_version into get_fw_version and get_bl_version
- only create debugfs file, when the reading succeeded

Changes in v3:
- use different debugfs directory name for each device

Changes in v2:
- better patch description
- Documentation uses "Firmware version" and "Bootloader version"
- removed conditional CONFIG_DEBUG_FS
- get_fw_version gets called from ccp_debugfs_init
- get_fw_version does print a hid_notice when an error occurs instead of failing.

---
 Documentation/hwmon/corsair-cpro.rst |  8 +++
 drivers/hwmon/corsair-cpro.c         | 88 ++++++++++++++++++++++++++++
 2 files changed, 96 insertions(+)
Documentation/hwmon/corsair-cpro.rst +8 -0
index 751f95476b57..15077203a2f8 100644
@@ -39,3 +39,11 @@ fan[1-6]_target		Sets fan speed target rpm.
 pwm[1-6]		Sets the fan speed. Values from 0-255. Can only be read if pwm
 			was set directly.
 ======================= =====================================================================
+
+Debugfs entries
+---------------
+
+======================= ===================
+firmware_version	Firmware version
+bootloader_version	Bootloader version
+======================= ===================
drivers/hwmon/corsair-cpro.c +88 -0

135 lines not on this page · raw message

Signature · 1 line
2.45.0
maintainer
#1 lore raw

On Mon, May 13, 2024 at 09:25:38PM +0200, Marius Zachmann wrote:
[ ...]

drivers/hwmon/corsair-cpro.c static int get_temp_cnct(struct ccp_device *ccp) · line 513

Quoted 9 lines
drivers/hwmon/corsair-cpro.c +8 -0
+/* read firmware version */
+static int get_fw_version(struct ccp_device *ccp)
+{
+	int ret;
+
+	ret = send_usb_cmd(ccp, CTL_GET_FW_VER, 0, 0, 0);
+	if (ret) {
+		hid_notice(ccp->hdev, "Failed to read firmware version.\n");

Please use the following pattern:

	if (ret) {
		hid_notice(ccp->hdev, "Failed to read firmware version.\n");
		return ret;
	}
	ccp->firmware_ver[0] = ccp->buffer[1];
	ccp->firmware_ver[1] = ccp->buffer[2];
	ccp->firmware_ver[2] = ccp->buffer[3];

	return 0;

Thanks,
Guenter