version 1.8, 2006/11/16 01:33:27 |
version 1.8.10.4, 2007/06/18 14:16:58 |
Line 196 USB_MATCH(utoppy) |
|
Line 196 USB_MATCH(utoppy) |
|
{ |
{ |
USB_MATCH_START(utoppy, uaa); |
USB_MATCH_START(utoppy, uaa); |
|
|
|
#ifndef USB_USE_IFATTACH |
if (uaa->iface == NULL) |
if (uaa->iface == NULL) |
return (UMATCH_NONE); |
return (UMATCH_NONE); |
|
#endif /* USB_USE_IFATTACH */ |
|
|
if (uaa->vendor == USB_VENDOR_TOPFIELD && |
if (uaa->vendor == USB_VENDOR_TOPFIELD && |
uaa->product == USB_PRODUCT_TOPFIELD_TF5000PVR) |
uaa->product == USB_PRODUCT_TOPFIELD_TF5000PVR) |
Line 210 USB_ATTACH(utoppy) |
|
Line 212 USB_ATTACH(utoppy) |
|
{ |
{ |
USB_ATTACH_START(utoppy, sc, uaa); |
USB_ATTACH_START(utoppy, sc, uaa); |
usbd_device_handle dev = uaa->device; |
usbd_device_handle dev = uaa->device; |
|
#ifdef USB_USE_IFATTACH |
|
usbd_interface_handle iface; |
|
#endif /* USB_USE_IFATTACH */ |
usb_endpoint_descriptor_t *ed; |
usb_endpoint_descriptor_t *ed; |
char *devinfop; |
char *devinfop; |
u_int8_t epcount; |
u_int8_t epcount; |
Line 224 USB_ATTACH(utoppy) |
|
Line 229 USB_ATTACH(utoppy) |
|
sc->sc_refcnt = 0; |
sc->sc_refcnt = 0; |
sc->sc_udev = dev; |
sc->sc_udev = dev; |
|
|
|
#ifdef USB_USE_IFATTACH |
|
if (usbd_set_config_index(dev, 0, 1) |
|
|| usbd_device2interface_handle(dev, 0, &iface)) { |
|
printf("%s: Configuration failed\n", USBDEVNAME(sc->sc_dev)); |
|
USB_ATTACH_ERROR_RETURN; |
|
} |
|
#endif /* USB_USE_IFATTACH */ |
|
|
epcount = 0; |
epcount = 0; |
|
#ifndef USB_USE_IFATTACH |
(void) usbd_endpoint_count(uaa->iface, &epcount); |
(void) usbd_endpoint_count(uaa->iface, &epcount); |
|
#else |
|
(void) usbd_endpoint_count(iface, &epcount); |
|
#endif /* USB_USE_IFATTACH */ |
if (epcount != UTOPPY_NUMENDPOINTS) { |
if (epcount != UTOPPY_NUMENDPOINTS) { |
printf("%s: Expected %d endpoints, got %d\n", |
printf("%s: Expected %d endpoints, got %d\n", |
USBDEVNAME(sc->sc_dev), UTOPPY_NUMENDPOINTS, epcount); |
USBDEVNAME(sc->sc_dev), UTOPPY_NUMENDPOINTS, epcount); |
Line 236 USB_ATTACH(utoppy) |
|
Line 253 USB_ATTACH(utoppy) |
|
sc->sc_out = -1; |
sc->sc_out = -1; |
|
|
for (i = 0; i < epcount; i++) { |
for (i = 0; i < epcount; i++) { |
|
#ifndef USB_USE_IFATTACH |
ed = usbd_interface2endpoint_descriptor(uaa->iface, i); |
ed = usbd_interface2endpoint_descriptor(uaa->iface, i); |
|
#else |
|
ed = usbd_interface2endpoint_descriptor(iface, i); |
|
#endif /* USB_USE_IFATTACH */ |
if (ed == NULL) { |
if (ed == NULL) { |
printf("%s: couldn't get ep %d\n", |
printf("%s: couldn't get ep %d\n", |
USBDEVNAME(sc->sc_dev), i); |
USBDEVNAME(sc->sc_dev), i); |
Line 259 USB_ATTACH(utoppy) |
|
Line 280 USB_ATTACH(utoppy) |
|
USB_ATTACH_ERROR_RETURN; |
USB_ATTACH_ERROR_RETURN; |
} |
} |
|
|
|
#ifndef USB_USE_IFATTACH |
sc->sc_iface = uaa->iface; |
sc->sc_iface = uaa->iface; |
|
#else |
|
sc->sc_iface = iface; |
|
#endif /* USB_USE_IFATTACH */ |
sc->sc_udev = dev; |
sc->sc_udev = dev; |
|
|
sc->sc_out_xfer = usbd_alloc_xfer(sc->sc_udev); |
|
if (sc->sc_out_xfer == NULL) { |
|
printf("%s: could not allocate bulk out xfer\n", |
|
USBDEVNAME(sc->sc_dev)); |
|
goto fail0; |
|
} |
|
|
|
sc->sc_out_buf = usbd_alloc_buffer(sc->sc_out_xfer, UTOPPY_FRAG_SIZE); |
|
if (sc->sc_out_buf == NULL) { |
|
printf("%s: could not allocate bulk out buffer\n", |
|
USBDEVNAME(sc->sc_dev)); |
|
goto fail1; |
|
} |
|
|
|
sc->sc_in_xfer = usbd_alloc_xfer(sc->sc_udev); |
|
if (sc->sc_in_xfer == NULL) { |
|
printf("%s: could not allocate bulk in xfer\n", |
|
USBDEVNAME(sc->sc_dev)); |
|
goto fail1; |
|
} |
|
|
|
sc->sc_in_buf = usbd_alloc_buffer(sc->sc_in_xfer, UTOPPY_FRAG_SIZE); |
|
if (sc->sc_in_buf == NULL) { |
|
printf("%s: could not allocate bulk in buffer\n", |
|
USBDEVNAME(sc->sc_dev)); |
|
goto fail2; |
|
} |
|
|
|
usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, |
usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev, |
USBDEV(sc->sc_dev)); |
USBDEV(sc->sc_dev)); |
|
|
USB_ATTACH_SUCCESS_RETURN; |
USB_ATTACH_SUCCESS_RETURN; |
|
|
fail2: usbd_free_xfer(sc->sc_in_xfer); |
|
sc->sc_in_xfer = NULL; |
|
|
|
fail1: usbd_free_xfer(sc->sc_out_xfer); |
|
sc->sc_out_xfer = NULL; |
|
|
|
fail0: sc->sc_dying = 1; |
|
USB_ATTACH_ERROR_RETURN; |
|
} |
} |
|
|
int |
int |
Line 338 USB_DETACH(utoppy) |
|
Line 326 USB_DETACH(utoppy) |
|
if (sc->sc_out_xfer != NULL) |
if (sc->sc_out_xfer != NULL) |
usbd_free_xfer(sc->sc_out_xfer); |
usbd_free_xfer(sc->sc_out_xfer); |
|
|
|
if (sc->sc_out_pipe != NULL) |
|
usbd_close_pipe(sc->sc_out_pipe); |
|
if (sc->sc_in_pipe != NULL) |
|
usbd_close_pipe(sc->sc_in_pipe); |
|
|
s = splusb(); |
s = splusb(); |
if (--sc->sc_refcnt >= 0) |
if (--sc->sc_refcnt >= 0) |
usb_detach_wait(USBDEV(sc->sc_dev)); |
usb_detach_wait(USBDEV(sc->sc_dev)); |
Line 535 utoppy_bulk_transfer(usbd_xfer_handle xf |
|
Line 528 utoppy_bulk_transfer(usbd_xfer_handle xf |
|
splx(s); |
splx(s); |
return (err); |
return (err); |
} |
} |
error = tsleep((caddr_t)xfer, PZERO, lbl, 0); |
error = tsleep(xfer, PZERO, lbl, 0); |
splx(s); |
splx(s); |
if (error) { |
if (error) { |
usbd_abort_pipe(pipe); |
usbd_abort_pipe(pipe); |
Line 1333 utoppy_readfile_next(struct utoppy_softc |
|
Line 1326 utoppy_readfile_next(struct utoppy_softc |
|
|
|
int |
int |
utoppyopen(dev_t dev, int flag, int mode, |
utoppyopen(dev_t dev, int flag, int mode, |
struct lwp *l) |
usb_proc_ptr p) |
{ |
{ |
struct utoppy_softc *sc; |
struct utoppy_softc *sc; |
int error = 0; |
int error = 0; |
Line 1374 utoppyopen(dev_t dev, int flag, int mode |
|
Line 1367 utoppyopen(dev_t dev, int flag, int mode |
|
goto done; |
goto done; |
} |
} |
|
|
|
sc->sc_out_xfer = usbd_alloc_xfer(sc->sc_udev, sc->sc_out_pipe); |
|
if (sc->sc_out_xfer == NULL) { |
|
error = ENOMEM; |
|
goto error; |
|
} |
|
|
|
sc->sc_out_buf = usbd_alloc_buffer(sc->sc_out_xfer, UTOPPY_FRAG_SIZE); |
|
if (sc->sc_out_buf == NULL) { |
|
error = ENOMEM; |
|
goto error; |
|
} |
|
|
|
sc->sc_in_xfer = usbd_alloc_xfer(sc->sc_udev, sc->sc_in_pipe); |
|
if (sc->sc_in_xfer == NULL) { |
|
error = ENOMEM; |
|
goto error; |
|
} |
|
|
|
sc->sc_in_buf = usbd_alloc_buffer(sc->sc_in_xfer, UTOPPY_FRAG_SIZE); |
|
if (sc->sc_in_buf == NULL) { |
|
error = ENOMEM; |
|
goto error; |
|
} |
|
|
sc->sc_out_data = malloc(UTOPPY_BSIZE + 1, M_DEVBUF, M_WAITOK); |
sc->sc_out_data = malloc(UTOPPY_BSIZE + 1, M_DEVBUF, M_WAITOK); |
if (sc->sc_out_data == NULL) { |
if (sc->sc_out_data == NULL) { |
error = ENOMEM; |
error = ENOMEM; |
Line 1396 utoppyopen(dev_t dev, int flag, int mode |
|
Line 1413 utoppyopen(dev_t dev, int flag, int mode |
|
" returned %d\n", USBDEVNAME(sc->sc_dev), error)); |
" returned %d\n", USBDEVNAME(sc->sc_dev), error)); |
error: |
error: |
usbd_abort_pipe(sc->sc_out_pipe); |
usbd_abort_pipe(sc->sc_out_pipe); |
|
if (sc->sc_out_xfer) |
|
usbd_free_xfer(sc->sc_out_xfer); |
usbd_close_pipe(sc->sc_out_pipe); |
usbd_close_pipe(sc->sc_out_pipe); |
sc->sc_out_pipe = NULL; |
sc->sc_out_pipe = NULL; |
|
sc->sc_out_xfer = NULL; |
usbd_abort_pipe(sc->sc_in_pipe); |
usbd_abort_pipe(sc->sc_in_pipe); |
|
if (sc->sc_in_xfer) |
|
usbd_free_xfer(sc->sc_in_xfer); |
usbd_close_pipe(sc->sc_in_pipe); |
usbd_close_pipe(sc->sc_in_pipe); |
sc->sc_in_pipe = NULL; |
sc->sc_in_pipe = NULL; |
|
sc->sc_in_xfer = NULL; |
} |
} |
|
|
done: |
done: |
Line 1418 utoppyopen(dev_t dev, int flag, int mode |
|
Line 1441 utoppyopen(dev_t dev, int flag, int mode |
|
|
|
int |
int |
utoppyclose(dev_t dev, int flag, int mode, |
utoppyclose(dev_t dev, int flag, int mode, |
struct lwp *l) |
usb_proc_ptr p) |
{ |
{ |
struct utoppy_softc *sc; |
struct utoppy_softc *sc; |
usbd_status err; |
usbd_status err; |
Line 1442 utoppyclose(dev_t dev, int flag, int mod |
|
Line 1465 utoppyclose(dev_t dev, int flag, int mod |
|
if (sc->sc_out_pipe != NULL) { |
if (sc->sc_out_pipe != NULL) { |
if ((err = usbd_abort_pipe(sc->sc_out_pipe)) != 0) |
if ((err = usbd_abort_pipe(sc->sc_out_pipe)) != 0) |
printf("usbd_abort_pipe(OUT) returned %d\n", err); |
printf("usbd_abort_pipe(OUT) returned %d\n", err); |
|
if (sc->sc_out_xfer) |
|
usbd_free_xfer(sc->sc_out_xfer); |
if ((err = usbd_close_pipe(sc->sc_out_pipe)) != 0) |
if ((err = usbd_close_pipe(sc->sc_out_pipe)) != 0) |
printf("usbd_close_pipe(OUT) returned %d\n", err); |
printf("usbd_close_pipe(OUT) returned %d\n", err); |
sc->sc_out_pipe = NULL; |
sc->sc_out_pipe = NULL; |
|
sc->sc_out_xfer = NULL; |
} |
} |
|
|
if (sc->sc_in_pipe != NULL) { |
if (sc->sc_in_pipe != NULL) { |
if ((err = usbd_abort_pipe(sc->sc_in_pipe)) != 0) |
if ((err = usbd_abort_pipe(sc->sc_in_pipe)) != 0) |
printf("usbd_abort_pipe(IN) returned %d\n", err); |
printf("usbd_abort_pipe(IN) returned %d\n", err); |
|
if (sc->sc_in_xfer) |
|
usbd_free_xfer(sc->sc_in_xfer); |
if ((err = usbd_close_pipe(sc->sc_in_pipe)) != 0) |
if ((err = usbd_close_pipe(sc->sc_in_pipe)) != 0) |
printf("usbd_close_pipe(IN) returned %d\n", err); |
printf("usbd_close_pipe(IN) returned %d\n", err); |
sc->sc_in_pipe = NULL; |
sc->sc_in_pipe = NULL; |
|
sc->sc_in_xfer = NULL; |
} |
} |
|
|
if (sc->sc_out_data) { |
if (sc->sc_out_data) { |
Line 1658 utoppywrite(dev_t dev, struct uio *uio, |
|
Line 1687 utoppywrite(dev_t dev, struct uio *uio, |
|
} |
} |
|
|
int |
int |
utoppyioctl(dev_t dev, u_long cmd, caddr_t data, int flag, |
utoppyioctl(dev_t dev, u_long cmd, usb_ioctlarg_t data, int flag, |
struct lwp *l) |
usb_proc_ptr p) |
{ |
{ |
struct utoppy_softc *sc; |
struct utoppy_softc *sc; |
struct utoppy_rename *ur; |
struct utoppy_rename *ur; |