Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: soc_button_array - bail out earlier if gpiod_count is zero

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>

authored by

Benjamin Tissoires and committed by
Dmitry Torokhov
3d5a9437 be8e7a7e

+5
+5
drivers/input/misc/soc_button_array.c
··· 167 167 168 168 button_info = (struct soc_button_info *)id->driver_data; 169 169 170 + if (gpiod_count(&pdev->dev, KBUILD_MODNAME) <= 0) { 171 + dev_dbg(&pdev->dev, "no GPIO attached, ignoring...\n"); 172 + return -ENODEV; 173 + } 174 + 170 175 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 171 176 if (!priv) 172 177 return -ENOMEM;