From 283235686ddff03e9b06344b76b6a77da1cf1cfd Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Fri, 24 Sep 2010 22:44:53 +0000 Subject: [PATCH] Move test for DEFINE_SPINLOCK into include/dahdi/kernel.h The check for DEFINE_SPINLOCK was spread throughout the source tree. If not defined we can just define it in inlucde/dahdi/kernel.h. Now include/dahdi/kernel.h is the only place that references SPIN_LOCK_UNLOCKED (which breaks lockdep checking if DEFINE_SPINLOCK is otherwise defined in the kernel). Signed-off-by: Shaun Ruffell Acked-by: Kinsey Moore Acked-by: Russ Meyerriecks Acked-by: Tzafrir Cohen Review: https://reviewboard.asterisk.org/r/940/ git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9411 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/dahdi-base.c | 5 ----- drivers/dahdi/dahdi_dynamic.c | 5 ----- drivers/dahdi/dahdi_dynamic_eth.c | 4 ---- drivers/dahdi/dahdi_dynamic_ethmf.c | 6 +----- drivers/dahdi/dahdi_dynamic_loc.c | 4 ---- drivers/dahdi/dahdi_transcode.c | 2 +- drivers/dahdi/tor2.c | 4 ---- drivers/dahdi/wct4xxp/base.c | 4 ---- drivers/dahdi/wcte12xp/base.c | 1 - drivers/dahdi/wcte12xp/wcte12xp.h | 2 -- drivers/dahdi/xpp/mmapdrv.c | 2 +- drivers/dahdi/xpp/parport_debug.c | 2 +- drivers/dahdi/xpp/xbus-core.c | 4 ++-- drivers/dahdi/xpp/xbus-pcm.c | 4 ++-- drivers/dahdi/xpp/xpp_usb.c | 2 +- include/dahdi/kernel.h | 4 ++++ 16 files changed, 13 insertions(+), 42 deletions(-) diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c index 234bf4a..70b7623 100644 --- a/drivers/dahdi/dahdi-base.c +++ b/drivers/dahdi/dahdi-base.c @@ -375,13 +375,8 @@ struct dahdi_timer { static LIST_HEAD(zaptimers); -#ifdef DEFINE_SPINLOCK static DEFINE_SPINLOCK(zaptimerlock); static DEFINE_SPINLOCK(bigzaplock); -#else -static spinlock_t zaptimerlock = SPIN_LOCK_UNLOCKED; -static spinlock_t bigzaplock = SPIN_LOCK_UNLOCKED; -#endif struct dahdi_zone { atomic_t refcount; diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c index 579b4e2..1a1d84b 100644 --- a/drivers/dahdi/dahdi_dynamic.c +++ b/drivers/dahdi/dahdi_dynamic.c @@ -113,13 +113,8 @@ struct dahdi_dynamic { struct list_head list; }; -#ifdef DEFINE_SPINLOCK static DEFINE_SPINLOCK(dspan_lock); static DEFINE_SPINLOCK(driver_lock); -#else -static spinlock_t dspan_lock = SPIN_LOCK_UNLOCKED; -static spinlock_t driver_lock = SPIN_LOCK_UNLOCKED; -#endif static LIST_HEAD(dspan_list); static LIST_HEAD(driver_list); diff --git a/drivers/dahdi/dahdi_dynamic_eth.c b/drivers/dahdi/dahdi_dynamic_eth.c index 449a971..31566d6 100644 --- a/drivers/dahdi/dahdi_dynamic_eth.c +++ b/drivers/dahdi/dahdi_dynamic_eth.c @@ -42,11 +42,7 @@ struct ztdeth_header { /* We take the raw message, put it in an ethernet frame, and add a two byte addressing header at the top for future use */ -#ifdef DEFINE_SPINLOCK static DEFINE_SPINLOCK(zlock); -#else -static spinlock_t zlock = SPIN_LOCK_UNLOCKED; -#endif static struct sk_buff_head skbs; diff --git a/drivers/dahdi/dahdi_dynamic_ethmf.c b/drivers/dahdi/dahdi_dynamic_ethmf.c index f8670c8..126001f 100644 --- a/drivers/dahdi/dahdi_dynamic_ethmf.c +++ b/drivers/dahdi/dahdi_dynamic_ethmf.c @@ -129,11 +129,7 @@ struct ztdeth { /** * Lock for adding and removing items in ethmf_list */ -#ifdef DEFINE_SPINLOCK static DEFINE_SPINLOCK(ethmf_lock); -#else -static spinlock_t ethmf_lock = SPIN_LOCK_UNLOCKED; -#endif /** * The active list of all running spans @@ -401,7 +397,7 @@ static int ztdethmf_transmit(void *pvt, unsigned char *msg, int msglen) unsigned char addr[ETH_ALEN]; int spans_ready = 0, index = 0; #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 10) - static spinlock_t lock = SPIN_LOCK_UNLOCKED; + static DEFINE_SPINLOCK(lock); unsigned long flags; #endif diff --git a/drivers/dahdi/dahdi_dynamic_loc.c b/drivers/dahdi/dahdi_dynamic_loc.c index 913f278..876cba4 100644 --- a/drivers/dahdi/dahdi_dynamic_loc.c +++ b/drivers/dahdi/dahdi_dynamic_loc.c @@ -57,11 +57,7 @@ #include -#ifdef DEFINE_SPINLOCK static DEFINE_SPINLOCK(zlock); -#else -static spinlock_t zlock = SPIN_LOCK_UNLOCKED; -#endif static struct ztdlocal { unsigned short key; diff --git a/drivers/dahdi/dahdi_transcode.c b/drivers/dahdi/dahdi_transcode.c index e6f607a..c12bf5a 100644 --- a/drivers/dahdi/dahdi_transcode.c +++ b/drivers/dahdi/dahdi_transcode.c @@ -46,7 +46,7 @@ static LIST_HEAD(registration_list); * is used as a simplistic way to spread the load amongst the different hardware * transcoders in the system. */ static LIST_HEAD(active_list); -static spinlock_t translock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(translock); EXPORT_SYMBOL(dahdi_transcoder_register); EXPORT_SYMBOL(dahdi_transcoder_unregister); diff --git a/drivers/dahdi/tor2.c b/drivers/dahdi/tor2.c index 5b1dcf7..f30f9f7 100644 --- a/drivers/dahdi/tor2.c +++ b/drivers/dahdi/tor2.c @@ -1129,11 +1129,7 @@ static void tor2_tasklet(unsigned long data) static int syncsrc = 0; static int syncnum = 0 /* -1 */; static int syncspan = 0; -#ifdef DEFINE_SPINLOCK static DEFINE_SPINLOCK(synclock); -#else -static spinlock_t synclock = SPIN_LOCK_UNLOCKED; -#endif static int tor2_findsync(struct tor2 *tor) { diff --git a/drivers/dahdi/wct4xxp/base.c b/drivers/dahdi/wct4xxp/base.c index b82488c..d04fce2 100644 --- a/drivers/dahdi/wct4xxp/base.c +++ b/drivers/dahdi/wct4xxp/base.c @@ -2225,11 +2225,7 @@ static void t4_serial_setup(struct t4 *wc, int unit) static int syncsrc = 0; static int syncnum = 0 /* -1 */; static int syncspan = 0; -#ifdef DEFINE_SPINLOCK static DEFINE_SPINLOCK(synclock); -#else -static spinlock_t synclock = SPIN_LOCK_UNLOCKED; -#endif static void __t4_set_rclk_src(struct t4 *wc, int span) { diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index bf953cb..edb7848 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -87,7 +87,6 @@ static const struct dahdi_echocan_ops vpm150m_ec_ops = { }; static struct t1 *ifaces[WC_MAX_IFACES]; -spinlock_t ifacelock = SPIN_LOCK_UNLOCKED; struct t1_desc { const char *name; diff --git a/drivers/dahdi/wcte12xp/wcte12xp.h b/drivers/dahdi/wcte12xp/wcte12xp.h index f08b9f3..079988f 100644 --- a/drivers/dahdi/wcte12xp/wcte12xp.h +++ b/drivers/dahdi/wcte12xp/wcte12xp.h @@ -77,8 +77,6 @@ #define TYPE_T1 1 #define TYPE_E1 2 -extern spinlock_t ifacelock; - struct command { struct list_head node; struct completion complete; diff --git a/drivers/dahdi/xpp/mmapdrv.c b/drivers/dahdi/xpp/mmapdrv.c index 6f38587..1ca3140 100644 --- a/drivers/dahdi/xpp/mmapdrv.c +++ b/drivers/dahdi/xpp/mmapdrv.c @@ -68,7 +68,7 @@ struct counter { static xbus_t *global_xbus; static bool tx_ready = 1; -static spinlock_t tx_ready_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(tx_ready_lock); static struct xframe_queue txpool; static unsigned int pcm_in_pool_count; static bool disconnecting; diff --git a/drivers/dahdi/xpp/parport_debug.c b/drivers/dahdi/xpp/parport_debug.c index 93049ef..23c0b41 100644 --- a/drivers/dahdi/xpp/parport_debug.c +++ b/drivers/dahdi/xpp/parport_debug.c @@ -36,7 +36,7 @@ static int parport_toggles[8]; /* 8 bit flip-flop */ void flip_parport_bit(unsigned char bitnum) { static unsigned char last_value; - spinlock_t lock = SPIN_LOCK_UNLOCKED; + DEFINE_SPINLOCK(lock); unsigned long flags; unsigned char mask; unsigned char value; diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c index 144d565..9223891 100644 --- a/drivers/dahdi/xpp/xbus-core.c +++ b/drivers/dahdi/xpp/xbus-core.c @@ -78,7 +78,7 @@ static void transport_init(xbus_t *xbus, struct xbus_ops *ops, ushort max_send_s static void transport_destroy(xbus_t *xbus); /* Data structures */ -static spinlock_t xbuses_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(xbuses_lock); #ifdef CONFIG_PROC_FS static struct proc_dir_entry *proc_xbuses = NULL; #endif @@ -405,7 +405,7 @@ xpacket_t *xframe_next_packet(xframe_t *frm, int len) return (xpacket_t *)(frm->packets + newlen - len); } -static spinlock_t serialize_dump_xframe = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(serialize_dump_xframe); static void do_hexdump(const char msg[], byte *data, uint16_t len) { diff --git a/drivers/dahdi/xpp/xbus-pcm.c b/drivers/dahdi/xpp/xbus-pcm.c index 39b772b..cad61fb 100644 --- a/drivers/dahdi/xpp/xbus-pcm.c +++ b/drivers/dahdi/xpp/xbus-pcm.c @@ -55,8 +55,8 @@ static struct xpp_ticker dahdi_ticker; * I.e: one of our AB or dahdi_ticker */ static struct xpp_ticker *ref_ticker = NULL; -static spinlock_t ref_ticker_lock = SPIN_LOCK_UNLOCKED; -static spinlock_t elect_syncer_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(ref_ticker_lock); +static DEFINE_SPINLOCK(elect_syncer_lock); static bool force_dahdi_sync = 0; /* from /sys/bus/astribanks/drivers/xppdrv/sync */ static xbus_t *global_ticker; static struct xpp_ticker global_ticks_series; diff --git a/drivers/dahdi/xpp/xpp_usb.c b/drivers/dahdi/xpp/xpp_usb.c index 40e5f9e..edc499b 100644 --- a/drivers/dahdi/xpp/xpp_usb.c +++ b/drivers/dahdi/xpp/xpp_usb.c @@ -242,7 +242,7 @@ struct xusb { }; -static spinlock_t xusb_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(xusb_lock); static xusb_t *xusb_array[MAX_BUSES] = {}; static unsigned bus_count = 0; diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h index 7e4e254..597e139 100644 --- a/include/dahdi/kernel.h +++ b/include/dahdi/kernel.h @@ -1262,6 +1262,10 @@ wait_for_completion_timeout(struct completion *x, unsigned long timeout) #endif /* 2.6.26 */ #endif /* 2.6.31 */ +#ifndef DEFINE_SPINLOCK +#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED +#endif + #ifndef DMA_BIT_MASK #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) #endif