Skip to content

Commit 7cf1a12

Browse files
Markus Pargmanngregkh
Markus Pargmann
authored andcommitted
w1-gpio: Detect of_gpio_error for first gpio
The first DT gpio is necessary for this driver, but errors returned for of_get_gpio are ignored. This patch adds a return value check for the first of_get_gpio. Signed-off-by: Markus Pargmann <[email protected]> Acked-by: Evgeniy Polyakov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e6418fc commit 7cf1a12

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/w1/masters/w1-gpio.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ static int w1_gpio_probe_dt(struct platform_device *pdev)
5858
{
5959
struct w1_gpio_platform_data *pdata = pdev->dev.platform_data;
6060
struct device_node *np = pdev->dev.of_node;
61+
int gpio;
6162

6263
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
6364
if (!pdata)
@@ -66,7 +67,11 @@ static int w1_gpio_probe_dt(struct platform_device *pdev)
6667
if (of_get_property(np, "linux,open-drain", NULL))
6768
pdata->is_open_drain = 1;
6869

69-
pdata->pin = of_get_gpio(np, 0);
70+
gpio = of_get_gpio(np, 0);
71+
if (gpio < 0)
72+
return gpio;
73+
pdata->pin = gpio;
74+
7075
pdata->ext_pullup_enable_pin = of_get_gpio(np, 1);
7176
pdev->dev.platform_data = pdata;
7277

0 commit comments

Comments
 (0)