1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
|
/*********************************************************************
*
* Filename: timer.c
* Version:
* Description:
* Status: Experimental.
* Author: Dag Brattli <dagb@cs.uit.no>
* Created at: Sat Aug 16 00:59:29 1997
* Modified at: Wed Dec 8 12:50:34 1999
* Modified by: Dag Brattli <dagb@cs.uit.no>
*
* Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>,
* All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Neither Dag Brattli nor University of Troms admit liability nor
* provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge.
*
********************************************************************/
#include <asm/system.h>
#include <linux/delay.h>
#include <net/irda/timer.h>
#include <net/irda/irda.h>
#include <net/irda/irtty.h>
#include <net/irda/irlap.h>
#include <net/irda/irlmp_event.h>
static void irlap_slot_timer_expired(void* data);
static void irlap_query_timer_expired(void* data);
static void irlap_final_timer_expired(void* data);
static void irlap_wd_timer_expired(void* data);
static void irlap_backoff_timer_expired(void* data);
static void irlap_media_busy_expired(void* data);
/*
* Function irda_start_timer (timer, timeout)
*
* Start an IrDA timer
*
*/
void irda_start_timer(struct timer_list *ptimer, int timeout, void *data,
TIMER_CALLBACK callback)
{
del_timer(ptimer);
ptimer->data = (unsigned long) data;
/*
* For most architectures void * is the same as unsigned long, but
* at least we try to use void * as long as possible. Since the
* timer functions use unsigned long, we cast the function here
*/
ptimer->function = (void (*)(unsigned long)) callback;
ptimer->expires = jiffies + timeout;
add_timer(ptimer);
}
void irlap_start_slot_timer(struct irlap_cb *self, int timeout)
{
irda_start_timer(&self->slot_timer, timeout, (void *) self,
irlap_slot_timer_expired);
}
void irlap_start_query_timer(struct irlap_cb *self, int timeout)
{
irda_start_timer( &self->query_timer, timeout, (void *) self,
irlap_query_timer_expired);
}
void irlap_start_final_timer(struct irlap_cb *self, int timeout)
{
irda_start_timer(&self->final_timer, timeout, (void *) self,
irlap_final_timer_expired);
}
void irlap_start_wd_timer(struct irlap_cb *self, int timeout)
{
irda_start_timer(&self->wd_timer, timeout, (void *) self,
irlap_wd_timer_expired);
}
void irlap_start_backoff_timer(struct irlap_cb *self, int timeout)
{
irda_start_timer(&self->backoff_timer, timeout, (void *) self,
irlap_backoff_timer_expired);
}
void irlap_start_mbusy_timer(struct irlap_cb *self)
{
irda_start_timer(&self->media_busy_timer, MEDIABUSY_TIMEOUT,
(void *) self, irlap_media_busy_expired);
}
void irlmp_start_watchdog_timer(struct lsap_cb *self, int timeout)
{
irda_start_timer(&self->watchdog_timer, timeout, (void *) self,
irlmp_watchdog_timer_expired);
}
void irlmp_start_discovery_timer(struct irlmp_cb *self, int timeout)
{
irda_start_timer(&self->discovery_timer, timeout, (void *) self,
irlmp_discovery_timer_expired);
}
void irlmp_start_idle_timer(struct lap_cb *self, int timeout)
{
irda_start_timer(&self->idle_timer, timeout, (void *) self,
irlmp_idle_timer_expired);
}
/*
* Function irlap_slot_timer_expired (data)
*
* IrLAP slot timer has expired
*
*/
static void irlap_slot_timer_expired(void *data)
{
struct irlap_cb *self = (struct irlap_cb *) data;
ASSERT(self != NULL, return;);
ASSERT(self->magic == LAP_MAGIC, return;);
irlap_do_event(self, SLOT_TIMER_EXPIRED, NULL, NULL);
}
/*
* Function irlap_query_timer_expired (data)
*
* IrLAP query timer has expired
*
*/
static void irlap_query_timer_expired(void *data)
{
struct irlap_cb *self = (struct irlap_cb *) data;
ASSERT(self != NULL, return;);
ASSERT(self->magic == LAP_MAGIC, return;);
irlap_do_event(self, QUERY_TIMER_EXPIRED, NULL, NULL);
}
/*
* Function irda_final_timer_expired (data)
*
*
*
*/
static void irlap_final_timer_expired(void *data)
{
struct irlap_cb *self = (struct irlap_cb *) data;
ASSERT(self != NULL, return;);
ASSERT(self->magic == LAP_MAGIC, return;);
irlap_do_event(self, FINAL_TIMER_EXPIRED, NULL, NULL);
}
/*
* Function irda_wd_timer_expired (data)
*
*
*
*/
static void irlap_wd_timer_expired(void *data)
{
struct irlap_cb *self = (struct irlap_cb *) data;
ASSERT(self != NULL, return;);
ASSERT(self->magic == LAP_MAGIC, return;);
irlap_do_event(self, WD_TIMER_EXPIRED, NULL, NULL);
}
/*
* Function irda_backoff_timer_expired (data)
*
*
*
*/
static void irlap_backoff_timer_expired(void *data)
{
struct irlap_cb *self = (struct irlap_cb *) data;
ASSERT(self != NULL, return;);
ASSERT(self->magic == LAP_MAGIC, return;);
irlap_do_event(self, BACKOFF_TIMER_EXPIRED, NULL, NULL);
}
/*
* Function irtty_media_busy_expired (data)
*
*
*/
void irlap_media_busy_expired(void* data)
{
struct irlap_cb *self = (struct irlap_cb *) data;
ASSERT(self != NULL, return;);
irda_device_set_media_busy(self->netdev, FALSE);
/* Send any pending Ultra frames if any */
if (!skb_queue_empty(&self->txq_ultra))
irlap_do_event(self, SEND_UI_FRAME, NULL, NULL);
}
|