Re: [PATCH 3/3] iio: accel: adxl313: Use dev_err_probe
From: Sanjay Chitroda
Date: Thu Apr 16 2026 - 15:42:20 EST
On 16 April 2026 1:54:47 pm IST, Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
>On Thu, Apr 16, 2026 at 10:46:31AM +0530, Sanjay Chitroda wrote:
>
>> dev_err_probe() makes error code handling simpler and handle
>> deferred probe nicely (avoid spamming logs).
>
>...
>
>> regmap = devm_regmap_init_i2c(client,
>> &adxl31x_i2c_regmap_config[chip_data->type]);
>> - if (IS_ERR(regmap)) {
>> - dev_err(&client->dev, "Error initializing i2c regmap: %ld\n",
>> - PTR_ERR(regmap));
>> - return PTR_ERR(regmap);
>> - }
>> + if (IS_ERR(regmap))
>> + return dev_err_probe(&client->dev, PTR_ERR(regmap),
>> + "Error initializing i2c regmap\n");
>
>Add
>
> struct device *dev = &client->dev;
>
>to the top of the function and use it here as
>
> if (IS_ERR(regmap))
> return dev_err_probe(dev, PTR_ERR(regmap), "Error initializing i2c regmap\n");
>
>Note, it's fine to have trailing string literals, even in strict mode
>checkpatch won't complain.
>
>...
Thank you Andy for the input.
I will address review comment in next series. Also, string literals is under 100 after the dev changes so keeping single line for both i2c & spi.
>
>> - if (IS_ERR(regmap)) {
>> - dev_err(&spi->dev, "Error initializing spi regmap: %ld\n",
>> - PTR_ERR(regmap));
>> - return PTR_ERR(regmap);
>> - }
>> + if (IS_ERR(regmap))
>> + return dev_err_probe(&spi->dev, PTR_ERR(regmap),
>> + "Error initializing spi regmap\n");
>
>Same way as in I2C driver.
>