Received: from eggs.gnu.org ([2001:4830:134:3::10]:35764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1byQTe-00057G-3v for qemu-devel@nongnu.org; Sun, 23 Oct 2016 17:38:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1byQTZ-0005gT-6v for qemu-devel@nongnu.org; Sun, 23 Oct 2016 17:38:46 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:32834) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1byQTY-0005g7-WD for qemu-devel@nongnu.org; Sun, 23 Oct 2016 17:38:41 -0400 Received: by mail-pf0-x241.google.com with SMTP id i85so14522299pfa.0 for ; Sun, 23 Oct 2016 14:38:40 -0700 (PDT) Reply-To: minyard@acm.org References: <1470153614-6657-1-git-send-email-minyard@acm.org> <76e1ee36-4e63-b22d-d41f-52d8ecfe3e14@acm.org> From: Corey Minyard Message-ID: Date: Sun, 23 Oct 2016 16:38:36 -0500 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] i2c: Fix SMBus read transactions to avoid double events List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , Corey Minyard Cc: Corey Minyard , Kwon , Peter Crosthwaite , QEMU Developers , Alistair Francis , KONRAD Frederic On 10/22/2016 04:20 AM, Peter Maydell wrote: >>> I got here because Coverity complains that the >>> i2c_start_transfer() calls in smbus.c don't check their >>> return value. That suggests to me that we'd be better off >>> having a different function (i2c_restart_transfer() ??) >>> for the "I know we already did this once, so don't try to >>> re-determine who to send this to" case, rather than trying to >>> handle both cases in the same function. >> >> Perhaps so. Or maybe i2c_continue_transfer(). That would >> be more clear. The second operation can't fail, but relying >> on that is frail. > i2c_continue_transfer() sounds like a better name, yes. > Would you like to write a patch that takes that approach? > If you cc me I'll review it and put it through the > target-arm tree. I was working on this and looking at old information, and realized that this won't work. The same problem exists in I2C devices when doing SMBus emulation, the device driver in the OS will cause a i2c_start_transfer() to be done twice without an intervening i2c_end_transfer(). Though a continue function would fix the smbus case, it won't fix the i2c case. I can't think of a better way to do it than I have done. Where do you want to go on this? -corey