From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6iAk-0002Ct-Tc for qemu-devel@nongnu.org; Wed, 09 Dec 2015 12:04:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a6iAi-00005f-8C for qemu-devel@nongnu.org; Wed, 09 Dec 2015 12:04:58 -0500 Received: from mail-qg0-x230.google.com ([2607:f8b0:400d:c04::230]:34262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a6iAi-00005b-3r for qemu-devel@nongnu.org; Wed, 09 Dec 2015 12:04:56 -0500 Received: by qgeb1 with SMTP id b1so89553625qge.1 for ; Wed, 09 Dec 2015 09:04:55 -0800 (PST) Sender: Paolo Bonzini References: <1664220.kcr3K9QWbf@dabox> <9231947.7qKgf3ndKO@dabox> <56585242.3050501@redhat.com> <1515037.S0cnTfez5T@hydra> From: Paolo Bonzini Message-ID: <56685F2C.2010202@redhat.com> Date: Wed, 9 Dec 2015 18:04:44 +0100 MIME-Version: 1.0 In-Reply-To: <1515037.S0cnTfez5T@hydra> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] i2c data address question was Re: [PATCH RFC] i2c-tiny-usb List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tim Sander Cc: qemu-devel@nongnu.org, Gerd Hoffmann On 09/12/2015 17:40, Tim Sander wrote: >> > If there is no slave at the requested address, i2c_start_transfer will >> > return 1. > Ok, that works. Now probably the last problem i see is that i fail to set the > data-address of the i2c-device? > I know the correct offset address for accesses on the bus e.g. > i2cget -y 0 0x50 2 > where 2 is an example offset for the access to this device. > > So any hint how setting the data-address on the i2c bus in qemu works? If you have a data address, you probably want to use functions like smbus_read_byte that do the right write-read sequence for you: if (i2c_start_transfer(bus, addr, 0)) { return -1; } i2c_send(bus, command); i2c_start_transfer(bus, addr, 1); data = i2c_recv(bus); i2c_nack(bus); i2c_end_transfer(bus); Paolo