Skip to contentSkip to conversation

Input: adc-joystick - Switch to use dev_err_probe() helper

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

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

PATCH 1/4 Input: adc-joystick - 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/joystick/adc-joystick.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/input/joystick/adc-joystick.c +3 -6
index c0deff5d4282..3590d845e381 100644
@@ -201,12 +201,9 @@ static int adc_joystick_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	joy->chans = devm_iio_channel_get_all(dev);
-	if (IS_ERR(joy->chans)) {
-		error = PTR_ERR(joy->chans);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Unable to get IIO channels");
-		return error;
-	}
+	if (IS_ERR(joy->chans))
+		return dev_err_probe(dev, PTR_ERR(joy->chans),
+				     "Unable to get IIO channels\n");
 
 	error = device_property_read_u32(dev, "poll-interval", &poll_interval);
 	if (error) {
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/4 Input: bcm-keypad - 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/keyboard/bcm-keypad.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/input/keyboard/bcm-keypad.c +3 -5
index 56a919ec23b5..bc8bd78d74f5 100644
@@ -368,11 +368,9 @@ static int bcm_kp_probe(struct platform_device *pdev)
 	kp->clk = devm_clk_get(&pdev->dev, "peri_clk");
 	if (IS_ERR(kp->clk)) {
 		error = PTR_ERR(kp->clk);
-		if (error != -ENOENT) {
-			if (error != -EPROBE_DEFER)
-				dev_err(&pdev->dev, "Failed to get clock\n");
-			return error;
-		}
+		if (error != -ENOENT)
+			return dev_err_probe(&pdev->dev, error,
+					     "Failed to get clock\n");
 		dev_dbg(&pdev->dev,
 			"No clock specified. Assuming it's enabled\n");
 		kp->clk = NULL;
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH -next 2/4] Input: bcm-keypad - Switch to use dev_err_probe() helper

Hi Yang,

Thank you for your patch,

Quoted 16 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/keyboard/bcm-keypad.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/input/keyboard/bcm-keypad.c +0 -0
index 56a919ec23b5..bc8bd78d74f5 100644
@@ -368,11 +368,9 @@ static int bcm_kp_probe(struct platform_device *pdev)
 	kp->clk = devm_clk_get(&pdev->dev, "peri_clk");

drivers/input/keyboard/bcm-keypad.c static int bcm_kp_probe(struct platform_device *pdev) · line 373

Quoted 10 lines
drivers/input/keyboard/bcm-keypad.c +3 -5
 	if (IS_ERR(kp->clk)) {
 		error = PTR_ERR(kp->clk);
-		if (error != -ENOENT) {
-			if (error != -EPROBE_DEFER)
-				dev_err(&pdev->dev, "Failed to get clock\n");
-			return error;
-		}
+		if (error != -ENOENT)
+			return dev_err_probe(&pdev->dev, error,
+					     "Failed to get clock\n");

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/keyboard/bcm-keypad.c +0 -0
 		dev_dbg(&pdev->dev,
 			"No clock specified. Assuming it's enabled\n");
 		kp->clk = NULL;
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/4 Input: gpio_keys - 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/keyboard/gpio_keys.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/input/keyboard/gpio_keys.c +2 -4
index a5dc4ab87fa1..ac74e85006a8 100644
@@ -530,10 +530,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 				 */
 				bdata->gpiod = NULL;
 			} else {
-				if (error != -EPROBE_DEFER)
-					dev_err(dev, "failed to get gpio: %d\n",
-						error);
-				return error;
+				return dev_err_probe(dev, error,
+						     "failed to get gpio\n");
 			}
 		}
 	} else if (gpio_is_valid(button->gpio)) {
Signature · 1 line
2.25.1
#4 lore raw

Re: [PATCH -next 3/4] Input: gpio_keys - Switch to use dev_err_probe() helper

Hi Yang,

Thank you for your patch,

Quoted 15 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/keyboard/gpio_keys.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/input/keyboard/gpio_keys.c +0 -0
index a5dc4ab87fa1..ac74e85006a8 100644

drivers/input/keyboard/gpio_keys.c static int gpio_keys_setup_key(struct platform_device *pdev, · line 534

Quoted 9 lines
drivers/input/keyboard/gpio_keys.c +2 -4
@@ -530,10 +530,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 				 */
 				bdata->gpiod = NULL;
 			} else {
-				if (error != -EPROBE_DEFER)
-					dev_err(dev, "failed to get gpio: %d\n",
-						error);
-				return error;
+				return dev_err_probe(dev, error,
+						     "failed to get gpio\n");

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

Quoted 5 lines
drivers/input/keyboard/gpio_keys.c +0 -0
 			}
 		}
 	} else if (gpio_is_valid(button->gpio)) {
Signature · 1 line
2.25.1
#5 lore raw

Re: [PATCH -next 3/4] Input: gpio_keys - Switch to use dev_err_probe() helper

Quoted 37 lines · Mattijs Korpershoek

Hi Yang,

Thank you for your patch,

Quoted 15 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/keyboard/gpio_keys.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/input/keyboard/gpio_keys.c +0 -0
index a5dc4ab87fa1..ac74e85006a8 100644

drivers/input/keyboard/gpio_keys.c static int gpio_keys_setup_key(struct platform_device *pdev, · line 534

Quoted 9 lines
drivers/input/keyboard/gpio_keys.c +2 -4
@@ -530,10 +530,8 @@ static int gpio_keys_setup_key(struct platform_device *pdev,
 				 */
 				bdata->gpiod = NULL;
 			} else {
-				if (error != -EPROBE_DEFER)
-					dev_err(dev, "failed to get gpio: %d\n",
-						error);
-				return error;
+				return dev_err_probe(dev, error,
+						     "failed to get gpio\n");

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
Quoted 7 lines

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

Argh, I missed the link. here it is:

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

Quoted 6 lines
Quoted 6 lines
drivers/input/keyboard/gpio_keys.c +0 -0
 			}
 		}
 	} else if (gpio_is_valid(button->gpio)) {
Signature · 1 line
2.25.1
#6 lore raw

PATCH 4/4 Input: gpio_keys_polled - 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/keyboard/gpio_keys_polled.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/input/keyboard/gpio_keys_polled.c +2 -6
index c3937d2fc744..ba00ecfbd343 100644
@@ -299,13 +299,9 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 							     NULL, GPIOD_IN,
 							     button->desc);
 			if (IS_ERR(bdata->gpiod)) {
-				error = PTR_ERR(bdata->gpiod);
-				if (error != -EPROBE_DEFER)
-					dev_err(dev,
-						"failed to get gpio: %d\n",
-						error);
 				fwnode_handle_put(child);
-				return error;
+				return dev_err_probe(dev, PTR_ERR(bdata->gpiod),
+						     "failed to get gpio\n");
 			}
 		} else if (gpio_is_valid(button->gpio)) {
 			/*
Signature · 1 line
2.25.1
#7 lore raw

Re: [PATCH -next 4/4] Input: gpio_keys_polled - Switch to use dev_err_probe() helper

Hi Yang,

Thank you for your patch,

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/keyboard/gpio_keys_polled.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/input/keyboard/gpio_keys_polled.c +0 -0
index c3937d2fc744..ba00ecfbd343 100644
@@ -299,13 +299,9 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 							     NULL, GPIOD_IN,
 							     button->desc);

drivers/input/keyboard/gpio_keys_polled.c static int gpio_keys_polled_probe(struct platform_device *pdev) · line 304

Quoted 10 lines
drivers/input/keyboard/gpio_keys_polled.c +2 -6
 			if (IS_ERR(bdata->gpiod)) {
-				error = PTR_ERR(bdata->gpiod);
-				if (error != -EPROBE_DEFER)
-					dev_err(dev,
-						"failed to get gpio: %d\n",
-						error);
 				fwnode_handle_put(child);
-				return error;
+				return dev_err_probe(dev, PTR_ERR(bdata->gpiod),
+						     "failed to get gpio\n");

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

Quoted 5 lines
drivers/input/keyboard/gpio_keys_polled.c +0 -0
 			}
 		} else if (gpio_is_valid(button->gpio)) {
 			/*
Signature · 1 line
2.25.1
#8 lore raw

Re: [PATCH -next 4/4] Input: gpio_keys_polled - Switch to use dev_err_probe() helper

Quoted 40 lines · Mattijs Korpershoek

Hi Yang,

Thank you for your patch,

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/keyboard/gpio_keys_polled.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/input/keyboard/gpio_keys_polled.c +0 -0
index c3937d2fc744..ba00ecfbd343 100644
@@ -299,13 +299,9 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
 							     NULL, GPIOD_IN,
 							     button->desc);

drivers/input/keyboard/gpio_keys_polled.c static int gpio_keys_polled_probe(struct platform_device *pdev) · line 304

Quoted 10 lines
drivers/input/keyboard/gpio_keys_polled.c +2 -6
 			if (IS_ERR(bdata->gpiod)) {
-				error = PTR_ERR(bdata->gpiod);
-				if (error != -EPROBE_DEFER)
-					dev_err(dev,
-						"failed to get gpio: %d\n",
-						error);
 				fwnode_handle_put(child);
-				return error;
+				return dev_err_probe(dev, PTR_ERR(bdata->gpiod),
+						     "failed to get gpio\n");

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
Quoted 7 lines

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

Argh, I missed the link. here it is:

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

Quoted 6 lines
Quoted 6 lines
drivers/input/keyboard/gpio_keys_polled.c +0 -0
 			}
 		} else if (gpio_is_valid(button->gpio)) {
 			/*
Signature · 1 line
2.25.1
#9 lore raw
In reply to Yang Yingliang

Hi Yang,

Thank you for your patch,

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/joystick/adc-joystick.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/input/joystick/adc-joystick.c +0 -0
index c0deff5d4282..3590d845e381 100644
@@ -201,12 +201,9 @@ static int adc_joystick_probe(struct platform_device *pdev)
 		return -ENOMEM;
 

drivers/input/joystick/adc-joystick.c static int adc_joystick_probe(struct platform_device *pdev) · line 206

Quoted 10 lines
drivers/input/joystick/adc-joystick.c +3 -6
 	joy->chans = devm_iio_channel_get_all(dev);
-	if (IS_ERR(joy->chans)) {
-		error = PTR_ERR(joy->chans);
-		if (error != -EPROBE_DEFER)
-			dev_err(dev, "Unable to get IIO channels");
-		return error;
-	}
+	if (IS_ERR(joy->chans))
+		return dev_err_probe(dev, PTR_ERR(joy->chans),
+				     "Unable to get IIO channels\n");

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/joystick/adc-joystick.c +0 -0
 	error = device_property_read_u32(dev, "poll-interval", &poll_interval);
 	if (error) {
Signature · 1 line
2.25.1