From: Frans Klaver Date: Fri, 16 Jun 2017 17:45:56 +0000 (+0200) Subject: staging: fusb302: don't bitshift __le16 type X-Git-Tag: v4.14-rc1~623^2~73 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9e8caa7a67535fc544c2504fae3e71a02cfb01a;p=platform%2Fkernel%2Flinux-rpi.git staging: fusb302: don't bitshift __le16 type The header field in struct pd_message is declared as an __le16 type. The data in the message is supposed to be little endian. This means we don't have to go and shift the individual bytes into position when we're filling the buffer, we can just copy the contents right away. As an added benefit we don't get fishy results on big endian systems anymore. Signed-off-by: Frans Klaver Reviewed-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c index 4a356e5..03a3809 100644 --- a/drivers/staging/typec/fusb302/fusb302.c +++ b/drivers/staging/typec/fusb302/fusb302.c @@ -1039,8 +1039,8 @@ static int fusb302_pd_send_message(struct fusb302_chip *chip, } /* packsym tells the FUSB302 chip that the next X bytes are payload */ buf[pos++] = FUSB302_TKN_PACKSYM | (len & 0x1F); - buf[pos++] = msg->header & 0xFF; - buf[pos++] = (msg->header >> 8) & 0xFF; + memcpy(&buf[pos], &msg->header, sizeof(msg->header)); + pos += sizeof(msg->header); len -= 2; memcpy(&buf[pos], msg->payload, len);