aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index cca749010cd0..d9074191edef 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -536,6 +536,14 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip)
536 return -EINVAL; 536 return -EINVAL;
537 537
538 /* 538 /*
539 * Do not allow both INPUT & OUTPUT flags to be set as they are
540 * contradictory.
541 */
542 if ((lflags & GPIOHANDLE_REQUEST_INPUT) &&
543 (lflags & GPIOHANDLE_REQUEST_OUTPUT))
544 return -EINVAL;
545
546 /*
539 * Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If 547 * Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If
540 * the hardware actually supports enabling both at the same time the 548 * the hardware actually supports enabling both at the same time the
541 * electrical result would be disastrous. 549 * electrical result would be disastrous.
@@ -926,7 +934,9 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
926 } 934 }
927 935
928 /* This is just wrong: we don't look for events on output lines */ 936 /* This is just wrong: we don't look for events on output lines */
929 if (lflags & GPIOHANDLE_REQUEST_OUTPUT) { 937 if ((lflags & GPIOHANDLE_REQUEST_OUTPUT) ||
938 (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) ||
939 (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)) {
930 ret = -EINVAL; 940 ret = -EINVAL;
931 goto out_free_label; 941 goto out_free_label;
932 } 942 }
@@ -940,10 +950,6 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
940 950
941 if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW) 951 if (lflags & GPIOHANDLE_REQUEST_ACTIVE_LOW)
942 set_bit(FLAG_ACTIVE_LOW, &desc->flags); 952 set_bit(FLAG_ACTIVE_LOW, &desc->flags);
943 if (lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN)
944 set_bit(FLAG_OPEN_DRAIN, &desc->flags);
945 if (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)
946 set_bit(FLAG_OPEN_SOURCE, &desc->flags);
947 953
948 ret = gpiod_direction_input(desc); 954 ret = gpiod_direction_input(desc);
949 if (ret) 955 if (ret)