From owner-svn-src-stable@FreeBSD.ORG Mon Apr 28 13:12:20 2014 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 42437616; Mon, 28 Apr 2014 13:12:20 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E3E101AB4; Mon, 28 Apr 2014 13:12:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3SDCJXj043269; Mon, 28 Apr 2014 13:12:19 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3SDCJtV043268; Mon, 28 Apr 2014 13:12:19 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201404281312.s3SDCJtV043268@svn.freebsd.org> From: Ian Lepore Date: Mon, 28 Apr 2014 13:12:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r265048 - stable/10/sys/dev/usb/serial X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Apr 2014 13:12:20 -0000 Author: ian Date: Mon Apr 28 13:12:19 2014 New Revision: 265048 URL: http://svnweb.freebsd.org/changeset/base/265048 Log: MFC r264800: fixes for problems found by Coverity scan... - Get transmit loop more in line with the other serial drivers. - Add a comment about FTDI and ZLPs. - Correctly check odditiy of baud rate divisor. - Correct IOCTL handling for "error" and "event" char. Modified: stable/10/sys/dev/usb/serial/uftdi.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/usb/serial/uftdi.c ============================================================================== --- stable/10/sys/dev/usb/serial/uftdi.c Mon Apr 28 12:46:23 2014 (r265047) +++ stable/10/sys/dev/usb/serial/uftdi.c Mon Apr 28 13:12:19 2014 (r265048) @@ -1155,11 +1155,17 @@ uftdi_write_callback(struct usb_xfer *xf * Otherwise, loop to format packets into the buffer while there * is data available, and room for a packet header and at least * one byte of payload. + * + * NOTE: The FTDI chip doesn't accept zero length + * packets. This cannot happen because the "pktlen" + * will always be non-zero when "ucom_get_data()" + * returns non-zero which we check below. */ pc = usbd_xfer_get_frame(xfer, 0); if (sc->sc_hdrlen == 0) { - ucom_get_data(&sc->sc_ucom, pc, 0, UFTDI_OBUFSIZE, - &buflen); + if (ucom_get_data(&sc->sc_ucom, pc, 0, UFTDI_OBUFSIZE, + &buflen) == 0) + break; } else { buflen = 0; while (buflen < UFTDI_OBUFSIZE - sc->sc_hdrlen - 1 && @@ -1417,7 +1423,7 @@ uftdi_encode_baudrate(struct uftdi_softc * 8ths by adding 1 and dividing by 2. */ divisor = (clk << 4) / speed; - if ((divisor & 0xfffffff0) == 1) + if ((divisor & 0xf) == 1) divisor &= 0xfffffff8; else if (sc->sc_devtype == DEVT_232A) divisor += roundoff_232a[divisor & 0x0f]; @@ -1759,10 +1765,11 @@ uftdi_ioctl(struct ucom_softc *ucom, uin err = uftdi_get_latency(ucom, (int *)data); break; case UFTDIIOC_SET_ERROR_CHAR: - err = uftdi_set_event_char(ucom, *(int *)data); + err = uftdi_set_error_char(ucom, *(int *)data); break; case UFTDIIOC_SET_EVENT_CHAR: - err = uftdi_set_error_char(ucom, *(int *)data); + err = uftdi_set_event_char(ucom, *(int *)data); + break; case UFTDIIOC_GET_HWREV: *(int *)data = sc->sc_bcdDevice; err = 0;