mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
iio: accel: adxl355: 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:
parent
07fd62916c
commit
70cc2c65c2
|
|
@ -336,10 +336,8 @@ static int adxl355_setup(struct adxl355_data *data)
|
|||
return ret;
|
||||
|
||||
do {
|
||||
if (--retries == 0) {
|
||||
dev_err(data->dev, "Shadow registers mismatch\n");
|
||||
return -EIO;
|
||||
}
|
||||
if (--retries == 0)
|
||||
return dev_err_probe(data->dev, -EIO, "Shadow registers mismatch\n");
|
||||
|
||||
/*
|
||||
* Perform a software reset to make sure the device is in a consistent
|
||||
|
|
@ -775,10 +773,8 @@ static int adxl355_probe_trigger(struct iio_dev *indio_dev, int irq)
|
|||
irq);
|
||||
|
||||
ret = devm_iio_trigger_register(data->dev, data->dready_trig);
|
||||
if (ret) {
|
||||
dev_err(data->dev, "iio trigger register failed\n");
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(data->dev, ret, "iio trigger register failed\n");
|
||||
|
||||
indio_dev->trig = iio_trigger_get(data->dready_trig);
|
||||
|
||||
|
|
@ -814,18 +810,14 @@ int adxl355_core_probe(struct device *dev, struct regmap *regmap,
|
|||
indio_dev->available_scan_masks = adxl355_avail_scan_masks;
|
||||
|
||||
ret = adxl355_setup(data);
|
||||
if (ret) {
|
||||
dev_err(dev, "ADXL355 setup failed\n");
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "ADXL355 setup failed\n");
|
||||
|
||||
ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
|
||||
&iio_pollfunc_store_time,
|
||||
&adxl355_trigger_handler, NULL);
|
||||
if (ret) {
|
||||
dev_err(dev, "iio triggered buffer setup failed\n");
|
||||
return ret;
|
||||
}
|
||||
if (ret)
|
||||
return dev_err_probe(dev, ret, "iio triggered buffer setup failed\n");
|
||||
|
||||
irq = fwnode_irq_get_byname(dev_fwnode(dev), "DRDY");
|
||||
if (irq > 0) {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ static const struct regmap_config adxl355_i2c_regmap_config = {
|
|||
static int adxl355_i2c_probe(struct i2c_client *client)
|
||||
{
|
||||
struct regmap *regmap;
|
||||
struct device *dev = &client->dev;
|
||||
const struct adxl355_chip_info *chip_data;
|
||||
|
||||
chip_data = i2c_get_match_data(client);
|
||||
|
|
@ -30,14 +31,10 @@ static int adxl355_i2c_probe(struct i2c_client *client)
|
|||
return -ENODEV;
|
||||
|
||||
regmap = devm_regmap_init_i2c(client, &adxl355_i2c_regmap_config);
|
||||
if (IS_ERR(regmap)) {
|
||||
dev_err(&client->dev, "Error initializing i2c regmap: %ld\n",
|
||||
PTR_ERR(regmap));
|
||||
if (IS_ERR(regmap))
|
||||
return dev_err_probe(dev, PTR_ERR(regmap), "Error initializing i2c regmap\n");
|
||||
|
||||
return PTR_ERR(regmap);
|
||||
}
|
||||
|
||||
return adxl355_core_probe(&client->dev, regmap, chip_data);
|
||||
return adxl355_core_probe(dev, regmap, chip_data);
|
||||
}
|
||||
|
||||
static const struct i2c_device_id adxl355_i2c_id[] = {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ static const struct regmap_config adxl355_spi_regmap_config = {
|
|||
static int adxl355_spi_probe(struct spi_device *spi)
|
||||
{
|
||||
const struct adxl355_chip_info *chip_data;
|
||||
struct device *dev = &spi->dev;
|
||||
struct regmap *regmap;
|
||||
|
||||
chip_data = spi_get_device_match_data(spi);
|
||||
|
|
@ -33,14 +34,10 @@ static int adxl355_spi_probe(struct spi_device *spi)
|
|||
return -EINVAL;
|
||||
|
||||
regmap = devm_regmap_init_spi(spi, &adxl355_spi_regmap_config);
|
||||
if (IS_ERR(regmap)) {
|
||||
dev_err(&spi->dev, "Error initializing spi regmap: %ld\n",
|
||||
PTR_ERR(regmap));
|
||||
if (IS_ERR(regmap))
|
||||
return dev_err_probe(dev, PTR_ERR(regmap), "Error initializing spi regmap\n");
|
||||
|
||||
return PTR_ERR(regmap);
|
||||
}
|
||||
|
||||
return adxl355_core_probe(&spi->dev, regmap, chip_data);
|
||||
return adxl355_core_probe(dev, regmap, chip_data);
|
||||
}
|
||||
|
||||
static const struct spi_device_id adxl355_spi_id[] = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user