RT-AC56 3.0.0.4.374.37 core
[tomato.git] / release / src-rt-6.x.4708 / include / emf / igs / osl_linux.h
blobc257764cd6ad09c8c7381e317ebbda0676c34a0d
1 /*
2 * Copyright (C) 2012, 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 347400 2012-07-26 17:29:23Z $
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(struct osl_lock));
36 if (lock == NULL)
38 printf("Memory alloc for lock object failed\n");
39 return (NULL);
42 strncpy(lock->name, name, sizeof(lock->name)-1);
43 lock->name[ sizeof(lock->name)-1 ] = '\0';
44 spin_lock_init(&lock->slock);
46 return (lock);
49 static inline void
50 OSL_LOCK_DESTROY(osl_lock_t lock)
52 MFREE(NULL, lock, sizeof(struct osl_lock));
53 return;
56 #define OSL_LOCK(lock) spin_lock_bh(&((lock)->slock))
57 #define OSL_UNLOCK(lock) spin_unlock_bh(&((lock)->slock))
59 #define DEV_IFNAME(dev) (((struct net_device *)dev)->name)
61 typedef struct osl_timer {
62 struct timer_list timer;
63 void (*fn)(void *);
64 void *arg;
65 uint ms;
66 bool periodic;
67 bool set;
68 #ifdef BCMDBG
69 char *name; /* Desription of the timer */
70 #endif
71 } osl_timer_t;
73 extern osl_timer_t *osl_timer_init(const char *name, void (*fn)(void *arg), void *arg);
74 extern void osl_timer_add(osl_timer_t *t, uint32 ms, bool periodic);
75 extern void osl_timer_update(osl_timer_t *t, uint32 ms, bool periodic);
76 extern bool osl_timer_del(osl_timer_t *t);
77 extern osl_lock_t OSL_LOCK_CREATE(uint8 *name);
78 extern void OSL_LOCK_DESTROY(osl_lock_t lock);
80 #endif /* _OSL_LINUX_H_ */