On Tue, Oct 09, 2001, Greg KH <[EMAIL PROTECTED]> wrote:
> Ok, In trying to resolve all of the USB differences between the -ac and
> Linus trees, I'm down to the attached diff. My question to everyone is
> which version of each file is the newer one?
Atleast one is a mix of both.
> diff -Naur -X dontdiff linux-2.4/drivers/usb/kaweth.c
>linux-2.4-ac/drivers/usb/kaweth.c
> --- linux-2.4/drivers/usb/kaweth.c Mon Sep 17 08:41:29 2001
> +++ linux-2.4-ac/drivers/usb/kaweth.c Wed Oct 3 10:12:45 2001
> @@ -949,12 +949,10 @@
> *-------------------------------------------------------------------*/
> static void usb_api_blocking_completion(urb_t *urb)
> {
> - api_wrapper_data *awd = (api_wrapper_data *)urb->context;
> -
> - if (waitqueue_active(awd->wakeup)) {
> - wake_up(awd->wakeup);
> - }
> + struct usb_api_data *awd = (struct usb_api_data *)urb->context;
>
> + awd->done=1;
> + wake_up(&awd->wqh);
> }
>
> /*-------------------------------------------------------------------*
> @@ -965,36 +963,31 @@
> static int usb_start_wait_urb(urb_t *urb, int timeout, int* actual_length)
> {
> DECLARE_WAITQUEUE(wait, current);
> - DECLARE_WAIT_QUEUE_HEAD(wqh);
> - api_wrapper_data awd;
> + struct usb_api_data awd;
> int status;
>
> - awd.wakeup = &wqh;
> - init_waitqueue_head(&wqh);
> + init_waitqueue_head(&awd.wqh);
> + awd.done = 0;
> +
> current->state = TASK_INTERRUPTIBLE;
> - add_wait_queue(&wqh, &wait);
> + add_wait_queue(&awd.wqh, &wait);
> urb->context = &awd;
> status = usb_submit_urb(urb);
> if (status) {
> // something went wrong
> usb_free_urb(urb);
> current->state = TASK_RUNNING;
> - remove_wait_queue(&wqh, &wait);
> + remove_wait_queue(&awd.wqh, &wait);
> return status;
> }
>
> - if (urb->status == -EINPROGRESS) {
> - while (timeout && urb->status == -EINPROGRESS)
> - status = timeout = schedule_timeout(timeout);
> - }
> - else {
> - status = 1;
> - }
> + while (timeout && !awd.done)
> + timeout = schedule_timeout(timeout);
>
> current->state = TASK_RUNNING;
> - remove_wait_queue(&wqh, &wait);
> + remove_wait_queue(&awd.wqh, &wait);
>
> - if (!status) {
> + if (!timeout) {
> // timeout
> kaweth_warn("usb_control/bulk_msg: timeout");
> usb_unlink_urb(urb); // remove urb safely
> diff -Naur -X dontdiff linux-2.4/drivers/usb/usb.c linux-2.4-ac/drivers/usb/usb.c
> --- linux-2.4/drivers/usb/usb.c Tue Oct 9 09:46:58 2001
> +++ linux-2.4-ac/drivers/usb/usb.c Tue Oct 9 09:47:49 2001
> @@ -1042,15 +1042,11 @@
> *-------------------------------------------------------------------*/
> static void usb_api_blocking_completion(urb_t *urb)
> {
> - api_wrapper_data *awd = (api_wrapper_data *)urb->context;
> + struct usb_api_data *awd = (struct usb_api_data *)urb->context;
>
> - if (waitqueue_active(awd->wakeup))
> - wake_up(awd->wakeup);
> -#if 0
> - else
> - dbg("(blocking_completion): waitqueue empty!");
> - // even occurs if urb was unlinked by timeout...
> -#endif
> + awd->done = 1;
> + wmb();
> + wake_up(&awd->wqh);
> }
>
> /*-------------------------------------------------------------------*
> @@ -1061,38 +1057,46 @@
> static int usb_start_wait_urb(urb_t *urb, int timeout, int* actual_length)
> {
> DECLARE_WAITQUEUE(wait, current);
> - DECLARE_WAIT_QUEUE_HEAD(wqh);
> - api_wrapper_data awd;
> + struct usb_api_data awd;
> int status;
> -
> - awd.wakeup = &wqh;
> - init_waitqueue_head(&wqh);
> - current->state = TASK_INTERRUPTIBLE;
> - add_wait_queue(&wqh, &wait);
> +
> + init_waitqueue_head(&awd.wqh);
> + awd.done = 0;
> +
> + set_current_state(TASK_UNINTERRUPTIBLE);
> + add_wait_queue(&awd.wqh, &wait);
> +
> urb->context = &awd;
> status = usb_submit_urb(urb);
> if (status) {
> // something went wrong
> usb_free_urb(urb);
> - current->state = TASK_RUNNING;
> - remove_wait_queue(&wqh, &wait);
> + set_current_state(TASK_RUNNING);
> + remove_wait_queue(&awd.wqh, &wait);
> return status;
> }
>
> - if (urb->status == -EINPROGRESS) {
> - while (timeout && urb->status == -EINPROGRESS)
> - status = timeout = schedule_timeout(timeout);
> - } else
> - status = 1;
> -
> - current->state = TASK_RUNNING;
> - remove_wait_queue(&wqh, &wait);
> -
> - if (!status) {
> - // timeout
> - printk("usb_control/bulk_msg: timeout\n");
> - usb_unlink_urb(urb); // remove urb safely
> - status = -ETIMEDOUT;
> + while (timeout && !awd.done)
> + {
> + timeout = schedule_timeout(timeout);
> + set_current_state(TASK_UNINTERRUPTIBLE);
> + rmb();
> + }
> +
> + set_current_state(TASK_RUNNING);
> + remove_wait_queue(&awd.wqh, &wait);
> +
> + if (!timeout && !awd.done) {
> + if (urb->status != -EINPROGRESS) { /* No callback?!! */
> + printk(KERN_ERR "usb: raced timeout, "
> + "pipe 0x%x status %d time left %d\n",
> + urb->pipe, urb->status, timeout);
> + status = urb->status;
> + } else {
> + printk("usb_control/bulk_msg: timeout\n");
> + usb_unlink_urb(urb); // remove urb safely
> + status = -ETIMEDOUT;
> + }
> } else
> status = urb->status;
>
> @@ -1116,15 +1120,14 @@
> if (!urb)
> return -ENOMEM;
>
> - FILL_CONTROL_URB(urb, usb_dev, pipe, (unsigned char*)cmd, data, len, /*
>build urb */
> - (usb_complete_t)usb_api_blocking_completion,0);
> + FILL_CONTROL_URB(urb, usb_dev, pipe, (unsigned char*)cmd, data, len,
> + usb_api_blocking_completion, 0);
>
> retv = usb_start_wait_urb(urb, timeout, &length);
> if (retv < 0)
> return retv;
> else
> return length;
> -
> }
>
> /**
> @@ -1205,8 +1208,8 @@
> if (!urb)
> return -ENOMEM;
>
> - FILL_BULK_URB(urb,usb_dev,pipe,(unsigned char*)data,len, /* build urb */
> - (usb_complete_t)usb_api_blocking_completion,0);
> + FILL_BULK_URB(urb, usb_dev, pipe, data, len,
> + usb_api_blocking_completion, 0);
>
> return usb_start_wait_urb(urb,timeout,actual_length);
> }
> @@ -1767,8 +1770,11 @@
> * These are the actual routines to send
> * and receive control messages.
> */
> -
> +#ifdef CONFIG_USB_LONG_TIMEOUT
> +#define GET_TIMEOUT 4
> +#else
> #define GET_TIMEOUT 3
> +#endif
> #define SET_TIMEOUT 3
>
> int usb_set_address(struct usb_device *dev)
I'm kinda curious why kaweth.c has it's own start_wait_urb.
Anyway, these look correct.
Is the wmb() necessary?
> --- linux-2.4/include/linux/usb.h Mon Oct 8 08:57:55 2001
> +++ linux-2.4-ac/include/linux/usb.h Mon Oct 8 16:31:15 2001
> @@ -539,13 +539,12 @@
> * SYNCHRONOUS CALL SUPPORT *
> *-------------------------------------------------------------------*/
>
> -typedef struct
> +struct usb_api_data
> {
> - wait_queue_head_t *wakeup;
> -
> - void* stuff;
> - /* more to follow */
> -} api_wrapper_data;
> + wait_queue_head_t wqh;
> + int done;
> + /* void* stuff; */ /* Possible extension later. */
> +};
>
> /* -------------------------------------------------------------------------- */
>
This ties in with the changes above.
> @@ -718,7 +717,7 @@
> * appropriately.
> *
> * NOTE: there's no encoding (yet?) for a "high speed" endpoint; treat them
> - * like full speed devices.
> + * like like full speed devices.
> */
>
> #define PIPE_ISOCHRONOUS 0
This is obviously not a correct fix :)
JE
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel