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] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 25 Apr 2016 18:09:01 +0000
From:	Konstantin Shkolnyy <Konstantin.Shkolnyy@...abs.com>
To:	Johan Hovold <johan@...nel.org>,
	Konstantin Shkolnyy <konstantin.shkolnyy@...il.com>
CC:	"linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [EXT] Re: [PATCH RESEND 3/5] USB: serial: cp210x: Added comments
 to CRTSCT flag code.

I was planning to define all these bits in a separate future patch.
Would you rather prefer the magic numbers defined before fixing the bugs?
I guess I can do that. Is something like this acceptable?

/* CP210X_GET_FLOW/CP210X_SET_FLOW read/write these 0x10 bytes */
struct cp210x_flow_ctl {
	u8	SERIAL_DTR_MASK        : 2; /* byte 0 */
	u8	                       : 1;
	u8	SERIAL_CTS_HANDSHAKE   : 1;
	u8	SERIAL_DSR_HANDSHAKE   : 1;
	u8	SERIAL_DCD_HANDSHAKE   : 1;
	u8	SERIAL_DSR_SENSITIVITY : 1;
	u8	                       : 1;
	u8; /* byte 1 */
	u8; /* byte 2 */
	u8; /* byte 3 */
	u8	SERIAL_AUTO_TRANSMIT   : 1; /* byte 4 */
	u8	SERIAL_AUTO_RECEIVE    : 1;
	u8	SERIAL_ERROR_CHAR      : 1;
	u8	SERIAL_NULL_STRIPPING  : 1;
	u8	SERIAL_BREAK_CHAR      : 1;
	u8	                       : 1;
	u8	SERIAL_RTS_MASK        : 2;
	u8; /* byte 5 */
	u8; /* byte 6 */
	u8	                       : 7; /* byte 7 */
	u8	SERIAL_XOFF_CONTINUE   : 1;
	__le32	ulXonLimit;
	__le32	ulXoffLimit;
} __packed;

> -----Original Message-----
> From: linux-usb-owner@...r.kernel.org [mailto:linux-usb-
> owner@...r.kernel.org] On Behalf Of Johan Hovold
> Sent: Monday, April 25, 2016 05:17
> To: Konstantin Shkolnyy
> Cc: johan@...nel.org; linux-usb@...r.kernel.org; linux-
> kernel@...r.kernel.org
> Subject: [EXT] Re: [PATCH RESEND 3/5] USB: serial: cp210x: Added comments
> to CRTSCT flag code.
> 
> On Sun, Apr 24, 2016 at 12:09:21PM -0500, Konstantin Shkolnyy wrote:
> > Documented "magic numbers" used in the CRTSCT flag code in terms of
> > register bit names from the chip specification.
> 
> Documenting these is long overdue. I even started adding defines just to
> be able to review the first patch in the series.
> 
> > Signed-off-by: Konstantin Shkolnyy <konstantin.shkolnyy@...il.com>
> > ---
> >  drivers/usb/serial/cp210x.c | 38
> ++++++++++++++++++++++++++++++++++----
> >  1 file changed, 34 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
> > index ede5c52..b2321a7 100644
> > --- a/drivers/usb/serial/cp210x.c
> > +++ b/drivers/usb/serial/cp210x.c
> > @@ -790,7 +790,7 @@ static void cp210x_get_termios_port(struct
> usb_serial_port *port,
> >
> >  	cp210x_read_reg_block(port, CP210X_GET_FLOW, modem_ctl,
> >  			sizeof(modem_ctl));
> > -	if (modem_ctl[0] & 0x08) {
> > +	if (modem_ctl[0] & 0x08) { /* if SERIAL_CTS_HANDSHAKE */
> 
> But instead of adding comments like this one and below, please add
> proper defines for the various flags and masks. That will make the code
> mostly self-explanatory.
> 
> >  		dev_dbg(dev, "%s - flow control = CRTSCTS\n", __func__);
> >  		cflag |= CRTSCTS;
> >  	} else {
> > @@ -952,17 +952,47 @@ static void cp210x_set_termios(struct tty_struct
> *tty,
> >  			__func__, modem_ctl[0], modem_ctl[4],
> modem_ctl[7]);
> >
> >  		if (cflag & CRTSCTS) {
> > -			modem_ctl[0] &= ~0x7B;
> > +			modem_ctl[0] &= ~0x7B; /* keep reserved D2 and D7
> */
> > +			/*
> > +			 * D1-D0 SERIAL_DTR_MASK     =01b: DTR is held
> active
> > +			 * D3 SERIAL_CTS_HANDSHAKE   =1: CTS is a
> handshake line
> > +			 * D4 SERIAL_DSR_HANDSHAKE   =0
> > +			 * D5 SERIAL_DCD_HANDSHAKE   =0
> > +			 * D6 SERIAL_DSR_SENSITIVITY =0
> > +			 */
> 
> > -		modem_ctl[7] = 0;
> > +		modem_ctl[7] = 0; /* SERIAL_XOFF_CONTINUE = 0 */
> 
> And this would be better as a bit operation as well (as already
> mentioned).
> 
> Thanks,
> Johan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