Broadcom SDK and wireless driver: another attempt to update to ver. 5.10.147.0
[tomato.git] / release / src-rt / include / emf / igs / osl_linux.h
blob146e36e412d12d0071ebccbe73e36cb74be989ee
1 /*
2 * Copyright (C) 2009, Broadcom Corporation
3 * All Rights Reserved.
4 *
5 * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom Corporation;
6 * the contents of this file may not be disclosed to third parties, copied
7 * or duplicated in any form, in whole or in part, without the prior
8 * written permission of Broadcom Corporation.
10 * $Id: osl_linux.h,v 1.2 2008/08/12 17:50:33 Exp $
13 #ifndef _OSL_LINUX_H_
14 #define _OSL_LINUX_H_
16 #include <linux/types.h>
17 #include <linux/timer.h>
18 #include <linux/kernel.h>
19 #include <linux/spinlock.h>
21 struct osl_lock
23 spinlock_t slock; /* Spin lock */
24 uint8 name[16]; /* Name of the lock */
27 typedef struct osl_lock *osl_lock_t;
29 static inline osl_lock_t
30 OSL_LOCK_CREATE(uint8 *name)
32 osl_lock_t lock;
34 lock = MALLOC(NULL, sizeof(osl_lock_t));
36 if (lock == NULL)
38 printf("Memory alloc for lock object failed\n");
39 return (NULL);
42 spin_lock_init(&lock->slock);
43 strncpy(lock->name, name, 16);
45 return (lock);
48 static inline void
49 OSL_LOCK_DESTROY(osl_lock_t lock)
51 MFREE(NULL, lock, sizeof(osl_lock_t));
52 return;
55 #define OSL_LOCK(lock) spin_lock_bh(&((lock)->slock))
56 #define OSL_UNLOCK(lock) spin_unlock_bh(&((lock)->slock))
58 #define DEV_IFNAME(dev) (((struct net_device *)dev)->name)
60 typedef struct osl_timer {
61 struct timer_list timer;
62 void (*fn)(void *);
63 void *arg;
64 uint ms;
65 bool periodic;
66 bool set;
67 } osl_timer_t;
69 extern osl_timer_t *osl_timer_init(const char *name, void (*fn)(void *arg), void *arg);
70 extern void osl_timer_add(osl_timer_t *t, uint32 ms, bool periodic);
71 extern void osl_timer_update(osl_timer_t *t, uint32 ms, bool periodic);
72 extern bool osl_timer_del(osl_timer_t *t);
73 extern osl_lock_t OSL_LOCK_CREATE(uint8 *name);
74 extern void OSL_LOCK_DESTROY(osl_lock_t lock);
76 #endif /* _OSL_LINUX_H_ */