Input: drv260x - Make use of the helper function dev_err_probe()

Started by Cai Huoqing on Sep 16, 2021

Subsystems (2)

Maintainers (2)

DORMANTno replies

open the first message on its own page

Message details and related content
When possible use dev_err_probe help to properly deal with the
PROBE_DEFER error, the benefit is that DEFER issue will be logged
in the devices_deferred debugfs file.
Using dev_err_probe() can reduce code size, and the error value
gets printed.

Signed-off-by: Cai Huoqing <redacted>
---
 drivers/input/misc/drv260x.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/input/misc/drv260x.c b/drivers/input/misc/drv260x.c
index 0efe56f49aa9..f21e05e4e035 100644
--- a/drivers/input/misc/drv260x.c
+++ b/drivers/input/misc/drv260x.c
@@ -470,10 +470,8 @@ static int drv260x_probe(struct i2c_client *client,
 		return -ENOMEM;
 
 	error = device_property_read_u32(dev, "mode", &haptics->mode);
-	if (error) {
-		dev_err(dev, "Can't fetch 'mode' property: %d\n", error);
-		return error;
-	}
+	if (error)
+		return dev_err_probe(dev, error, "Can't fetch 'mode' property\n");
 
 	if (haptics->mode < DRV260X_LRA_MODE ||
 	    haptics->mode > DRV260X_ERM_MODE) {
@@ -482,10 +480,8 @@ static int drv260x_probe(struct i2c_client *client,
 	}
 
 	error = device_property_read_u32(dev, "library-sel", &haptics->library);
-	if (error) {
-		dev_err(dev, "Can't fetch 'library-sel' property: %d\n", error);
-		return error;
-	}
+	if (error)
+		return dev_err_probe(dev, error, "Can't fetch 'library-sel' property\n");
 
 	if (haptics->library < DRV260X_LIB_EMPTY ||
 	    haptics->library > DRV260X_ERM_LIB_F) {
@@ -517,11 +513,9 @@ static int drv260x_probe(struct i2c_client *client,
 					     drv260x_calculate_voltage(voltage);
 
 	haptics->regulator = devm_regulator_get(dev, "vbat");
-	if (IS_ERR(haptics->regulator)) {
-		error = PTR_ERR(haptics->regulator);
-		dev_err(dev, "unable to get regulator, error: %d\n", error);
-		return error;
-	}
+	if (IS_ERR(haptics->regulator))
+		return dev_err_probe(dev, PTR_ERR(haptics->regulator),
+				     "unable to get regulator\n");
 
 	haptics->enable_gpio = devm_gpiod_get_optional(dev, "enable",
 						       GPIOD_OUT_HIGH);
-- 
2.25.1
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help