Skip to contentSkip to conversation

Input: da7280 - Switch to use dev_err_probe() helper

PATCH In review Yang Yingliang 2 participants 7 messages Sep 20, 2022 – Sep 22, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 Input: da7280 - Switch to use dev_err_probe() helper

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
 drivers/input/misc/da7280.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/input/misc/da7280.c +3 -6
index b08610d6e575..b1ca4fd94e9e 100644
@@ -1166,12 +1166,9 @@ static int da7280_probe(struct i2c_client *client,
 	if (haptics->const_op_mode == DA7280_PWM_MODE) {
 		haptics->pwm_dev = devm_pwm_get(dev, NULL);
 		error = PTR_ERR_OR_ZERO(haptics->pwm_dev);
-		if (error) {
-			if (error != -EPROBE_DEFER)
-				dev_err(dev, "Unable to request PWM: %d\n",
-					error);
-			return error;
-		}
+		if (error)
+			return dev_err_probe(dev, error,
+					     "Unable to request PWM\n");
 
 		/* Sync up PWM state and ensure it is off. */
 		pwm_init_state(haptics->pwm_dev, &state);
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/5 Input: gpio-vibra - Switch to use dev_err_probe() helper

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
 drivers/input/misc/gpio-vibra.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/input/misc/gpio-vibra.c +6 -12
index f79f75595dd7..94f5b450beae 100644
@@ -114,21 +114,15 @@ static int gpio_vibrator_probe(struct platform_device *pdev)
 
 	vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc");
 	err = PTR_ERR_OR_ZERO(vibrator->vcc);
-	if (err) {
-		if (err != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Failed to request regulator: %d\n",
-				err);
-		return err;
-	}
+	if (err)
+		return dev_err_probe(&pdev->dev, err,
+				     "Failed to request regulator\n");
 
 	vibrator->gpio = devm_gpiod_get(&pdev->dev, "enable", GPIOD_OUT_LOW);
 	err = PTR_ERR_OR_ZERO(vibrator->gpio);
-	if (err) {
-		if (err != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Failed to request main gpio: %d\n",
-				err);
-		return err;
-	}
+	if (err)
+		return dev_err_probe(&pdev->dev, err,
+				     "Failed to request main gpio\n");
 
 	INIT_WORK(&vibrator->play_work, gpio_vibrator_play_work);
 
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/5 Input: pwm-beeper - Switch to use dev_err_probe() helper

In reply to Yang Yingliang

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
 drivers/input/misc/pwm-beeper.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/input/misc/pwm-beeper.c +6 -14
index d6b12477748a..c1d9310e9a06 100644
@@ -132,13 +132,9 @@ static int pwm_beeper_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	beeper->pwm = devm_pwm_get(dev, NULL);
-	if (IS_ERR(beeper->pwm)) {
-		error = PTR_ERR(beeper->pwm);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Failed to request PWM device: %d\n",
-				error);
-		return error;
-	}
+	if (IS_ERR(beeper->pwm))
+		return dev_err_probe(dev, PTR_ERR(beeper->pwm),
+				     "Failed to request PWM device\n");
 
 	/* Sync up PWM state and ensure it is off. */
 	pwm_init_state(beeper->pwm, &state);
@@ -151,13 +147,9 @@ static int pwm_beeper_probe(struct platform_device *pdev)
 	}
 
 	beeper->amplifier = devm_regulator_get(dev, "amp");
-	if (IS_ERR(beeper->amplifier)) {
-		error = PTR_ERR(beeper->amplifier);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Failed to get 'amp' regulator: %d\n",
-				error);
-		return error;
-	}
+	if (IS_ERR(beeper->amplifier))
+		return dev_err_probe(dev, PTR_ERR(beeper->amplifier),
+				     "Failed to get 'amp' regulator\n");
 
 	INIT_WORK(&beeper->work, pwm_beeper_work);
 
Signature · 1 line
2.25.1
#3 lore raw

PATCH 4/5 Input: pwm-vibra - Switch to use dev_err_probe() helper

In reply to Yang Yingliang

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
 drivers/input/misc/pwm-vibra.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/input/misc/pwm-vibra.c +6 -12
index 81e777a04b88..fe6074e6fe68 100644
@@ -135,21 +135,15 @@ static int pwm_vibrator_probe(struct platform_device *pdev)
 
 	vibrator->vcc = devm_regulator_get(&pdev->dev, "vcc");
 	err = PTR_ERR_OR_ZERO(vibrator->vcc);
-	if (err) {
-		if (err != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Failed to request regulator: %d",
-				err);
-		return err;
-	}
+	if (err)
+		return dev_err_probe(&pdev->dev, err,
+				     "Failed to request regulator\n");
 
 	vibrator->pwm = devm_pwm_get(&pdev->dev, "enable");
 	err = PTR_ERR_OR_ZERO(vibrator->pwm);
-	if (err) {
-		if (err != -EPROBE_DEFER)
-			dev_err(&pdev->dev, "Failed to request main pwm: %d",
-				err);
-		return err;
-	}
+	if (err)
+		return dev_err_probe(&pdev->dev, err,
+				     "Failed to request main pwm\n");
 
 	INIT_WORK(&vibrator->play_work, pwm_vibrator_play_work);
 
