Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp434989ybk; Wed, 20 May 2020 03:27:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx50bYcA0qf3PPgFxYXn3euJL/UpxojhoooAp1J49Nwx84MmcwcUYcoeR9mi+js7fBQR+yb X-Received: by 2002:a17:906:eb1a:: with SMTP id mb26mr2922983ejb.362.1589970450981; Wed, 20 May 2020 03:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589970450; cv=none; d=google.com; s=arc-20160816; b=jR3l6HiUDs7MdWumr1MPL2ToM8K0wGdRq3VqbbadICOQ6DhcXNy2/37YX78G6tRew1 lHEloAxOE2IWEBD3KzNK3DmN+jRQi9A4SeqItre2CzJ+KECuA3K1NH/DacyZlFH5C9Uf RC6l0nJTTPEXqB5IGxjT+Wn6Q2ClWKLM173lVjT3XALc9m7fnZHpA5Znm/HZB+J+0NAn uTWDV3wfrmSr/Kh5pT43QgC9zPB/cMcRX6WBL9y0aNGETDkfRa9eZeHAfLBQw52njE2X HoL+0SCo5WY4HXTvs9mHPQfTbwgTuxKAdy8xcNt1ywoiVCn12vt6ZX0FItbvG1Mb0HCk kEPg== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=qjhk6P9Uw4KWt017ZOU971JJE/eZbpasp8jnGtnd26U=; b=tu4lJuMNy7ZSx2zdQfDenw6XaU9sJ3IUb1Taa3aEmaXv0Dl52W0nQzOi7epm6ma/bC Lu0SzJM058FnlbYR6CZEzfYMrX3AWo+ZYbB3SB3tYTsBMZBalAQmYlpxCnpMmq779ICF bxoHZXQMI5ZMiP44T49wjIchJPVeGiGEsWVUXOaD+dppPHV38SylcUJRtdfON0709fi4 ZIfOplIcqhIkMmvmTop90lmUM1U9YfmIa0tik4T2eZKLez/Tcv4B396wtoX9GoedQTaz 8muqItoeTw8emaYdNfKOqyKk5Dg604/VjrcRb1/dqKv/vH38TdA9c2wyNr7Fl9gM5g8q nzaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id o5si1505889edz.312.2020.05.20.03.27.08; Wed, 20 May 2020 03:27:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726819AbgETKYy (ORCPT + 99 others); Wed, 20 May 2020 06:24:54 -0400 Received: from mga12.intel.com ([192.55.52.136]:3048 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726224AbgETKYy (ORCPT ); Wed, 20 May 2020 06:24:54 -0400 IronPort-SDR: 1jc4ByAPkSWJ0uDGtwtfLJ2D+xpUfdyFxAtjyIIrvqQ25RBxghZjJsaggaPuXsmqhvRN4sHpN+ O74FsrGVzodw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2020 03:24:53 -0700 IronPort-SDR: Nhksymg73kKZB1ULTIzriSwEHijsFG3lboDHBnmMS2BN0DW2yzcwXvhIDWAJqgHL4zldive+jM 9zD0x8K4JzHg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,413,1583222400"; d="scan'208";a="264633133" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga003.jf.intel.com with ESMTP; 20 May 2020 03:24:49 -0700 Received: from andy by smile with local (Exim 4.93) (envelope-from ) id 1jbLu8-007omv-GV; Wed, 20 May 2020 13:24:52 +0300 Date: Wed, 20 May 2020 13:24:52 +0300 From: Andy Shevchenko To: Tali Perry Cc: ofery@google.com, 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 v11 2/3] i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver Message-ID: <20200520102452.GP1634618@smile.fi.intel.com> References: <20200520095113.185414-1-tali.perry1@gmail.com> <20200520095113.185414-3-tali.perry1@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200520095113.185414-3-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 Wed, May 20, 2020 at 12:51:12PM +0300, Tali Perry wrote: > Add Nuvoton NPCM BMC I2C controller driver. ... > +#ifdef CONFIG_DEBUG_FS Why?! > +#include > +#endif ... > +/* Status of one I2C module */ > +struct npcm_i2c { > + struct i2c_adapter adap; > + struct device *dev; Isn't it adap.dev->parent? > +}; ... > +static void npcm_i2c_master_abort(struct npcm_i2c *bus) > +{ > + /* Only current master is allowed to issue a stop condition */ > + if (npcm_i2c_is_master(bus)) { if (!npcm_i2c_is_master(bus)) return; ? > + npcm_i2c_eob_int(bus, true); > + npcm_i2c_master_stop(bus); > + npcm_i2c_clear_master_status(bus); > + } > +} ... > +/* SDA status is set - TX or RX, master */ > +static void npcm_i2c_irq_handle_sda(struct npcm_i2c *bus, u8 i2cst) > +{ > + u8 fif_cts; > + if (bus->state == I2C_IDLE) { > + if (npcm_i2c_is_master(bus)) { if (a) { if (b) { ... } } == if (a && b) { ... } Check whole code for such pattern. > + } > + > + /* SDA interrupt, after start\restart */ > + } else { > + if (NPCM_I2CST_XMIT & i2cst) { > + bus->operation = I2C_WRITE_OPER; > + npcm_i2c_irq_master_handler_write(bus); > + } else { > + bus->operation = I2C_READ_OPER; > + npcm_i2c_irq_master_handler_read(bus); > + } > + } > +} ... > + } > + + /* 1MHz */ ? > + else if (bus_freq_hz <= I2C_MAX_FAST_MODE_PLUS_FREQ) { > + } > + > + /* Frequency larger than 1 MHZ is not supported */ > + else > + return -EINVAL; ... > + // master and slave modes share a single irq. It's again being inconsistent with comment style. Choose one and fix all comments accordingly (SPDX is another story, though) ... > +static int i2c_debugfs_get(void *data, u64 *val) > +{ > + *val = *(u64 *)(data); > + return 0; > +} > +DEFINE_DEBUGFS_ATTRIBUTE(i2c_debugfs_ops, i2c_debugfs_get, NULL, "0x%02llx\n"); Why not to use debugfs_create_u64(), or how is it called? > +static void i2c_init_debugfs(struct platform_device *pdev, struct npcm_i2c *bus) > +{ > + if (!npcm_i2c_debugfs_dir) > + return; > + > + if (!pdev || !bus) > + return; How is it possible? > + bus->debugfs = debugfs_create_dir(dev_name(&pdev->dev), > + npcm_i2c_debugfs_dir); > + if (IS_ERR_OR_NULL(bus->debugfs)) { > + bus->debugfs = NULL; > + return; > + } struct dentry *d; d = create(...); if (IS_ERR_OR_NULL(d)) return; bus->... = d; > + > + debugfs_create_file("ber_count", 0444, bus->debugfs, > + &bus->ber_count, > + &i2c_debugfs_ops); > + > + debugfs_create_file("rec_succ_count", 0444, bus->debugfs, > + &bus->rec_succ_count, > + &i2c_debugfs_ops); > + > + debugfs_create_file("rec_fail_count", 0444, bus->debugfs, > + &bus->rec_fail_count, > + &i2c_debugfs_ops); > + > + debugfs_create_file("nack_count", 0444, bus->debugfs, > + &bus->nack_count, > + &i2c_debugfs_ops); > + > + debugfs_create_file("timeout_count", 0444, bus->debugfs, > + &bus->timeout_count, > + &i2c_debugfs_ops); > +} ... > +#ifdef CONFIG_DEBUG_FS Why?! > + i2c_init_debugfs(pdev, bus); > +#endif ... > +#ifdef CONFIG_DEBUG_FS Ditto. > + debugfs_remove_recursive(bus->debugfs); > +#endif > +static int __init npcm_i2c_init(void) > +{ > + npcm_i2c_debugfs_dir = debugfs_create_dir("i2c", NULL); You didn't compile this with !CONFIG_DEBUG_FS? > + if (IS_ERR_OR_NULL(npcm_i2c_debugfs_dir)) { > + pr_warn("i2c init of debugfs failed\n"); > + npcm_i2c_debugfs_dir = NULL; > + } See above for the better pattern. Why do you need noisy warning? What does it say to user? Can they use device or not? > + return 0; > +} -- With Best Regards, Andy Shevchenko