usb_ecm: Use the current configuration instead of a fixed one.
[haiku.git] / src / add-ons / kernel / drivers / network / usb_ecm / BeOSCompatibility.h
blob74f5b2af4fc3506751f32d187c7e68938d718f51
1 /*
2 Driver for USB Ethernet Control Model devices
3 Copyright (C) 2008 Michael Lotz <mmlr@mlotz.ch>
4 Distributed under the terms of the MIT license.
5 */
6 #ifndef HAIKU_TARGET_PLATFORM_HAIKU
7 #ifndef _BEOS_COMPATIBILITY_H_
8 #define _BEOS_COMPATIBILITY_H_
10 #include <OS.h>
12 #define USB_ENDPOINT_ATTR_CONTROL 0x00
13 #define USB_ENDPOINT_ATTR_ISOCHRONOUS 0x01
14 #define USB_ENDPOINT_ATTR_BULK 0x02
15 #define USB_ENDPOINT_ATTR_INTERRUPT 0x03
16 #define USB_ENDPOINT_ATTR_MASK 0x03
18 #define USB_ENDPOINT_ADDR_DIR_IN 0x80
19 #define USB_ENDPOINT_ADDR_DIR_OUT 0x00
21 typedef struct mutex {
22 sem_id sem;
23 int32 count;
24 } mutex;
27 static inline void
28 mutex_init(mutex *lock, const char *name)
30 lock->sem = create_sem(0, name);
31 lock->count = 0;
35 static inline void
36 mutex_destroy(mutex *lock)
38 delete_sem(lock->sem);
42 static inline status_t
43 mutex_lock(mutex *lock)
45 if (atomic_add(&lock->count, -1) < 0)
46 return acquire_sem(lock->sem);
47 return B_OK;
51 static inline void
52 mutex_unlock(mutex *lock)
54 if (atomic_add(&lock->count, 1) < -1)
55 release_sem(lock->sem);
58 #endif /* !HAIKU_TARGET_PLATFORM_HAIKU */
59 #endif /* _BEOS_COMPATIBILITY_H_ */