Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751612AbbKJAej (ORCPT ); Mon, 9 Nov 2015 19:34:39 -0500 Received: from mail-vk0-f44.google.com ([209.85.213.44]:36099 "EHLO mail-vk0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751066AbbKJAeg (ORCPT ); Mon, 9 Nov 2015 19:34:36 -0500 MIME-Version: 1.0 In-Reply-To: References: <1447047839-5223-1-git-send-email-liguo.zhang@mediatek.com> <1447047839-5223-2-git-send-email-liguo.zhang@mediatek.com> From: Daniel Kurtz Date: Tue, 10 Nov 2015 08:34:16 +0800 X-Google-Sender-Auth: ulYU6bGgSD0NCkOUxi3pJCa4iMs Message-ID: Subject: Re: [PATCH v2 1/2] i2c: mediatek: add i2c first write then read optimization To: Andy Shevchenko Cc: Liguo Zhang , Wolfram Sang , srv_heupstream , Matthias Brugger , Eddie Huang , Xudong Chen , Sascha Hauer , Linux I2C , "linux-kernel@vger.kernel.org" , linux-arm Mailing List , linux-mediatek@lists.infradead.org Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1751 Lines: 49 On Mon, Nov 9, 2015 at 10:25 PM, Andy Shevchenko wrote: > On Mon, Nov 9, 2015 at 7:43 AM, Liguo Zhang wrote: >> For platform with auto restart support, between every transfer, >> i2c controller will trigger an interrupt and SW need to handle >> it to start new transfer. When doing write-then-read transfer, >> instead of restart mechanism, using WRRD mode to have controller >> send both transfer in one request to reduce latency. > > >> @@ -518,6 +529,16 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap, >> if (ret) >> return ret; >> >> + i2c->auto_restart = i2c->dev_comp->auto_restart; >> + >> + /* checking if we can skip restart and optimize using WRRD mode */ >> + if (i2c->auto_restart && num == 2) { >> + if (!(msgs[0].flags & I2C_M_RD) && (msgs[1].flags & I2C_M_RD) && >> + msgs[0].addr == msgs[1].addr) { > > Nitpick (optional): > > ((msgs[0].flags & msgs[1].flags) & I2C_M_RD) > ? IMHO, this makes the code less readable. Leave this to the compiler's optimizer. -Dan > >> + i2c->auto_restart = 0; >> + } >> + } > > -- > With Best Regards, > Andy Shevchenko > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/