Re: [PATCH v7 2/3] i2c: ma35d1: Add Nuvoton MA35D1 I2C driver support

Andi Shyti <[email protected]> Wed, 29 Jul 2026 23:06:40 +0200
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 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.

> +	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.

> +
> +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.

> +	struct device *dev = &pdev->dev;

nit: can you please sort the declaration by line length, in a
reverse christmast tree shape?

> +	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.

Thanks,
Andi

> +	}