lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 31 Oct 2017 09:59:28 +0100
From:   Johan Hovold <johan@...nel.org>
To:     "Ji-Ze Hong (Peter Hong)" <hpeter@...il.com>
Cc:     johan@...nel.org, gregkh@...uxfoundation.org,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
        hpeter+linux_kernel@...il.com, peter_hong@...tek.com.tw
Subject: Re: [PATCH V1 2/2] usb: serial: f81534: Implement break control

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) <hpeter+linux_kernel@...il.com>
> ---
>  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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