mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: typec: ucsi: correctly access opcode
@ 2023-05-23 16:23 Min-Hua Chen
  2023-05-24 10:30 ` Heikki Krogerus
  0 siblings, 1 reply; 2+ messages in thread
From: Min-Hua Chen @ 2023-05-23 16:23 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman; +Cc: Min-Hua Chen, linux-usb, linux-kernel

hdr->opcode is __le32 type, use le32_to_cpu() to cast opcode
to integer in the switch..case statement to fix the following
sparse warnings:

drivers/usb/typec/ucsi/ucsi_glink.c:248:20: sparse: warning: restricted __le32 degrades to integer
drivers/usb/typec/ucsi/ucsi_glink.c:248:20: sparse: warning: restricted __le32 degrades to integer
drivers/usb/typec/ucsi/ucsi_glink.c:248:20: sparse: warning: restricted __le32 degrades to integer

No functional change.

Signed-off-by: Min-Hua Chen <minhuadotchen@gmail.com>
---
 drivers/usb/typec/ucsi/ucsi_glink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
index b454a5159896..1fe9cb5b6bd9 100644
--- a/drivers/usb/typec/ucsi/ucsi_glink.c
+++ b/drivers/usb/typec/ucsi/ucsi_glink.c
@@ -245,7 +245,7 @@ static void pmic_glink_ucsi_callback(const void *data, size_t len, void *priv)
 	struct pmic_glink_ucsi *ucsi = priv;
 	const struct pmic_glink_hdr *hdr = data;
 
-	switch (hdr->opcode) {
+	switch (le32_to_cpu(hdr->opcode)) {
 	case UC_UCSI_READ_BUF_REQ:
 		pmic_glink_ucsi_read_ack(ucsi, data, len);
 		break;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] usb: typec: ucsi: correctly access opcode
  2023-05-23 16:23 [PATCH] usb: typec: ucsi: correctly access opcode Min-Hua Chen
@ 2023-05-24 10:30 ` Heikki Krogerus
  0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2023-05-24 10:30 UTC (permalink / raw)
  To: Min-Hua Chen; +Cc: Greg Kroah-Hartman, linux-usb, linux-kernel

On Wed, May 24, 2023 at 12:23:12AM +0800, Min-Hua Chen wrote:
> hdr->opcode is __le32 type, use le32_to_cpu() to cast opcode
> to integer in the switch..case statement to fix the following
> sparse warnings:
> 
> drivers/usb/typec/ucsi/ucsi_glink.c:248:20: sparse: warning: restricted __le32 degrades to integer
> drivers/usb/typec/ucsi/ucsi_glink.c:248:20: sparse: warning: restricted __le32 degrades to integer
> drivers/usb/typec/ucsi/ucsi_glink.c:248:20: sparse: warning: restricted __le32 degrades to integer
> 
> No functional change.
> 
> Signed-off-by: Min-Hua Chen <minhuadotchen@gmail.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/ucsi/ucsi_glink.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi_glink.c b/drivers/usb/typec/ucsi/ucsi_glink.c
> index b454a5159896..1fe9cb5b6bd9 100644
> --- a/drivers/usb/typec/ucsi/ucsi_glink.c
> +++ b/drivers/usb/typec/ucsi/ucsi_glink.c
> @@ -245,7 +245,7 @@ static void pmic_glink_ucsi_callback(const void *data, size_t len, void *priv)
>  	struct pmic_glink_ucsi *ucsi = priv;
>  	const struct pmic_glink_hdr *hdr = data;
>  
> -	switch (hdr->opcode) {
> +	switch (le32_to_cpu(hdr->opcode)) {
>  	case UC_UCSI_READ_BUF_REQ:
>  		pmic_glink_ucsi_read_ack(ucsi, data, len);
>  		break;
> -- 
> 2.34.1

-- 
heikki

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-24 10:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-23 16:23 [PATCH] usb: typec: ucsi: correctly access opcode Min-Hua Chen
2023-05-24 10:30 ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®