Re: [PATCH 6/8] tty: Replace ASYNC_INITIALIZED bit and update atomically
On Sat, Apr 09, 2016 at 05:53:25PM -0700, Peter Hurley wrote: > Replace ASYNC_INITIALIZED bit in the tty_port::flags field with > TTY_PORT_INITIALIZED bit in the tty_port::iflags field. Introduce helpers > tty_port_set_initialized() and tty_port_initialized() to abstract > atomic bit ops. > > Note: the transforms for test_and_set_bit() and test_and_clear_bit() > are unnecessary as the state transitions are already mutually exclusive; > the tty lock prevents concurrent open/close/hangup. > > Signed-off-by: Peter Hurley> --- > drivers/char/pcmcia/synclink_cs.c | 12 +- > drivers/ipack/devices/ipoctal.c| 5 ++--- > drivers/isdn/i4l/isdn_tty.c| 10 - > drivers/s390/char/con3215.c| 12 +- > drivers/tty/amiserial.c| 14 ++-- > drivers/tty/cyclades.c | 14 ++-- > drivers/tty/isicom.c | 6 ++--- > drivers/tty/moxa.c | 10 - > drivers/tty/mxser.c| 14 +--- > drivers/tty/n_gsm.c| 8 +++ > drivers/tty/rocket.c | 10 - > drivers/tty/serial/crisv10.c | 17 +++--- > drivers/tty/serial/serial_core.c | 24 +++- > drivers/tty/synclink.c | 46 > ++ > drivers/tty/synclink_gt.c | 16 ++--- > drivers/tty/synclinkmp.c | 16 ++--- > drivers/tty/tty_port.c | 13 ++- > drivers/usb/class/cdc-acm.c| 4 ++-- > drivers/usb/serial/console.c | 4 ++-- > drivers/usb/serial/generic.c | 6 ++--- > drivers/usb/serial/mxuport.c | 6 ++--- > drivers/usb/serial/sierra.c| 4 ++-- > drivers/usb/serial/usb-serial.c| 2 +- > drivers/usb/serial/usb_wwan.c | 4 ++-- For usb-serial Acked-by: Johan Hovold Thanks, Johan
Re: [PATCH 6/8] tty: Replace ASYNC_INITIALIZED bit and update atomically
On Sat, Apr 09, 2016 at 05:53:25PM -0700, Peter Hurley wrote: > Replace ASYNC_INITIALIZED bit in the tty_port::flags field with > TTY_PORT_INITIALIZED bit in the tty_port::iflags field. Introduce helpers > tty_port_set_initialized() and tty_port_initialized() to abstract > atomic bit ops. > > Note: the transforms for test_and_set_bit() and test_and_clear_bit() > are unnecessary as the state transitions are already mutually exclusive; > the tty lock prevents concurrent open/close/hangup. > > Signed-off-by: Peter Hurley > --- > drivers/char/pcmcia/synclink_cs.c | 12 +- > drivers/ipack/devices/ipoctal.c| 5 ++--- > drivers/isdn/i4l/isdn_tty.c| 10 - > drivers/s390/char/con3215.c| 12 +- > drivers/tty/amiserial.c| 14 ++-- > drivers/tty/cyclades.c | 14 ++-- > drivers/tty/isicom.c | 6 ++--- > drivers/tty/moxa.c | 10 - > drivers/tty/mxser.c| 14 +--- > drivers/tty/n_gsm.c| 8 +++ > drivers/tty/rocket.c | 10 - > drivers/tty/serial/crisv10.c | 17 +++--- > drivers/tty/serial/serial_core.c | 24 +++- > drivers/tty/synclink.c | 46 > ++ > drivers/tty/synclink_gt.c | 16 ++--- > drivers/tty/synclinkmp.c | 16 ++--- > drivers/tty/tty_port.c | 13 ++- > drivers/usb/class/cdc-acm.c| 4 ++-- > drivers/usb/serial/console.c | 4 ++-- > drivers/usb/serial/generic.c | 6 ++--- > drivers/usb/serial/mxuport.c | 6 ++--- > drivers/usb/serial/sierra.c| 4 ++-- > drivers/usb/serial/usb-serial.c| 2 +- > drivers/usb/serial/usb_wwan.c | 4 ++-- For usb-serial Acked-by: Johan Hovold Thanks, Johan
[PATCH 6/8] tty: Replace ASYNC_INITIALIZED bit and update atomically
Replace ASYNC_INITIALIZED bit in the tty_port::flags field with TTY_PORT_INITIALIZED bit in the tty_port::iflags field. Introduce helpers tty_port_set_initialized() and tty_port_initialized() to abstract atomic bit ops. Note: the transforms for test_and_set_bit() and test_and_clear_bit() are unnecessary as the state transitions are already mutually exclusive; the tty lock prevents concurrent open/close/hangup. Signed-off-by: Peter Hurley--- drivers/char/pcmcia/synclink_cs.c | 12 +- drivers/ipack/devices/ipoctal.c| 5 ++--- drivers/isdn/i4l/isdn_tty.c| 10 - drivers/s390/char/con3215.c| 12 +- drivers/tty/amiserial.c| 14 ++-- drivers/tty/cyclades.c | 14 ++-- drivers/tty/isicom.c | 6 ++--- drivers/tty/moxa.c | 10 - drivers/tty/mxser.c| 14 +--- drivers/tty/n_gsm.c| 8 +++ drivers/tty/rocket.c | 10 - drivers/tty/serial/crisv10.c | 17 +++--- drivers/tty/serial/serial_core.c | 24 +++- drivers/tty/synclink.c | 46 ++ drivers/tty/synclink_gt.c | 16 ++--- drivers/tty/synclinkmp.c | 16 ++--- drivers/tty/tty_port.c | 13 ++- drivers/usb/class/cdc-acm.c| 4 ++-- drivers/usb/serial/console.c | 4 ++-- drivers/usb/serial/generic.c | 6 ++--- drivers/usb/serial/mxuport.c | 6 ++--- drivers/usb/serial/sierra.c| 4 ++-- drivers/usb/serial/usb-serial.c| 2 +- drivers/usb/serial/usb_wwan.c | 4 ++-- include/linux/tty.h| 13 +++ net/irda/ircomm/ircomm_tty.c | 15 +++-- net/irda/ircomm/ircomm_tty_ioctl.c | 2 +- 27 files changed, 157 insertions(+), 150 deletions(-) diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index bf54f4e..345ca7c 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -1272,7 +1272,7 @@ static int startup(MGSLPC_INFO * info, struct tty_struct *tty) if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):startup(%s)\n", __FILE__, __LINE__, info->device_name); - if (info->port.flags & ASYNC_INITIALIZED) + if (tty_port_initialized(>port)) return 0; if (!info->tx_buf) { @@ -1311,7 +1311,7 @@ static int startup(MGSLPC_INFO * info, struct tty_struct *tty) if (tty) clear_bit(TTY_IO_ERROR, >flags); - info->port.flags |= ASYNC_INITIALIZED; + tty_port_set_initialized(>port, 1); return 0; } @@ -1322,7 +1322,7 @@ static void shutdown(MGSLPC_INFO * info, struct tty_struct *tty) { unsigned long flags; - if (!(info->port.flags & ASYNC_INITIALIZED)) + if (!tty_port_initialized(>port)) return; if (debug_level >= DEBUG_LEVEL_INFO) @@ -1361,7 +1361,7 @@ static void shutdown(MGSLPC_INFO * info, struct tty_struct *tty) if (tty) set_bit(TTY_IO_ERROR, >flags); - info->port.flags &= ~ASYNC_INITIALIZED; + tty_port_set_initialized(>port, 0); } static void mgslpc_program_hw(MGSLPC_INFO *info, struct tty_struct *tty) @@ -2338,7 +2338,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp) if (tty_port_close_start(port, tty, filp) == 0) goto cleanup; - if (port->flags & ASYNC_INITIALIZED) + if (tty_port_initialized(port)) mgslpc_wait_until_sent(tty, info->timeout); mgslpc_flush_buffer(tty); @@ -2371,7 +2371,7 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout) if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent")) return; - if (!(info->port.flags & ASYNC_INITIALIZED)) + if (!tty_port_initialized(>port)) goto exit; orig_jiffies = jiffies; diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c index 035d544..75dd15d 100644 --- a/drivers/ipack/devices/ipoctal.c +++ b/drivers/ipack/devices/ipoctal.c @@ -629,8 +629,7 @@ static void ipoctal_hangup(struct tty_struct *tty) tty_port_hangup(>tty_port); ipoctal_reset_channel(channel); - - clear_bit(ASYNCB_INITIALIZED, >tty_port.flags); + tty_port_set_initialized(>tty_port, 0); wake_up_interruptible(>tty_port.open_wait); } @@ -642,7 +641,7 @@ static void ipoctal_shutdown(struct tty_struct *tty) return; ipoctal_reset_channel(channel); - clear_bit(ASYNCB_INITIALIZED, >tty_port.flags); + tty_port_set_initialized(>tty_port, 0); } static void ipoctal_cleanup(struct tty_struct *tty) diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 023a350a..63eaa0a 100644 ---
[PATCH 6/8] tty: Replace ASYNC_INITIALIZED bit and update atomically
Replace ASYNC_INITIALIZED bit in the tty_port::flags field with TTY_PORT_INITIALIZED bit in the tty_port::iflags field. Introduce helpers tty_port_set_initialized() and tty_port_initialized() to abstract atomic bit ops. Note: the transforms for test_and_set_bit() and test_and_clear_bit() are unnecessary as the state transitions are already mutually exclusive; the tty lock prevents concurrent open/close/hangup. Signed-off-by: Peter Hurley --- drivers/char/pcmcia/synclink_cs.c | 12 +- drivers/ipack/devices/ipoctal.c| 5 ++--- drivers/isdn/i4l/isdn_tty.c| 10 - drivers/s390/char/con3215.c| 12 +- drivers/tty/amiserial.c| 14 ++-- drivers/tty/cyclades.c | 14 ++-- drivers/tty/isicom.c | 6 ++--- drivers/tty/moxa.c | 10 - drivers/tty/mxser.c| 14 +--- drivers/tty/n_gsm.c| 8 +++ drivers/tty/rocket.c | 10 - drivers/tty/serial/crisv10.c | 17 +++--- drivers/tty/serial/serial_core.c | 24 +++- drivers/tty/synclink.c | 46 ++ drivers/tty/synclink_gt.c | 16 ++--- drivers/tty/synclinkmp.c | 16 ++--- drivers/tty/tty_port.c | 13 ++- drivers/usb/class/cdc-acm.c| 4 ++-- drivers/usb/serial/console.c | 4 ++-- drivers/usb/serial/generic.c | 6 ++--- drivers/usb/serial/mxuport.c | 6 ++--- drivers/usb/serial/sierra.c| 4 ++-- drivers/usb/serial/usb-serial.c| 2 +- drivers/usb/serial/usb_wwan.c | 4 ++-- include/linux/tty.h| 13 +++ net/irda/ircomm/ircomm_tty.c | 15 +++-- net/irda/ircomm/ircomm_tty_ioctl.c | 2 +- 27 files changed, 157 insertions(+), 150 deletions(-) diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index bf54f4e..345ca7c 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -1272,7 +1272,7 @@ static int startup(MGSLPC_INFO * info, struct tty_struct *tty) if (debug_level >= DEBUG_LEVEL_INFO) printk("%s(%d):startup(%s)\n", __FILE__, __LINE__, info->device_name); - if (info->port.flags & ASYNC_INITIALIZED) + if (tty_port_initialized(>port)) return 0; if (!info->tx_buf) { @@ -1311,7 +1311,7 @@ static int startup(MGSLPC_INFO * info, struct tty_struct *tty) if (tty) clear_bit(TTY_IO_ERROR, >flags); - info->port.flags |= ASYNC_INITIALIZED; + tty_port_set_initialized(>port, 1); return 0; } @@ -1322,7 +1322,7 @@ static void shutdown(MGSLPC_INFO * info, struct tty_struct *tty) { unsigned long flags; - if (!(info->port.flags & ASYNC_INITIALIZED)) + if (!tty_port_initialized(>port)) return; if (debug_level >= DEBUG_LEVEL_INFO) @@ -1361,7 +1361,7 @@ static void shutdown(MGSLPC_INFO * info, struct tty_struct *tty) if (tty) set_bit(TTY_IO_ERROR, >flags); - info->port.flags &= ~ASYNC_INITIALIZED; + tty_port_set_initialized(>port, 0); } static void mgslpc_program_hw(MGSLPC_INFO *info, struct tty_struct *tty) @@ -2338,7 +2338,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp) if (tty_port_close_start(port, tty, filp) == 0) goto cleanup; - if (port->flags & ASYNC_INITIALIZED) + if (tty_port_initialized(port)) mgslpc_wait_until_sent(tty, info->timeout); mgslpc_flush_buffer(tty); @@ -2371,7 +2371,7 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout) if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent")) return; - if (!(info->port.flags & ASYNC_INITIALIZED)) + if (!tty_port_initialized(>port)) goto exit; orig_jiffies = jiffies; diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c index 035d544..75dd15d 100644 --- a/drivers/ipack/devices/ipoctal.c +++ b/drivers/ipack/devices/ipoctal.c @@ -629,8 +629,7 @@ static void ipoctal_hangup(struct tty_struct *tty) tty_port_hangup(>tty_port); ipoctal_reset_channel(channel); - - clear_bit(ASYNCB_INITIALIZED, >tty_port.flags); + tty_port_set_initialized(>tty_port, 0); wake_up_interruptible(>tty_port.open_wait); } @@ -642,7 +641,7 @@ static void ipoctal_shutdown(struct tty_struct *tty) return; ipoctal_reset_channel(channel); - clear_bit(ASYNCB_INITIALIZED, >tty_port.flags); + tty_port_set_initialized(>tty_port, 0); } static void ipoctal_cleanup(struct tty_struct *tty) diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index 023a350a..63eaa0a 100644 --- a/drivers/isdn/i4l/isdn_tty.c