fix ambassador.c
Subsystems (3)
PATCH 1/1 fix ambassador.c
Hi,
drivers/atm/ambassador.c:
This patch cleans up sti/cli usage as well as minor timer cleanups.
ambassador.c | 34 ++++++++++++++--------------------
1 files changed, 14 insertions(+), 20 deletions(-)
drivers/atm/ambassador.c +14 -20
@@ -310,10 +310,12 @@ 0xdeadbeef }; +static void do_housekeeping (unsigned long arg);/********** globals **********/ +static amb_dev * amb_devs =NULL ; -static struct timer_list housekeeping; +static struct timer_list housekeeping =TIMER_INITIALIZER (do_housekeeping,0 ,1 );static unsigned short debug =0 ;static unsigned int cmds =8 ;
@@ -952,8 +954,9 @@rx_in * rx;unsigned long flags; -save_flags (flags); -cli (); + + txq = &dev->txq; +spin_lock_irqsave (&txq->lock, flags);PRINTK (KERN_INFO ,"don't panic - putting adapter into reset" ); wr_plain (dev, offsetof(amb_mem, reset_control),
@@ -964,7 +967,7 @@ cmd->request =cpu_to_be32 (SRB_COMPLETE );PRINTK (KERN_INFO ,"completing all TXs" ); - txq = &dev->txq; + tx = txq->in.ptr;while (txq->pending--) {if (tx == txq->in.start)
@@ -978,6 +981,7 @@PRINTK (KERN_INFO ,"freeing all RX buffers" );for (pool =0 ; pool <NUM_RX_POOLS ; ++pool) { rxq = &dev->rxq[pool]; +spin_lock (&rxq->lock); rx = rxq->in.ptr;while (rxq->pending--) {if (rx == rxq->in.start)
@@ -985,11 +989,12 @@ --rx; dev_kfree_skb_any (bus_to_virt (rx->handle)); } +spin_unlock (&rxq->lock); }PRINTK (KERN_INFO ,"don't panic over - close all VCs and rmmod" );set_bit (dead, &dev->flags); -restore_flags (flags); +spin_unlock_irqrestore (&txq->lock, flags);return ; }#endif
@@ -1671,13 +1676,6 @@ };/********** housekeeping **********/ - -static inline void set_timer (struct timer_list * timer,unsigned long delay) { - timer->expires = jiffies + delay; -add_timer (timer); -return ; -} -static void do_housekeeping (unsigned long arg) {amb_dev * dev = amb_devs;// data is set to zero at module unload
@@ -1693,7 +1691,7 @@ dev = dev->prev; } -set_timer (&housekeeping,10 *HZ ); +mod_timer (&housekeeping, jiffies +10 *HZ ); }return ;
@@ -2559,7 +2557,7 @@/********** module entry **********/ -static int __init amb_module_init (void ) { +static int __devinit amb_module_init (void ) {int devs;PRINTD (DBG_FLOW |DBG_INIT ,"init_module" );
@@ -2579,11 +2577,7 @@ devs =amb_probe ();if (devs) { -init_timer (&housekeeping); - housekeeping.function = do_housekeeping; -// paranoia - housekeeping.data =1 ; -set_timer (&housekeeping,0 ); +mod_timer (&housekeeping, jiffies); }else {PRINTK (KERN_INFO ,"no (usable) adapters found" ); }
@@ -2593,7 +2587,7 @@/********** module exit **********/ -static void __exit amb_module_exit (void) { +static void __devexit amb_module_exit (void) {amb_dev * dev;PRINTD (DBG_FLOW |DBG_INIT ,"cleanup_module" );
Vinay K Nallamothu <[email protected]> :
[...]
Quoted 2 lines
drivers/atm/ambassador.c:
This patch cleans up sti/cli usage as well as minor timer cleanups.
[...]
The "dont_panic" function which uses cli/sti is only called from code belonging to a "#if 0" section since revision 1.1 according to bk.
Remove it, everybody should feel better.
--
Ueimor
Quoted 10 lines · Francois Romieu
Vinay K Nallamothu <[email protected]> :
[...]Quoted 2 lines
drivers/atm/ambassador.c:
This patch cleans up sti/cli usage as well as minor timer cleanups.[...]
The "
dont_panic" function which uses cli/sti is only called from code belonging to a "#if 0" section since revision 1.1 according to bk.Remove it, everybody should feel better.
Thanks for the suggestions. Here is the updated patch. Applies cleanly against 2.6.0-test3-bk9
drivers/atm/ambassador.c:
1. remove the function dont_panic which is mostly unused.
2. remove amb_ioctl which is never used.
3. minor timer code cleanups
ambassador.c | 132 ++--------------------------------------------------------- 1 files changed, 6 insertions(+), 126 deletions(-)
drivers/atm/ambassador.c +6 -126
@@ -310,10 +310,11 @@ 0xdeadbeef }; +static void do_housekeeping (unsigned long arg);/********** globals **********/ static amb_dev * amb_devs =NULL ; -static struct timer_list housekeeping; +static struct timer_list housekeeping =TIMER_INITIALIZER (do_housekeeping,0 ,1 );static unsigned short debug =0 ;static unsigned int cmds =8 ;
@@ -937,63 +938,6 @@return IRQ_HANDLED ; } -/********** don't panic... yeah, right **********/ - -#ifdef DEBUG_AMBASSADOR -static void dont_panic (amb_dev * dev) { -amb_cq * cq = &dev->cq; -volatile amb_cq_ptrs * ptrs = &cq->ptrs; -amb_txq * txq; -amb_rxq * rxq; -command * cmd; -tx_in * tx; -tx_simple * tx_descr; -unsigned char pool; -rx_in * rx; - -unsigned long flags; -save_flags (flags); -cli (); - -PRINTK (KERN_INFO ,"don't panic - putting adapter into reset" ); -wr_plain (dev, offsetof(amb_mem , reset_control), -rd_plain (dev, offsetof(amb_mem , reset_control)) |AMB_RESET_BITS ); - -PRINTK (KERN_INFO ,"marking all commands complete" ); -for (cmd = ptrs->start; cmd < ptrs->limit; ++cmd) - cmd->request =cpu_to_be32 (SRB_COMPLETE ); - -PRINTK (KERN_INFO ,"completing all TXs" ); - txq = &dev->txq; - tx = txq->in.ptr; -while (txq->pending--) { -if (tx == txq->in.start) - tx = txq->in.limit; - --tx; - tx_descr =bus_to_virt (be32_to_cpu (tx->tx_descr_addr)); -amb_kfree_skb (tx_descr->skb); -kfree (tx_descr); - } - -PRINTK (KERN_INFO ,"freeing all RX buffers" ); -for (pool =0 ; pool <NUM_RX_POOLS ; ++pool) { - rxq = &dev->rxq[pool]; - rx = rxq->in.ptr; -while (rxq->pending--) { -if (rx == rxq->in.start) - rx = rxq->in.limit; - --rx; -dev_kfree_skb_any (bus_to_virt (rx->handle)); - } - } - -PRINTK (KERN_INFO ,"don't panic over - close all VCs and rmmod" ); -set_bit (dead, &dev->flags); -restore_flags (flags); -return ; -} -#endif -/********** make rate (not quite as much fun as Horizon) **********/ static unsigned int make_rate (unsigned int rate, rounding r,
@@ -1420,32 +1364,6 @@return ; } -/********** DebugIoctl **********/ - -#if 0 -static int amb_ioctl (struct atm_dev * dev,unsigned int cmd,void * arg) { -unsigned short newdebug; -if (cmd ==AMB_SETDEBUG ) { -if (!capable (CAP_NET_ADMIN )) -return -EPERM ; -if (copy_from_user (&newdebug, arg,sizeof (newdebug))) { -// moan -return -EFAULT ; - }else { - debug = newdebug; -return 0 ; - } - }else if (cmd ==AMB_DONTPANIC ) { -if (!capable (CAP_NET_ADMIN )) -return -EPERM ; -dont_panic (dev); - }else { -// moan -return -ENOIOCTLCMD ; - } -} -#endif -/********** Set socket options for a VC **********/ // int amb_getsockopt (struct atm_vcc * atm_vcc, int level, int optname, void * optval, int optlen);
@@ -1524,33 +1442,6 @@ tx.tx_descr_length =cpu_to_be16 (sizeof (tx_frag)+sizeof (tx_frag_end)); tx.tx_descr_addr =cpu_to_be32 (virt_to_bus (&tx_descr->tx_frag)); -#ifdef DEBUG_AMBASSADOR -/* wey-hey! */ -if (vc ==1023 ) { -unsigned int i; -unsigned short d =0 ; -char * s = skb->data; -switch (*s++) { -case 'D' : { -for (i =0 ; i <4 ; ++i) { - d = (d<<4 ) | ((*s <='9' ) ? (*s -'0' ) : (*s -'a' +10 )); - ++s; - } -PRINTK (KERN_INFO ,"debug bitmap is now %hx" , debug = d); -break ; - } -case 'R' : { -if (*s++ =='e' && *s++ =='s' && *s++ =='e' && *s++ =='t' ) -dont_panic (dev); -break ; - } -default : { -break ; - } - } - } -#endif -while (tx_give (dev, &tx))schedule ();return 0 ;
@@ -1663,21 +1554,14 @@/********** Operation Structure **********/ static const struct atmdev_ops amb_ops = { - .open = amb_open, + .open = amb_open, .close = amb_close, - .send = amb_send, + .send = amb_send, .proc_read = amb_proc_read, .owner =THIS_MODULE , };/********** housekeeping **********/ - -static inline void set_timer (struct timer_list * timer,unsigned long delay) { - timer->expires = jiffies + delay; -add_timer (timer); -return ; -} -static void do_housekeeping (unsigned long arg) {amb_dev * dev = amb_devs;// data is set to zero at module unload
@@ -1693,7 +1577,7 @@ dev = dev->prev; } -set_timer (&housekeeping,10 *HZ ); +mod_timer (&housekeeping, jiffies +10 *HZ ); }return ;
@@ -2579,11 +2463,7 @@ devs =amb_probe ();if (devs) { -init_timer (&housekeeping); - housekeeping.function = do_housekeeping; -// paranoia - housekeeping.data =1 ; -set_timer (&housekeeping,0 ); +mod_timer (&housekeeping, jiffies); }else {PRINTK (KERN_INFO ,"no (usable) adapters found" ); }