Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jan 2008 18:15:37 +0100
From:      Hans Petter Selasky <hselasky@c2i.net>
To:        Stefan Lambrev <stefan.lambrev@moneybookers.com>
Cc:        freebsd-usb@freebsd.org
Subject:   Re: [SOLVED] Re: Problem with usb4bsd rev566
Message-ID:  <200801171815.38196.hselasky@c2i.net>
In-Reply-To: <478F8670.3030500@moneybookers.com>
References:  <477BC1A3.5080406@moneybookers.com> <200801161802.48506.hselasky@c2i.net> <478F8670.3030500@moneybookers.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801171815.38196.hselasky>