Skip to contentSkip to conversation

iio: adc: hx711: remove errors during deferred probe

PATCH In review Nate Drude 2 participants 2 messages Nov 4, 2022

Subsystems (2)
lore
Share & tools
lore

Nate Drude

author
#0 lore raw

PATCH 1/1 iio: adc: hx711: remove errors during deferred probe

This patch removes noisy kernel messages like "failed to sck-gpiod" or "failed to get dout-gpiod" when the probe is deferred.

---
 drivers/iio/adc/hx711.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/iio/adc/hx711.c +6 -4
index f7ee856a6b8b..8ba4a5b113aa 100644
@@ -482,8 +482,9 @@ static int hx711_probe(struct platform_device *pdev)
 	 */
 	hx711_data->gpiod_pd_sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW);
 	if (IS_ERR(hx711_data->gpiod_pd_sck)) {
-		dev_err(dev, "failed to get sck-gpiod: err=%ld\n",
-					PTR_ERR(hx711_data->gpiod_pd_sck));
+		if (PTR_ERR(hx711_data->gpiod_pd_sck) != -EPROBE_DEFER)
+			dev_err(dev, "failed to get sck-gpiod: err=%ld\n",
+						PTR_ERR(hx711_data->gpiod_pd_sck));
 		return PTR_ERR(hx711_data->gpiod_pd_sck);
 	}
 
@@ -493,8 +494,9 @@ static int hx711_probe(struct platform_device *pdev)
 	 */
 	hx711_data->gpiod_dout = devm_gpiod_get(dev, "dout", GPIOD_IN);
 	if (IS_ERR(hx711_data->gpiod_dout)) {
-		dev_err(dev, "failed to get dout-gpiod: err=%ld\n",
-					PTR_ERR(hx711_data->gpiod_dout));
+		if (PTR_ERR(hx711_data->gpiod_dout) != -EPROBE_DEFER)
+			dev_err(dev, "failed to get dout-gpiod: err=%ld\n",
+						PTR_ERR(hx711_data->gpiod_dout));
 		return PTR_ERR(hx711_data->gpiod_dout);
 	}
 
Signature · 1 line
2.38.1
#1 lore raw

Le 04/11/2022 à 18:22, Nate Drude a écrit :

Quoted 26 lines

This patch removes noisy kernel messages like "failed to sck-gpiod" or "failed to get dout-gpiod" when the probe is deferred.

---
  drivers/iio/adc/hx711.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)
drivers/iio/adc/hx711.c +3 -2
index f7ee856a6b8b..8ba4a5b113aa 100644
@@ -482,8 +482,9 @@ static int hx711_probe(struct platform_device *pdev)
  	 */
  	hx711_data->gpiod_pd_sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW);
  	if (IS_ERR(hx711_data->gpiod_pd_sck)) {
-		dev_err(dev, "failed to get sck-gpiod: err=%ld\n",
-					PTR_ERR(hx711_data->gpiod_pd_sck));
+		if (PTR_ERR(hx711_data->gpiod_pd_sck) != -EPROBE_DEFER)
+			dev_err(dev, "failed to get sck-gpiod: err=%ld\n",
+						PTR_ERR(hx711_data->gpiod_pd_sck));
  		return PTR_ERR(hx711_data->gpiod_pd_sck);
  	}
 
@@ -493,8 +494,9 @@ static int hx711_probe(struct platform_device *pdev)
  	 */

drivers/iio/adc/hx711.c static int hx711_probe(struct platform_device *pdev) · line 502

Quoted 10 lines
drivers/iio/adc/hx711.c +3 -2
  	hx711_data->gpiod_dout = devm_gpiod_get(dev, "dout", GPIOD_IN);
  	if (IS_ERR(hx711_data->gpiod_dout)) {
-		dev_err(dev, "failed to get dout-gpiod: err=%ld\n",
-					PTR_ERR(hx711_data->gpiod_dout));
+		if (PTR_ERR(hx711_data->gpiod_dout) != -EPROBE_DEFER)
+			dev_err(dev, "failed to get dout-gpiod: err=%ld\n",
+						PTR_ERR(hx711_data->gpiod_dout));
  		return PTR_ERR(hx711_data->gpiod_dout);
  	}
 

Hi,
using dev_err_probe() looks like a better candidate for that.

It can be can folded with the return (saving some LoC and the {} around the error handling path), and display the error code in a human readable manner.

CJ