From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751605AbdJaI7e (ORCPT ); Tue, 31 Oct 2017 04:59:34 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:46543 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751378AbdJaI7a (ORCPT ); Tue, 31 Oct 2017 04:59:30 -0400 X-Google-Smtp-Source: ABhQp+TQ0/OuzFv/rC66qPw7P0Q8/vKzUoYRutbkg/BOPsuw4pE55bSD/8UU9Wg5eK+IwvUkiMLUPA== Date: Tue, 31 Oct 2017 09:59:28 +0100 From: Johan Hovold To: "Ji-Ze Hong (Peter Hong)" Cc: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, hpeter+linux_kernel@gmail.com, peter_hong@fintek.com.tw Subject: Re: [PATCH V1 2/2] usb: serial: f81534: Implement break control Message-ID: <20171031085928.GO7223@localhost> References: <1507861295-10071-1-git-send-email-hpeter+linux_kernel@gmail.com> <1507861295-10071-2-git-send-email-hpeter+linux_kernel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1507861295-10071-2-git-send-email-hpeter+linux_kernel@gmail.com> User-Agent: Mutt/1.7.2 (2016-11-26) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 13, 2017 at 10:21:35AM +0800, Ji-Ze Hong (Peter Hong) wrote: > Implement Fintek f81534 break on/off with LCR register. > It's the same with 16550A LCR register layout. > > Signed-off-by: Ji-Ze Hong (Peter Hong) > --- > drivers/usb/serial/f81534.c | 46 +++++++++++++++++++++++++++++++++++++++------ > 1 file changed, 40 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c > index 3f47afa..9ea407d 100644 > --- a/drivers/usb/serial/f81534.c > +++ b/drivers/usb/serial/f81534.c > @@ -128,11 +128,13 @@ struct f81534_serial_private { > > struct f81534_port_private { > struct mutex mcr_mutex; > + struct mutex lcr_mutex; I guess we could have used a single mutex for this, but I kept both. > struct work_struct lsr_work; > struct usb_serial_port *port; > unsigned long tx_empty; > spinlock_t msr_lock; > u8 shadow_mcr; > + u8 shadow_lcr; > u8 shadow_msr; > u8 phy_num; > }; > @@ -493,35 +496,64 @@ static int f81534_set_port_config(struct usb_serial_port *port, u32 baudrate, > } > > divisor = f81534_calc_baud_divisor(baudrate, F81534_MAX_BAUDRATE); > + > + mutex_lock(&port_priv->lcr_mutex); > + > value = UART_LCR_DLAB; > status = f81534_set_port_register(port, F81534_LINE_CONTROL_REG, > value); > if (status) { > dev_err(&port->dev, "%s: set LCR failed\n", __func__); > - return status; > + goto final; And I gave this label the more descriptive "out_unlock" name. [...] > - return 0; > + port_priv->shadow_lcr = value; > +final: > + mutex_unlock(&port_priv->lcr_mutex); > + return status; > +} > + > +static void f81534_break_ctl(struct tty_struct *tty, int break_state) > +{ > + struct usb_serial_port *port = tty->driver_data; > + struct f81534_port_private *port_priv = usb_get_serial_port_data(port); > + int status; > + > + mutex_lock(&port_priv->lcr_mutex); > + > + if (break_state) > + port_priv->shadow_lcr |= UART_LCR_SBC; > + else > + port_priv->shadow_lcr &= ~UART_LCR_SBC; > + > + status = f81534_set_port_register(port, F81534_LINE_CONTROL_REG, > + port_priv->shadow_lcr); > + if (status) > + dev_err(&port->dev, "set break failed: %x\n", status); And fixed the s/%x/%d/ here as well. > + > + mutex_unlock(&port_priv->lcr_mutex); > } Now applied. Thanks, Johan