From owner-svn-src-head@FreeBSD.ORG Wed Jan 22 09:57:27 2014 Return-Path: Delivered-To: svn-src-head@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 1892FD51; Wed, 22 Jan 2014 09:57:27 +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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id EBB1E1567; Wed, 22 Jan 2014 09:57:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0M9vQQW070901; Wed, 22 Jan 2014 09:57:26 GMT (envelope-from hselasky@svn.freebsd.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0M9vQfY070899; Wed, 22 Jan 2014 09:57:26 GMT (envelope-from hselasky@svn.freebsd.org) Message-Id: <201401220957.s0M9vQfY070899@svn.freebsd.org> From: Hans Petter Selasky Date: Wed, 22 Jan 2014 09:57:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r261014 - head/sys/dev/usb/wlan X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jan 2014 09:57:27 -0000 Author: hselasky Date: Wed Jan 22 09:57:26 2014 New Revision: 261014 URL: http://svnweb.freebsd.org/changeset/base/261014 Log: - Fix some non-portable code with regard to endianness. Don't use memmove(). - Fix a range check for maximum transmit length. - Fix read from missing field when transmitting data. MFC after: 2 weeks Modified: head/sys/dev/usb/wlan/if_run.c head/sys/dev/usb/wlan/if_runvar.h Modified: head/sys/dev/usb/wlan/if_run.c ============================================================================== --- head/sys/dev/usb/wlan/if_run.c Wed Jan 22 09:30:36 2014 (r261013) +++ head/sys/dev/usb/wlan/if_run.c Wed Jan 22 09:57:26 2014 (r261014) @@ -1356,11 +1356,22 @@ run_efuse_read(struct run_softc *sc, uin uint16_t reg; int error, ntries; + switch (count) { + case 1: + *val = 0xff; /* address not found */ + break; + case 2: + *val = 0xffff; /* address not found */ + addr *= 2; + break; + default: + *val = 0xffff; /* address not found */ + return (USB_ERR_INVAL); + } + if ((error = run_read(sc, RT3070_EFUSE_CTRL, &tmp)) != 0) return (error); - if (count == 2) - addr *= 2; /*- * Read one 16-byte block into registers EFUSE_DATA[0-3]: * DATA0: F E D C @@ -1381,21 +1392,21 @@ run_efuse_read(struct run_softc *sc, uin if (ntries == 100) return (ETIMEDOUT); - if ((tmp & RT3070_EFUSE_AOUT_MASK) == RT3070_EFUSE_AOUT_MASK) { - *val = 0xffff; /* address not found */ + if ((tmp & RT3070_EFUSE_AOUT_MASK) == RT3070_EFUSE_AOUT_MASK) return (0); - } + /* determine to which 32-bit register our 16-bit word belongs */ reg = RT3070_EFUSE_DATA3 - (addr & 0xc); if ((error = run_read(sc, reg, &tmp)) != 0) return (error); - if (count == 2) - *val = (addr & 2) ? tmp >> 16 : tmp & 0xffff; - else { - tmp >>= (8 *(addr & 0x3)); - memmove(val, &tmp, sizeof(*val)); - } + /* get correct bytes */ + *val = (uint16_t)(tmp >> (8 * (addr & 0x3))); + + /* mask for byte read, if any */ + if (count == 1) + *val &= 0xff; + return (0); } @@ -3083,10 +3094,9 @@ tr_setup: STAILQ_REMOVE_HEAD(&pq->tx_qh, next); m = data->m; - size = (sc->mac_ver == 0x5592) ? - RUN_MAX_TXSZ + sizeof(uint32_t) : RUN_MAX_TXSZ; - if ((m->m_pkthdr.len + - sizeof(data->desc) + 3 + 8) > size) { + size = (sc->mac_ver == 0x5592) ? + sizeof(data->desc) + sizeof(uint32_t) : sizeof(data->desc); + if ((m->m_pkthdr.len + size + 3 + 8) > RUN_MAX_TXSZ) { DPRINTF("data overflow, %u bytes\n", m->m_pkthdr.len); @@ -3098,8 +3108,6 @@ tr_setup: } pc = usbd_xfer_get_frame(xfer, 0); - size = (sc->mac_ver == 0x5592) ? - sizeof(data->desc) + sizeof(uint32_t) : sizeof(data->desc); usbd_copy_in(pc, 0, &data->desc, size); usbd_m_copy_in(pc, size, m, 0, m->m_pkthdr.len); size += m->m_pkthdr.len; Modified: head/sys/dev/usb/wlan/if_runvar.h ============================================================================== --- head/sys/dev/usb/wlan/if_runvar.h Wed Jan 22 09:30:36 2014 (r261013) +++ head/sys/dev/usb/wlan/if_runvar.h Wed Jan 22 09:57:26 2014 (r261014) @@ -89,6 +89,7 @@ struct run_tx_data { uint32_t align[0]; /* dummy field */ uint8_t desc[sizeof(struct rt2870_txd) + sizeof(struct rt2860_txwi)]; + uint8_t desc_extra[4]; /* used by v5592 */ uint8_t ridx; }; STAILQ_HEAD(run_tx_data_head, run_tx_data);