From: Pan Li <incarnation.p....@outlook.com>

    Makes header assignmen happy by shared the memory between
__le16 and u16.

Signed-off-by: Pan Li <incarnation.p....@outlook.com>
---
 drivers/staging/typec/pd.h    | 10 +++++++++-
 drivers/staging/typec/tcpci.c |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/typec/pd.h b/drivers/staging/typec/pd.h
index 510ef72..b85c0ab 100644
--- a/drivers/staging/typec/pd.h
+++ b/drivers/staging/typec/pd.h
@@ -105,10 +105,18 @@ static inline unsigned int pd_header_msgid_le(__le16 
header)
 #define PD_MAX_PAYLOAD         7
 
 struct pd_message {
-       __le16 header;
+       union {
+               __le16 header;
+               u16 header_u16;
+       };
        __le32 payload[PD_MAX_PAYLOAD];
 } __packed;
 
+static inline void pd_message_header_set(struct pd_message *msg, u16 header)
+{
+       msg->header_u16 = header;
+}
+
 /* PDO: Power Data Object */
 #define PDO_MAX_OBJECTS                7
 
diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index b6bf15b..8437ea1 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -390,7 +390,7 @@ static irqreturn_t tcpci_irq(int irq, void *dev_id)
                regmap_read(tcpci->regmap, TCPC_RX_BYTE_CNT, &cnt);
 
                tcpci_read16(tcpci, TCPC_RX_HDR, &header);
-               msg.header = header;
+               pd_message_header_set(&msg, header);
 
                if (WARN_ON(cnt > sizeof(msg.payload)))
                        cnt = sizeof(msg.payload);
-- 
1.9.1

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to