usb_process.c (187994) | usb_process.c (188411) |
---|---|
1/* $FreeBSD: head/sys/dev/usb2/core/usb2_process.c 187994 2009-02-02 00:49:39Z alfred $ */ | 1/* $FreeBSD: head/sys/dev/usb2/core/usb2_process.c 188411 2009-02-09 21:56:33Z 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. --- 149 unchanged lines hidden (view full) --- 159 up->up_ptr = NULL; 160 usb2_cv_signal(&up->up_cv); 161 mtx_unlock(up->up_mtx); 162 163 USB_THREAD_EXIT(0); 164} 165 166/*------------------------------------------------------------------------* | 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. --- 149 unchanged lines hidden (view full) --- 159 up->up_ptr = NULL; 160 usb2_cv_signal(&up->up_cv); 161 mtx_unlock(up->up_mtx); 162 163 USB_THREAD_EXIT(0); 164} 165 166/*------------------------------------------------------------------------* |
167 * usb2_proc_setup | 167 * usb2_proc_create |
168 * 169 * This function will create a process using the given "prio" that can 170 * execute callbacks. The mutex pointed to by "p_mtx" will be applied 171 * before calling the callbacks and released after that the callback 172 * has returned. The structure pointed to by "up" is assumed to be 173 * zeroed before this function is called. 174 * 175 * Return values: 176 * 0: success 177 * Else: failure 178 *------------------------------------------------------------------------*/ | 168 * 169 * This function will create a process using the given "prio" that can 170 * execute callbacks. The mutex pointed to by "p_mtx" will be applied 171 * before calling the callbacks and released after that the callback 172 * has returned. The structure pointed to by "up" is assumed to be 173 * zeroed before this function is called. 174 * 175 * Return values: 176 * 0: success 177 * Else: failure 178 *------------------------------------------------------------------------*/ |
179uint8_t 180usb2_proc_setup(struct usb2_process *up, struct mtx *p_mtx, uint8_t prio) | 179int 180usb2_proc_create(struct usb2_process *up, struct mtx *p_mtx, 181 const char *pmesg, uint8_t prio) |
181{ 182 up->up_mtx = p_mtx; 183 up->up_prio = prio; 184 185 TAILQ_INIT(&up->up_qhead); 186 187 usb2_cv_init(&up->up_cv, "wmsg"); 188 usb2_cv_init(&up->up_drain, "dmsg"); 189 190 if (USB_THREAD_CREATE(&usb2_process, up, | 182{ 183 up->up_mtx = p_mtx; 184 up->up_prio = prio; 185 186 TAILQ_INIT(&up->up_qhead); 187 188 usb2_cv_init(&up->up_cv, "wmsg"); 189 usb2_cv_init(&up->up_drain, "dmsg"); 190 191 if (USB_THREAD_CREATE(&usb2_process, up, |
191 &up->up_ptr, "usbproc")) { | 192 &up->up_ptr, pmesg)) { |
192 DPRINTFN(0, "Unable to create USB process."); 193 up->up_ptr = NULL; 194 goto error; 195 } 196 return (0); 197 198error: | 193 DPRINTFN(0, "Unable to create USB process."); 194 up->up_ptr = NULL; 195 goto error; 196 } 197 return (0); 198 199error: |
199 usb2_proc_unsetup(up); 200 return (1); | 200 usb2_proc_free(up); 201 return (ENOMEM); |
201} 202 203/*------------------------------------------------------------------------* | 202} 203 204/*------------------------------------------------------------------------* |
204 * usb2_proc_unsetup | 205 * usb2_proc_free |
205 * 206 * NOTE: If the structure pointed to by "up" is all zero, this 207 * function does nothing. 208 * 209 * NOTE: Messages that are pending on the process queue will not be 210 * removed nor called. 211 *------------------------------------------------------------------------*/ 212void | 206 * 207 * NOTE: If the structure pointed to by "up" is all zero, this 208 * function does nothing. 209 * 210 * NOTE: Messages that are pending on the process queue will not be 211 * removed nor called. 212 *------------------------------------------------------------------------*/ 213void |
213usb2_proc_unsetup(struct usb2_process *up) | 214usb2_proc_free(struct usb2_process *up) |
214{ 215 if (!(up->up_mtx)) { 216 /* not initialised */ 217 return; 218 } 219 usb2_proc_drain(up); 220 221 usb2_cv_destroy(&up->up_cv); --- 254 unchanged lines hidden --- | 215{ 216 if (!(up->up_mtx)) { 217 /* not initialised */ 218 return; 219 } 220 usb2_proc_drain(up); 221 222 usb2_cv_destroy(&up->up_cv); --- 254 unchanged lines hidden --- |