On Thu, Aug 04, 2016 at 11:34:07AM +0100, Francois Berder wrote: > 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: Francois Berder <Francois.Berder@xxxxxxxxxx> > --- > drivers/tty/serial/sc16is7xx.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c > index f36e6df..546c913 100644 > --- a/drivers/tty/serial/sc16is7xx.c > +++ b/drivers/tty/serial/sc16is7xx.c > @@ -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)); > > -- > 2.6.2 > > >From e4d5c43f6bd950e65bb36974a4d8cf38a77bca5b Mon Sep 17 00:00:00 2001 > From: Francois Berder <Francois.Berder@xxxxxxxxxx> > Date: Thu, 30 Jun 2016 18:26:33 +0100 > Subject: [PATCH] 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: Francois Berder <Francois.Berder@xxxxxxxxxx> > --- > drivers/tty/serial/sc16is7xx.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c > index f36e6df..546c913 100644 > --- a/drivers/tty/serial/sc16is7xx.c > +++ b/drivers/tty/serial/sc16is7xx.c > @@ -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)); > > -- > 2.6.2 > This patch was twice in the same email, just include it inline, so that I can apply it properly. Can you please resend? thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html