diff mbox series

[4/4] iio: frequency: adf4371: make use of dev_err_probe()

Message ID 20241009-dev-adf4371-minor-improv-v1-4-97f4f22ed941@analog.com (mailing list archive)
State Accepted
Headers show
Series iio: frequecy: adf4371: minor improvements | expand

Commit Message

Nuno Sa via B4 Relay Oct. 9, 2024, 2:16 p.m. UTC
From: Nuno Sa <nuno.sa@analog.com>

Use dev_err_probe() to simplify probe() error handling. While at it, add
some error log in case we fail to get clkin.

Signed-off-by: Nuno Sa <nuno.sa@analog.com>
---
 drivers/iio/frequency/adf4371.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c
index 45c8398a45d0..d752507e0c98 100644
--- a/drivers/iio/frequency/adf4371.c
+++ b/drivers/iio/frequency/adf4371.c
@@ -4,6 +4,7 @@ 
  *
  * Copyright 2019 Analog Devices Inc.
  */
+#include "linux/dev_printk.h"
 #include <linux/bitfield.h>
 #include <linux/clk.h>
 #include <linux/device.h>
@@ -554,11 +555,9 @@  static int adf4371_probe(struct spi_device *spi)
 		return -ENOMEM;
 
 	regmap = devm_regmap_init_spi(spi, &adf4371_regmap_config);
-	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");
 
 	st = iio_priv(indio_dev);
 	st->spi = spi;
@@ -577,15 +576,14 @@  static int adf4371_probe(struct spi_device *spi)
 
 	clkin = devm_clk_get_enabled(&spi->dev, "clkin");
 	if (IS_ERR(clkin))
-		return PTR_ERR(clkin);
+		return dev_err_probe(&spi->dev, PTR_ERR(clkin),
+				     "Failed to get clkin\n");
 
 	st->clkin_freq = clk_get_rate(clkin);
 
 	ret = adf4371_setup(st);
-	if (ret < 0) {
-		dev_err(&spi->dev, "ADF4371 setup failed\n");
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(&spi->dev, ret, "ADF4371 setup failed\n");
 
 	return devm_iio_device_register(&spi->dev, indio_dev);
 }