From owner-freebsd-stable@FreeBSD.ORG Fri Nov 21 14:21:35 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 26AA11065672 for ; Fri, 21 Nov 2008 14:21:35 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 614018FC12 for ; Fri, 21 Nov 2008 14:21:34 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id QAA15561; Fri, 21 Nov 2008 16:21:28 +0200 (EET) (envelope-from avg@icyb.net.ua) Message-ID: <4926C3E7.7010001@icyb.net.ua> Date: Fri, 21 Nov 2008 16:21:27 +0200 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.17 (X11/20081106) MIME-Version: 1.0 To: joerg_wunsch@uriah.heep.sax.de, FreeBSD Stable References: <4926BDE5.5020708@icyb.net.ua> In-Reply-To: <4926BDE5.5020708@icyb.net.ua> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Subject: Re: smbmsg(8): slave address confusion? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Nov 2008 14:21:35 -0000 on 21/11/2008 15:55 Andriy Gapon said the following: > It seems that smbmsg is another victim in "Great SMBus Slave Address > Confusion" - there are two schools: one that think that slave address is > (addr >> 1) and there other thinks that slave address is (addr & ~0x1). > It seems that smb driver in FreeBSD takes the first approach, but smbmsg > is keen on the second. Patch and new output: diff --git a/usr.sbin/smbmsg/smbmsg.c b/usr.sbin/smbmsg/smbmsg.c index 425b782..f2b8139 100644 --- a/usr.sbin/smbmsg/smbmsg.c +++ b/usr.sbin/smbmsg/smbmsg.c @@ -68,8 +68,8 @@ static unsigned short oword, iword; * 240 are reserved. Address 0 is the global address, but we do not * care for this detail. */ -#define MIN_I2C_ADDR 16 -#define MAX_I2C_ADDR 240 +#define MIN_I2C_ADDR 8 +#define MAX_I2C_ADDR 120 static int do_io(void); static int getnum(const char *s); @@ -109,7 +109,7 @@ probe_i2c(void) printf("Probing for devices on %s:\n", dev); - for (addr = MIN_I2C_ADDR; addr < MAX_I2C_ADDR; addr += 2) { + for (addr = MIN_I2C_ADDR; addr < MAX_I2C_ADDR; addr++) { c.slave = addr; flags = 0; if (ioctl(fd, SMB_RECVB, &c) != -1) $ smbmsg -p Probing for devices on /dev/smb0: Device @0x08: w Device @0x44: rw Device @0x50: rw Device @0x52: rw Device @0x69: rw The only thing I am hesitant about - which address format is to present to user? (addr >> 1) as above or (addr & ~0x1) as conventional for linux folk. -- Andriy Gapon