Re: [PATCH] ASoC: uda1380: add error handling for I2C operations in write function In uda1380_write(), multiple I2C operations are performed without proper error handling: 1. The return value of the second i2c_master_send() (sending register address) is not checked 2. The return value of i2c_master_recv() (reading back data) is not checked 3. Error logging uses pr_debug() which may not capture critical failures
From: Mark Brown
Date: Thu Mar 19 2026 - 08:24:19 EST
On Thu, Mar 19, 2026 at 02:26:33PM +0800, Wenyuan Li wrote:
> If any of these I2C operations fail, the driver may continue execution
> with invalid data, leading to incorrect device state or silent failures.
>
> Fix this by:
> - Adding proper return value checks for all I2C operations
> - Converting pr_debug() to dev_err() with %pe format for human-readable
> error codes
> - Moving variable declaration to function beginning (C90 style)
> - Providing detailed error messages including register address and
> expected values
This is multiple different changes, as covered in submitting-patches.rst
it should really be a patch series with one change per patch.
> + ret = i2c_master_send(uda1380->i2c, data, 3);
> + if (ret != 3) {
> + dev_err(component->dev, "write failed: %pe\n", ERR_PTR(ret));
> + return ret < 0 ? ret : -EIO;
> + }
i2c_master_send() doesn't return a pointer, it returns an errno or the
transfer length.
Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
Attachment:
signature.asc
Description: PGP signature