Re: [PATCH v9 2/2] i2c: amlogic: Add Amlogic A9 I2C controller driver

From: Markus Elfring

Date: Tue Nov 17 2026 - 04:36:34 EST


…
> +++ b/drivers/i2c/busses/i2c-amlogic-a9.c
> @@ -0,0 +1,429 @@
…
> +static irqreturn_t aml_i2c_irq(int irqno, void *dev_id)
> +{
…
> + if (!(irq_state & A9_TRANS_DONE) ||
> + (i2c->state == A9_STATE_READ && i2c->pos < i2c->msg->len)) {
> + return IRQ_HANDLED;
> + }
…

How do you think about to omit curly brackets here?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v7.4-rc3#n197


…
> +static int aml_i2c_xfer_msg(struct aml_i2c *i2c, struct i2c_msg *msg, bool last)
> +{
…
> + spin_lock_irqsave(&i2c->lock, flags);
> + i2c->state = (msg->flags & I2C_M_RD) ? A9_STATE_READ : A9_STATE_WRITE;
> + aml_i2c_prepare_xfer(i2c, A9_FIFO_FILL_FULL);
> + reinit_completion(&i2c->done);
> +
> + aml_i2c_set_mask(i2c, REG_CFG_BUS, BUS_NO_STOP, (last ? 0 : BUS_NO_STOP));
> +
> + /* Start the transfer */
> + aml_i2c_do_start(i2c, msg);
> + spin_unlock_irqrestore(&i2c->lock, flags);
> +
> + time_left = msecs_to_jiffies(I2C_TIMEOUT_MS);
> + time_left = wait_for_completion_timeout(&i2c->done, time_left);
> +
> + /*
> + * Protect access to i2c struct and registers from interrupt
> + * handlers triggered by a transfer terminated after the
> + * timeout period
> + */
> +
> + if (!time_left) {
> + spin_lock_irqsave(&i2c->lock, flags);
> + i2c->state = A9_STATE_IDLE;
> + aml_i2c_set_mask(i2c, REG_CFG_IRQ_ENABLE,
> + A9_RX_THRESH_READ | A9_TX_THRESH_WRITE, 0);
> + clear_irq_status(i2c, IRQ_ALL_MASK);
> + reset_fifo_pos(i2c);
> + spin_unlock_irqrestore(&i2c->lock, flags);
> + return -ETIMEDOUT;
> + }
> +
> + return i2c->error;
> +}
…

What did hinder you to apply further lock guards for such a function implementation?
https://elixir.bootlin.com/linux/v7.4-rc1/source/include/linux/spinlock.h#L642-L645


…
> +module_platform_driver(aml_i2c_driver);
> +
> +MODULE_DESCRIPTION("Amlogic I2C Bus driver");
> +MODULE_AUTHOR("Junyi Zhao <junyi.zhao@xxxxxxxxxxx>");…

Would another macro call “MODULE_AUTHOR” become helpful here?
https://elixir.bootlin.com/linux/v7.4-rc1/source/include/linux/module.h#L233-L236

Regards,
Markus