[PATCH v1] Input: ads7846: ads7846_get_value - fix unaligned pointer value warning

From: Oleksij Rempel
Date: Wed Jul 07 2021 - 08:41:34 EST


Fix warning reported by the kernel test robot:
drivers/input/touchscreen/ads7846.c:705:24: warning: taking address
of packed member 'data' of class or structure 'ads7846_buf' may result
in an unaligned pointer value [-Waddress-of-packed-member]

Fixes: 6965eece2a89 ("Input: ads7846 - convert to one message")
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
---
drivers/input/touchscreen/ads7846.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index adb4c2230c31..1987dedac94f 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -702,7 +702,7 @@ static int ads7846_get_value(struct ads7846_buf *buf)
{
int value;

- value = be16_to_cpup(&buf->data);
+ value = get_unaligned_be16(&buf->data);

/* enforce ADC output is 12 bits width */
return (value >> 3) & 0xfff;
--
2.30.2