Skip to contentSkip to conversation

HID: intel-thc-hid: Intel-quickspi: Fix some error codes

PATCH Applied Dan Carpenter 4 participants 6 messages Apr 23 – Apr 28

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: intel-thc-hid: Intel-quickspi: Fix some error codes

If we have a partial read that is supposed to be treated as failure but in this code we forgot to set the error code. Return -EINVAL.

Fixes 9d8d51735a3a ("HID: intel-thc-hid: intel-quickspi: Add HIDSPI protocol implementation")
---
 drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c +2 -2
index 16f780bc879b..cb19057f1191 100644
@@ -94,7 +94,7 @@ static int quickspi_get_device_descriptor(struct quickspi_device *qsdev)
 		dev_err_once(qsdev->dev, "Read DEVICE_DESCRIPTOR failed, ret = %d\n", ret);
 		dev_err_once(qsdev->dev, "DEVICE_DESCRIPTOR expected len = %u, actual read = %u\n",
 			     input_len, read_len);
-		return ret;
+		return ret ?: -EINVAL;
 	}
 
 	input_rep_type = ((struct input_report_body_header *)read_buf)->input_report_type;
@@ -318,7 +318,7 @@ int reset_tic(struct quickspi_device *qsdev)
 		dev_err_once(qsdev->dev, "Read RESET_RESPONSE body failed, ret = %d\n", ret);
 		dev_err_once(qsdev->dev, "RESET_RESPONSE body expected len = %u, actual = %u\n",
 			     read_len, actual_read_len);
-		return ret;
+		return ret ?: -EINVAL;
 	}
 
 	input_rep_type = FIELD_GET(HIDSPI_IN_REP_BDY_HDR_REP_TYPE, reset_response);
Signature · 1 line
2.53.0
#1 lore raw

Hi Dan,

Quoted 39 lines · Dan Carpenter

If we have a partial read that is supposed to be treated as failure but in this code we forgot to set the error code. Return -EINVAL.

Fixes 9d8d51735a3a ("HID: intel-thc-hid: intel-quickspi: Add HIDSPI

protocol implementation")

---
 drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c index 16f780bc879b..cb19057f1191 100644

drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c +1 -1
@@ -94,7 +94,7 @@ static int quickspi_get_device_descriptor(struct 
 quickspi_device *qsdev)
 		dev_err_once(qsdev->dev, "Read DEVICE_DESCRIPTOR failed, ret = 
 %d\n", ret);
 		dev_err_once(qsdev->dev, "DEVICE_DESCRIPTOR expected len = %u, 
 actual read = %u\n",
 			     input_len, read_len);
-		return ret;
+		return ret ?: -EINVAL;
drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c +0 -0
 	}
 
 	input_rep_type = ((struct input_report_body_header 

*)read_buf)->input_report_type;

drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c +1 -1
@@ -318,7 +318,7 @@ int reset_tic(struct quickspi_device *qsdev)
 		dev_err_once(qsdev->dev, "Read RESET_RESPONSE body failed, ret = 
 %d\n", ret);
 		dev_err_once(qsdev->dev, "RESET_RESPONSE body expected len = %u, 
 actual = %u\n",
 			     read_len, actual_read_len);
-		return ret;
+		return ret ?: -EINVAL;
 	}
Quoted 3 lines

input_rep_type = FIELD_GET(HIDSPI_IN_REP_BDY_HDR_REP_TYPE, reset_response);

Signature · 1 line
2.53.0

I think this would be throwing away other possible different return values from thc_tic_pio_read? You'd be losing the -EINTR,-EBUSY, -ETIMEDOUT conditions that might be useful to the upper layers.

Should that block be split into two separate error conditions?

Mark

#2 lore raw
Quoted 10 lines · Mark Pearson

Hi Dan,

Quoted 7 lines · Dan Carpenter

dev_err_once(qsdev->dev, "RESET_RESPONSE body expected len = %u,
actual = %u\n",

drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c +1 -1
 			     read_len, actual_read_len);
-		return ret;
+		return ret ?: -EINVAL;
 	}
Quoted 8 lines
Quoted 3 lines

input_rep_type = FIELD_GET(HIDSPI_IN_REP_BDY_HDR_REP_TYPE, reset_response);

