* Make sure that state is XMIT_P/XMIT_S when calling this function
* (and that nobody messed up with the state). - Jean II
*/
-void irlap_start_poll_timer(struct irlap_cb *self, int timeout)
+static void irlap_start_poll_timer(struct irlap_cb *self, int timeout)
{
ASSERT(self != NULL, return;);
ASSERT(self->magic == LAP_MAGIC, return;);
self->frame_sent = FALSE;
/*
- * Remember to multiply the query timeout value with
- * the number of slots used
+ * Go to reply state until end of discovery to
+ * inhibit our own transmissions. Set the timer
+ * to not stay forever there... Jean II
*/
- irlap_start_query_timer(self, QUERY_TIMEOUT*info->S);
+ irlap_start_query_timer(self, info->S, info->s);
irlap_next_state(self, LAP_REPLY);
} else {
/* This is the final slot. How is it possible ?
* Not much. It's too late to answer those discovery frames,
* so we just pass the info to IrLMP who will put it in the
* log (and post an event).
+ * Another cause would be devices that do discovery much
+ * slower than us, however the latest fixes should minimise
+ * those cases...
* Jean II
*/
IRDA_DEBUG(1, "%s(), Receiving final discovery request, missed the discovery slots :-(\n", __FUNCTION__);
if (irda_device_is_receiving(self->netdev) && !self->add_wait) {
IRDA_DEBUG(2, "%s(), device is slow to answer, "
"waiting some more!\n", __FUNCTION__);
- irlap_start_slot_timer(self, MSECS_TO_JIFFIES(10));
+ irlap_start_slot_timer(self, msecs_to_jiffies(10));
self->add_wait = TRUE;
return ret;
}
switch (event) {
case QUERY_TIMER_EXPIRED:
- IRDA_DEBUG(2, "%s(), QUERY_TIMER_EXPIRED <%ld>\n",
+ IRDA_DEBUG(0, "%s(), QUERY_TIMER_EXPIRED <%ld>\n",
__FUNCTION__, jiffies);
irlap_next_state(self, LAP_NDM);
break;
irlap_next_state(self, LAP_NDM);
irlap_discovery_indication(self, info->discovery);
- } else if ((info->s >= self->slot) && (!self->frame_sent)) {
- discovery_rsp = irlmp_get_discovery_response();
- discovery_rsp->data.daddr = info->daddr;
+ } else {
+ /* If it's our slot, send our reply */
+ if ((info->s >= self->slot) && (!self->frame_sent)) {
+ discovery_rsp = irlmp_get_discovery_response();
+ discovery_rsp->data.daddr = info->daddr;
- irlap_send_discovery_xid_frame(self, info->S,
- self->slot, FALSE,
- discovery_rsp);
+ irlap_send_discovery_xid_frame(self, info->S,
+ self->slot,
+ FALSE,
+ discovery_rsp);
- self->frame_sent = TRUE;
- irlap_next_state(self, LAP_REPLY);
+ self->frame_sent = TRUE;
+ }
+ /* Readjust our timer to accomodate devices
+ * doing faster or slower discovery than us...
+ * Jean II */
+ irlap_start_query_timer(self, info->S, info->s);
+
+ /* Keep state */
+ //irlap_next_state(self, LAP_REPLY);
}
break;
default:
* 1.5 times the time taken to transmit a SNRM frame. So this time should
* between 15 msecs and 45 msecs.
*/
- irlap_start_backoff_timer(self, MSECS_TO_JIFFIES(20 +
+ irlap_start_backoff_timer(self, msecs_to_jiffies(20 +
(jiffies % 30)));
} else {
/* Always switch state before calling upper layers */
if (irda_device_is_receiving(self->netdev) && !self->add_wait) {
IRDA_DEBUG(1, "FINAL_TIMER_EXPIRED when receiving a "
"frame! Waiting a little bit more!\n");
- irlap_start_final_timer(self, MSECS_TO_JIFFIES(300));
+ irlap_start_final_timer(self, msecs_to_jiffies(300));
/*
* Don't allow this to happen one more time in a row,