1
0
Fork 0

gpio: fixes for v5.4-rc2

- fix a bug with emulated open-drain/source where lines' values can no longer
   be changed
 - fix getting nonexclusive gpiods from DT
 - fix an incorrect offset for the level trigger in gpio-eic-sprd
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAl2TIpgACgkQEacuoBRx
 13JSkw//UW+uD/qfzosg0CXI5CpISoMPsy692xy2O9thn6eYsxcW8hAJAsLz2eDx
 Q8ctyysJ6jSoqC0Y8SNkbfm0sBx4QgUb6Ty8pT8cmV6XS2G/iLekuIqJQGHOQtvv
 ha1z50bCi43pfVQmEVlTkKN5iE9d+VVl52aGXCY9ZBlFPQz6G7QUQ77TwkpdRMJY
 YfQMoFZkWDVZc4DvAJYBuou5+RkB+L53u/cyzo5nz1z9SDM1HhyrooidO1oXW+1F
 DYj0xqsBni2OTvxp3q/r9gOPz2lJ5jVZiGj/TWfQaWtNxjputZ9+rfPNrK5D1P05
 O3uib/srIhA0Be3Y5lrJsrdpLtrExF7dBiXBTHqS07Tdjg9aa5OcOi14DQDy+r6u
 3Ux07QQV+3bin+KVsXnWmKlpyeFJldO28j1Gk31AZg4Q6CsphPtdHg1qD9HPXKU9
 H86MGsFTo+Xnf99/Yh+8xf3Zg1b0LpDxTrizF2ztaPyue/P5mbmYf9q03MWtMZO6
 dSUy/bD5tfx09nNe4yWWD+L+K51/QjV10Jv1eMx58I88oXtAFrceMHHmNUIN4EPY
 R8l+H2/1aysczS+kYyTwSzWDsnCfN8xGv1t0yb8HJb+0AUgF+p/rQJLWMh1IH7c+
 IEOr5JbE8M1h1TXk1eYNJMAh4qiorFWgL7bfRqbMOMVKzrNCYAg=
 =mKSK
 -----END PGP SIGNATURE-----

Merge tag 'gpio-v5.4-rc2-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into fixes

gpio: fixes for v5.4-rc2

- fix a bug with emulated open-drain/source where lines' values can no longer
  be changed
- fix getting nonexclusive gpiods from DT
- fix an incorrect offset for the level trigger in gpio-eic-sprd
alistair/sunxi64-5.4-dsi
Linus Walleij 2019-10-02 16:13:28 +02:00
commit b8cd253a06
3 changed files with 24 additions and 12 deletions

View File

@ -530,11 +530,12 @@ static void sprd_eic_handle_one_type(struct gpio_chip *chip)
}
for_each_set_bit(n, &reg, SPRD_EIC_PER_BANK_NR) {
girq = irq_find_mapping(chip->irq.domain,
bank * SPRD_EIC_PER_BANK_NR + n);
u32 offset = bank * SPRD_EIC_PER_BANK_NR + n;
girq = irq_find_mapping(chip->irq.domain, offset);
generic_handle_irq(girq);
sprd_eic_toggle_trigger(chip, girq, n);
sprd_eic_toggle_trigger(chip, girq, offset);
}
}
}

View File

@ -317,7 +317,7 @@ struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
transitory = flags & OF_GPIO_TRANSITORY;
ret = gpiod_request(desc, label);
if (ret == -EBUSY && (flags & GPIOD_FLAGS_BIT_NONEXCLUSIVE))
if (ret == -EBUSY && (dflags & GPIOD_FLAGS_BIT_NONEXCLUSIVE))
return desc;
if (ret)
return ERR_PTR(ret);

View File

@ -3070,8 +3070,10 @@ int gpiod_direction_output(struct gpio_desc *desc, int value)
if (!ret)
goto set_output_value;
/* Emulate open drain by not actively driving the line high */
if (value)
return gpiod_direction_input(desc);
if (value) {
ret = gpiod_direction_input(desc);
goto set_output_flag;
}
}
else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) {
ret = gpio_set_config(gc, gpio_chip_hwgpio(desc),
@ -3079,8 +3081,10 @@ int gpiod_direction_output(struct gpio_desc *desc, int value)
if (!ret)
goto set_output_value;
/* Emulate open source by not actively driving the line low */
if (!value)
return gpiod_direction_input(desc);
if (!value) {
ret = gpiod_direction_input(desc);
goto set_output_flag;
}
} else {
gpio_set_config(gc, gpio_chip_hwgpio(desc),
PIN_CONFIG_DRIVE_PUSH_PULL);
@ -3088,6 +3092,17 @@ int gpiod_direction_output(struct gpio_desc *desc, int value)
set_output_value:
return gpiod_direction_output_raw_commit(desc, value);
set_output_flag:
/*
* When emulating open-source or open-drain functionalities by not
* actively driving the line (setting mode to input) we still need to
* set the IS_OUT flag or otherwise we won't be able to set the line
* value anymore.
*/
if (ret == 0)
set_bit(FLAG_IS_OUT, &desc->flags);
return ret;
}
EXPORT_SYMBOL_GPL(gpiod_direction_output);
@ -3448,8 +3463,6 @@ static void gpio_set_open_drain_value_commit(struct gpio_desc *desc, bool value)
if (value) {
ret = chip->direction_input(chip, offset);
if (!ret)
clear_bit(FLAG_IS_OUT, &desc->flags);
} else {
ret = chip->direction_output(chip, offset, 0);
if (!ret)
@ -3479,8 +3492,6 @@ static void gpio_set_open_source_value_commit(struct gpio_desc *desc, bool value
set_bit(FLAG_IS_OUT, &desc->flags);
} else {
ret = chip->direction_input(chip, offset);
if (!ret)
clear_bit(FLAG_IS_OUT, &desc->flags);
}
trace_gpio_direction(desc_to_gpio(desc), !value, ret);
if (ret < 0)