of_get_gpio() might return -EPROBE_DEFER meaning that the driver providing the gpio isn't ready yet. If that happens for the first gpio the resulting kernel output without this patch is: w1-gpio somename: Failed to parse DT platform somename: Driver w1-gpio requests probe deferral The first message is misleading and so is suppressed with this patch. Further if determining the gpio to switch the external pullup yields -EPROBE_DEFER this error should be passed back to the caller instead of just continuing without pullup.
Unified · Split
| @@ -89,11 +89,22 @@ static int w1_gpio_probe_dt(struct platform_device *pdev) · 88 unmodified lines | ||
| 89 | 89 | pdata->is_open_drain = 1; |
| 90 | 90 | |
| 91 | 91 | gpio = of_get_gpio(np, 0); |
| 92 | − if (gpio < 0) | |
| 92 | + if (gpio < 0) { | |
| 93 | + if (gpio != -EPROBE_DEFER) | |
| 94 | + dev_err(&pdev->dev, | |
| 95 | + "Failed to parse gpio property for data pin (%d)\n", | |
| 96 | + gpio); | |
| 97 | + | |
| 93 | 98 | return gpio; |
| 99 | + } | |
| 94 | 100 | pdata->pin = gpio; |
| 95 | 101 | |
| 96 | − pdata->ext_pullup_enable_pin = of_get_gpio(np, 1); | |
| 102 | + gpio = of_get_gpio(np, 1); | |
| 103 | + if (gpio == -EPROBE_DEFER) | |
| 104 | + return gpio; | |
| 105 | + /* ignore other errors as the pullup gpio is optional */ | |
| 106 | + pdata->ext_pullup_enable_pin = gpio; | |
| 107 | + | |
| 97 | 108 | pdev->dev.platform_data = pdata; |
| 98 | 109 | |
| 99 | 110 | return 0; |
| @@ -107,10 +118,8 @@ static int w1_gpio_probe(struct platform_device *pdev) · 7 unmodified lines | ||
| 107 | 118 | |
| 108 | 119 | if (of_have_populated_dt()) { |
| 109 | 120 | err = w1_gpio_probe_dt(pdev); |
| 110 | − if (err < 0) { | |
| 111 | − dev_err(&pdev->dev, "Failed to parse DT\n"); | |
| 121 | + if (err < 0) | |
| 112 | 122 | return err; |
| 113 | − } | |
| 114 | 123 | } |
| 115 | 124 | |
| 116 | 125 | pdata = dev_get_platdata(&pdev->dev); |