Merge tag 'pinctrl-v4.15-1' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw...
[sfrench/cifs-2.6.git] / drivers / gpio / gpiolib.c
index 7397260141b477ce679e9b33a5015ead07de0702..aad84a6306c4e5ddbc3364d58add85fa1b1e2583 100644 (file)
@@ -3528,8 +3528,21 @@ int gpiod_configure_flags(struct gpio_desc *desc, const char *con_id,
 
        if (lflags & GPIO_ACTIVE_LOW)
                set_bit(FLAG_ACTIVE_LOW, &desc->flags);
+
        if (lflags & GPIO_OPEN_DRAIN)
                set_bit(FLAG_OPEN_DRAIN, &desc->flags);
+       else if (dflags & GPIOD_FLAGS_BIT_OPEN_DRAIN) {
+               /*
+                * This enforces open drain mode from the consumer side.
+                * This is necessary for some busses like I2C, but the lookup
+                * should *REALLY* have specified them as open drain in the
+                * first place, so print a little warning here.
+                */
+               set_bit(FLAG_OPEN_DRAIN, &desc->flags);
+               gpiod_warn(desc,
+                          "enforced open drain please flag it properly in DT/ACPI DSDT/board file\n");
+       }
+
        if (lflags & GPIO_OPEN_SOURCE)
                set_bit(FLAG_OPEN_SOURCE, &desc->flags);
        if (lflags & GPIO_SLEEP_MAY_LOSE_VALUE)