iio: accel: adxl313: Use dev_err_probe()

dev_err_probe() makes error code handling simpler and handles
deferred probe nicely (avoid spamming logs).

Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
Sanjay Chitroda 2026-04-17 18:19:18 +05:30 committed by Jonathan Cameron
parent d2ed8a2f63
commit c27837e49f
3 changed files with 10 additions and 17 deletions

View File

@ -1252,10 +1252,8 @@ int adxl313_core_probe(struct device *dev,
indio_dev->available_scan_masks = adxl313_scan_masks;
ret = adxl313_setup(dev, data, setup);
if (ret) {
dev_err(dev, "ADXL313 setup failed\n");
return ret;
}
if (ret)
return dev_err_probe(dev, ret, "ADXL313 setup failed\n");
int_line = adxl313_get_int_type(dev, &irq);
if (int_line == ADXL313_INT_NONE) {

View File

@ -65,6 +65,7 @@ MODULE_DEVICE_TABLE(of, adxl313_of_match);
static int adxl313_i2c_probe(struct i2c_client *client)
{
const struct adxl313_chip_info *chip_data;
struct device *dev = &client->dev;
struct regmap *regmap;
/*
@ -75,13 +76,10 @@ static int adxl313_i2c_probe(struct i2c_client *client)
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(dev, PTR_ERR(regmap), "Error initializing i2c regmap\n");
return adxl313_core_probe(&client->dev, regmap, chip_data, NULL);
return adxl313_core_probe(dev, regmap, chip_data, NULL);
}
static struct i2c_driver adxl313_i2c_driver = {

View File

@ -70,6 +70,7 @@ static int adxl313_spi_setup(struct device *dev, struct regmap *regmap)
static int adxl313_spi_probe(struct spi_device *spi)
{
const struct adxl313_chip_info *chip_data;
struct device *dev = &spi->dev;
struct regmap *regmap;
int ret;
@ -83,14 +84,10 @@ static int adxl313_spi_probe(struct spi_device *spi)
regmap = devm_regmap_init_spi(spi,
&adxl31x_spi_regmap_config[chip_data->type]);
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(dev, PTR_ERR(regmap), "Error initializing spi regmap\n");
return adxl313_core_probe(&spi->dev, regmap,
chip_data, &adxl313_spi_setup);
return adxl313_core_probe(dev, regmap, chip_data, &adxl313_spi_setup);
}
static const struct spi_device_id adxl313_spi_id[] = {