linux-stable/drivers/tty
Hugo Villeneuve 48533c0db7 serial: sc16is7xx: fix bug when first setting GPIO direction
commit 9baeea723c upstream.

When configuring a pin as an output pin with a value of logic 0, we
end up as having a value of logic 1 on the output pin. Setting a
logic 0 a second time (or more) after that will correctly output a
logic 0 on the output pin.

By default, all GPIO pins are configured as inputs. When we enter
sc16is7xx_gpio_direction_output() for the first time, we first set the
desired value in IOSTATE, and then we configure the pin as an output.
The datasheet states that writing to IOSTATE register will trigger a
transfer of the value to the I/O pin configured as output, so if the
pin is configured as an input, nothing will be transferred.

Therefore, set the direction first in IODIR, and then set the desired
value in IOSTATE.

This is what is done in NXP application note AN10587.

Fixes: dfeae619d7 ("serial: sc16is7xx")
Cc: stable@vger.kernel.org
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Reviewed-by: Lech Perczak <lech.perczak@camlingroup.com>
Tested-by: Lech Perczak <lech.perczak@camlingroup.com>
Link: https://lore.kernel.org/r/20230807214556.540627-6-hugo@hugovil.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-09-23 10:47:57 +02:00
..
hvc hvc/xen: prevent concurrent accesses to the shared ring 2023-04-05 11:15:35 +02:00
ipwireless
serdev
serial serial: sc16is7xx: fix bug when first setting GPIO direction 2023-09-23 10:47:57 +02:00
vt vc_screen: reload load of struct vc_data pointer in vcs_write() to avoid UAF 2023-05-30 12:42:13 +01:00
Kconfig
Makefile
amiserial.c
cyclades.c treewide: Remove uninitialized_var() usage 2023-08-11 11:45:01 +02:00
ehv_bytechan.c
goldfish.c tty: drivers/tty/, stop using tty_schedule_flip() 2022-07-29 17:10:37 +02:00
isicom.c treewide: Remove uninitialized_var() usage 2023-08-11 11:45:01 +02:00
mips_ejtag_fdc.c
moxa.c tty: drivers/tty/, stop using tty_schedule_flip() 2022-07-29 17:10:37 +02:00
moxa.h
mxser.c mxser: fix xmit_buf leak in activate when LSR == 0xff 2022-04-15 14:14:51 +02:00
mxser.h
n_gsm.c tty: n_gsm: fix sleep-in-atomic-context bug in gsm_control_send 2022-11-25 17:40:23 +01:00
n_hdlc.c
n_null.c
n_r3964.c
n_tracerouter.c
n_tracesink.c
n_tracesink.h
n_tty.c n_tty: wake up poll(POLLRDNORM) on receiving data 2022-02-16 12:51:46 +01:00
nozomi.c
pty.c tty: use new tty_insert_flip_string_and_push_buffer() in pty_write() 2022-07-29 17:10:37 +02:00
rocket.c
rocket.h
rocket_int.h
synclink.c
synclink_gt.c tty: synclink_gt: Fix null-pointer-dereference in slgt_clean() 2022-06-14 16:59:36 +02:00
synclinkmp.c
sysrq.c
tty_audit.c
tty_baudrate.c
tty_buffer.c tty: use new tty_insert_flip_string_and_push_buffer() in pty_write() 2022-07-29 17:10:37 +02:00
tty_io.c tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH 2023-05-17 11:13:27 +02:00
tty_ioctl.c tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH 2023-05-17 11:13:27 +02:00
tty_jobctrl.c
tty_ldisc.c
tty_ldsem.c
tty_mutex.c
tty_port.c
vcc.c