Deleted Added
full compact
usb_msctest.c (193074) usb_msctest.c (194227)
1/* $FreeBSD: head/sys/dev/usb/usb_msctest.c 193074 2009-05-30 00:22:57Z thompsa $ */
1/* $FreeBSD: head/sys/dev/usb/usb_msctest.c 194227 2009-06-15 00:33:18Z thompsa $ */
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 199 unchanged lines hidden (view full) ---

209 default:
210 error = 2;
211 break;
212 }
213 }
214 sc->error = error;
215 sc->state = ST_COMMAND;
216 sc->status_try = 1;
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.

--- 199 unchanged lines hidden (view full) ---

209 default:
210 error = 2;
211 break;
212 }
213 }
214 sc->error = error;
215 sc->state = ST_COMMAND;
216 sc->status_try = 1;
217 usb2_cv_signal(&sc->cv);
217 cv_signal(&sc->cv);
218}
219
220static void
221bbb_transfer_start(struct bbb_transfer *sc, uint8_t xfer_index)
222{
223 sc->state = xfer_index;
224 usb2_transfer_start(sc->xfer[xfer_index]);
225}

--- 219 unchanged lines hidden (view full) ---

445 sc->data_rem = data_len;
446 sc->data_timeout = (data_timeout + USB_MS_HZ);
447 sc->actlen = 0;
448 sc->cmd_len = cmd_len;
449
450 usb2_transfer_start(sc->xfer[sc->state]);
451
452 while (usb2_transfer_pending(sc->xfer[sc->state])) {
218}
219
220static void
221bbb_transfer_start(struct bbb_transfer *sc, uint8_t xfer_index)
222{
223 sc->state = xfer_index;
224 usb2_transfer_start(sc->xfer[xfer_index]);
225}

--- 219 unchanged lines hidden (view full) ---

445 sc->data_rem = data_len;
446 sc->data_timeout = (data_timeout + USB_MS_HZ);
447 sc->actlen = 0;
448 sc->cmd_len = cmd_len;
449
450 usb2_transfer_start(sc->xfer[sc->state]);
451
452 while (usb2_transfer_pending(sc->xfer[sc->state])) {
453 usb2_cv_wait(&sc->cv, &sc->mtx);
453 cv_wait(&sc->cv, &sc->mtx);
454 }
455 return (sc->error);
456}
457
458/*------------------------------------------------------------------------*
459 * usb2_test_autoinstall
460 *
461 * Return values:

--- 41 unchanged lines hidden (view full) ---

503 return (USB_ERR_INVAL);
504 }
505
506 sc = malloc(sizeof(*sc), M_USB, M_WAITOK | M_ZERO);
507 if (sc == NULL) {
508 return (USB_ERR_NOMEM);
509 }
510 mtx_init(&sc->mtx, "USB autoinstall", NULL, MTX_DEF);
454 }
455 return (sc->error);
456}
457
458/*------------------------------------------------------------------------*
459 * usb2_test_autoinstall
460 *
461 * Return values:

--- 41 unchanged lines hidden (view full) ---

503 return (USB_ERR_INVAL);
504 }
505
506 sc = malloc(sizeof(*sc), M_USB, M_WAITOK | M_ZERO);
507 if (sc == NULL) {
508 return (USB_ERR_NOMEM);
509 }
510 mtx_init(&sc->mtx, "USB autoinstall", NULL, MTX_DEF);
511 usb2_cv_init(&sc->cv, "WBBB");
511 cv_init(&sc->cv, "WBBB");
512
513 err = usb2_transfer_setup(udev,
514 &iface_index, sc->xfer, bbb_config,
515 ST_MAX, sc, &sc->mtx);
516
517 if (err) {
518 goto done;
519 }

--- 43 unchanged lines hidden (view full) ---

563 }
564 err = USB_ERR_INVAL;
565 goto done;
566
567done:
568 mtx_unlock(&sc->mtx);
569 usb2_transfer_unsetup(sc->xfer, ST_MAX);
570 mtx_destroy(&sc->mtx);
512
513 err = usb2_transfer_setup(udev,
514 &iface_index, sc->xfer, bbb_config,
515 ST_MAX, sc, &sc->mtx);
516
517 if (err) {
518 goto done;
519 }

--- 43 unchanged lines hidden (view full) ---

563 }
564 err = USB_ERR_INVAL;
565 goto done;
566
567done:
568 mtx_unlock(&sc->mtx);
569 usb2_transfer_unsetup(sc->xfer, ST_MAX);
570 mtx_destroy(&sc->mtx);
571 usb2_cv_destroy(&sc->cv);
571 cv_destroy(&sc->cv);
572 free(sc, M_USB);
573 return (err);
574}
572 free(sc, M_USB);
573 return (err);
574}