Signature · 1 line
2.53.0

I think this would be throwing away other possible different return values from thc_tic_pio_read? You'd be losing the -EINTR,-EBUSY, -ETIMEDOUT conditions that might be useful to the upper layers.

Should that block be split into two separate error conditions?

It doesn't throw away any error codes. Writing "return ret ?: -EINVAL;" is a short hand for "return ret ? ret : -EINVAL;".

regards,
dan carpenter

Reviewed-by
#3 lore raw
Quoted 18 lines · Dan Carpenter
Quoted 17 lines · Mark Pearson

Hi Dan,

Quoted 10 lines · Dan Carpenter

dev_err_once(qsdev->dev, "RESET_RESPONSE body expected len = %u,
actual = %u\n",

drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c +1 -1
 			     read_len, actual_read_len);
-		return ret;
+		return ret ?: -EINVAL;
 	}
 
 	input_rep_type = FIELD_GET(HIDSPI_IN_REP_BDY_HDR_REP_TYPE, reset_response);
Signature · 1 line
2.53.0

I think this would be throwing away other possible different return values from thc_tic_pio_read? You'd be losing the -EINTR,-EBUSY, -ETIMEDOUT conditions that might be useful to the upper layers.

Quoted 5 lines
Quoted 1 line

Should that block be split into two separate error conditions?

It doesn't throw away any error codes. Writing "return ret ?: -EINVAL;" is a short hand for "return ret ? ret : -EINVAL;".

Yeah, you're right - read it to fast. Sorry!

maintainer Reviewed-by on v1 1/1
#4 lore raw
In reply to Dan Carpenter
Quoted 37 lines

-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Thursday, April 23, 2026 3:10 PM
To: Xu, Even <[email protected]>
Cc: Sun, Xinpeng <[email protected]>; Jiri Kosina <[email protected]>; Benjamin Tissoires <[email protected]>; Mark Pearson <mpearson- [email protected]>; Srinivas Pandruvada <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: [PATCH] HID: intel-thc-hid: Intel-quickspi: Fix some error codes

If we have a partial read that is supposed to be treated as failure but in this code we forgot to set the error code. Return -EINVAL.

Fixes 9d8d51735a3a ("HID: intel-thc-hid: intel-quickspi: Add HIDSPI protocol

implementation")

---
 drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c +1 -1
index 16f780bc879b..cb19057f1191 100644
@@ -94,7 +94,7 @@ static int quickspi_get_device_descriptor(struct
 quickspi_device *qsdev)
 		dev_err_once(qsdev->dev, "Read DEVICE_DESCRIPTOR failed,
 ret = %d\n", ret);
 		dev_err_once(qsdev->dev, "DEVICE_DESCRIPTOR expected len
 = %u, actual read = %u\n",
 			     input_len, read_len);
-		return ret;
+		return ret ?: -EINVAL;
Quoted 1 line

}

Good capture! If ret > 0, but read length != expected length, the error also needs to be thrown. Thanks for the patch!

Quoted 17 lines

input_rep_type = ((struct input_report_body_header *)read_buf)-

Quoted 1 line

input_report_type; @@ -318,7 +318,7 @@ int reset_tic(struct quickspi_device

*qsdev)
dev_err_once(qsdev->dev, "Read RESET_RESPONSE body failed,
ret = %d\n", ret);
dev_err_once(qsdev->dev, "RESET_RESPONSE body expected
len = %u, actual = %u\n",

drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c +1 -1
 			     read_len, actual_read_len);
-		return ret;
+		return ret ?: -EINVAL;
 	}
 
 	input_rep_type = FIELD_GET(HIDSPI_IN_REP_BDY_HDR_REP_TYPE,

reset_response);
--
2.53.0

maintainer Applied
#5 lore raw
In reply to Dan Carpenter
Quoted 5 lines · Dan Carpenter

If we have a partial read that is supposed to be treated as failure but in this code we forgot to set the error code. Return -EINVAL.

Fixes 9d8d51735a3a ("HID: intel-thc-hid: intel-quickspi: Add HIDSPI protocol implementation")

Applied to hid.git#for-7.1/upstream-fixes, thanks Dan.

Signature · 2 lines
Jiri Kosina
SUSE Labs