git: f22498bb4b48 - stable/13 - linuxkpi: i2c: Fix 7bit/8bit addressing

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Wed, 07 Sep 2022 15:10:43 UTC
The branch stable/13 has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=f22498bb4b48ec4b8b8041367aa80099ec0caf26

commit f22498bb4b48ec4b8b8041367aa80099ec0caf26
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2022-08-19 12:37:05 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-09-07 15:09:06 +0000

    linuxkpi: i2c: Fix 7bit/8bit addressing
    
    Linux is using 7 bit addressing while FreeBSD uses 8 bit addresses
    internally, but i2c(8) uses 7 bit address.
    This confused me when originally doing the code and I thought that
    0x50 was the 8bit EDID address while it's the 7bit address and since
    I did all my testing using this I didn't noticed the problem.
    
    Reported by:    avg
    PR:             265920 (somewhat)
    
    (cherry picked from commit 319a4bddb0b991377208293283a87946e4b5d055)
---
 sys/compat/linuxkpi/common/src/linux_i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_i2c.c b/sys/compat/linuxkpi/common/src/linux_i2c.c
index 80b47a74c2e5..a94ed630ab73 100644
--- a/sys/compat/linuxkpi/common/src/linux_i2c.c
+++ b/sys/compat/linuxkpi/common/src/linux_i2c.c
@@ -185,7 +185,7 @@ lkpi_i2c_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs)
 	    M_DEVBUF, M_WAITOK | M_ZERO);
 
 	for (i = 0; i < nmsgs; i++) {
-		linux_msgs[i].addr = msgs[i].slave;
+		linux_msgs[i].addr = msgs[i].slave >> 1;
 		linux_msgs[i].len = msgs[i].len;
 		linux_msgs[i].buf = msgs[i].buf;
 		if (msgs[i].flags & IIC_M_RD) {