Signature · 1 line
2.25.1
#4 lore raw

PATCH 5/5 Input: rotary_encoder - Switch to use dev_err_probe() helper

In reply to Yang Yingliang

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
 drivers/input/misc/rotary_encoder.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/input/misc/rotary_encoder.c +3 -6
index 6d613f2a017c..e106cab58e8f 100644
@@ -236,12 +236,9 @@ static int rotary_encoder_probe(struct platform_device *pdev)
 		device_property_read_bool(dev, "rotary-encoder,relative-axis");
 
 	encoder->gpios = devm_gpiod_get_array(dev, NULL, GPIOD_IN);
-	if (IS_ERR(encoder->gpios)) {
-		err = PTR_ERR(encoder->gpios);
-		if (err != -EPROBE_DEFER)
-			dev_err(dev, "unable to get gpios: %d\n", err);
-		return err;
-	}
+	if (IS_ERR(encoder->gpios))
+		return dev_err_probe(dev, PTR_ERR(encoder->gpios),
+				     "unable to get gpios\n");
 	if (encoder->gpios->ndescs < 2) {
 		dev_err(dev, "not enough gpios found\n");
 		return -EINVAL;
Signature · 1 line
2.25.1
#5 lore raw
In reply to Yang Yingliang

Hi Yang,

Thank you for your series,

Quoted 17 lines · Yang Yingliang

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
 drivers/input/misc/da7280.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/input/misc/da7280.c +0 -0
index b08610d6e575..b1ca4fd94e9e 100644
@@ -1166,12 +1166,9 @@ static int da7280_probe(struct i2c_client *client,
 	if (haptics->const_op_mode == DA7280_PWM_MODE) {
 		haptics->pwm_dev = devm_pwm_get(dev, NULL);

drivers/input/misc/da7280.c static int da7280_probe(struct i2c_client *client, · line 1171

Quoted 10 lines
drivers/input/misc/da7280.c +3 -6
 		error = PTR_ERR_OR_ZERO(haptics->pwm_dev);
-		if (error) {
-			if (error != -EPROBE_DEFER)
-				dev_err(dev, "Unable to request PWM: %d\n",
-					error);
-			return error;
-		}
+		if (error)
+			return dev_err_probe(dev, error,
+					     "Unable to request PWM\n");

For the whole series:

If we look at the input tree, we can see that there is no occurence of dev_err_probe():

$ ~/src/linux/drivers/input/ 483fed3b5dc8 grep -rsn dev_err_probe
$ ~/src/linux/drivers/input/ 483fed3b5dc8

The reason for this is that the input maintainer (Dmitry) dislikes dev_err_probe() as he stated in [1]

So I don't think he will apply this.

Regards,
Mattijs

[1] https://lore.kernel.org/r/[email protected]

Quoted 5 lines
drivers/input/misc/da7280.c +0 -0
 		/* Sync up PWM state and ensure it is off. */
 		pwm_init_state(haptics->pwm_dev, &state);
Signature · 1 line
2.25.1
#6 lore raw

Hi Mattijs,

Quoted 38 lines · Mattijs Korpershoek

Hi Yang,

Thank you for your series,

Quoted 17 lines · Yang Yingliang

In the probe path, dev_err() can be replaced with dev_err_probe() which will check if error code is -EPROBE_DEFER and prints the error name. It also sets the defer probe reason which can be checked later through debugfs.

---
  drivers/input/misc/da7280.c | 9 +++------
  1 file changed, 3 insertions(+), 6 deletions(-)
drivers/input/misc/da7280.c +0 -0
index b08610d6e575..b1ca4fd94e9e 100644
@@ -1166,12 +1166,9 @@ static int da7280_probe(struct i2c_client *client,
  	if (haptics->const_op_mode == DA7280_PWM_MODE) {
  		haptics->pwm_dev = devm_pwm_get(dev, NULL);

drivers/input/misc/da7280.c static int da7280_probe(struct i2c_client *client, · line 1171

Quoted 10 lines
drivers/input/misc/da7280.c +3 -6
  		error = PTR_ERR_OR_ZERO(haptics->pwm_dev);
-		if (error) {
-			if (error != -EPROBE_DEFER)
-				dev_err(dev, "Unable to request PWM: %d\n",
-					error);
-			return error;
-		}
+		if (error)
+			return dev_err_probe(dev, error,
+					     "Unable to request PWM\n");

For the whole series:

If we look at the input tree, we can see that there is no occurence of dev_err_probe():

Quoted 7 lines
$ ~/src/linux/drivers/input/ 483fed3b5dc8 grep -rsn dev_err_probe
$ ~/src/linux/drivers/input/ 483fed3b5dc8

The reason for this is that the input maintainer (Dmitry) dislikes dev_err_probe() as he stated in [1]

So I don't think he will apply this.

OK, thanks for replying and mentioning it.

Quoted 11 lines

Regards,
Mattijs

[1] https://lore.kernel.org/r/[email protected]

Quoted 4 lines
drivers/input/misc/da7280.c +0 -0
  		/* Sync up PWM state and ensure it is off. */
  		pwm_init_state(haptics->pwm_dev, &state);
Signature · 1 line
2.25.1

.