public inbox for linux-i2c@vger.kernel.org
 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 V4 4/5] i2c: ls2x: Add driver for Loongson-2K/LS7A I2C controller
Date: Wed, 30 Nov 2022 22:41:12 +0200	[thread overview]
Message-ID: <Y4e/6KewuHjAluSZ@smile.fi.intel.com> (raw)
In-Reply-To: <f6cc2dbe5cd190031ab4f772d1cf250934288546.1669777792.git.zhoubinbin@loongson.cn>

On Wed, Nov 30, 2022 at 01:56:20PM +0800, Binbin Zhou wrote:
> This I2C module is integrated into the Loongson-2K SoCs and Loongson
> LS7A bridge chip.

Looks like some of my comments were not addressed. Are you sure
you have read the previous reviews carefully?

...

> +static int ls2x_i2c_xfer(struct i2c_adapter *adap,
> +			struct i2c_msg *msgs, int num)
> +{
> +	int ret, retry;
> +	struct ls2x_i2c_priv *priv = i2c_get_adapdata(adap);
> +
> +	for (retry = 0; retry < adap->retries; retry++) {
> +		ret = ls2x_i2c_doxfer(adap, msgs, num);
> +		if (ret != -EAGAIN)
> +			return ret;
> +
> +		dev_dbg(priv->dev, "Retrying transmission (%d)\n", retry);

> +		udelay(100);

Why atomic? This long (esp. atomic) delay must be explained.

> +	}
> +
> +	return -EREMOTEIO;
> +}

...

> +static void ls2x_i2c_reginit(struct ls2x_i2c_priv *priv)
> +{
> +	u8 data;
> +
> +	/* Enable operations about frequency divider register */
> +	data = readb(priv->base + I2C_LS2X_CTR);
> +	writeb(data & ~0x80, priv->base + I2C_LS2X_CTR);

Magic number.

> +	ls2x_i2c_adjust_bus_speed(priv);
> +
> +	/* Set to normal I2C operating mode and enable interrupts */
> +	data = readb(priv->base + I2C_LS2X_CTR);
> +	writeb(data | 0xe0, priv->base + I2C_LS2X_CTR);

Ditto.

> +}

...

> +	r = devm_request_irq(dev, irq, ls2x_i2c_irq_handler,
> +				IRQF_SHARED, "ls2x-i2c", priv);

Indentation.

> +	if (r < 0)
> +		return dev_err_probe(dev, r, "Unable to request irq %d\n", irq);

...

> +	adap->dev.of_node = pdev->dev.of_node;

Why is this needed?

> +	device_set_node(&adap->dev, dev_fwnode(dev));

...

> +	/* i2c device drivers may be active on return from add_adapter() */
> +	r = i2c_add_adapter(adap);

Why not use devm_ variant of this?

> +	if (r)
> +		return dev_err_probe(dev, r, "Failure adding adapter\n");

...

> +static int ls2x_i2c_suspend(struct device *dev)
> +{
> +	struct platform_device *pdev = to_platform_device(dev);
> +	struct ls2x_i2c_priv *priv = platform_get_drvdata(pdev);

Can't you use dev_get_drvdata() directly? Why?

> +
> +	priv->suspended = 1;
> +
> +	return 0;
> +}
> +
> +static int ls2x_i2c_resume(struct device *dev)
> +{
> +	struct platform_device *pdev = to_platform_device(dev);
> +	struct ls2x_i2c_priv *priv = platform_get_drvdata(pdev);

Ditto.

> +	priv->suspended = 0;
> +	ls2x_i2c_reginit(priv);
> +
> +	return 0;
> +}

...

> +static const struct dev_pm_ops ls2x_i2c_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(ls2x_i2c_suspend, ls2x_i2c_resume)
> +};

Use corresponding DEFINE_ macro.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2022-11-30 20:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30  5:55 [PATCH V4 0/5] i2c: ls2x: Add support for the Loongson-2K/LS7A I2C controller Binbin Zhou
2022-11-30  5:55 ` [PATCH V4 1/5] i2c: gpio: Fix potential unused warning for 'i2c_gpio_dt_ids' Binbin Zhou
2022-11-30 20:29   ` Andy Shevchenko
2022-12-05  9:29   ` Wolfram Sang
2022-11-30  5:55 ` [PATCH V4 2/5] i2c: gpio: Add support on ACPI-based system Binbin Zhou
2022-11-30 20:32   ` Andy Shevchenko
2022-11-30  5:55 ` [PATCH V4 3/5] dt-bindings: i2c: add bindings for Loongson LS2X I2C Binbin Zhou
2022-12-02  8:57   ` Krzysztof Kozlowski
2022-11-30  5:56 ` [PATCH V4 4/5] i2c: ls2x: Add driver for Loongson-2K/LS7A I2C controller Binbin Zhou
2022-11-30 20:41   ` Andy Shevchenko [this message]
2022-12-02  3:22     ` Binbin Zhou
2022-12-02  8:29       ` Andy Shevchenko
2022-12-05  2:23         ` Binbin Zhou
2022-12-05  8:38   ` Wolfram Sang
2022-12-05  8:54     ` Binbin Zhou
2022-12-05  8:58       ` Wolfram Sang
2022-11-30  5:56 ` [PATCH V4 5/5] LoongArch: Enable LS2X I2C in loongson3_defconfig Binbin Zhou
2022-11-30 13:47 ` [PATCH V4 3/5] dt-bindings: i2c: add bindings for Loongson LS2X I2C Rob Herring

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=Y4e/6KewuHjAluSZ@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