usb_device.c (184610) | usb_device.c (184824) |
---|---|
1/* $FreeBSD: head/sys/dev/usb2/core/usb2_device.c 184610 2008-11-04 02:31:03Z alfred $ */ | 1/* $FreeBSD: head/sys/dev/usb2/core/usb2_device.c 184824 2008-11-10 20:54:31Z 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. --- 280 unchanged lines hidden (view full) --- 290 /* initialise USB pipe structure */ 291 pipe->edesc = edesc; 292 pipe->iface_index = iface_index; 293 TAILQ_INIT(&pipe->pipe_q.head); 294 pipe->pipe_q.command = &usb2_pipe_start; 295 296 /* clear stall, if any */ 297 if (udev->bus->methods->clear_stall) { | 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. --- 280 unchanged lines hidden (view full) --- 290 /* initialise USB pipe structure */ 291 pipe->edesc = edesc; 292 pipe->iface_index = iface_index; 293 TAILQ_INIT(&pipe->pipe_q.head); 294 pipe->pipe_q.command = &usb2_pipe_start; 295 296 /* clear stall, if any */ 297 if (udev->bus->methods->clear_stall) { |
298 mtx_lock(&udev->bus->mtx); | 298 USB_BUS_LOCK(udev->bus); |
299 (udev->bus->methods->clear_stall) (udev, pipe); | 299 (udev->bus->methods->clear_stall) (udev, pipe); |
300 mtx_unlock(&udev->bus->mtx); | 300 USB_BUS_UNLOCK(udev->bus); |
301 } 302 return; 303} 304 305/*------------------------------------------------------------------------* 306 * usb2_free_pipe_data 307 * 308 * This function will free USB pipe data for the given interface --- 416 unchanged lines hidden (view full) --- 725 (et != UE_INTERRUPT)) { 726 /* 727 * Should not stall control 728 * nor isochronous endpoints. 729 */ 730 DPRINTF("Invalid endpoint\n"); 731 return (0); 732 } | 301 } 302 return; 303} 304 305/*------------------------------------------------------------------------* 306 * usb2_free_pipe_data 307 * 308 * This function will free USB pipe data for the given interface --- 416 unchanged lines hidden (view full) --- 725 (et != UE_INTERRUPT)) { 726 /* 727 * Should not stall control 728 * nor isochronous endpoints. 729 */ 730 DPRINTF("Invalid endpoint\n"); 731 return (0); 732 } |
733 mtx_lock(&udev->bus->mtx); | 733 USB_BUS_LOCK(udev->bus); |
734 735 /* store current stall state */ 736 was_stalled = pipe->is_stalled; 737 738 /* check for no change */ 739 if (was_stalled && do_stall) { 740 /* if the pipe is already stalled do nothing */ | 734 735 /* store current stall state */ 736 was_stalled = pipe->is_stalled; 737 738 /* check for no change */ 739 if (was_stalled && do_stall) { 740 /* if the pipe is already stalled do nothing */ |
741 mtx_unlock(&udev->bus->mtx); | 741 USB_BUS_UNLOCK(udev->bus); |
742 DPRINTF("No change\n"); 743 return (0); 744 } 745 /* set stalled state */ 746 pipe->is_stalled = 1; 747 748 if (do_stall || (!was_stalled)) { 749 if (!was_stalled) { --- 14 unchanged lines hidden (view full) --- 764 pipe->toggle_next = 0; /* reset data toggle */ 765 pipe->is_stalled = 0; /* clear stalled state */ 766 767 (udev->bus->methods->clear_stall) (udev, pipe); 768 769 /* start up the current or next transfer, if any */ 770 usb2_command_wrapper(&pipe->pipe_q, pipe->pipe_q.curr); 771 } | 742 DPRINTF("No change\n"); 743 return (0); 744 } 745 /* set stalled state */ 746 pipe->is_stalled = 1; 747 748 if (do_stall || (!was_stalled)) { 749 if (!was_stalled) { --- 14 unchanged lines hidden (view full) --- 764 pipe->toggle_next = 0; /* reset data toggle */ 765 pipe->is_stalled = 0; /* clear stalled state */ 766 767 (udev->bus->methods->clear_stall) (udev, pipe); 768 769 /* start up the current or next transfer, if any */ 770 usb2_command_wrapper(&pipe->pipe_q, pipe->pipe_q.curr); 771 } |
772 mtx_unlock(&udev->bus->mtx); | 772 USB_BUS_UNLOCK(udev->bus); |
773 return (0); 774} 775 776/*------------------------------------------------------------------------* 777 * usb2_reset_iface_endpoints - used in USB device side mode 778 *------------------------------------------------------------------------*/ 779usb2_error_t 780usb2_reset_iface_endpoints(struct usb2_device *udev, uint8_t iface_index) --- 421 unchanged lines hidden (view full) --- 1202 if (udev == NULL) { 1203 /* nothing to do */ 1204 return (0); 1205 } 1206 DPRINTFN(4, "udev=%p do_suspend=%d\n", udev, do_suspend); 1207 1208 sx_assert(udev->default_sx + 1, SA_LOCKED); 1209 | 773 return (0); 774} 775 776/*------------------------------------------------------------------------* 777 * usb2_reset_iface_endpoints - used in USB device side mode 778 *------------------------------------------------------------------------*/ 779usb2_error_t 780usb2_reset_iface_endpoints(struct usb2_device *udev, uint8_t iface_index) --- 421 unchanged lines hidden (view full) --- 1202 if (udev == NULL) { 1203 /* nothing to do */ 1204 return (0); 1205 } 1206 DPRINTFN(4, "udev=%p do_suspend=%d\n", udev, do_suspend); 1207 1208 sx_assert(udev->default_sx + 1, SA_LOCKED); 1209 |
1210 mtx_lock(&udev->bus->mtx); | 1210 USB_BUS_LOCK(udev->bus); |
1211 /* filter the suspend events */ 1212 if (udev->flags.suspended == do_suspend) { | 1211 /* filter the suspend events */ 1212 if (udev->flags.suspended == do_suspend) { |
1213 mtx_unlock(&udev->bus->mtx); | 1213 USB_BUS_UNLOCK(udev->bus); |
1214 /* nothing to do */ 1215 return (0); 1216 } 1217 udev->flags.suspended = do_suspend; | 1214 /* nothing to do */ 1215 return (0); 1216 } 1217 udev->flags.suspended = do_suspend; |
1218 mtx_unlock(&udev->bus->mtx); | 1218 USB_BUS_UNLOCK(udev->bus); |
1219 1220 /* do the suspend or resume */ 1221 1222 for (i = 0; i != USB_IFACE_MAX; i++) { 1223 1224 iface = usb2_get_iface(udev, i); 1225 if (iface == NULL) { 1226 /* looks like the end of the USB interfaces */ --- 11 unchanged lines hidden (view full) --- 1238 *------------------------------------------------------------------------*/ 1239static void 1240usb2_clear_stall_proc(struct usb2_proc_msg *_pm) 1241{ 1242 struct usb2_clear_stall_msg *pm = (void *)_pm; 1243 struct usb2_device *udev = pm->udev; 1244 1245 /* Change lock */ | 1219 1220 /* do the suspend or resume */ 1221 1222 for (i = 0; i != USB_IFACE_MAX; i++) { 1223 1224 iface = usb2_get_iface(udev, i); 1225 if (iface == NULL) { 1226 /* looks like the end of the USB interfaces */ --- 11 unchanged lines hidden (view full) --- 1238 *------------------------------------------------------------------------*/ 1239static void 1240usb2_clear_stall_proc(struct usb2_proc_msg *_pm) 1241{ 1242 struct usb2_clear_stall_msg *pm = (void *)_pm; 1243 struct usb2_device *udev = pm->udev; 1244 1245 /* Change lock */ |
1246 mtx_unlock(&udev->bus->mtx); | 1246 USB_BUS_UNLOCK(udev->bus); |
1247 mtx_lock(udev->default_mtx); 1248 1249 /* Start clear stall callback */ 1250 usb2_transfer_start(udev->default_xfer[1]); 1251 1252 /* Change lock */ 1253 mtx_unlock(udev->default_mtx); | 1247 mtx_lock(udev->default_mtx); 1248 1249 /* Start clear stall callback */ 1250 usb2_transfer_start(udev->default_xfer[1]); 1251 1252 /* Change lock */ 1253 mtx_unlock(udev->default_mtx); |
1254 mtx_lock(&udev->bus->mtx); | 1254 USB_BUS_LOCK(udev->bus); |
1255 return; 1256} 1257 1258/*------------------------------------------------------------------------* 1259 * usb2_alloc_device 1260 * 1261 * This function allocates a new USB device. This function is called 1262 * when a new device has been put in the powered state, but not yet in --- 848 unchanged lines hidden --- | 1255 return; 1256} 1257 1258/*------------------------------------------------------------------------* 1259 * usb2_alloc_device 1260 * 1261 * This function allocates a new USB device. This function is called 1262 * when a new device has been put in the powered state, but not yet in --- 848 unchanged lines hidden --- |