Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3923766imm; Tue, 29 May 2018 17:09:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKCOpKmqGN8nIOQoXuSDSXUZicg1DVJcAq3w+T196qGDAGs/Q/Q6o3qFoAGEXpjGzpkRkyg X-Received: by 2002:a65:65ce:: with SMTP id y14-v6mr405488pgv.270.1527638998467; Tue, 29 May 2018 17:09:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527638998; cv=none; d=google.com; s=arc-20160816; b=LRYCC3Hoi5x9WEtEF8vPiY533Ne5JyoorsF2vlJRaemKknhNRAfTJ/ZD7v8BlBFPEV BxyjQU9g/0PM9ifYFVZp9k5+Zn/fHzCASs6uueS2GmL2bEeVvPihQL7+1wIjOY8y4YPu Twu/mnaghBhDu1DlLiS7Qq2WkoRBKFS2sXvugUqw+un1eC1CSglF44da0A4y4Bz9wwsq 7JESHU+jAoSF15xPPKaPjNlePnXjP9d3dWLrupmkgpMboOWMIw3CKOfBufkkxV+NJ0++ 0Sl6JU7icC7LGedtV3iWP6xF7yO7T1Z855LhVUnOObTuQLEuHQUWV+fgMfjWFySzHlvL YF1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=BMClRgPnYgCR0bp97kUv9ZNgEb2hF8r5HLQ5AZlI6ms=; b=vjo1JwU2F72NeDPZdKGMkJcDrrnRZfsCCy/nUpSvSsWLdguhRpoR7XYXs1GSLon4WB Jv/TIfMq6476M7zO6pWas0ZPkVIA32c+Q2zs+VzB3QB+Iden4M7hNiy7WCpFMCwk4bgj pQZEtGBeBpGY0+RRkRkJmDSWjMJqvjrzoE8JXaKaEIlO1zkSsAeyFqafAyNW3rAYt9f6 WcHJJw7D6dgq1a2O93j8J1GkkBxclVlZUQ/WqGvmPYhdyJnkACTOKfh1RqoALsjj6ULr ACV5wf3eC5ksPFw5E6Fua62pSvjoYxe0zzAov9b7xY1czoJQ+E6vc+lYtKO86ggjUCkE s3Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pWHzmVra; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w20-v6si33886507pfn.12.2018.05.29.17.09.44; Tue, 29 May 2018 17:09:58 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pWHzmVra; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967388AbeE3AIJ (ORCPT + 99 others); Tue, 29 May 2018 20:08:09 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:34022 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755408AbeE3AIE (ORCPT ); Tue, 29 May 2018 20:08:04 -0400 Received: by mail-qt0-f195.google.com with SMTP id m5-v6so21097556qti.1; Tue, 29 May 2018 17:08:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=BMClRgPnYgCR0bp97kUv9ZNgEb2hF8r5HLQ5AZlI6ms=; b=pWHzmVraUD9Vdm3friyJ25a9/FJJB8wIKitsh/e3fWWKwEqlo4t0KgqtjY4XUjcw9O lRaD3Woyg5btRnq7O+yjOtqpwWbj/bN4Od0LNljIhRfOEJ8pwVV8DUVqWyhDKrPcDraO Ei7HiDiRi0MCB5XHoVc8REY/uNcUcZeVS3uVuBaTeOgJ3AiGSSl0b/RHJ4NHHd2psC0F 8Q1Sb0rDYYdJ72Jkv3nHrTaWDmZXFvA6DCyfdNzSrR15t3pxOTTHozSrvmF+cJTYqpoW v0J602TaI8OCNbaHRGBE+K7iWFy7SLyMzWPtmvWaMciMLT3xSO1QMiXsGQP/52k3LMkl dqtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=BMClRgPnYgCR0bp97kUv9ZNgEb2hF8r5HLQ5AZlI6ms=; b=tMo1Ik9zU6tlP9Rdr8z8pzTZiYh64WMF3LYnWbFtUq7i6cR5YaDOAnNEqwGXXfqP92 sDSEwlSiphPiXVry5kdkMhXxqVZrGhRTZ3unkV3TKwO7pl+0vE7ZKCdz8FNY+OHR45Tx HUYdKW7SJoVB0xHYtHY6i6n9HD1IKVuLX0fhd4D4oKd1szlM2nl0p2CXR+uLF+p+V7Em rwoDGppMC1ReMvlmpFa4YzaCR98Nj6SfeBvjU75fHjOilqbHqDsmRQSAqoDoNZFsiAZP uCEebBjpfb9aQj671Zco73rRWBm7PbI3fSEGo5NdGe/Yj2tUplEd4Ovw5qH8PpMrmYhs upzw== X-Gm-Message-State: APt69E3BDMfJZmLRgipVNFOm3tO+GqN1zjX/6gI/AL2kiAP78h8d/4fZ +IUWx21WkA9WLD3OILFTgsHN0tnlKuyrwLASEPQ= X-Received: by 2002:aed:3ce8:: with SMTP id e37-v6mr494457qtf.295.1527638883434; Tue, 29 May 2018 17:08:03 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:9896:0:0:0:0:0 with HTTP; Tue, 29 May 2018 17:08:02 -0700 (PDT) In-Reply-To: <1527632665-25707-6-git-send-email-eajames@linux.vnet.ibm.com> References: <1527632665-25707-1-git-send-email-eajames@linux.vnet.ibm.com> <1527632665-25707-6-git-send-email-eajames@linux.vnet.ibm.com> From: Andy Shevchenko Date: Wed, 30 May 2018 03:08:02 +0300 Message-ID: Subject: Re: [PATCH v7 5/7] drivers/i2c: Add transfer implementation for FSI algorithm To: Eddie James Cc: linux-i2c , Linux Kernel Mailing List , devicetree , Wolfram Sang , Rob Herring , Benjamin Herrenschmidt , Joel Stanley , Mark Rutland , Greg Kroah-Hartman , "Edward A. James" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > +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. > + } > + return rc; How it can be non-zero? > +} > + > +static int fsi_i2c_read_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, > + u8 fifo_count) > +{ > + int read; > + int rc = 0; Redundant assignment. > + struct fsi_i2c_master *i2c = port->master; > + int xfr_remaining = msg->len - port->xfrd; > + u32 dummy; > + > + while (fifo_count) { > + read = fifo_count; > + /* fsi limited to max 4 byte aligned ops */ > + if (fifo_count > 4) > + read = 4; > + else if (read == 3) > + read = 2; See above for write case and do in similar way. > + > + if (xfr_remaining) { > + if (xfr_remaining < read) > + read = xfr_remaining; read = min(read, _remaining); > + > + rc = fsi_device_read(i2c->fsi, I2C_FSI_FIFO, > + &msg->buf[port->xfrd], read); > + if (rc) > + return rc; > + > + port->xfrd += read; > + xfr_remaining -= read; > + } else { > + /* no more buffer but data in fifo, need to clear it */ > + rc = fsi_device_read(i2c->fsi, I2C_FSI_FIFO, &dummy, > + read); > + if (rc) > + return rc; > + } > + > + fifo_count -= read; > + } > + > + return rc; How non-zero possible here? > +} > + if (port->xfrd < msg->len) > + rc = -ENODATA; > + else > + rc = msg->len; > + > + return rc; if (...) return -ENODATA; return msg->len; ? > + u32 status = 0; Redundant assignment. > + return -ETIME; ETIMEDOUT ? -- With Best Regards, Andy Shevchenko