Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3862130ybb; Mon, 23 Mar 2020 09:02:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsyGudJCFHcUZkJApu5U7qT1KfzVxn3XapVSXQy0iQ8mEaFGHIoG+hIO/wVyWJr5V8T9Oul X-Received: by 2002:aca:ebca:: with SMTP id j193mr30188oih.124.1584979378557; Mon, 23 Mar 2020 09:02:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584979378; cv=none; d=google.com; s=arc-20160816; b=pbPsXs4aoXKugNQweyTlAm/gGPfdcqs7P5TuVxmorwwqTVZSE/NxXBsXc/Vl8gcGWB htI9MXmQ1t3YfciGU69x2OQRi50gCj0hnqmtUYOHuTy3xZS7jVv50Ix1RFIYbh0sFYnr E/LefZza4bkU+fJYKh0hr5nDVUHnD+0Z4Yo/r7EzuJtcv4M6svrC9+sbzy+IcvNhedP8 k6JJbU2V0OvzDDRKyH1Mlf/HmwIghsLh/lDOknm8qlzDVqSdXTBESX76uwIoWD23Bfgu vlDyrd7GCPCYQeAJ9N2fysyavzxB6f+yjO+c+U6mu4LgD2Mkj7PC2a1JmIVA4iQbHMpr xCIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=jojqDCzx75kCNaumESPC7q/wMSeSak3OcLMRviVxsFs=; b=lCsZYzyQMOeOqu6nxV4HGKCFUOkQmseg2W/E+Nn9z2U/KGdfGj0UY/A/lyNDeK0Ig4 4WQxhEGN8sl/7t2CUfORnbcw9AlyWYDhcP8EnLPSaDsZjpZZ45crflUSVVk7NNsrTy9i 9upUgyD+lGsI82x1EAg9Bko9cTqZTy4W/vGIdfgBwokgB7fqWiUWDLPjUOokqYcs3yT/ yR6RqsQdc2LduuNQyeShWl0sr3yTZ5A9Iw55sNMthVSr+dh+26V0JN5drWNMYJyNfYgu F2bghxCZq10ylkPDjYos9oXFmmvV8tUW1ViFqwnjw6JgpRxOsZS7QILGg5E3269N1eOU lt/Q== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s139si7439729oih.7.2020.03.23.09.02.42; Mon, 23 Mar 2020 09:02: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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727270AbgCWQCB (ORCPT + 99 others); Mon, 23 Mar 2020 12:02:01 -0400 Received: from mga02.intel.com ([134.134.136.20]:32341 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727202AbgCWQCB (ORCPT ); Mon, 23 Mar 2020 12:02:01 -0400 IronPort-SDR: TvtmP/Q0fha7U9o6c0qGRituI6dHQ7XK4V9zApEYEE/05K5MWsaf6tovA+3url+ImvYXOi5NCz Ytsq6ycqWMrQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2020 09:02:00 -0700 IronPort-SDR: phtAgXXYbKsiJe/zuUmNdIE1gUiEZCE8YR7T4VrWwwkSIrwsF2/9wxBJwxSQMlx+2lPFi5ZkMR RMlpw1k/n3nw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,296,1580803200"; d="scan'208";a="264820911" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga002.jf.intel.com with ESMTP; 23 Mar 2020 09:01:56 -0700 Received: from andy by smile with local (Exim 4.93) (envelope-from ) id 1jGPWY-00CHV3-M7; Mon, 23 Mar 2020 18:01:58 +0200 Date: Mon, 23 Mar 2020 18:01:58 +0200 From: Andy Shevchenko To: Tali Perry Cc: brendanhiggins@google.com, avifishman70@gmail.com, tmaimon77@gmail.com, kfting@nuvoton.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, robh+dt@kernel.org, wsa@the-dreams.de, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v9 3/3] i2c: npcm7xx: Add support for slave mode for Nuvoton Message-ID: <20200323160158.GR1922688@smile.fi.intel.com> References: <20200323134437.259210-1-tali.perry1@gmail.com> <20200323134437.259210-4-tali.perry1@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200323134437.259210-4-tali.perry1@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 23, 2020 at 03:44:37PM +0200, Tali Perry wrote: > Add support for slave mode for Nuvoton > NPCM BMC I2C controller driver. Same comments apply as per previous patch. ... > +#if IS_ENABLED(CONFIG_I2C_SLAVE) Perhaps create a separate module and compile it when user selects? See I?C DesignWare split. ... > +#if IS_ENABLED(CONFIG_I2C_SLAVE) > + if (bus->slave) { > + npcm_i2c_slave_enable_l(bus, I2C_SLAVE_ADDR1, bus->slave->addr, > + true); > + } Put it on one line and drop {} -- it will be much better to read. > +#endif ... > +static void npcm_i2c_write_to_fifo_slave(struct npcm_i2c *bus, > + u16 max_bytes_to_send) > +{ > + // Fill the FIFO, while the FIFO is not full and there are more bytes to > + // write > + npcm_i2c_clear_fifo_int(bus); > + npcm_i2c_clear_tx_fifo(bus); > + iowrite8(0, bus->reg + NPCM_I2CTXF_CTL); > + > + while ((max_bytes_to_send--) && (I2C_HW_FIFO_SIZE - > + npcm_i2c_get_fifo_fullness(bus))) { > + if (bus->slv_wr_size > 0) { > + npcm_i2c_wr_byte(bus, > + bus->slv_wr_buf[bus->slv_wr_ind % > + I2C_HW_FIFO_SIZE]); > + bus->slv_wr_ind = (bus->slv_wr_ind + 1) % > + I2C_HW_FIFO_SIZE; > + bus->slv_wr_size--; // size indicates the # of bytes in > + // the SW FIFO, not HW. > + } else { > + break; > + } This looks ugly. Can you redo the style. > + } > +} ... > +#if IS_ENABLED(CONFIG_I2C_SLAVE) > + if (bus->slave) { > + bus->slv_rd_buf[bus->slv_rd_ind % > + I2C_HW_FIFO_SIZE] = data; > + bus->slv_rd_ind++; > + if (bus->slv_rd_ind == 1 && bus->read_block_use) > + // 1st byte is length in block protocol > + bus->slv_rd_size = data + > + (u8)bus->PEC_use + > + (u8)bus->read_block_use; > + } > +#endif Ditto. ... > I2C_FUNC_SMBUS_EMUL | > I2C_FUNC_SMBUS_BLOCK_DATA | > I2C_FUNC_SMBUS_PEC > +#if IS_ENABLED(CONFIG_I2C_SLAVE) > + | I2C_FUNC_SLAVE > +#endif Completely inconsistent style. > ; -- With Best Regards, Andy Shevchenko