Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03842c17 authored by Francois Berder's avatar Francois Berder Committed by Greg Kroah-Hartman
Browse files

sc16is7xx: always write state when configuring GPIO as an output



The regmap_update first reads the IOState register and then triggers
a write if needed. However, GPIOS might be configured as an input so
 the read to IOState on this GPIO is the current state which might
be random.

Signed-off-by: default avatarFrancois Berder <Francois.Berder@imgtec.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c03e1b87
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -1130,9 +1130,13 @@ static int sc16is7xx_gpio_direction_output(struct gpio_chip *chip,
{
	struct sc16is7xx_port *s = gpiochip_get_data(chip);
	struct uart_port *port = &s->p[0].port;
	u8 state = sc16is7xx_port_read(port, SC16IS7XX_IOSTATE_REG);

	sc16is7xx_port_update(port, SC16IS7XX_IOSTATE_REG, BIT(offset),
			      val ? BIT(offset) : 0);
	if (val)
		state |= BIT(offset);
	else
		state &= ~BIT(offset);
	sc16is7xx_port_write(port, SC16IS7XX_IOSTATE_REG, state);
	sc16is7xx_port_update(port, SC16IS7XX_IODIR_REG, BIT(offset),
			      BIT(offset));