]> Pileus Git - ~andy/linux/commitdiff
w1-gpio: Detect of_gpio_error for first gpio
authorMarkus Pargmann <mpa@pengutronix.de>
Tue, 29 Oct 2013 08:19:23 +0000 (09:19 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Oct 2013 23:58:18 +0000 (16:58 -0700)
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 <mpa@pengutronix.de>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/w1/masters/w1-gpio.c

index f54ece268c982d1dce13224c78efce9434dbffbb..ae53e88328457624fe032bd663ffa612e7e9c23d 100644 (file)
@@ -58,6 +58,7 @@ static int w1_gpio_probe_dt(struct platform_device *pdev)
 {
        struct w1_gpio_platform_data *pdata = pdev->dev.platform_data;
        struct device_node *np = pdev->dev.of_node;
+       int gpio;
 
        pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
        if (!pdata)
@@ -66,7 +67,11 @@ static int w1_gpio_probe_dt(struct platform_device *pdev)
        if (of_get_property(np, "linux,open-drain", NULL))
                pdata->is_open_drain = 1;
 
-       pdata->pin = of_get_gpio(np, 0);
+       gpio = of_get_gpio(np, 0);
+       if (gpio < 0)
+               return gpio;
+       pdata->pin = gpio;
+
        pdata->ext_pullup_enable_pin = of_get_gpio(np, 1);
        pdev->dev.platform_data = pdata;