Deleted Added
full compact
usb_generic.c (188986) usb_generic.c (189110)
1/* $FreeBSD: head/sys/dev/usb/usb_generic.c 188986 2009-02-24 03:41:52Z thompsa $ */
1/* $FreeBSD: head/sys/dev/usb/usb_generic.c 189110 2009-02-27 17:27:16Z 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.

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

144 }
145 }
146 mtx_lock(f->priv_mtx);
147
148 return (error);
149}
150
151static int
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.

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

144 }
145 }
146 mtx_lock(f->priv_mtx);
147
148 return (error);
149}
150
151static int
152ugen_open(struct usb2_fifo *f, int fflags, struct thread *td)
152ugen_open(struct usb2_fifo *f, int fflags)
153{
154 struct usb2_pipe *pipe = f->priv_sc0;
155 struct usb2_endpoint_descriptor *ed = pipe->edesc;
156 uint8_t type;
157
158 DPRINTFN(6, "flag=0x%x\n", fflags);
159
160 mtx_lock(f->priv_mtx);

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

178 f->flag_short = 0;
179 f->fifo_zlp = 0;
180 mtx_unlock(f->priv_mtx);
181
182 return (0);
183}
184
185static void
153{
154 struct usb2_pipe *pipe = f->priv_sc0;
155 struct usb2_endpoint_descriptor *ed = pipe->edesc;
156 uint8_t type;
157
158 DPRINTFN(6, "flag=0x%x\n", fflags);
159
160 mtx_lock(f->priv_mtx);

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

178 f->flag_short = 0;
179 f->fifo_zlp = 0;
180 mtx_unlock(f->priv_mtx);
181
182 return (0);
183}
184
185static void
186ugen_close(struct usb2_fifo *f, int fflags, struct thread *td)
186ugen_close(struct usb2_fifo *f, int fflags)
187{
188 DPRINTFN(6, "flag=0x%x\n", fflags);
189
190 /* cleanup */
191
192 mtx_lock(f->priv_mtx);
193 usb2_transfer_stop(f->xfer[0]);
194 usb2_transfer_stop(f->xfer[1]);

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

867 * Special case - handle clearing of stall
868 */
869 if (req->bmRequestType == UT_WRITE_ENDPOINT) {
870
871 pipe = usb2_get_pipe_by_addr(udev, req->wIndex[0]);
872 if (pipe == NULL) {
873 return (EINVAL);
874 }
187{
188 DPRINTFN(6, "flag=0x%x\n", fflags);
189
190 /* cleanup */
191
192 mtx_lock(f->priv_mtx);
193 usb2_transfer_stop(f->xfer[0]);
194 usb2_transfer_stop(f->xfer[1]);

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

867 * Special case - handle clearing of stall
868 */
869 if (req->bmRequestType == UT_WRITE_ENDPOINT) {
870
871 pipe = usb2_get_pipe_by_addr(udev, req->wIndex[0]);
872 if (pipe == NULL) {
873 return (EINVAL);
874 }
875 if (usb2_check_thread_perm(udev, curthread, FREAD | FWRITE,
876 pipe->iface_index, req->wIndex[0] & UE_ADDR)) {
877 return (EPERM);
878 }
879 if ((req->bRequest == UR_CLEAR_FEATURE) &&
880 (UGETW(req->wValue) == UF_ENDPOINT_HALT)) {
881 usb2_clear_data_toggle(udev, pipe);
882 }
883 }
884 /* TODO: add more checks to verify the interface index */
885
886 return (0);

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

1362 if ((fflags & FWRITE) && f_tx &&
1363 (f_tx->xfer[0] || f_tx->xfer[1])) {
1364 return (1); /* TX FIFO in use */
1365 }
1366 return (0); /* not in use */
1367}
1368
1369static int
875 if ((req->bRequest == UR_CLEAR_FEATURE) &&
876 (UGETW(req->wValue) == UF_ENDPOINT_HALT)) {
877 usb2_clear_data_toggle(udev, pipe);
878 }
879 }
880 /* TODO: add more checks to verify the interface index */
881
882 return (0);

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

