From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Tali Perry <tali.perry1@gmail.com>
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
Date: Wed, 20 May 2020 13:24:52 +0300 [thread overview]
Message-ID: <20200520102452.GP1634618@smile.fi.intel.com> (raw)
In-Reply-To: <20200520095113.185414-3-tali.perry1@gmail.com>
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 <linux/debugfs.h>
> +#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
next prev parent reply other threads:[~2020-05-20 10:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-20 9:51 [PATCH v11 0/3] i2c: npcm7xx: add NPCM i2c controller driver Tali Perry
2020-05-20 9:51 ` [PATCH v11 1/3] dt-bindings: i2c: npcm7xx: add NPCM I2C controller Tali Perry
2020-05-21 14:08 ` Rob Herring
2020-05-20 9:51 ` [PATCH v11 2/3] i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver Tali Perry
2020-05-20 10:24 ` Andy Shevchenko [this message]
2020-05-20 11:37 ` Avi Fishman
2020-05-20 11:49 ` Andy Shevchenko
2020-05-20 9:51 ` [PATCH v11 3/3] i2c: npcm7xx: Add support for slave mode for Nuvoton Tali Perry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200520102452.GP1634618@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=avifishman70@gmail.com \
--cc=benjaminfair@google.com \
--cc=brendanhiggins@google.com \
--cc=devicetree@vger.kernel.org \
--cc=kfting@nuvoton.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ofery@google.com \
--cc=openbmc@lists.ozlabs.org \
--cc=robh+dt@kernel.org \
--cc=tali.perry1@gmail.com \
--cc=tmaimon77@gmail.com \
--cc=venture@google.com \
--cc=wsa@the-dreams.de \
--cc=yuenn@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).