linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: drv260x - Make use of the helper function dev_err_probe()
@ 2021-09-16 15:32 Cai Huoqing
  0 siblings, 0 replies; only message in thread
From: Cai Huoqing @ 2021-09-16 15:32 UTC (permalink / raw)
  To: caihuoqing; +Cc: Dmitry Torokhov, linux-input, linux-kernel

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 <caihuoqing@baidu.com>
---
 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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-16 15:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16 15:32 [PATCH] Input: drv260x - Make use of the helper function dev_err_probe() Cai Huoqing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).