]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Input: soc_button_array - bail out earlier if gpiod_count is zero
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Fri, 25 Nov 2016 19:36:01 +0000 (11:36 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Fri, 25 Nov 2016 19:39:50 +0000 (11:39 -0800)
The PNP0C40 device of the Surface 3 doesn't have any GPIO attached to it.
Instead of trying to access the GPIO, request the count beforehand and
bail out if it is null or if an error is returned.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/soc_button_array.c

index bbd433c4a5aa96618345910d364509d436d9221c..908b51089dee4b1cb128393cba441eecc477c994 100644 (file)
@@ -167,6 +167,11 @@ static int soc_button_probe(struct platform_device *pdev)
 
        button_info = (struct soc_button_info *)id->driver_data;
 
+       if (gpiod_count(&pdev->dev, KBUILD_MODNAME) <= 0) {
+               dev_dbg(&pdev->dev, "no GPIO attached, ignoring...\n");
+               return -ENODEV;
+       }
+
        priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
        if (!priv)
                return -ENOMEM;