Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: zychen <zychennvt@gmail.com>
To: Andi Shyti <andi.shyti@kernel.org>
Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Jacky Huang <ychuang3@nuvoton.com>,
	Shan-Chun Hung <schung@nuvoton.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>
Subject: Re: [PATCH v7 2/3] i2c: ma35d1: Add Nuvoton MA35D1 I2C driver support
Date: Tue, 4 Aug 2026 14:02:58 +0800	[thread overview]
Message-ID: <db91085b-ae1e-4cfd-8f8e-89c379684303@gmail.com> (raw)
In-Reply-To: <ampnhe-GqNoQwmJZ@zenone.zhora.eu>


Hi Andi,

Andi Shyti 於 2026/7/30 上午 05:06 寫道:
> Hi Zi-Yu,
> 
> ...
> 
>> +static void ma35d1_i2c_stop(struct ma35d1_i2c *i2c, int ret)
>> +{
>> +	ma35d1_i2c_write_ctl(i2c, MA35_CTL_STO_SI);
> 
> I think there is a valid review from sashiko here.
> 
Address sashiko's review, I will introduce a new helper to handle
bus errors and spurious interrupts based on the current state, while
keeping ma35d1_i2c_stop() unchanged and used exclusively during
active transfers.

>> +	if (ret)
>> +		i2c->err = ret;
>> +
>> +	ma35d1_i2c_controller_complete(i2c);
>> +}
> 
> ...
> 
>> +static irqreturn_t ma35d1_i2c_irq(int irqno, void *dev_id)
>> +{
>> +	struct ma35d1_i2c *i2c = dev_id;
>> +	unsigned long status;
>> +
>> +	status = readl(i2c->regs + MA35_STATUS0);
>> +
>> +	if (status == MA35_BUS_ERROR) {
>> +		dev_err(i2c->dev, "Bus error during transfer\n");
>> +		ma35d1_i2c_stop(i2c, -EIO);
>> +		goto out;
>> +	}
>> +
>> +	if (ma35d1_is_controller_status(status))
>> +		ma35d1_i2c_irq_controller_trx(i2c, status);
>> +	else
>> +		ma35d1_i2c_irq_target_trx(i2c, status);
> 
> Why are these functions void? We should at least print an error
> in case of failures.
> 
Agree.
Changed the return types of both TRX helper functions to irqreturn_t.
On unhandled/unknown status codes, will return IRQ_NONE.

>> +
>> +out:
>> +	return IRQ_HANDLED;
>> +}
> 
> ...
> 
>> +static int ma35d1_i2c_probe(struct platform_device *pdev)
>> +{
>> +	struct ma35d1_i2c *i2c;
>> +	struct resource *res;
>> +	int ret, clkdiv;
>> +	u32 val;
>> +	unsigned int busfreq;
> 
> you can immediately initialize busfreq here.
Sure.

> 
>> +	struct device *dev = &pdev->dev;
> 
> nit: can you please sort the declaration by line length, in a
> reverse christmast tree shape?
Sure.
> 
>> +	i2c = devm_kzalloc(dev, sizeof(*i2c), GFP_KERNEL);
>> +	if (!i2c)
>> +		return -ENOMEM;
> 
> ...
> 
>> +	ret = devm_add_action_or_reset(dev, ma35d1_i2c_pm_cleanup, dev);
>> +	if (ret)
>> +		goto rpm_put;
>> +
>> +	writel(MA35_CTL_I2CEN | MA35_CTL_INTEN, i2c->regs + MA35_CTL0);
>> +	writel(FIELD_PREP(MA35_CLKDIV_MSK, clkdiv), i2c->regs + MA35_CLKDIV);
>> +
>> +	ret = devm_request_irq(dev, i2c->irq, ma35d1_i2c_irq, 0, dev_name(dev),
>> +			       i2c);
>> +	if (ret) {
>> +		dev_err_probe(dev, ret, "cannot claim IRQ %d\n", i2c->irq);
>> +		goto rpm_put;
> 
> The actions in rpm_put are executed twice, considering
> devm_add_action_or_reset.
> 
Agree.
Removed the redundant rpm_put label and changed error paths to return
ret directly, leaving PM cleanup to devm_add_action_or_reset().

All these changes will be included in v8.

> Thanks,
> Andi
> 
>> +	}

Best regards,
Zi-Yu


  reply	other threads:[~2026-08-04  6:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27  8:18 [PATCH v7 0/3] i2c: ma35d1: Add support for MA35D1 I2C controller Zi-Yu Chen
2026-07-27  8:18 ` [PATCH v7 1/3] dt-bindings: i2c: nuvoton,ma35d1-i2c: Add " Zi-Yu Chen
2026-07-27  8:18 ` [PATCH v7 2/3] i2c: ma35d1: Add Nuvoton MA35D1 I2C driver support Zi-Yu Chen
2026-07-29 21:06   ` Andi Shyti
2026-08-04  6:02     ` zychen [this message]
2026-07-27  8:18 ` [PATCH v7 3/3] arm64: dts: nuvoton: Add I2C nodes for MA35D1 SoC Zi-Yu Chen

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=db91085b-ae1e-4cfd-8f8e-89c379684303@gmail.com \
    --to=zychennvt@gmail.com \
    --cc=andi.shyti@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=schung@nuvoton.com \
    --cc=ychuang3@nuvoton.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