Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4875435imm; Wed, 30 May 2018 13:54:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK9sBufPFjiDdObdb3XLI1HSYDvfcjHRhBxjkYS4jlvMkBLtyryNzXCJsTDBSIJBQ30KBZq X-Received: by 2002:a17:902:ab8b:: with SMTP id f11-v6mr4181367plr.372.1527713688873; Wed, 30 May 2018 13:54:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527713688; cv=none; d=google.com; s=arc-20160816; b=cGlOimWMlQEUrdDU/Wr3LqMmAd01x28Kwk+mtgBBZwSOzzNf+7RV3R/yzEg6QO2me9 KFl+U/OFIbqbNxgM3aMoPGtfqTBiMJrR9AW6anM0R/I0heog87WTQ8fEfp6d0sfT+Dx7 Thv7Oy+/XxLaAdeM7J1/phQBeEp533s41HKWq/VO1KDvl8h98UOZo5PYas1zSj9VDYUr 6cIHDw89Yc2oX3SJsDjgJawaKM6Tu1MFsO7orBmKExqngk4gICjrSTo50XFrOvpf1van PJ162xclsK+uoheL3k5G2aEK4f5JzYuwBR4PSTf35v06ghmIayemu4jZ3zQM0DepZ/im LVsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :from:references:cc:to:subject:arc-authentication-results; bh=RorFfxtrxH3SjpCcfW2vpdHqT3umjZilzlwWTa4UwMg=; b=vGI43dmDcllXkDzlKwrGSLHxLs+FXZDBe6EAMoOiwjtCrIejieP8+mEOvHGtQPwF78 Gb3nbJ3Fy1Wrb0goNursf7BkGh5MNE4CIUBqTgddbIDiOj407OUKzXKj+wM/aaX9aQEl ImK53P0uanp5AE+Hy1mENjOoE0bG7wON+SxTehfm5dCJZ6DUO4LkPnp27ngMhLbKQsMK OKhDx3oIO15MUVWSzJ7etx0q5sdpqxGPOWoUSvQyKUlggLKLztiO9SBEGvJISQUy+NlF EJTcfzG+KF239fGbK+hjLlPsvFGLezLsqswMoYV/yvQabGb+7Bj0szlK58JaMafRhqUZ BUXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h127-v6si38859911pfb.111.2018.05.30.13.54.35; Wed, 30 May 2018 13:54:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932334AbeE3UyE (ORCPT + 99 others); Wed, 30 May 2018 16:54:04 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43032 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932238AbeE3UyC (ORCPT ); Wed, 30 May 2018 16:54:02 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4UKkTiH090296 for ; Wed, 30 May 2018 16:54:01 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ja0vqps3t-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 30 May 2018 16:54:01 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 May 2018 14:54:00 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 30 May 2018 14:53:56 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4UKrtom12190076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 30 May 2018 13:53:55 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 452036E050; Wed, 30 May 2018 14:53:55 -0600 (MDT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 69AEF6E04C; Wed, 30 May 2018 14:53:54 -0600 (MDT) Received: from [9.41.241.240] (unknown [9.41.241.240]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 30 May 2018 14:53:54 -0600 (MDT) Subject: Re: [PATCH v7 5/7] drivers/i2c: Add transfer implementation for FSI algorithm To: Andy Shevchenko Cc: linux-i2c , Linux Kernel Mailing List , devicetree , Wolfram Sang , Rob Herring , Benjamin Herrenschmidt , Joel Stanley , Mark Rutland , Greg Kroah-Hartman , "Edward A. James" References: <1527632665-25707-1-git-send-email-eajames@linux.vnet.ibm.com> <1527632665-25707-6-git-send-email-eajames@linux.vnet.ibm.com> From: Eddie James Date: Wed, 30 May 2018 15:53:53 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18053020-0012-0000-0000-0000165A7179 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009099; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000264; SDB=6.01039983; UDB=6.00532322; IPR=6.00819117; MB=3.00021382; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-30 20:53:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18053020-0013-0000-0000-0000530BEA02 Message-Id: <710a9afe-e268-9dbc-5183-9793d4eae2d3@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-30_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1805300221 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/29/2018 07:08 PM, Andy Shevchenko wrote: > On Wed, May 30, 2018 at 1:24 AM, Eddie James wrote: >> From: "Edward A. James" >> >> Execute I2C transfers from the FSI-attached I2C master. Use polling >> instead of interrupts as we have no hardware IRQ over FSI. >> + if (msg->flags & I2C_M_RD) >> + cmd |= I2C_CMD_READ; > I think we have a helper for this, though not sure. Didn't see any other I2C drivers using any helper for msg->flags. > >> +static int fsi_i2c_write_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, >> + u8 fifo_count) >> +{ >> + int write; >> + int rc = 0; > Redundant assignment. > >> + struct fsi_i2c_master *i2c = port->master; >> + int bytes_to_write = i2c->fifo_size - fifo_count; >> + int bytes_remaining = msg->len - port->xfrd; >> + if (bytes_to_write > bytes_remaining) >> + bytes_to_write = bytes_remaining; > _write = min(_write, _remaining); > >> + while (bytes_to_write > 0) { >> + write = bytes_to_write; >> + /* fsi limited to max 4 byte aligned ops */ >> + if (bytes_to_write > 4) >> + write = 4; >> + else if (write == 3) >> + write = 2; > write = min_t(int, 4, rounddown_pow_of_two(bytes_to_write)); > > Also check it carefully, it might be optimized even more, though I > didn't think much. I think it is more readable this way, and I'm not convinced the min(rounddown()) is faster. I did however add a common function to do this check since it's performed in both the read and write fifo functions. Let me know what you think on v8. Thanks, Eddie