From owner-dev-commits-src-all@freebsd.org Tue May 11 23:07:59 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 61FD4629B46; Tue, 11 May 2021 23:07:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fftqz2LNQz3CWW; Tue, 11 May 2021 23:07:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3ECE520B0F; Tue, 11 May 2021 23:07:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 14BN7x77094910; Tue, 11 May 2021 23:07:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 14BN7xUk094908; Tue, 11 May 2021 23:07:59 GMT (envelope-from git) Date: Tue, 11 May 2021 23:07:59 GMT Message-Id: <202105112307.14BN7xUk094908@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Poul-Henning Kamp Subject: git: b2ae176d914a - main - Sixteen bit I2c addresses are always little endian. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: phk X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b2ae176d914acd63247e24d7e23dbe8f239fbfb0 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 23:07:59 -0000 The branch main has been updated by phk: URL: https://cgit.FreeBSD.org/src/commit/?id=b2ae176d914acd63247e24d7e23dbe8f239fbfb0 commit b2ae176d914acd63247e24d7e23dbe8f239fbfb0 Author: Poul-Henning Kamp AuthorDate: 2021-05-11 23:07:06 +0000 Commit: Poul-Henning Kamp CommitDate: 2021-05-11 23:07:06 +0000 Sixteen bit I2c addresses are always little endian. --- usr.sbin/i2c/i2c.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/usr.sbin/i2c/i2c.c b/usr.sbin/i2c/i2c.c index 1df12cf44460..23613ee744f9 100644 --- a/usr.sbin/i2c/i2c.c +++ b/usr.sbin/i2c/i2c.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -570,22 +571,18 @@ i2c_rdwr_transfer(const char *dev, struct options i2c_opt, char *i2c_buf) struct iic_msg msgs[2]; struct iic_rdwr_data xfer; int fd, i; - union { - uint8_t buf[2]; - uint8_t off8; - uint16_t off16; - } off; + uint8_t off_buf[2]; i = 0; if (i2c_opt.width > 0) { msgs[i].flags = IIC_M_WR | IIC_M_NOSTOP; msgs[i].slave = i2c_opt.addr; - msgs[i].buf = off.buf; + msgs[i].buf = off_buf; if (i2c_opt.width == 8) { - off.off8 = (uint8_t)i2c_opt.off; + off_buf[0] = i2c_opt.off; msgs[i].len = 1; } else { - off.off16 = (uint16_t)i2c_opt.off; + le16enc(off_buf, i2c_opt.off); msgs[i].len = 2; } ++i;