From owner-p4-projects@FreeBSD.ORG Sat Jul 22 07:27:04 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0975716A4DF; Sat, 22 Jul 2006 07:27:04 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C002D16A4DD for ; Sat, 22 Jul 2006 07:27:03 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8ABEB43D46 for ; Sat, 22 Jul 2006 07:27:03 +0000 (GMT) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k6M7R3fY003030 for ; Sat, 22 Jul 2006 07:27:03 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k6M7R3F7003027 for perforce@freebsd.org; Sat, 22 Jul 2006 07:27:03 GMT (envelope-from hselasky@FreeBSD.org) Date: Sat, 22 Jul 2006 07:27:03 GMT Message-Id: <200607220727.k6M7R3F7003027@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 102112 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Jul 2006 07:27:04 -0000 http://perforce.freebsd.org/chv.cgi?CH=102112 Change 102112 by hselasky@hselasky_mini_itx on 2006/07/22 07:26:22 Factorize "usbd_m_copy_in" into using "m_apply()". Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb_subr.c#9 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb_subr.c#9 (text+ko) ==== @@ -1681,39 +1681,30 @@ return; } - /*---------------------------------------------------------------------------* - * usbd_m_copy_in - copy a mbuf chain directly to DMA-able memory + * usbd_m_copy_in - copy a mbuf chain directly into DMA-able memory *---------------------------------------------------------------------------*/ +struct usbd_m_copy_in_arg { + struct usbd_page_cache *cache; + u_int32_t dst_offset; +}; + +static int32_t +usbd_m_copy_in_cb(void *arg, void *src, u_int32_t count) +{ + register struct usbd_m_copy_in_arg *ua = arg; + usbd_copy_in(ua->cache, ua->dst_offset, src, count); + ua->dst_offset += count; + return 0; +} + void usbd_m_copy_in(struct usbd_page_cache *cache, u_int32_t dst_offset, struct mbuf *m, u_int32_t src_offset, u_int32_t src_len) { - u_int32_t count; - - while (src_offset > 0) { - __KASSERT(m != NULL, ("usbd_m_copy_in, offset > " - "size of mbuf chain")); - if (src_offset < m->m_len) { - break; - } - src_offset -= m->m_len; - m = m->m_next; - } - - while (src_len > 0) { - __KASSERT(m != NULL, ("usbd_m_copy_in, length > " - "size of mbuf chain")); - count = min(m->m_len - src_offset, src_len); - - usbd_copy_in(cache, dst_offset, ((caddr_t)(m->m_data)) + - src_offset, count); - - src_len -= count; - dst_offset += count; - src_offset = 0; - m = m->m_next; - } + struct usbd_m_copy_in_arg arg = { cache, dst_offset }; + register int error; + error = m_apply(m, src_offset, src_len, &usbd_m_copy_in_cb, &arg); return; }