1358 if ((fflags & FWRITE) && f_tx &&
1359 (f_tx->xfer[0] || f_tx->xfer[1])) {
1360 return (1); /* TX FIFO in use */
1361 }
1362 return (0); /* not in use */
1363}
1364
1365static int
1370ugen_ioctl(struct usb2_fifo *f, u_long cmd, void *addr, int fflags,
1371 struct thread *td)
1366ugen_ioctl(struct usb2_fifo *f, u_long cmd, void *addr, int fflags)
1372{
1373 struct usb2_config usb2_config[1];
1374 struct usb2_device_request req;
1375 union {
1376 struct usb2_fs_complete *pcomp;
1377 struct usb2_fs_start *pstart;
1378 struct usb2_fs_stop *pstop;
1379 struct usb2_fs_open *popen;

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

1453 }
1454 ed = pipe->edesc;
1455 if (ed == NULL) {
1456 error = ENXIO;
1457 break;
1458 }
1459 iface_index = pipe->iface_index;
1460
1367{
1368 struct usb2_config usb2_config[1];
1369 struct usb2_device_request req;
1370 union {
1371 struct usb2_fs_complete *pcomp;
1372 struct usb2_fs_start *pstart;
1373 struct usb2_fs_stop *pstop;
1374 struct usb2_fs_open *popen;

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

1448 }
1449 ed = pipe->edesc;
1450 if (ed == NULL) {
1451 error = ENXIO;
1452 break;
1453 }
1454 iface_index = pipe->iface_index;
1455
1461 error = usb2_check_thread_perm(f->udev, curthread, fflags,
1462 iface_index, u.popen->ep_no);
1463 if (error) {
1464 break;
1465 }
1466 bzero(usb2_config, sizeof(usb2_config));
1467
1468 usb2_config[0].type = ed->bmAttributes & UE_XFERTYPE;
1469 usb2_config[0].endpoint = ed->bEndpointAddress & UE_ADDR;
1470 usb2_config[0].direction = ed->bEndpointAddress & (UE_DIR_OUT | UE_DIR_IN);
1471 usb2_config[0].mh.interval = USB_DEFAULT_INTERVAL;
1472 usb2_config[0].mh.flags.proxy_buffer = 1;
1473 usb2_config[0].mh.callback = &ugen_default_fs_callback;

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

1943 default:
1944 error = ENOIOCTL;
1945 break;
1946 }
1947 return (error);
1948}
1949
1950static int
1456 bzero(usb2_config, sizeof(usb2_config));
1457
1458 usb2_config[0].type = ed->bmAttributes & UE_XFERTYPE;
1459 usb2_config[0].endpoint = ed->bEndpointAddress & UE_ADDR;
1460 usb2_config[0].direction = ed->bEndpointAddress & (UE_DIR_OUT | UE_DIR_IN);
1461 usb2_config[0].mh.interval = USB_DEFAULT_INTERVAL;
1462 usb2_config[0].mh.flags.proxy_buffer = 1;
1463 usb2_config[0].mh.callback = &ugen_default_fs_callback;

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

1933 default:
1934 error = ENOIOCTL;
1935 break;
1936 }
1937 return (error);
1938}
1939
1940static int
1951ugen_ioctl_post(struct usb2_fifo *f, u_long cmd, void *addr, int fflags,
1952 struct thread *td)
1941ugen_ioctl_post(struct usb2_fifo *f, u_long cmd, void *addr, int fflags)
1953{
1954 union {
1955 struct usb2_interface_descriptor *idesc;
1956 struct usb2_alt_interface *ai;
1957 struct usb2_device_descriptor *ddesc;
1958 struct usb2_config_descriptor *cdesc;
1959 struct usb2_device_stats *stat;
1960 struct usb2_fs_init *pinit;

--- 235 unchanged lines hidden ---
1942{
1943 union {
1944 struct usb2_interface_descriptor *idesc;
1945 struct usb2_alt_interface *ai;
1946 struct usb2_device_descriptor *ddesc;
1947 struct usb2_config_descriptor *cdesc;
1948 struct usb2_device_stats *stat;
1949 struct usb2_fs_init *pinit;

--- 235 unchanged lines hidden ---