usb_util.c (193045) | usb_util.c (194227) |
---|---|
1/* $FreeBSD: head/sys/dev/usb/usb_util.c 193045 2009-05-29 18:46:57Z thompsa $ */ | 1/* $FreeBSD: head/sys/dev/usb/usb_util.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. --- 23 unchanged lines hidden (view full) --- 33#include <dev/usb/usb_process.h> 34#include <dev/usb/usb_device.h> 35#include <dev/usb/usb_request.h> 36#include <dev/usb/usb_busdma.h> 37 38#include <dev/usb/usb_controller.h> 39#include <dev/usb/usb_bus.h> 40 | 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. --- 23 unchanged lines hidden (view full) --- 33#include <dev/usb/usb_process.h> 34#include <dev/usb/usb_device.h> 35#include <dev/usb/usb_request.h> 36#include <dev/usb/usb_busdma.h> 37 38#include <dev/usb/usb_controller.h> 39#include <dev/usb/usb_bus.h> 40 |
41/* function prototypes */ 42#if (USB_HAVE_CONDVAR == 0) 43static int usb2_msleep(void *chan, struct mtx *mtx, int priority, const char *wmesg, int timo); | |
44 | 41 |
45#endif 46 | |
47/*------------------------------------------------------------------------* 48 * device_delete_all_children - delete all children of a device 49 *------------------------------------------------------------------------*/ 50#ifndef device_delete_all_children 51int 52device_delete_all_children(device_t dev) 53{ 54 device_t *devlist; --- 173 unchanged lines hidden (view full) --- 228 p->bLength = totlen; 229 p->bDescriptorType = UDESC_STRING; 230 231 while (max_len--) { 232 USETW2(p->bString[max_len], 0, s[max_len]); 233 } 234 return (totlen); 235} | 42/*------------------------------------------------------------------------* 43 * device_delete_all_children - delete all children of a device 44 *------------------------------------------------------------------------*/ 45#ifndef device_delete_all_children 46int 47device_delete_all_children(device_t dev) 48{ 49 device_t *devlist; --- 173 unchanged lines hidden (view full) --- 223 p->bLength = totlen; 224 p->bDescriptorType = UDESC_STRING; 225 226 while (max_len--) { 227 USETW2(p->bString[max_len], 0, s[max_len]); 228 } 229 return (totlen); 230} |
236 237#if (USB_HAVE_CONDVAR == 0) 238 239/*------------------------------------------------------------------------* 240 * usb2_cv_init - wrapper function 241 *------------------------------------------------------------------------*/ 242void 243usb2_cv_init(struct cv *cv, const char *desc) 244{ 245 cv_init(cv, desc); 246} 247 248/*------------------------------------------------------------------------* 249 * usb2_cv_destroy - wrapper function 250 *------------------------------------------------------------------------*/ 251void 252usb2_cv_destroy(struct cv *cv) 253{ 254 cv_destroy(cv); 255} 256 257/*------------------------------------------------------------------------* 258 * usb2_cv_wait - wrapper function 259 *------------------------------------------------------------------------*/ 260void 261usb2_cv_wait(struct cv *cv, struct mtx *mtx) 262{ 263 int err; 264 265 err = usb2_msleep(cv, mtx, 0, cv_wmesg(cv), 0); 266} 267 268/*------------------------------------------------------------------------* 269 * usb2_cv_wait_sig - wrapper function 270 *------------------------------------------------------------------------*/ 271int 272usb2_cv_wait_sig(struct cv *cv, struct mtx *mtx) 273{ 274 int err; 275 276 err = usb2_msleep(cv, mtx, PCATCH, cv_wmesg(cv), 0); 277 return (err); 278} 279 280/*------------------------------------------------------------------------* 281 * usb2_cv_timedwait - wrapper function 282 *------------------------------------------------------------------------*/ 283int 284usb2_cv_timedwait(struct cv *cv, struct mtx *mtx, int timo) 285{ 286 int err; 287 288 if (timo == 0) 289 timo = 1; /* zero means no timeout */ 290 err = usb2_msleep(cv, mtx, 0, cv_wmesg(cv), timo); 291 return (err); 292} 293 294/*------------------------------------------------------------------------* 295 * usb2_cv_signal - wrapper function 296 *------------------------------------------------------------------------*/ 297void 298usb2_cv_signal(struct cv *cv) 299{ 300 wakeup_one(cv); 301} 302 303/*------------------------------------------------------------------------* 304 * usb2_cv_broadcast - wrapper function 305 *------------------------------------------------------------------------*/ 306void 307usb2_cv_broadcast(struct cv *cv) 308{ 309 wakeup(cv); 310} 311 312/*------------------------------------------------------------------------* 313 * usb2_msleep - wrapper function 314 *------------------------------------------------------------------------*/ 315static int 316usb2_msleep(void *chan, struct mtx *mtx, int priority, const char *wmesg, 317 int timo) 318{ 319 int err; 320 321 if (mtx == &Giant) { 322 err = tsleep(chan, priority, wmesg, timo); 323 } else { 324#ifdef mtx_sleep 325 err = mtx_sleep(chan, mtx, priority, wmesg, timo); 326#else 327 err = msleep(chan, mtx, priority, wmesg, timo); 328#endif 329 } 330 return (err); 331} 332 333#endif | |