> I found some urbs which are members of bigger structures (and
> therefore not allocated via usb_alloc-urb() in
>
> acm.c (doing the spin_lock_init by hand)
> devio.c
> dsbr100.c
> hid.c
> microtek.c (doing the spin_lock_init by hand)
> printer.c
> usbkbd.c
> usbmouse.c
> wacom.c

Doing this by hand is necessary for SMP to work on some architectures.
Yet it is ugly. It'll break whenever the internal URB handling is changed.
It isn't really that hard to add a function to the API to do that.
In fact the attached patch does just that.
Last time I proposed such an interface it was rejected.
Please reconsider your position. Almost every other data structure in the 
kernel can be initialised this way.

        Regards
                Oliver
--- usb.c.alt   Sun Jun 17 02:19:31 2001
+++ usb.c       Sun Jun 17 02:24:59 2001
@@ -982,6 +982,15 @@
 }
 
 /**
+ *      usb_init_urb - initialise an urb that is part of a larger structure
+ *      @urb: pointer to the urb to be initialised
+ */
+void usb_init_urb(urb_t* urb)
+{
+        spin_lock_init(&urb->lock);
+}
+
+/**
  *     usb_free_urb - frees the memory used by a urb
  *     @urb: pointer to the urb to free
  *
@@ -2360,6 +2369,7 @@
 EXPORT_SYMBOL(usb_get_current_frame_number);
 
 EXPORT_SYMBOL(usb_alloc_urb);
+EXPORT_SYMBOL(usb_init_urb);
 EXPORT_SYMBOL(usb_free_urb);
 EXPORT_SYMBOL(usb_submit_urb);
 EXPORT_SYMBOL(usb_unlink_urb);

Reply via email to