Input: gpio_event: Don't call gpio_cansleep before gpio_request.
authorArve Hjønnevåg <arve@android.com>
Fri, 2 Apr 2010 02:52:27 +0000 (19:52 -0700)
committermgross <mark.gross@intel.com>
Wed, 9 Nov 2011 20:05:49 +0000 (12:05 -0800)
If the gpio did not exist it would crash in gpiolib.

Signed-off-by: Arve Hjønnevåg <arve@android.com>
drivers/input/misc/gpio_matrix.c

index f645471..08b8813 100644 (file)
@@ -336,18 +336,18 @@ int gpio_event_matrix_func(struct gpio_event_input_devs *input_devs,
                }
 
                for (i = 0; i < mi->noutputs; i++) {
-                       if (gpio_cansleep(mi->output_gpios[i])) {
-                               pr_err("gpiomatrix: unsupported output gpio %d,"
-                                       " can sleep\n", mi->output_gpios[i]);
-                               err = -EINVAL;
-                               goto err_request_output_gpio_failed;
-                       }
                        err = gpio_request(mi->output_gpios[i], "gpio_kp_out");
                        if (err) {
                                pr_err("gpiomatrix: gpio_request failed for "
                                        "output %d\n", mi->output_gpios[i]);
                                goto err_request_output_gpio_failed;
                        }
+                       if (gpio_cansleep(mi->output_gpios[i])) {
+                               pr_err("gpiomatrix: unsupported output gpio %d,"
+                                       " can sleep\n", mi->output_gpios[i]);
+                               err = -EINVAL;
+                               goto err_output_gpio_configure_failed;
+                       }
                        if (mi->flags & GPIOKPF_DRIVE_INACTIVE)
                                err = gpio_direction_output(mi->output_gpios[i],
                                        !(mi->flags & GPIOKPF_ACTIVE_HIGH));