Re: [PATCH v7 2/3] i2c: ma35d1: Add Nuvoton MA35D1 I2C driver support
zychen <[email protected]> Tue, 4 Aug 2026 14:02:58 +0800
| Newsgroups | org.kernel.vger.linux-i2c,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
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