devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Binbin Zhou <zhoubinbin@loongson.cn>
Cc: Wolfram Sang <wsa@kernel.org>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	linux-i2c@vger.kernel.org, loongarch@lists.linux.dev,
	devicetree@vger.kernel.org, Huacai Chen <chenhuacai@loongson.cn>,
	WANG Xuerui <kernel@xen0n.name>, Arnd Bergmann <arnd@arndb.de>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Jianmin Lv <lvjianmin@loongson.cn>
Subject: Re: [PATCH V5 3/4] i2c: ls2x: Add driver for Loongson-2K/LS7A I2C controller
Date: Tue, 6 Dec 2022 17:23:55 +0200	[thread overview]
Message-ID: <Y49ei1fpEawXvGQB@smile.fi.intel.com> (raw)
In-Reply-To: <e088e2ffaef1492adc09b7cdbde0afcea2eeb8b2.1670293176.git.zhoubinbin@loongson.cn>

On Tue, Dec 06, 2022 at 11:16:56AM +0800, Binbin Zhou wrote:
> This I2C module is integrated into the Loongson-2K SoCs and Loongson
> LS7A bridge chip.

Much better, thanks!

...

> +/*
> + * The I2C controller has a fixed I2C bus frequency by default, but to
> + * be compatible with more client devices, we can obtain the set I2C
> + * bus frequency from ACPI or FDT.
> + */
> +static void ls2x_i2c_adjust_bus_speed(struct ls2x_i2c_priv *priv)
> +{
> +	u16 val = 0x12c; /* Default value of I2C divider latch register */

Besides comment better to be placed on top of the commented line, the value
is better to have its own definition where you place the comment and elaborate
what it means in practice (The clock frequency is changed?  Bus speed is
different?)

> +	struct i2c_timings *t = &priv->i2c_t;
> +	u32 acpi_speed = i2c_acpi_find_bus_speed(priv->dev);
> +
> +	i2c_parse_fw_timings(priv->dev, t, false);
> +
> +	if (acpi_speed || t->bus_freq_hz)
> +		val = 10 * HZ_PER_MHZ / max(t->bus_freq_hz, acpi_speed) - 1;
> +
> +	/* Set LS2X I2C frequency */
> +	writel(val, priv->base + I2C_LS2X_PRER_LO);
> +}

...

> +	writeb(data | LS2X_CTR_EN | LS2X_CTR_IEN | LS2X_CTR_MST,
> +			priv->base + I2C_LS2X_CTR);

Wrong indentation.

...

> +	r = devm_request_irq(dev, irq, ls2x_i2c_irq_handler,
> +			     IRQF_SHARED, "ls2x-i2c", priv);
> +	if (r < 0)
> +		return dev_err_probe(dev, r, "Unable to request irq %d\n", irq);

You requested IRQ without filling all data structures. Is it fine? Have you
checked that with CONFIG_DEBUG_SHIRQ being enabled?

...

> +	r = devm_i2c_add_adapter(dev, adap);
> +	if (r)
> +		return dev_err_probe(dev, r, "Failure adding adapter\n");
> +
> +	return 0;
> +}

Looking at the above...

> +static int ls2x_i2c_remove(struct platform_device *pdev)
> +{
> +	struct ls2x_i2c_priv *priv = platform_get_drvdata(pdev);
> +
> +	i2c_del_adapter(&priv->adapter);

...are you sure this is correct?

> +	return 0;
> +}

...

> +static int ls2x_i2c_suspend(struct device *dev)
> +{
> +	struct ls2x_i2c_priv *priv = dev_get_drvdata(dev);

> +	priv->suspended = 1;

No protection needed?

> +	return 0;
> +}
> +
> +static int ls2x_i2c_resume(struct device *dev)
> +{
> +	struct ls2x_i2c_priv *priv = dev_get_drvdata(dev);

> +	priv->suspended = 0;

Ditto.

> +	ls2x_i2c_reginit(priv);
> +	return 0;
> +}

...

> +MODULE_ALIAS("platform:ls2x-i2c");

Why is this required?

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2022-12-06 15:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-06  3:16 [PATCH V5 0/4] i2c: ls2x: Add support for the Loongson-2K/LS7A I2C controller Binbin Zhou
2022-12-06  3:16 ` [PATCH V5 1/4] i2c: gpio: Add support on ACPI-based system Binbin Zhou
2022-12-06 15:13   ` Andy Shevchenko
2022-12-07  7:10     ` Binbin Zhou
2022-12-12  9:40       ` Andy Shevchenko
2022-12-06  3:16 ` [PATCH V5 2/4] dt-bindings: i2c: add Loongson LS2X I2C controller Binbin Zhou
2022-12-06  3:16 ` [PATCH V5 3/4] i2c: ls2x: Add driver for Loongson-2K/LS7A " Binbin Zhou
2022-12-06  3:17   ` Binbin Zhou
2022-12-06 15:23   ` Andy Shevchenko [this message]
2022-12-08  8:55     ` Binbin Zhou
2022-12-12  9:47       ` Andy Shevchenko
2022-12-12 12:41         ` Binbin Zhou
2022-12-06  3:17 ` [PATCH V5 4/4] LoongArch: Enable LS2X I2C in loongson3_defconfig Binbin Zhou

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=Y49ei1fpEawXvGQB@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=chenhuacai@loongson.cn \
    --cc=devicetree@vger.kernel.org \
    --cc=kernel@xen0n.name \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=lvjianmin@loongson.cn \
    --cc=mika.westerberg@linux.intel.com \
    --cc=robh+dt@kernel.org \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=wsa@kernel.org \
    --cc=zhoubinbin@loongson.cn \
    /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).