]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/net/hamradio/6pack.c
net/hamradio/6pack: use mod_timer() to rearm timers
[linux.git] / drivers / net / hamradio / 6pack.c
index 17e6dcd2eb4248c6378439194a283ad1f93f70c6..a19868cba48cb06388e9b56dd18800228ba07540 100644 (file)
@@ -120,7 +120,7 @@ struct sixpack {
        struct timer_list       tx_t;
        struct timer_list       resync_t;
        refcount_t              refcnt;
-       struct semaphore        dead_sem;
+       struct completion       dead;
        spinlock_t              lock;
 };
 
@@ -389,7 +389,7 @@ static struct sixpack *sp_get(struct tty_struct *tty)
 static void sp_put(struct sixpack *sp)
 {
        if (refcount_dec_and_test(&sp->refcnt))
-               up(&sp->dead_sem);
+               complete(&sp->dead);
 }
 
 /*
@@ -523,10 +523,7 @@ static void resync_tnc(struct timer_list *t)
 
 
        /* Start resync timer again -- the TNC might be still absent */
-
-       del_timer(&sp->resync_t);
-       sp->resync_t.expires    = jiffies + SIXP_RESYNC_TIMEOUT;
-       add_timer(&sp->resync_t);
+       mod_timer(&sp->resync_t, jiffies + SIXP_RESYNC_TIMEOUT);
 }
 
 static inline int tnc_init(struct sixpack *sp)
@@ -537,9 +534,7 @@ static inline int tnc_init(struct sixpack *sp)
 
        sp->tty->ops->write(sp->tty, &inbyte, 1);
 
-       del_timer(&sp->resync_t);
-       sp->resync_t.expires = jiffies + SIXP_RESYNC_TIMEOUT;
-       add_timer(&sp->resync_t);
+       mod_timer(&sp->resync_t, jiffies + SIXP_RESYNC_TIMEOUT);
 
        return 0;
 }
@@ -576,7 +571,7 @@ static int sixpack_open(struct tty_struct *tty)
 
        spin_lock_init(&sp->lock);
        refcount_set(&sp->refcnt, 1);
-       sema_init(&sp->dead_sem, 0);
+       init_completion(&sp->dead);
 
        /* !!! length of the buffers. MTU is IP MTU, not PACLEN!  */
 
@@ -670,10 +665,10 @@ static void sixpack_close(struct tty_struct *tty)
         * we have to wait for all existing users to finish.
         */
        if (!refcount_dec_and_test(&sp->refcnt))
-               down(&sp->dead_sem);
+               wait_for_completion(&sp->dead);
 
        /* We must stop the queue to avoid potentially scribbling
-        * on the free buffers. The sp->dead_sem is not sufficient
+        * on the free buffers. The sp->dead completion is not sufficient
         * to protect us from sp->xbuff access.
         */
        netif_stop_queue(sp->dev);
@@ -897,11 +892,8 @@ static void decode_prio_command(struct sixpack *sp, unsigned char cmd)
         /* if the state byte has been received, the TNC is present,
            so the resync timer can be reset. */
 
-       if (sp->tnc_state == TNC_IN_SYNC) {
-               del_timer(&sp->resync_t);
-               sp->resync_t.expires    = jiffies + SIXP_INIT_RESYNC_TIMEOUT;
-               add_timer(&sp->resync_t);
-       }
+       if (sp->tnc_state == TNC_IN_SYNC)
+               mod_timer(&sp->resync_t, jiffies + SIXP_INIT_RESYNC_TIMEOUT);
 
        sp->status1 = cmd & SIXP_PRIO_DATA_MASK;
 }