2 * Copyright (C) 2012, Broadcom Corporation
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 $
16 #include <linux/types.h>
17 #include <linux/timer.h>
18 #include <linux/kernel.h>
19 #include <linux/spinlock.h>
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
)
34 lock
= MALLOC(NULL
, sizeof(struct osl_lock
));
38 printf("Memory alloc for lock object failed\n");
42 strncpy(lock
->name
, name
, sizeof(lock
->name
)-1);
43 lock
->name
[ sizeof(lock
->name
)-1 ] = '\0';
44 spin_lock_init(&lock
->slock
);
50 OSL_LOCK_DESTROY(osl_lock_t lock
)
52 MFREE(NULL
, lock
, sizeof(struct osl_lock
));
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
;
69 char *name
; /* Desription of the timer */
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_ */