From owner-freebsd-usb@FreeBSD.ORG Thu Jan 17 17:14:51 2008 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9BE1D16A417 for ; Thu, 17 Jan 2008 17:14:51 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe09.swipnet.se [212.247.155.1]) by mx1.freebsd.org (Postfix) with ESMTP id 26D1C13C459 for ; Thu, 17 Jan 2008 17:14:50 +0000 (UTC) (envelope-from hselasky@c2i.net) X-Cloudmark-Score: 0.000000 [] Received: from [85.19.218.45] (account mc467741@c2i.net [85.19.218.45] verified) by mailfe09.swip.net (CommuniGate Pro SMTP 5.1.13) with ESMTPA id 601056197; Thu, 17 Jan 2008 18:14:49 +0100 From: Hans Petter Selasky To: Stefan Lambrev Date: Thu, 17 Jan 2008 18:15:37 +0100 User-Agent: KMail/1.9.7 References: <477BC1A3.5080406@moneybookers.com> <200801161802.48506.hselasky@c2i.net> <478F8670.3030500@moneybookers.com> In-Reply-To: <478F8670.3030500@moneybookers.com> MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200801171815.38196.hselasky@c2i.net> Cc: freebsd-usb@freebsd.org Subject: Re: [SOLVED] Re: Problem with usb4bsd rev566 X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2008 17:14:51 -0000 On Thursday 17 January 2008, Stefan Lambrev wrote: > Hi Hans, > > Unfortunately with rev568 I still see: > > /usr/src/sys/dev/usb/usb_transfer.c: In function 'usbd_callback_intr_td': > /usr/src/sys/dev/usb/usb_transfer.c:2094: warning: 'xfer[2]' may be used > uninitialized in this function > /usr/src/sys/dev/usb/usb_transfer.c:2094: warning: 'xfer[3]' may be used > uninitialized in this function > *** Error code 1 > > And the code does not compile. I've given it another try: +static void +usbd_callback_intr_td_sub(struct usbd_xfer **xfer, uint8_t dropcount) +{ + struct usbd_memory_info *info = xfer[0]->usb_root; + + mtx_unlock(info->usb_mtx); + + /* + * We exploit the fact that the mutex is the same for + * all callbacks: + */ + mtx_lock(info->priv_mtx); + + /* call callback(s) */ + switch (dropcount) { + case 4: + usbd_callback_wrapper(xfer[3], info, USBD_CONTEXT_CALLBACK); + case 3: + usbd_callback_wrapper(xfer[2], info, USBD_CONTEXT_CALLBACK); + case 2: + usbd_callback_wrapper(xfer[1], info, USBD_CONTEXT_CALLBACK); + case 1: + usbd_callback_wrapper(xfer[0], info, USBD_CONTEXT_CALLBACK); + default: + break; + } + mtx_unlock(info->priv_mtx); + mtx_lock(info->usb_mtx); + info->memory_refcount -= dropcount; + return; +} + /*------------------------------------------------------------------------* * usbd_callback_intr_td * @@ -2093,7 +2125,6 @@ struct usbd_memory_info *info = arg; struct usbd_xfer *xfer[4]; struct thread *td; - uint8_t dropcount; /* adjust priority */ td = curthread; @@ -2110,60 +2141,31 @@ repeat: xfer[0] = LIST_FIRST(&(info->done_head)); if (xfer[0]) { - do { LIST_REMOVE(xfer[0], done_list); xfer[0]->done_list.le_prev = NULL; xfer[1] = LIST_FIRST(&(info->done_head)); if (xfer[1] == NULL) { - dropcount = 1; - break; + usbd_callback_intr_td_sub(xfer, 1); + goto repeat; } LIST_REMOVE(xfer[1], done_list); xfer[1]->done_list.le_prev = NULL; xfer[2] = LIST_FIRST(&(info->done_head)); if (xfer[2] == NULL) { - dropcount = 2; - break; + usbd_callback_intr_td_sub(xfer, 2); + goto repeat; } LIST_REMOVE(xfer[2], done_list); xfer[2]->done_list.le_prev = NULL; xfer[3] = LIST_FIRST(&(info->done_head)); if (xfer[3] == NULL) { - dropcount = 3; - break; + usbd_callback_intr_td_sub(xfer, 3); + goto repeat; } LIST_REMOVE(xfer[3], done_list); xfer[3]->done_list.le_prev = NULL; - dropcount = 4; - } while (0); - - mtx_unlock(info->usb_mtx); - - /* - * we exploit the fact that the mutex is the same for - * all callbacks - */ - mtx_lock(info->priv_mtx); - - /* call callback(s) */ - switch (dropcount) { - case 4: - usbd_callback_wrapper(xfer[3], info, USBD_CONTEXT_CALLBACK); - case 3: - usbd_callback_wrapper(xfer[2], info, USBD_CONTEXT_CALLBACK); - case 2: - usbd_callback_wrapper(xfer[1], info, USBD_CONTEXT_CALLBACK); - case 1: - usbd_callback_wrapper(xfer[0], info, USBD_CONTEXT_CALLBACK); - default: - break; - } - mtx_unlock(info->priv_mtx); - - mtx_lock(info->usb_mtx); - info->memory_refcount -= dropcount; - goto repeat; - + usbd_callback_intr_td_sub(xfer, 4); + goto repeat; } else { if (info->memory_refcount != 0) { info->done_sleep = 1; Could you do an "svn update" and see if it finally compiles without errors ? --HPS --HPS