History

w1-gpio: handle of_get_gpio() returning -EPROBE_DEFER better

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.

Uwe Kleine-König committed 12 years ago

Commit 0b336ce1 parent c9afbb01 file · +14 −5Browse files

Unified · Split

drivers/w1/masters/w1-gpio.c+14−5
@@ -89,11 +89,22 @@ static int w1_gpio_probe_dt(struct platform_device *pdev) · 88 unmodified lines
8989 pdata->is_open_drain = 1;
9090
9191 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+
9398 return gpio;
99+ }
94100 pdata->pin = gpio;
95101
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+
97108 pdev->dev.platform_data = pdata;
98109
99110 return 0;
@@ -107,10 +118,8 @@ static int w1_gpio_probe(struct platform_device *pdev) · 7 unmodified lines
107118
108119 if (of_have_populated_dt()) {
109120 err = w1_gpio_probe_dt(pdev);
110− if (err < 0) {
111− dev_err(&pdev->dev, "Failed to parse DT\n");
121+ if (err < 0)
112122 return err;
113− }
114123 }
115124
116125 pdata = dev_get_platdata(&pdev->dev);