[NET] IRDA: Fix whitespace errors.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
YOSHIFUJI Hideaki 2007-02-09 23:24:53 +09:00 committed by David S. Miller
parent 981c0ff690
commit 6819bc2e1e
40 changed files with 1441 additions and 1441 deletions

View file

@ -138,7 +138,7 @@ static void irda_disconnect_indication(void *instance, void *sap,
sk->sk_shutdown |= SEND_SHUTDOWN; sk->sk_shutdown |= SEND_SHUTDOWN;
sk->sk_state_change(sk); sk->sk_state_change(sk);
sock_orphan(sk); sock_orphan(sk);
release_sock(sk); release_sock(sk);
/* Close our TSAP. /* Close our TSAP.
@ -158,7 +158,7 @@ static void irda_disconnect_indication(void *instance, void *sap,
irttp_close_tsap(self->tsap); irttp_close_tsap(self->tsap);
self->tsap = NULL; self->tsap = NULL;
} }
} }
/* Note : once we are there, there is not much you want to do /* Note : once we are there, there is not much you want to do
* with the socket anymore, apart from closing it. * with the socket anymore, apart from closing it.
@ -1211,7 +1211,7 @@ static int irda_release(struct socket *sock)
IRDA_DEBUG(2, "%s()\n", __FUNCTION__); IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
if (sk == NULL) if (sk == NULL)
return 0; return 0;
lock_sock(sk); lock_sock(sk);
@ -1259,7 +1259,7 @@ static int irda_release(struct socket *sock)
* memory leak is now gone... - Jean II * memory leak is now gone... - Jean II
*/ */
return 0; return 0;
} }
/* /*
@ -1312,7 +1312,7 @@ static int irda_sendmsg(struct kiocb *iocb, struct socket *sock,
len = self->max_data_size; len = self->max_data_size;
} }
skb = sock_alloc_send_skb(sk, len + self->max_header_size + 16, skb = sock_alloc_send_skb(sk, len + self->max_header_size + 16,
msg->msg_flags & MSG_DONTWAIT, &err); msg->msg_flags & MSG_DONTWAIT, &err);
if (!skb) if (!skb)
return -ENOBUFS; return -ENOBUFS;
@ -1714,7 +1714,7 @@ static int irda_shutdown(struct socket *sock, int how)
self->daddr = DEV_ADDR_ANY; /* Until we get re-connected */ self->daddr = DEV_ADDR_ANY; /* Until we get re-connected */
self->saddr = 0x0; /* so IrLMP assign us any link */ self->saddr = 0x0; /* so IrLMP assign us any link */
return 0; return 0;
} }
/* /*

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: discovery.c * Filename: discovery.c
* Version: 0.1 * Version: 0.1
* Description: Routines for handling discoveries at the IrLMP layer * Description: Routines for handling discoveries at the IrLMP layer
@ -10,24 +10,24 @@
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* Modified at: Fri May 28 3:11 CST 1999 * Modified at: Fri May 28 3:11 CST 1999
* Modified by: Horst von Brand <vonbrand@sleipnir.valparaiso.cl> * Modified by: Horst von Brand <vonbrand@sleipnir.valparaiso.cl>
* *
* Copyright (c) 1999 Dag Brattli, All Rights Reserved. * Copyright (c) 1999 Dag Brattli, All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
********************************************************************/ ********************************************************************/
#include <linux/string.h> #include <linux/string.h>
@ -65,9 +65,9 @@ void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *new)
spin_lock_irqsave(&cachelog->hb_spinlock, flags); spin_lock_irqsave(&cachelog->hb_spinlock, flags);
/* /*
* Remove all discoveries of devices that has previously been * Remove all discoveries of devices that has previously been
* discovered on the same link with the same name (info), or the * discovered on the same link with the same name (info), or the
* same daddr. We do this since some devices (mostly PDAs) change * same daddr. We do this since some devices (mostly PDAs) change
* their device address between every discovery. * their device address between every discovery.
*/ */
@ -79,10 +79,10 @@ void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *new)
discovery = (discovery_t *) hashbin_get_next(cachelog); discovery = (discovery_t *) hashbin_get_next(cachelog);
if ((node->data.saddr == new->data.saddr) && if ((node->data.saddr == new->data.saddr) &&
((node->data.daddr == new->data.daddr) || ((node->data.daddr == new->data.daddr) ||
(strcmp(node->data.info, new->data.info) == 0))) (strcmp(node->data.info, new->data.info) == 0)))
{ {
/* This discovery is a previous discovery /* This discovery is a previous discovery
* from the same device, so just remove it * from the same device, so just remove it
*/ */
hashbin_remove_this(cachelog, (irda_queue_t *) node); hashbin_remove_this(cachelog, (irda_queue_t *) node);
@ -134,7 +134,7 @@ void irlmp_add_discovery_log(hashbin_t *cachelog, hashbin_t *log)
discovery = (discovery_t *) hashbin_remove_first(log); discovery = (discovery_t *) hashbin_remove_first(log);
} }
/* Delete the now empty log */ /* Delete the now empty log */
hashbin_delete(log, (FREE_FUNC) kfree); hashbin_delete(log, (FREE_FUNC) kfree);
} }
@ -232,7 +232,7 @@ void irlmp_dump_discoveries(hashbin_t *log)
while (discovery != NULL) { while (discovery != NULL) {
IRDA_DEBUG(0, "Discovery:\n"); IRDA_DEBUG(0, "Discovery:\n");
IRDA_DEBUG(0, " daddr=%08x\n", discovery->data.daddr); IRDA_DEBUG(0, " daddr=%08x\n", discovery->data.daddr);
IRDA_DEBUG(0, " saddr=%08x\n", discovery->data.saddr); IRDA_DEBUG(0, " saddr=%08x\n", discovery->data.saddr);
IRDA_DEBUG(0, " nickname=%s\n", discovery->data.info); IRDA_DEBUG(0, " nickname=%s\n", discovery->data.info);
discovery = (discovery_t *) hashbin_get_next(log); discovery = (discovery_t *) hashbin_get_next(log);
@ -321,26 +321,26 @@ static inline discovery_t *discovery_seq_idx(loff_t pos)
{ {
discovery_t *discovery; discovery_t *discovery;
for (discovery = (discovery_t *) hashbin_get_first(irlmp->cachelog); for (discovery = (discovery_t *) hashbin_get_first(irlmp->cachelog);
discovery != NULL; discovery != NULL;
discovery = (discovery_t *) hashbin_get_next(irlmp->cachelog)) { discovery = (discovery_t *) hashbin_get_next(irlmp->cachelog)) {
if (pos-- == 0) if (pos-- == 0)
break; break;
} }
return discovery; return discovery;
} }
static void *discovery_seq_start(struct seq_file *seq, loff_t *pos) static void *discovery_seq_start(struct seq_file *seq, loff_t *pos)
{ {
spin_lock_irq(&irlmp->cachelog->hb_spinlock); spin_lock_irq(&irlmp->cachelog->hb_spinlock);
return *pos ? discovery_seq_idx(*pos - 1) : SEQ_START_TOKEN; return *pos ? discovery_seq_idx(*pos - 1) : SEQ_START_TOKEN;
} }
static void *discovery_seq_next(struct seq_file *seq, void *v, loff_t *pos) static void *discovery_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{ {
++*pos; ++*pos;
return (v == SEQ_START_TOKEN) return (v == SEQ_START_TOKEN)
? (void *) hashbin_get_first(irlmp->cachelog) ? (void *) hashbin_get_first(irlmp->cachelog)
: (void *) hashbin_get_next(irlmp->cachelog); : (void *) hashbin_get_next(irlmp->cachelog);
} }
@ -357,9 +357,9 @@ static int discovery_seq_show(struct seq_file *seq, void *v)
else { else {
const discovery_t *discovery = v; const discovery_t *discovery = v;
seq_printf(seq, "nickname: %s, hint: 0x%02x%02x", seq_printf(seq, "nickname: %s, hint: 0x%02x%02x",
discovery->data.info, discovery->data.info,
discovery->data.hints[0], discovery->data.hints[0],
discovery->data.hints[1]); discovery->data.hints[1]);
#if 0 #if 0
if ( discovery->data.hints[0] & HINT_PNP) if ( discovery->data.hints[0] & HINT_PNP)
@ -376,20 +376,20 @@ static int discovery_seq_show(struct seq_file *seq, void *v)
seq_puts(seq, "Fax "); seq_puts(seq, "Fax ");
if ( discovery->data.hints[0] & HINT_LAN) if ( discovery->data.hints[0] & HINT_LAN)
seq_puts(seq, "LAN Access "); seq_puts(seq, "LAN Access ");
if ( discovery->data.hints[1] & HINT_TELEPHONY) if ( discovery->data.hints[1] & HINT_TELEPHONY)
seq_puts(seq, "Telephony "); seq_puts(seq, "Telephony ");
if ( discovery->data.hints[1] & HINT_FILE_SERVER) if ( discovery->data.hints[1] & HINT_FILE_SERVER)
seq_puts(seq, "File Server "); seq_puts(seq, "File Server ");
if ( discovery->data.hints[1] & HINT_COMM) if ( discovery->data.hints[1] & HINT_COMM)
seq_puts(seq, "IrCOMM "); seq_puts(seq, "IrCOMM ");
if ( discovery->data.hints[1] & HINT_OBEX) if ( discovery->data.hints[1] & HINT_OBEX)
seq_puts(seq, "IrOBEX "); seq_puts(seq, "IrOBEX ");
#endif #endif
seq_printf(seq,", saddr: 0x%08x, daddr: 0x%08x\n\n", seq_printf(seq,", saddr: 0x%08x, daddr: 0x%08x\n\n",
discovery->data.saddr, discovery->data.saddr,
discovery->data.daddr); discovery->data.daddr);
seq_putc(seq, '\n'); seq_putc(seq, '\n');
} }
return 0; return 0;

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: ircomm_core.c * Filename: ircomm_core.c
* Version: 1.0 * Version: 1.0
* Description: IrCOMM service interface * Description: IrCOMM service interface
@ -8,25 +8,25 @@
* Created at: Sun Jun 6 20:37:34 1999 * Created at: Sun Jun 6 20:37:34 1999
* Modified at: Tue Dec 21 13:26:41 1999 * Modified at: Tue Dec 21 13:26:41 1999
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1999 Dag Brattli, All Rights Reserved. * Copyright (c) 1999 Dag Brattli, All Rights Reserved.
* Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com> * Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
********************************************************************/ ********************************************************************/
#include <linux/module.h> #include <linux/module.h>
@ -49,7 +49,7 @@
#include <net/irda/ircomm_core.h> #include <net/irda/ircomm_core.h>
static int __ircomm_close(struct ircomm_cb *self); static int __ircomm_close(struct ircomm_cb *self);
static void ircomm_control_indication(struct ircomm_cb *self, static void ircomm_control_indication(struct ircomm_cb *self,
struct sk_buff *skb, int clen); struct sk_buff *skb, int clen);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
@ -69,22 +69,22 @@ hashbin_t *ircomm = NULL;
static int __init ircomm_init(void) static int __init ircomm_init(void)
{ {
ircomm = hashbin_new(HB_LOCK); ircomm = hashbin_new(HB_LOCK);
if (ircomm == NULL) { if (ircomm == NULL) {
IRDA_ERROR("%s(), can't allocate hashbin!\n", __FUNCTION__); IRDA_ERROR("%s(), can't allocate hashbin!\n", __FUNCTION__);
return -ENOMEM; return -ENOMEM;
} }
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
{ struct proc_dir_entry *ent; { struct proc_dir_entry *ent;
ent = create_proc_entry("ircomm", 0, proc_irda); ent = create_proc_entry("ircomm", 0, proc_irda);
if (ent) if (ent)
ent->proc_fops = &ircomm_proc_fops; ent->proc_fops = &ircomm_proc_fops;
} }
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
IRDA_MESSAGE("IrCOMM protocol (Dag Brattli)\n"); IRDA_MESSAGE("IrCOMM protocol (Dag Brattli)\n");
return 0; return 0;
} }
@ -139,7 +139,7 @@ struct ircomm_cb *ircomm_open(notify_t *notify, __u8 service_type, int line)
hashbin_insert(ircomm, (irda_queue_t *) self, line, NULL); hashbin_insert(ircomm, (irda_queue_t *) self, line, NULL);
ircomm_next_state(self, IRCOMM_IDLE); ircomm_next_state(self, IRCOMM_IDLE);
return self; return self;
} }
@ -195,8 +195,8 @@ int ircomm_close(struct ircomm_cb *self)
entry = hashbin_remove(ircomm, self->line, NULL); entry = hashbin_remove(ircomm, self->line, NULL);
IRDA_ASSERT(entry == self, return -1;); IRDA_ASSERT(entry == self, return -1;);
return __ircomm_close(self); return __ircomm_close(self);
} }
EXPORT_SYMBOL(ircomm_close); EXPORT_SYMBOL(ircomm_close);
@ -206,9 +206,9 @@ EXPORT_SYMBOL(ircomm_close);
* *
* Impl. of this function is differ from one of the reference. This * Impl. of this function is differ from one of the reference. This
* function does discovery as well as sending connect request * function does discovery as well as sending connect request
* *
*/ */
int ircomm_connect_request(struct ircomm_cb *self, __u8 dlsap_sel, int ircomm_connect_request(struct ircomm_cb *self, __u8 dlsap_sel,
__u32 saddr, __u32 daddr, struct sk_buff *skb, __u32 saddr, __u32 daddr, struct sk_buff *skb,
__u8 service_type) __u8 service_type)
{ {
@ -243,20 +243,20 @@ void ircomm_connect_indication(struct ircomm_cb *self, struct sk_buff *skb,
struct ircomm_info *info) struct ircomm_info *info)
{ {
int clen = 0; int clen = 0;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
/* Check if the packet contains data on the control channel */ /* Check if the packet contains data on the control channel */
if (skb->len > 0) if (skb->len > 0)
clen = skb->data[0]; clen = skb->data[0];
/* /*
* If there are any data hiding in the control channel, we must * If there are any data hiding in the control channel, we must
* deliver it first. The side effect is that the control channel * deliver it first. The side effect is that the control channel
* will be removed from the skb * will be removed from the skb
*/ */
if (self->notify.connect_indication) if (self->notify.connect_indication)
self->notify.connect_indication(self->notify.instance, self, self->notify.connect_indication(self->notify.instance, self,
info->qos, info->max_data_size, info->qos, info->max_data_size,
info->max_header_size, skb); info->max_header_size, skb);
else { else {
@ -282,7 +282,7 @@ int ircomm_connect_response(struct ircomm_cb *self, struct sk_buff *userdata)
ret = ircomm_do_event(self, IRCOMM_CONNECT_RESPONSE, userdata, NULL); ret = ircomm_do_event(self, IRCOMM_CONNECT_RESPONSE, userdata, NULL);
return ret; return ret;
} }
EXPORT_SYMBOL(ircomm_connect_response); EXPORT_SYMBOL(ircomm_connect_response);
@ -299,7 +299,7 @@ void ircomm_connect_confirm(struct ircomm_cb *self, struct sk_buff *skb,
if (self->notify.connect_confirm ) if (self->notify.connect_confirm )
self->notify.connect_confirm(self->notify.instance, self->notify.connect_confirm(self->notify.instance,
self, info->qos, self, info->qos,
info->max_data_size, info->max_data_size,
info->max_header_size, skb); info->max_header_size, skb);
else { else {
@ -322,7 +322,7 @@ int ircomm_data_request(struct ircomm_cb *self, struct sk_buff *skb)
IRDA_ASSERT(self != NULL, return -EFAULT;); IRDA_ASSERT(self != NULL, return -EFAULT;);
IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -EFAULT;); IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -EFAULT;);
IRDA_ASSERT(skb != NULL, return -EFAULT;); IRDA_ASSERT(skb != NULL, return -EFAULT;);
ret = ircomm_do_event(self, IRCOMM_DATA_REQUEST, skb, NULL); ret = ircomm_do_event(self, IRCOMM_DATA_REQUEST, skb, NULL);
return ret; return ret;
@ -337,7 +337,7 @@ EXPORT_SYMBOL(ircomm_data_request);
* *
*/ */
void ircomm_data_indication(struct ircomm_cb *self, struct sk_buff *skb) void ircomm_data_indication(struct ircomm_cb *self, struct sk_buff *skb)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(skb->len > 0, return;); IRDA_ASSERT(skb->len > 0, return;);
@ -363,9 +363,9 @@ void ircomm_process_data(struct ircomm_cb *self, struct sk_buff *skb)
clen = skb->data[0]; clen = skb->data[0];
/* /*
* If there are any data hiding in the control channel, we must * If there are any data hiding in the control channel, we must
* deliver it first. The side effect is that the control channel * deliver it first. The side effect is that the control channel
* will be removed from the skb * will be removed from the skb
*/ */
if (clen > 0) if (clen > 0)
@ -375,7 +375,7 @@ void ircomm_process_data(struct ircomm_cb *self, struct sk_buff *skb)
skb_pull(skb, clen+1); skb_pull(skb, clen+1);
if (skb->len) if (skb->len)
ircomm_data_indication(self, skb); ircomm_data_indication(self, skb);
else { else {
IRDA_DEBUG(4, "%s(), data was control info only!\n", IRDA_DEBUG(4, "%s(), data was control info only!\n",
__FUNCTION__ ); __FUNCTION__ );
@ -391,13 +391,13 @@ void ircomm_process_data(struct ircomm_cb *self, struct sk_buff *skb)
int ircomm_control_request(struct ircomm_cb *self, struct sk_buff *skb) int ircomm_control_request(struct ircomm_cb *self, struct sk_buff *skb)
{ {
int ret; int ret;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -EFAULT;); IRDA_ASSERT(self != NULL, return -EFAULT;);
IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -EFAULT;); IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -EFAULT;);
IRDA_ASSERT(skb != NULL, return -EFAULT;); IRDA_ASSERT(skb != NULL, return -EFAULT;);
ret = ircomm_do_event(self, IRCOMM_CONTROL_REQUEST, skb, NULL); ret = ircomm_do_event(self, IRCOMM_CONTROL_REQUEST, skb, NULL);
return ret; return ret;
@ -411,10 +411,10 @@ EXPORT_SYMBOL(ircomm_control_request);
* Data has arrived on the control channel * Data has arrived on the control channel
* *
*/ */
static void ircomm_control_indication(struct ircomm_cb *self, static void ircomm_control_indication(struct ircomm_cb *self,
struct sk_buff *skb, int clen) struct sk_buff *skb, int clen)
{ {
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
/* Use udata for delivering data on the control channel */ /* Use udata for delivering data on the control channel */
if (self->notify.udata_indication) { if (self->notify.udata_indication) {
@ -427,8 +427,8 @@ static void ircomm_control_indication(struct ircomm_cb *self,
/* Remove data channel from control channel */ /* Remove data channel from control channel */
skb_trim(ctrl_skb, clen+1); skb_trim(ctrl_skb, clen+1);
self->notify.udata_indication(self->notify.instance, self, self->notify.udata_indication(self->notify.instance, self,
ctrl_skb); ctrl_skb);
/* Drop reference count - /* Drop reference count -
@ -455,7 +455,7 @@ int ircomm_disconnect_request(struct ircomm_cb *self, struct sk_buff *userdata)
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -1;);
ret = ircomm_do_event(self, IRCOMM_DISCONNECT_REQUEST, userdata, ret = ircomm_do_event(self, IRCOMM_DISCONNECT_REQUEST, userdata,
&info); &info);
return ret; return ret;
} }
@ -472,7 +472,7 @@ void ircomm_disconnect_indication(struct ircomm_cb *self, struct sk_buff *skb,
struct ircomm_info *info) struct ircomm_info *info)
{ {
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(info != NULL, return;); IRDA_ASSERT(info != NULL, return;);
if (self->notify.disconnect_indication) { if (self->notify.disconnect_indication) {
@ -486,7 +486,7 @@ void ircomm_disconnect_indication(struct ircomm_cb *self, struct sk_buff *skb,
/* /*
* Function ircomm_flow_request (self, flow) * Function ircomm_flow_request (self, flow)
* *
* *
* *
*/ */
void ircomm_flow_request(struct ircomm_cb *self, LOCAL_FLOW flow) void ircomm_flow_request(struct ircomm_cb *self, LOCAL_FLOW flow)
@ -517,7 +517,7 @@ static void *ircomm_seq_start(struct seq_file *seq, loff_t *pos)
self = (struct ircomm_cb *) hashbin_get_next(ircomm)) { self = (struct ircomm_cb *) hashbin_get_next(ircomm)) {
if (off++ == *pos) if (off++ == *pos)
break; break;
} }
return self; return self;
} }
@ -535,7 +535,7 @@ static void ircomm_seq_stop(struct seq_file *seq, void *v)
} }
static int ircomm_seq_show(struct seq_file *seq, void *v) static int ircomm_seq_show(struct seq_file *seq, void *v)
{ {
const struct ircomm_cb *self = v; const struct ircomm_cb *self = v;
IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -EINVAL; ); IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -EINVAL; );
@ -548,7 +548,7 @@ static int ircomm_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, seq_printf(seq,
" state: %s, slsap_sel: %#02x, dlsap_sel: %#02x, mode:", " state: %s, slsap_sel: %#02x, dlsap_sel: %#02x, mode:",
ircomm_state[ self->state], ircomm_state[ self->state],
self->slsap_sel, self->dlsap_sel); self->slsap_sel, self->dlsap_sel);
if(self->service_type & IRCOMM_3_WIRE_RAW) if(self->service_type & IRCOMM_3_WIRE_RAW)
seq_printf(seq, " 3-wire-raw"); seq_printf(seq, " 3-wire-raw");

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: ircomm_event.c * Filename: ircomm_event.c
* Version: 1.0 * Version: 1.0
* Description: IrCOMM layer state machine * Description: IrCOMM layer state machine
@ -8,24 +8,24 @@
* Created at: Sun Jun 6 20:33:11 1999 * Created at: Sun Jun 6 20:33:11 1999
* Modified at: Sun Dec 12 13:44:32 1999 * Modified at: Sun Dec 12 13:44:32 1999
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1999 Dag Brattli, All Rights Reserved. * Copyright (c) 1999 Dag Brattli, All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
********************************************************************/ ********************************************************************/
#include <linux/sched.h> #include <linux/sched.h>
@ -41,13 +41,13 @@
#include <net/irda/ircomm_core.h> #include <net/irda/ircomm_core.h>
#include <net/irda/ircomm_event.h> #include <net/irda/ircomm_event.h>
static int ircomm_state_idle(struct ircomm_cb *self, IRCOMM_EVENT event, static int ircomm_state_idle(struct ircomm_cb *self, IRCOMM_EVENT event,
struct sk_buff *skb, struct ircomm_info *info); struct sk_buff *skb, struct ircomm_info *info);
static int ircomm_state_waiti(struct ircomm_cb *self, IRCOMM_EVENT event, static int ircomm_state_waiti(struct ircomm_cb *self, IRCOMM_EVENT event,
struct sk_buff *skb, struct ircomm_info *info); struct sk_buff *skb, struct ircomm_info *info);
static int ircomm_state_waitr(struct ircomm_cb *self, IRCOMM_EVENT event, static int ircomm_state_waitr(struct ircomm_cb *self, IRCOMM_EVENT event,
struct sk_buff *skb, struct ircomm_info *info); struct sk_buff *skb, struct ircomm_info *info);
static int ircomm_state_conn(struct ircomm_cb *self, IRCOMM_EVENT event, static int ircomm_state_conn(struct ircomm_cb *self, IRCOMM_EVENT event,
struct sk_buff *skb, struct ircomm_info *info); struct sk_buff *skb, struct ircomm_info *info);
char *ircomm_state[] = { char *ircomm_state[] = {
@ -60,26 +60,26 @@ char *ircomm_state[] = {
#ifdef CONFIG_IRDA_DEBUG #ifdef CONFIG_IRDA_DEBUG
static char *ircomm_event[] = { static char *ircomm_event[] = {
"IRCOMM_CONNECT_REQUEST", "IRCOMM_CONNECT_REQUEST",
"IRCOMM_CONNECT_RESPONSE", "IRCOMM_CONNECT_RESPONSE",
"IRCOMM_TTP_CONNECT_INDICATION", "IRCOMM_TTP_CONNECT_INDICATION",
"IRCOMM_LMP_CONNECT_INDICATION", "IRCOMM_LMP_CONNECT_INDICATION",
"IRCOMM_TTP_CONNECT_CONFIRM", "IRCOMM_TTP_CONNECT_CONFIRM",
"IRCOMM_LMP_CONNECT_CONFIRM", "IRCOMM_LMP_CONNECT_CONFIRM",
"IRCOMM_LMP_DISCONNECT_INDICATION", "IRCOMM_LMP_DISCONNECT_INDICATION",
"IRCOMM_TTP_DISCONNECT_INDICATION", "IRCOMM_TTP_DISCONNECT_INDICATION",
"IRCOMM_DISCONNECT_REQUEST", "IRCOMM_DISCONNECT_REQUEST",
"IRCOMM_TTP_DATA_INDICATION", "IRCOMM_TTP_DATA_INDICATION",
"IRCOMM_LMP_DATA_INDICATION", "IRCOMM_LMP_DATA_INDICATION",
"IRCOMM_DATA_REQUEST", "IRCOMM_DATA_REQUEST",
"IRCOMM_CONTROL_REQUEST", "IRCOMM_CONTROL_REQUEST",
"IRCOMM_CONTROL_INDICATION", "IRCOMM_CONTROL_INDICATION",
}; };
#endif /* CONFIG_IRDA_DEBUG */ #endif /* CONFIG_IRDA_DEBUG */
static int (*state[])(struct ircomm_cb *self, IRCOMM_EVENT event, static int (*state[])(struct ircomm_cb *self, IRCOMM_EVENT event,
struct sk_buff *skb, struct ircomm_info *info) = struct sk_buff *skb, struct ircomm_info *info) =
{ {
ircomm_state_idle, ircomm_state_idle,
ircomm_state_waiti, ircomm_state_waiti,
@ -93,14 +93,14 @@ static int (*state[])(struct ircomm_cb *self, IRCOMM_EVENT event,
* IrCOMM is currently idle * IrCOMM is currently idle
* *
*/ */
static int ircomm_state_idle(struct ircomm_cb *self, IRCOMM_EVENT event, static int ircomm_state_idle(struct ircomm_cb *self, IRCOMM_EVENT event,
struct sk_buff *skb, struct ircomm_info *info) struct sk_buff *skb, struct ircomm_info *info)
{ {
int ret = 0; int ret = 0;
switch (event) { switch (event) {
case IRCOMM_CONNECT_REQUEST: case IRCOMM_CONNECT_REQUEST:
ircomm_next_state(self, IRCOMM_WAITI); ircomm_next_state(self, IRCOMM_WAITI);
ret = self->issue.connect_request(self, skb, info); ret = self->issue.connect_request(self, skb, info);
break; break;
case IRCOMM_TTP_CONNECT_INDICATION: case IRCOMM_TTP_CONNECT_INDICATION:
@ -119,10 +119,10 @@ static int ircomm_state_idle(struct ircomm_cb *self, IRCOMM_EVENT event,
/* /*
* Function ircomm_state_waiti (self, event, skb) * Function ircomm_state_waiti (self, event, skb)
* *
* The IrCOMM user has requested an IrCOMM connection to the remote * The IrCOMM user has requested an IrCOMM connection to the remote
* device and is awaiting confirmation * device and is awaiting confirmation
*/ */
static int ircomm_state_waiti(struct ircomm_cb *self, IRCOMM_EVENT event, static int ircomm_state_waiti(struct ircomm_cb *self, IRCOMM_EVENT event,
struct sk_buff *skb, struct ircomm_info *info) struct sk_buff *skb, struct ircomm_info *info)
{ {
int ret = 0; int ret = 0;
@ -152,8 +152,8 @@ static int ircomm_state_waiti(struct ircomm_cb *self, IRCOMM_EVENT event,
* IrCOMM has received an incoming connection request and is awaiting * IrCOMM has received an incoming connection request and is awaiting
* response from the user * response from the user
*/ */
static int ircomm_state_waitr(struct ircomm_cb *self, IRCOMM_EVENT event, static int ircomm_state_waitr(struct ircomm_cb *self, IRCOMM_EVENT event,
struct sk_buff *skb, struct ircomm_info *info) struct sk_buff *skb, struct ircomm_info *info)
{ {
int ret = 0; int ret = 0;
@ -185,7 +185,7 @@ static int ircomm_state_waitr(struct ircomm_cb *self, IRCOMM_EVENT event,
* IrCOMM is connected to the peer IrCOMM device * IrCOMM is connected to the peer IrCOMM device
* *
*/ */
static int ircomm_state_conn(struct ircomm_cb *self, IRCOMM_EVENT event, static int ircomm_state_conn(struct ircomm_cb *self, IRCOMM_EVENT event,
struct sk_buff *skb, struct ircomm_info *info) struct sk_buff *skb, struct ircomm_info *info)
{ {
int ret = 0; int ret = 0;
@ -228,7 +228,7 @@ static int ircomm_state_conn(struct ircomm_cb *self, IRCOMM_EVENT event,
* *
*/ */
int ircomm_do_event(struct ircomm_cb *self, IRCOMM_EVENT event, int ircomm_do_event(struct ircomm_cb *self, IRCOMM_EVENT event,
struct sk_buff *skb, struct ircomm_info *info) struct sk_buff *skb, struct ircomm_info *info)
{ {
IRDA_DEBUG(4, "%s: state=%s, event=%s\n", __FUNCTION__ , IRDA_DEBUG(4, "%s: state=%s, event=%s\n", __FUNCTION__ ,
ircomm_state[self->state], ircomm_event[event]); ircomm_state[self->state], ircomm_event[event]);
@ -245,7 +245,7 @@ int ircomm_do_event(struct ircomm_cb *self, IRCOMM_EVENT event,
void ircomm_next_state(struct ircomm_cb *self, IRCOMM_STATE state) void ircomm_next_state(struct ircomm_cb *self, IRCOMM_STATE state)
{ {
self->state = state; self->state = state;
IRDA_DEBUG(4, "%s: next state=%s, service type=%d\n", __FUNCTION__ , IRDA_DEBUG(4, "%s: next state=%s, service type=%d\n", __FUNCTION__ ,
ircomm_state[self->state], self->service_type); ircomm_state[self->state], self->service_type);
} }

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: ircomm_lmp.c * Filename: ircomm_lmp.c
* Version: 1.0 * Version: 1.0
* Description: Interface between IrCOMM and IrLMP * Description: Interface between IrCOMM and IrLMP
@ -9,25 +9,25 @@
* Modified at: Sun Dec 12 13:44:17 1999 * Modified at: Sun Dec 12 13:44:17 1999
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* Sources: Previous IrLPT work by Thomas Davis * Sources: Previous IrLPT work by Thomas Davis
* *
* Copyright (c) 1999 Dag Brattli, All Rights Reserved. * Copyright (c) 1999 Dag Brattli, All Rights Reserved.
* Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com> * Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
********************************************************************/ ********************************************************************/
#include <linux/sched.h> #include <linux/sched.h>
@ -45,11 +45,11 @@
/* /*
* Function ircomm_lmp_connect_request (self, userdata) * Function ircomm_lmp_connect_request (self, userdata)
* *
* *
* *
*/ */
static int ircomm_lmp_connect_request(struct ircomm_cb *self, static int ircomm_lmp_connect_request(struct ircomm_cb *self,
struct sk_buff *userdata, struct sk_buff *userdata,
struct ircomm_info *info) struct ircomm_info *info)
{ {
int ret = 0; int ret = 0;
@ -61,14 +61,14 @@ static int ircomm_lmp_connect_request(struct ircomm_cb *self,
skb_get(userdata); skb_get(userdata);
ret = irlmp_connect_request(self->lsap, info->dlsap_sel, ret = irlmp_connect_request(self->lsap, info->dlsap_sel,
info->saddr, info->daddr, NULL, userdata); info->saddr, info->daddr, NULL, userdata);
return ret; return ret;
} }
/* /*
* Function ircomm_lmp_connect_response (self, skb) * Function ircomm_lmp_connect_response (self, skb)
* *
* *
* *
*/ */
static int ircomm_lmp_connect_response(struct ircomm_cb *self, static int ircomm_lmp_connect_response(struct ircomm_cb *self,
@ -78,7 +78,7 @@ static int ircomm_lmp_connect_response(struct ircomm_cb *self,
int ret; int ret;
IRDA_DEBUG(0, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
/* Any userdata supplied? */ /* Any userdata supplied? */
if (userdata == NULL) { if (userdata == NULL) {
tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC); tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
@ -88,8 +88,8 @@ static int ircomm_lmp_connect_response(struct ircomm_cb *self,
/* Reserve space for MUX and LAP header */ /* Reserve space for MUX and LAP header */
skb_reserve(tx_skb, LMP_MAX_HEADER); skb_reserve(tx_skb, LMP_MAX_HEADER);
} else { } else {
/* /*
* Check that the client has reserved enough space for * Check that the client has reserved enough space for
* headers * headers
*/ */
IRDA_ASSERT(skb_headroom(userdata) >= LMP_MAX_HEADER, IRDA_ASSERT(skb_headroom(userdata) >= LMP_MAX_HEADER,
@ -105,22 +105,22 @@ static int ircomm_lmp_connect_response(struct ircomm_cb *self,
return 0; return 0;
} }
static int ircomm_lmp_disconnect_request(struct ircomm_cb *self, static int ircomm_lmp_disconnect_request(struct ircomm_cb *self,
struct sk_buff *userdata, struct sk_buff *userdata,
struct ircomm_info *info) struct ircomm_info *info)
{ {
struct sk_buff *tx_skb; struct sk_buff *tx_skb;
int ret; int ret;
IRDA_DEBUG(0, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
if (!userdata) { if (!userdata) {
tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC); tx_skb = alloc_skb(LMP_MAX_HEADER, GFP_ATOMIC);
if (!tx_skb) if (!tx_skb)
return -ENOMEM; return -ENOMEM;
/* Reserve space for MUX and LAP header */ /* Reserve space for MUX and LAP header */
skb_reserve(tx_skb, LMP_MAX_HEADER); skb_reserve(tx_skb, LMP_MAX_HEADER);
userdata = tx_skb; userdata = tx_skb;
} else { } else {
/* Don't forget to refcount it - should be NULL anyway */ /* Don't forget to refcount it - should be NULL anyway */
@ -136,7 +136,7 @@ static int ircomm_lmp_disconnect_request(struct ircomm_cb *self,
* Function ircomm_lmp_flow_control (skb) * Function ircomm_lmp_flow_control (skb)
* *
* This function is called when a data frame we have sent to IrLAP has * This function is called when a data frame we have sent to IrLAP has
* been deallocated. We do this to make sure we don't flood IrLAP with * been deallocated. We do this to make sure we don't flood IrLAP with
* frames, since we are not using the IrTTP flow control mechanism * frames, since we are not using the IrTTP flow control mechanism
*/ */
static void ircomm_lmp_flow_control(struct sk_buff *skb) static void ircomm_lmp_flow_control(struct sk_buff *skb)
@ -150,29 +150,29 @@ static void ircomm_lmp_flow_control(struct sk_buff *skb)
cb = (struct irda_skb_cb *) skb->cb; cb = (struct irda_skb_cb *) skb->cb;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
line = cb->line; line = cb->line;
self = (struct ircomm_cb *) hashbin_lock_find(ircomm, line, NULL); self = (struct ircomm_cb *) hashbin_lock_find(ircomm, line, NULL);
if (!self) { if (!self) {
IRDA_DEBUG(2, "%s(), didn't find myself\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), didn't find myself\n", __FUNCTION__ );
return; return;
} }
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return;); IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return;);
self->pkt_count--; self->pkt_count--;
if ((self->pkt_count < 2) && (self->flow_status == FLOW_STOP)) { if ((self->pkt_count < 2) && (self->flow_status == FLOW_STOP)) {
IRDA_DEBUG(2, "%s(), asking TTY to start again!\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), asking TTY to start again!\n", __FUNCTION__ );
self->flow_status = FLOW_START; self->flow_status = FLOW_START;
if (self->notify.flow_indication) if (self->notify.flow_indication)
self->notify.flow_indication(self->notify.instance, self->notify.flow_indication(self->notify.instance,
self, FLOW_START); self, FLOW_START);
} }
} }
/* /*
* Function ircomm_lmp_data_request (self, userdata) * Function ircomm_lmp_data_request (self, userdata)
* *
@ -180,7 +180,7 @@ static void ircomm_lmp_flow_control(struct sk_buff *skb)
* *
*/ */
static int ircomm_lmp_data_request(struct ircomm_cb *self, static int ircomm_lmp_data_request(struct ircomm_cb *self,
struct sk_buff *skb, struct sk_buff *skb,
int not_used) int not_used)
{ {
struct irda_skb_cb *cb; struct irda_skb_cb *cb;
@ -189,8 +189,8 @@ static int ircomm_lmp_data_request(struct ircomm_cb *self,
IRDA_ASSERT(skb != NULL, return -1;); IRDA_ASSERT(skb != NULL, return -1;);
cb = (struct irda_skb_cb *) skb->cb; cb = (struct irda_skb_cb *) skb->cb;
cb->line = self->line; cb->line = self->line;
IRDA_DEBUG(4, "%s(), sending frame\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s(), sending frame\n", __FUNCTION__ );
@ -199,13 +199,13 @@ static int ircomm_lmp_data_request(struct ircomm_cb *self,
skb->destructor = ircomm_lmp_flow_control; skb->destructor = ircomm_lmp_flow_control;
if ((self->pkt_count++ > 7) && (self->flow_status == FLOW_START)) { if ((self->pkt_count++ > 7) && (self->flow_status == FLOW_START)) {
IRDA_DEBUG(2, "%s(), asking TTY to slow down!\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), asking TTY to slow down!\n", __FUNCTION__ );
self->flow_status = FLOW_STOP; self->flow_status = FLOW_STOP;
if (self->notify.flow_indication) if (self->notify.flow_indication)
self->notify.flow_indication(self->notify.instance, self->notify.flow_indication(self->notify.instance,
self, FLOW_STOP); self, FLOW_STOP);
} }
ret = irlmp_data_request(self->lsap, skb); ret = irlmp_data_request(self->lsap, skb);
if (ret) { if (ret) {
IRDA_ERROR("%s(), failed\n", __FUNCTION__); IRDA_ERROR("%s(), failed\n", __FUNCTION__);
@ -227,11 +227,11 @@ static int ircomm_lmp_data_indication(void *instance, void *sap,
struct ircomm_cb *self = (struct ircomm_cb *) instance; struct ircomm_cb *self = (struct ircomm_cb *) instance;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -1;);
IRDA_ASSERT(skb != NULL, return -1;); IRDA_ASSERT(skb != NULL, return -1;);
ircomm_do_event(self, IRCOMM_LMP_DATA_INDICATION, skb, NULL); ircomm_do_event(self, IRCOMM_LMP_DATA_INDICATION, skb, NULL);
/* Drop reference count - see ircomm_tty_data_indication(). */ /* Drop reference count - see ircomm_tty_data_indication(). */
@ -241,15 +241,15 @@ static int ircomm_lmp_data_indication(void *instance, void *sap,
} }
/* /*
* Function ircomm_lmp_connect_confirm (instance, sap, qos, max_sdu_size, * Function ircomm_lmp_connect_confirm (instance, sap, qos, max_sdu_size,
* max_header_size, skb) * max_header_size, skb)
* *
* Connection has been confirmed by peer device * Connection has been confirmed by peer device
* *
*/ */
static void ircomm_lmp_connect_confirm(void *instance, void *sap, static void ircomm_lmp_connect_confirm(void *instance, void *sap,
struct qos_info *qos, struct qos_info *qos,
__u32 max_seg_size, __u32 max_seg_size,
__u8 max_header_size, __u8 max_header_size,
struct sk_buff *skb) struct sk_buff *skb)
{ {
@ -312,7 +312,7 @@ static void ircomm_lmp_connect_indication(void *instance, void *sap,
* Peer device has closed the connection, or the link went down for some * Peer device has closed the connection, or the link went down for some
* other reason * other reason
*/ */
static void ircomm_lmp_disconnect_indication(void *instance, void *sap, static void ircomm_lmp_disconnect_indication(void *instance, void *sap,
LM_REASON reason, LM_REASON reason,
struct sk_buff *skb) struct sk_buff *skb)
{ {

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: ircomm_param.c * Filename: ircomm_param.c
* Version: 1.0 * Version: 1.0
* Description: Parameter handling for the IrCOMM protocol * Description: Parameter handling for the IrCOMM protocol
@ -8,24 +8,24 @@
* Created at: Mon Jun 7 10:25:11 1999 * Created at: Mon Jun 7 10:25:11 1999
* Modified at: Sun Jan 30 14:32:03 2000 * Modified at: Sun Jan 30 14:32:03 2000
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved. * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
********************************************************************/ ********************************************************************/
#include <linux/sched.h> #include <linux/sched.h>
@ -41,23 +41,23 @@
#include <net/irda/ircomm_param.h> #include <net/irda/ircomm_param.h>
static int ircomm_param_service_type(void *instance, irda_param_t *param, static int ircomm_param_service_type(void *instance, irda_param_t *param,
int get); int get);
static int ircomm_param_port_type(void *instance, irda_param_t *param, static int ircomm_param_port_type(void *instance, irda_param_t *param,
int get); int get);
static int ircomm_param_port_name(void *instance, irda_param_t *param, static int ircomm_param_port_name(void *instance, irda_param_t *param,
int get); int get);
static int ircomm_param_service_type(void *instance, irda_param_t *param, static int ircomm_param_service_type(void *instance, irda_param_t *param,
int get); int get);
static int ircomm_param_data_rate(void *instance, irda_param_t *param, static int ircomm_param_data_rate(void *instance, irda_param_t *param,
int get); int get);
static int ircomm_param_data_format(void *instance, irda_param_t *param, static int ircomm_param_data_format(void *instance, irda_param_t *param,
int get); int get);
static int ircomm_param_flow_control(void *instance, irda_param_t *param, static int ircomm_param_flow_control(void *instance, irda_param_t *param,
int get); int get);
static int ircomm_param_xon_xoff(void *instance, irda_param_t *param, int get); static int ircomm_param_xon_xoff(void *instance, irda_param_t *param, int get);
static int ircomm_param_enq_ack(void *instance, irda_param_t *param, int get); static int ircomm_param_enq_ack(void *instance, irda_param_t *param, int get);
static int ircomm_param_line_status(void *instance, irda_param_t *param, static int ircomm_param_line_status(void *instance, irda_param_t *param,
int get); int get);
static int ircomm_param_dte(void *instance, irda_param_t *param, int get); static int ircomm_param_dte(void *instance, irda_param_t *param, int get);
static int ircomm_param_dce(void *instance, irda_param_t *param, int get); static int ircomm_param_dce(void *instance, irda_param_t *param, int get);
@ -85,7 +85,7 @@ static pi_minor_info_t pi_minor_call_table_9_wire[] = {
static pi_major_info_t pi_major_call_table[] = { static pi_major_info_t pi_major_call_table[] = {
{ pi_minor_call_table_common, 3 }, { pi_minor_call_table_common, 3 },
{ pi_minor_call_table_non_raw, 6 }, { pi_minor_call_table_non_raw, 6 },
{ pi_minor_call_table_9_wire, 3 } { pi_minor_call_table_9_wire, 3 }
/* { pi_minor_call_table_centronics } */ /* { pi_minor_call_table_centronics } */
}; };
@ -119,20 +119,20 @@ int ircomm_param_request(struct ircomm_tty_cb *self, __u8 pi, int flush)
spin_lock_irqsave(&self->spinlock, flags); spin_lock_irqsave(&self->spinlock, flags);
skb = self->ctrl_skb; skb = self->ctrl_skb;
if (!skb) { if (!skb) {
skb = alloc_skb(256, GFP_ATOMIC); skb = alloc_skb(256, GFP_ATOMIC);
if (!skb) { if (!skb) {
spin_unlock_irqrestore(&self->spinlock, flags); spin_unlock_irqrestore(&self->spinlock, flags);
return -ENOMEM; return -ENOMEM;
} }
skb_reserve(skb, self->max_header_size); skb_reserve(skb, self->max_header_size);
self->ctrl_skb = skb; self->ctrl_skb = skb;
} }
/* /*
* Inserting is a little bit tricky since we don't know how much * Inserting is a little bit tricky since we don't know how much
* room we will need. But this should hopefully work OK * room we will need. But this should hopefully work OK
*/ */
count = irda_param_insert(self, pi, skb->tail, skb_tailroom(skb), count = irda_param_insert(self, pi, skb->tail, skb_tailroom(skb),
&ircomm_param_info); &ircomm_param_info);
@ -162,7 +162,7 @@ int ircomm_param_request(struct ircomm_tty_cb *self, __u8 pi, int flush)
* query and then the remote device sends its initial parameters * query and then the remote device sends its initial parameters
* *
*/ */
static int ircomm_param_service_type(void *instance, irda_param_t *param, static int ircomm_param_service_type(void *instance, irda_param_t *param,
int get) int get)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
@ -179,7 +179,7 @@ static int ircomm_param_service_type(void *instance, irda_param_t *param,
/* Find all common service types */ /* Find all common service types */
service_type &= self->service_type; service_type &= self->service_type;
if (!service_type) { if (!service_type) {
IRDA_DEBUG(2, IRDA_DEBUG(2,
"%s(), No common service type to use!\n", __FUNCTION__ ); "%s(), No common service type to use!\n", __FUNCTION__ );
return -1; return -1;
} }
@ -198,12 +198,12 @@ static int ircomm_param_service_type(void *instance, irda_param_t *param,
else if (service_type & IRCOMM_3_WIRE_RAW) else if (service_type & IRCOMM_3_WIRE_RAW)
self->settings.service_type = IRCOMM_3_WIRE_RAW; self->settings.service_type = IRCOMM_3_WIRE_RAW;
IRDA_DEBUG(0, "%s(), resulting service type=0x%02x\n", __FUNCTION__ , IRDA_DEBUG(0, "%s(), resulting service type=0x%02x\n", __FUNCTION__ ,
self->settings.service_type); self->settings.service_type);
/* /*
* Now the line is ready for some communication. Check if we are a * Now the line is ready for some communication. Check if we are a
* server, and send over some initial parameters. * server, and send over some initial parameters.
* Client do it in ircomm_tty_state_setup(). * Client do it in ircomm_tty_state_setup().
* Note : we may get called from ircomm_tty_getvalue_confirm(), * Note : we may get called from ircomm_tty_getvalue_confirm(),
* therefore before we even have open any socket. And self->client * therefore before we even have open any socket. And self->client
@ -235,13 +235,13 @@ static int ircomm_param_port_type(void *instance, irda_param_t *param, int get)
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
if (get) if (get)
param->pv.i = IRCOMM_SERIAL; param->pv.i = IRCOMM_SERIAL;
else { else {
self->settings.port_type = (__u8) param->pv.i; self->settings.port_type = (__u8) param->pv.i;
IRDA_DEBUG(0, "%s(), port type=%d\n", __FUNCTION__ , IRDA_DEBUG(0, "%s(), port type=%d\n", __FUNCTION__ ,
self->settings.port_type); self->settings.port_type);
} }
return 0; return 0;
@ -256,7 +256,7 @@ static int ircomm_param_port_type(void *instance, irda_param_t *param, int get)
static int ircomm_param_port_name(void *instance, irda_param_t *param, int get) static int ircomm_param_port_name(void *instance, irda_param_t *param, int get)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
@ -279,7 +279,7 @@ static int ircomm_param_port_name(void *instance, irda_param_t *param, int get)
static int ircomm_param_data_rate(void *instance, irda_param_t *param, int get) static int ircomm_param_data_rate(void *instance, irda_param_t *param, int get)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
@ -287,7 +287,7 @@ static int ircomm_param_data_rate(void *instance, irda_param_t *param, int get)
param->pv.i = self->settings.data_rate; param->pv.i = self->settings.data_rate;
else else
self->settings.data_rate = param->pv.i; self->settings.data_rate = param->pv.i;
IRDA_DEBUG(2, "%s(), data rate = %d\n", __FUNCTION__ , param->pv.i); IRDA_DEBUG(2, "%s(), data rate = %d\n", __FUNCTION__ , param->pv.i);
return 0; return 0;
@ -299,7 +299,7 @@ static int ircomm_param_data_rate(void *instance, irda_param_t *param, int get)
* Exchange data format to be used in this settings * Exchange data format to be used in this settings
* *
*/ */
static int ircomm_param_data_format(void *instance, irda_param_t *param, static int ircomm_param_data_format(void *instance, irda_param_t *param,
int get) int get)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
@ -311,7 +311,7 @@ static int ircomm_param_data_format(void *instance, irda_param_t *param,
param->pv.i = self->settings.data_format; param->pv.i = self->settings.data_format;
else else
self->settings.data_format = (__u8) param->pv.i; self->settings.data_format = (__u8) param->pv.i;
return 0; return 0;
} }
@ -321,14 +321,14 @@ static int ircomm_param_data_format(void *instance, irda_param_t *param,
* Exchange flow control settings to be used in this settings * Exchange flow control settings to be used in this settings
* *
*/ */
static int ircomm_param_flow_control(void *instance, irda_param_t *param, static int ircomm_param_flow_control(void *instance, irda_param_t *param,
int get) int get)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
if (get) if (get)
param->pv.i = self->settings.flow_control; param->pv.i = self->settings.flow_control;
else else
@ -351,7 +351,7 @@ static int ircomm_param_xon_xoff(void *instance, irda_param_t *param, int get)
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
if (get) { if (get) {
param->pv.i = self->settings.xonxoff[0]; param->pv.i = self->settings.xonxoff[0];
param->pv.i |= self->settings.xonxoff[1] << 8; param->pv.i |= self->settings.xonxoff[1] << 8;
@ -360,7 +360,7 @@ static int ircomm_param_xon_xoff(void *instance, irda_param_t *param, int get)
self->settings.xonxoff[1] = (__u16) param->pv.i >> 8; self->settings.xonxoff[1] = (__u16) param->pv.i >> 8;
} }
IRDA_DEBUG(0, "%s(), XON/XOFF = 0x%02x,0x%02x\n", __FUNCTION__ , IRDA_DEBUG(0, "%s(), XON/XOFF = 0x%02x,0x%02x\n", __FUNCTION__ ,
param->pv.i & 0xff, param->pv.i >> 8); param->pv.i & 0xff, param->pv.i >> 8);
return 0; return 0;
@ -378,7 +378,7 @@ static int ircomm_param_enq_ack(void *instance, irda_param_t *param, int get)
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
if (get) { if (get) {
param->pv.i = self->settings.enqack[0]; param->pv.i = self->settings.enqack[0];
param->pv.i |= self->settings.enqack[1] << 8; param->pv.i |= self->settings.enqack[1] << 8;
@ -396,10 +396,10 @@ static int ircomm_param_enq_ack(void *instance, irda_param_t *param, int get)
/* /*
* Function ircomm_param_line_status (self, param) * Function ircomm_param_line_status (self, param)
* *
* *
* *
*/ */
static int ircomm_param_line_status(void *instance, irda_param_t *param, static int ircomm_param_line_status(void *instance, irda_param_t *param,
int get) int get)
{ {
IRDA_DEBUG(2, "%s(), not impl.\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), not impl.\n", __FUNCTION__ );
@ -427,7 +427,7 @@ static int ircomm_param_dte(void *instance, irda_param_t *param, int get)
dte = (__u8) param->pv.i; dte = (__u8) param->pv.i;
self->settings.dce = 0; self->settings.dce = 0;
if (dte & IRCOMM_DELTA_DTR) if (dte & IRCOMM_DELTA_DTR)
self->settings.dce |= (IRCOMM_DELTA_DSR| self->settings.dce |= (IRCOMM_DELTA_DSR|
IRCOMM_DELTA_RI | IRCOMM_DELTA_RI |
@ -436,7 +436,7 @@ static int ircomm_param_dte(void *instance, irda_param_t *param, int get)
self->settings.dce |= (IRCOMM_DSR| self->settings.dce |= (IRCOMM_DSR|
IRCOMM_RI | IRCOMM_RI |
IRCOMM_CD); IRCOMM_CD);
if (dte & IRCOMM_DELTA_RTS) if (dte & IRCOMM_DELTA_RTS)
self->settings.dce |= IRCOMM_DELTA_CTS; self->settings.dce |= IRCOMM_DELTA_CTS;
if (dte & IRCOMM_RTS) if (dte & IRCOMM_RTS)
@ -455,7 +455,7 @@ static int ircomm_param_dte(void *instance, irda_param_t *param, int get)
/* /*
* Function ircomm_param_dce (instance, param) * Function ircomm_param_dce (instance, param)
* *
* *
* *
*/ */
static int ircomm_param_dce(void *instance, irda_param_t *param, int get) static int ircomm_param_dce(void *instance, irda_param_t *param, int get)

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: ircomm_ttp.c * Filename: ircomm_ttp.c
* Version: 1.0 * Version: 1.0
* Description: Interface between IrCOMM and IrTTP * Description: Interface between IrCOMM and IrTTP
@ -8,25 +8,25 @@
* Created at: Sun Jun 6 20:48:27 1999 * Created at: Sun Jun 6 20:48:27 1999
* Modified at: Mon Dec 13 11:35:13 1999 * Modified at: Mon Dec 13 11:35:13 1999
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1999 Dag Brattli, All Rights Reserved. * Copyright (c) 1999 Dag Brattli, All Rights Reserved.
* Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com> * Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
********************************************************************/ ********************************************************************/
#include <linux/sched.h> #include <linux/sched.h>
@ -43,8 +43,8 @@
static int ircomm_ttp_data_indication(void *instance, void *sap, static int ircomm_ttp_data_indication(void *instance, void *sap,
struct sk_buff *skb); struct sk_buff *skb);
static void ircomm_ttp_connect_confirm(void *instance, void *sap, static void ircomm_ttp_connect_confirm(void *instance, void *sap,
struct qos_info *qos, struct qos_info *qos,
__u32 max_sdu_size, __u32 max_sdu_size,
__u8 max_header_size, __u8 max_header_size,
struct sk_buff *skb); struct sk_buff *skb);
static void ircomm_ttp_connect_indication(void *instance, void *sap, static void ircomm_ttp_connect_indication(void *instance, void *sap,
@ -54,25 +54,25 @@ static void ircomm_ttp_connect_indication(void *instance, void *sap,
struct sk_buff *skb); struct sk_buff *skb);
static void ircomm_ttp_flow_indication(void *instance, void *sap, static void ircomm_ttp_flow_indication(void *instance, void *sap,
LOCAL_FLOW cmd); LOCAL_FLOW cmd);
static void ircomm_ttp_disconnect_indication(void *instance, void *sap, static void ircomm_ttp_disconnect_indication(void *instance, void *sap,
LM_REASON reason, LM_REASON reason,
struct sk_buff *skb); struct sk_buff *skb);
static int ircomm_ttp_data_request(struct ircomm_cb *self, static int ircomm_ttp_data_request(struct ircomm_cb *self,
struct sk_buff *skb, struct sk_buff *skb,
int clen); int clen);
static int ircomm_ttp_connect_request(struct ircomm_cb *self, static int ircomm_ttp_connect_request(struct ircomm_cb *self,
struct sk_buff *userdata, struct sk_buff *userdata,
struct ircomm_info *info); struct ircomm_info *info);
static int ircomm_ttp_connect_response(struct ircomm_cb *self, static int ircomm_ttp_connect_response(struct ircomm_cb *self,
struct sk_buff *userdata); struct sk_buff *userdata);
static int ircomm_ttp_disconnect_request(struct ircomm_cb *self, static int ircomm_ttp_disconnect_request(struct ircomm_cb *self,
struct sk_buff *userdata, struct sk_buff *userdata,
struct ircomm_info *info); struct ircomm_info *info);
/* /*
* Function ircomm_open_tsap (self) * Function ircomm_open_tsap (self)
* *
* *
* *
*/ */
int ircomm_open_tsap(struct ircomm_cb *self) int ircomm_open_tsap(struct ircomm_cb *self)
@ -113,11 +113,11 @@ int ircomm_open_tsap(struct ircomm_cb *self)
/* /*
* Function ircomm_ttp_connect_request (self, userdata) * Function ircomm_ttp_connect_request (self, userdata)
* *
* *
* *
*/ */
static int ircomm_ttp_connect_request(struct ircomm_cb *self, static int ircomm_ttp_connect_request(struct ircomm_cb *self,
struct sk_buff *userdata, struct sk_buff *userdata,
struct ircomm_info *info) struct ircomm_info *info)
{ {
int ret = 0; int ret = 0;
@ -129,16 +129,16 @@ static int ircomm_ttp_connect_request(struct ircomm_cb *self,
skb_get(userdata); skb_get(userdata);
ret = irttp_connect_request(self->tsap, info->dlsap_sel, ret = irttp_connect_request(self->tsap, info->dlsap_sel,
info->saddr, info->daddr, NULL, info->saddr, info->daddr, NULL,
TTP_SAR_DISABLE, userdata); TTP_SAR_DISABLE, userdata);
return ret; return ret;
} }
/* /*
* Function ircomm_ttp_connect_response (self, skb) * Function ircomm_ttp_connect_response (self, skb)
* *
* *
* *
*/ */
static int ircomm_ttp_connect_response(struct ircomm_cb *self, static int ircomm_ttp_connect_response(struct ircomm_cb *self,
@ -147,7 +147,7 @@ static int ircomm_ttp_connect_response(struct ircomm_cb *self,
int ret; int ret;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
/* Don't forget to refcount it - should be NULL anyway */ /* Don't forget to refcount it - should be NULL anyway */
if(userdata) if(userdata)
skb_get(userdata); skb_get(userdata);
@ -160,14 +160,14 @@ static int ircomm_ttp_connect_response(struct ircomm_cb *self,
/* /*
* Function ircomm_ttp_data_request (self, userdata) * Function ircomm_ttp_data_request (self, userdata)
* *
* Send IrCOMM data to IrTTP layer. Currently we do not try to combine * Send IrCOMM data to IrTTP layer. Currently we do not try to combine
* control data with pure data, so they will be sent as separate frames. * control data with pure data, so they will be sent as separate frames.
* Should not be a big problem though, since control frames are rare. But * Should not be a big problem though, since control frames are rare. But
* some of them are sent after connection establishment, so this can * some of them are sent after connection establishment, so this can
* increase the latency a bit. * increase the latency a bit.
*/ */
static int ircomm_ttp_data_request(struct ircomm_cb *self, static int ircomm_ttp_data_request(struct ircomm_cb *self,
struct sk_buff *skb, struct sk_buff *skb,
int clen) int clen)
{ {
int ret; int ret;
@ -176,7 +176,7 @@ static int ircomm_ttp_data_request(struct ircomm_cb *self,
IRDA_DEBUG(2, "%s(), clen=%d\n", __FUNCTION__ , clen); IRDA_DEBUG(2, "%s(), clen=%d\n", __FUNCTION__ , clen);
/* /*
* Insert clen field, currently we either send data only, or control * Insert clen field, currently we either send data only, or control
* only frames, to make things easier and avoid queueing * only frames, to make things easier and avoid queueing
*/ */
@ -210,7 +210,7 @@ static int ircomm_ttp_data_indication(void *instance, void *sap,
struct ircomm_cb *self = (struct ircomm_cb *) instance; struct ircomm_cb *self = (struct ircomm_cb *) instance;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -1;);
IRDA_ASSERT(skb != NULL, return -1;); IRDA_ASSERT(skb != NULL, return -1;);
@ -224,8 +224,8 @@ static int ircomm_ttp_data_indication(void *instance, void *sap,
} }
static void ircomm_ttp_connect_confirm(void *instance, void *sap, static void ircomm_ttp_connect_confirm(void *instance, void *sap,
struct qos_info *qos, struct qos_info *qos,
__u32 max_sdu_size, __u32 max_sdu_size,
__u8 max_header_size, __u8 max_header_size,
struct sk_buff *skb) struct sk_buff *skb)
{ {
@ -261,7 +261,7 @@ out:
* Function ircomm_ttp_connect_indication (instance, sap, qos, max_sdu_size, * Function ircomm_ttp_connect_indication (instance, sap, qos, max_sdu_size,
* max_header_size, skb) * max_header_size, skb)
* *
* *
* *
*/ */
static void ircomm_ttp_connect_indication(void *instance, void *sap, static void ircomm_ttp_connect_indication(void *instance, void *sap,
@ -301,11 +301,11 @@ out:
/* /*
* Function ircomm_ttp_disconnect_request (self, userdata, info) * Function ircomm_ttp_disconnect_request (self, userdata, info)
* *
* *
* *
*/ */
static int ircomm_ttp_disconnect_request(struct ircomm_cb *self, static int ircomm_ttp_disconnect_request(struct ircomm_cb *self,
struct sk_buff *userdata, struct sk_buff *userdata,
struct ircomm_info *info) struct ircomm_info *info)
{ {
int ret; int ret;
@ -322,10 +322,10 @@ static int ircomm_ttp_disconnect_request(struct ircomm_cb *self,
/* /*
* Function ircomm_ttp_disconnect_indication (instance, sap, reason, skb) * Function ircomm_ttp_disconnect_indication (instance, sap, reason, skb)
* *
* *
* *
*/ */
static void ircomm_ttp_disconnect_indication(void *instance, void *sap, static void ircomm_ttp_disconnect_indication(void *instance, void *sap,
LM_REASON reason, LM_REASON reason,
struct sk_buff *skb) struct sk_buff *skb)
{ {
@ -361,7 +361,7 @@ static void ircomm_ttp_flow_indication(void *instance, void *sap,
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return;); IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return;);
if (self->notify.flow_indication) if (self->notify.flow_indication)
self->notify.flow_indication(self->notify.instance, self, cmd); self->notify.flow_indication(self->notify.instance, self, cmd);
} }

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: ircomm_tty.c * Filename: ircomm_tty.c
* Version: 1.0 * Version: 1.0
* Description: IrCOMM serial TTY driver * Description: IrCOMM serial TTY driver
@ -9,25 +9,25 @@
* Modified at: Wed Feb 23 00:09:02 2000 * Modified at: Wed Feb 23 00:09:02 2000
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* Sources: serial.c and previous IrCOMM work by Takahide Higuchi * Sources: serial.c and previous IrCOMM work by Takahide Higuchi
* *
* Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved. * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
* Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com> * Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
********************************************************************/ ********************************************************************/
#include <linux/init.h> #include <linux/init.h>
@ -69,7 +69,7 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
struct sk_buff *skb); struct sk_buff *skb);
static int ircomm_tty_control_indication(void *instance, void *sap, static int ircomm_tty_control_indication(void *instance, void *sap,
struct sk_buff *skb); struct sk_buff *skb);
static void ircomm_tty_flow_indication(void *instance, void *sap, static void ircomm_tty_flow_indication(void *instance, void *sap,
LOCAL_FLOW cmd); LOCAL_FLOW cmd);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static int ircomm_tty_read_proc(char *buf, char **start, off_t offset, int len, static int ircomm_tty_read_proc(char *buf, char **start, off_t offset, int len,
@ -113,7 +113,7 @@ static int __init ircomm_tty_init(void)
driver = alloc_tty_driver(IRCOMM_TTY_PORTS); driver = alloc_tty_driver(IRCOMM_TTY_PORTS);
if (!driver) if (!driver)
return -ENOMEM; return -ENOMEM;
ircomm_tty = hashbin_new(HB_LOCK); ircomm_tty = hashbin_new(HB_LOCK);
if (ircomm_tty == NULL) { if (ircomm_tty == NULL) {
IRDA_ERROR("%s(), can't allocate hashbin!\n", __FUNCTION__); IRDA_ERROR("%s(), can't allocate hashbin!\n", __FUNCTION__);
put_tty_driver(driver); put_tty_driver(driver);
@ -163,11 +163,11 @@ static void __exit ircomm_tty_cleanup(void)
{ {
int ret; int ret;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
ret = tty_unregister_driver(driver); ret = tty_unregister_driver(driver);
if (ret) { if (ret) {
IRDA_ERROR("%s(), failed to unregister driver\n", IRDA_ERROR("%s(), failed to unregister driver\n",
__FUNCTION__); __FUNCTION__);
return; return;
} }
@ -179,7 +179,7 @@ static void __exit ircomm_tty_cleanup(void)
/* /*
* Function ircomm_startup (self) * Function ircomm_startup (self)
* *
* *
* *
*/ */
static int ircomm_tty_startup(struct ircomm_tty_cb *self) static int ircomm_tty_startup(struct ircomm_tty_cb *self)
@ -203,17 +203,17 @@ static int ircomm_tty_startup(struct ircomm_tty_cb *self)
/* These callbacks we must handle ourselves */ /* These callbacks we must handle ourselves */
notify.data_indication = ircomm_tty_data_indication; notify.data_indication = ircomm_tty_data_indication;
notify.udata_indication = ircomm_tty_control_indication; notify.udata_indication = ircomm_tty_control_indication;
notify.flow_indication = ircomm_tty_flow_indication; notify.flow_indication = ircomm_tty_flow_indication;
/* Use the ircomm_tty interface for these ones */ /* Use the ircomm_tty interface for these ones */
notify.disconnect_indication = ircomm_tty_disconnect_indication; notify.disconnect_indication = ircomm_tty_disconnect_indication;
notify.connect_confirm = ircomm_tty_connect_confirm; notify.connect_confirm = ircomm_tty_connect_confirm;
notify.connect_indication = ircomm_tty_connect_indication; notify.connect_indication = ircomm_tty_connect_indication;
strlcpy(notify.name, "ircomm_tty", sizeof(notify.name)); strlcpy(notify.name, "ircomm_tty", sizeof(notify.name));
notify.instance = self; notify.instance = self;
if (!self->ircomm) { if (!self->ircomm) {
self->ircomm = ircomm_open(&notify, self->service_type, self->ircomm = ircomm_open(&notify, self->service_type,
self->line); self->line);
} }
if (!self->ircomm) if (!self->ircomm)
@ -237,10 +237,10 @@ err:
/* /*
* Function ircomm_block_til_ready (self, filp) * Function ircomm_block_til_ready (self, filp)
* *
* *
* *
*/ */
static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
struct file *filp) struct file *filp)
{ {
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
@ -248,7 +248,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
int do_clocal = 0, extra_count = 0; int do_clocal = 0, extra_count = 0;
unsigned long flags; unsigned long flags;
struct tty_struct *tty; struct tty_struct *tty;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
tty = self->tty; tty = self->tty;
@ -256,7 +256,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
/* /*
* If non-blocking mode is set, or the port is not enabled, * If non-blocking mode is set, or the port is not enabled,
* then make the check up front and then exit. * then make the check up front and then exit.
*/ */
if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){
/* nonblock mode is set or port is not enabled */ /* nonblock mode is set or port is not enabled */
self->flags |= ASYNC_NORMAL_ACTIVE; self->flags |= ASYNC_NORMAL_ACTIVE;
@ -268,17 +268,17 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
IRDA_DEBUG(1, "%s(), doing CLOCAL!\n", __FUNCTION__ ); IRDA_DEBUG(1, "%s(), doing CLOCAL!\n", __FUNCTION__ );
do_clocal = 1; do_clocal = 1;
} }
/* Wait for carrier detect and the line to become /* Wait for carrier detect and the line to become
* free (i.e., not in use by the callout). While we are in * free (i.e., not in use by the callout). While we are in
* this loop, self->open_count is dropped by one, so that * this loop, self->open_count is dropped by one, so that
* mgsl_close() knows when to free things. We restore it upon * mgsl_close() knows when to free things. We restore it upon
* exit, either normal or abnormal. * exit, either normal or abnormal.
*/ */
retval = 0; retval = 0;
add_wait_queue(&self->open_wait, &wait); add_wait_queue(&self->open_wait, &wait);
IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n", IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
__FILE__,__LINE__, tty->driver->name, self->open_count ); __FILE__,__LINE__, tty->driver->name, self->open_count );
@ -290,7 +290,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
} }
spin_unlock_irqrestore(&self->spinlock, flags); spin_unlock_irqrestore(&self->spinlock, flags);
self->blocked_open++; self->blocked_open++;
while (1) { while (1) {
if (tty->termios->c_cflag & CBAUD) { if (tty->termios->c_cflag & CBAUD) {
/* Here, we use to lock those two guys, but /* Here, we use to lock those two guys, but
@ -298,45 +298,45 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
* I don't see the point (and I see the deadlock). * I don't see the point (and I see the deadlock).
* Jean II */ * Jean II */
self->settings.dte |= IRCOMM_RTS + IRCOMM_DTR; self->settings.dte |= IRCOMM_RTS + IRCOMM_DTR;
ircomm_param_request(self, IRCOMM_DTE, TRUE); ircomm_param_request(self, IRCOMM_DTE, TRUE);
} }
current->state = TASK_INTERRUPTIBLE; current->state = TASK_INTERRUPTIBLE;
if (tty_hung_up_p(filp) || if (tty_hung_up_p(filp) ||
!test_bit(ASYNC_B_INITIALIZED, &self->flags)) { !test_bit(ASYNC_B_INITIALIZED, &self->flags)) {
retval = (self->flags & ASYNC_HUP_NOTIFY) ? retval = (self->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS; -EAGAIN : -ERESTARTSYS;
break; break;
} }
/* /*
* Check if link is ready now. Even if CLOCAL is * Check if link is ready now. Even if CLOCAL is
* specified, we cannot return before the IrCOMM link is * specified, we cannot return before the IrCOMM link is
* ready * ready
*/ */
if (!test_bit(ASYNC_B_CLOSING, &self->flags) && if (!test_bit(ASYNC_B_CLOSING, &self->flags) &&
(do_clocal || (self->settings.dce & IRCOMM_CD)) && (do_clocal || (self->settings.dce & IRCOMM_CD)) &&
self->state == IRCOMM_TTY_READY) self->state == IRCOMM_TTY_READY)
{ {
break; break;
} }
if (signal_pending(current)) { if (signal_pending(current)) {
retval = -ERESTARTSYS; retval = -ERESTARTSYS;
break; break;
} }
IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n", IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
__FILE__,__LINE__, tty->driver->name, self->open_count ); __FILE__,__LINE__, tty->driver->name, self->open_count );
schedule(); schedule();
} }
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
remove_wait_queue(&self->open_wait, &wait); remove_wait_queue(&self->open_wait, &wait);
if (extra_count) { if (extra_count) {
/* ++ is not atomic, so this should be protected - Jean II */ /* ++ is not atomic, so this should be protected - Jean II */
spin_lock_irqsave(&self->spinlock, flags); spin_lock_irqsave(&self->spinlock, flags);
@ -344,14 +344,14 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
spin_unlock_irqrestore(&self->spinlock, flags); spin_unlock_irqrestore(&self->spinlock, flags);
} }
self->blocked_open--; self->blocked_open--;
IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n", IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
__FILE__,__LINE__, tty->driver->name, self->open_count); __FILE__,__LINE__, tty->driver->name, self->open_count);
if (!retval) if (!retval)
self->flags |= ASYNC_NORMAL_ACTIVE; self->flags |= ASYNC_NORMAL_ACTIVE;
return retval; return retval;
} }
/* /*
@ -384,7 +384,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
IRDA_ERROR("%s(), kmalloc failed!\n", __FUNCTION__); IRDA_ERROR("%s(), kmalloc failed!\n", __FUNCTION__);
return -ENOMEM; return -ENOMEM;
} }
self->magic = IRCOMM_TTY_MAGIC; self->magic = IRCOMM_TTY_MAGIC;
self->flow = FLOW_STOP; self->flow = FLOW_STOP;
@ -398,13 +398,13 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
/* Init some important stuff */ /* Init some important stuff */
init_timer(&self->watchdog_timer); init_timer(&self->watchdog_timer);
init_waitqueue_head(&self->open_wait); init_waitqueue_head(&self->open_wait);
init_waitqueue_head(&self->close_wait); init_waitqueue_head(&self->close_wait);
spin_lock_init(&self->spinlock); spin_lock_init(&self->spinlock);
/* /*
* Force TTY into raw mode by default which is usually what * Force TTY into raw mode by default which is usually what
* we want for IrCOMM and IrLPT. This way applications will * we want for IrCOMM and IrLPT. This way applications will
* not have to twiddle with printcap etc. * not have to twiddle with printcap etc.
*/ */
tty->termios->c_iflag = 0; tty->termios->c_iflag = 0;
tty->termios->c_oflag = 0; tty->termios->c_oflag = 0;
@ -420,7 +420,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
self->tty = tty; self->tty = tty;
spin_unlock_irqrestore(&self->spinlock, flags); spin_unlock_irqrestore(&self->spinlock, flags);
IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __FUNCTION__ , tty->driver->name, IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __FUNCTION__ , tty->driver->name,
self->line, self->open_count); self->line, self->open_count);
/* Not really used by us, but lets do it anyway */ /* Not really used by us, but lets do it anyway */
@ -473,7 +473,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
ret = ircomm_tty_block_til_ready(self, filp); ret = ircomm_tty_block_til_ready(self, filp);
if (ret) { if (ret) {
IRDA_DEBUG(2, IRDA_DEBUG(2,
"%s(), returning after block_til_ready with %d\n", __FUNCTION__ , "%s(), returning after block_til_ready with %d\n", __FUNCTION__ ,
ret); ret);
@ -519,7 +519,7 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
* serial port won't be shutdown. * serial port won't be shutdown.
*/ */
IRDA_DEBUG(0, "%s(), bad serial port count; " IRDA_DEBUG(0, "%s(), bad serial port count; "
"tty->count is 1, state->count is %d\n", __FUNCTION__ , "tty->count is 1, state->count is %d\n", __FUNCTION__ ,
self->open_count); self->open_count);
self->open_count = 1; self->open_count = 1;
} }
@ -546,7 +546,7 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
spin_unlock_irqrestore(&self->spinlock, flags); spin_unlock_irqrestore(&self->spinlock, flags);
/* /*
* Now we wait for the transmit buffer to clear; and we notify * Now we wait for the transmit buffer to clear; and we notify
* the line discipline to only process XON/XOFF characters. * the line discipline to only process XON/XOFF characters.
*/ */
tty->closing = 1; tty->closing = 1;
@ -576,7 +576,7 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
/* /*
* Function ircomm_tty_flush_buffer (tty) * Function ircomm_tty_flush_buffer (tty)
* *
* *
* *
*/ */
static void ircomm_tty_flush_buffer(struct tty_struct *tty) static void ircomm_tty_flush_buffer(struct tty_struct *tty)
@ -586,9 +586,9 @@ static void ircomm_tty_flush_buffer(struct tty_struct *tty)
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
/* /*
* Let do_softint() do this to avoid race condition with * Let do_softint() do this to avoid race condition with
* do_softint() ;-) * do_softint() ;-)
*/ */
schedule_work(&self->tqueue); schedule_work(&self->tqueue);
} }
@ -597,7 +597,7 @@ static void ircomm_tty_flush_buffer(struct tty_struct *tty)
* Function ircomm_tty_do_softint (work) * Function ircomm_tty_do_softint (work)
* *
* We use this routine to give the write wakeup to the user at at a * We use this routine to give the write wakeup to the user at at a
* safe time (as fast as possible after write have completed). This * safe time (as fast as possible after write have completed). This
* can be compared to the Tx interrupt. * can be compared to the Tx interrupt.
*/ */
static void ircomm_tty_do_softint(struct work_struct *work) static void ircomm_tty_do_softint(struct work_struct *work)
@ -638,7 +638,7 @@ static void ircomm_tty_do_softint(struct work_struct *work)
/* Unlink transmit buffer */ /* Unlink transmit buffer */
spin_lock_irqsave(&self->spinlock, flags); spin_lock_irqsave(&self->spinlock, flags);
skb = self->tx_skb; skb = self->tx_skb;
self->tx_skb = NULL; self->tx_skb = NULL;
@ -650,9 +650,9 @@ static void ircomm_tty_do_softint(struct work_struct *work)
/* Drop reference count - see ircomm_ttp_data_request(). */ /* Drop reference count - see ircomm_ttp_data_request(). */
dev_kfree_skb(skb); dev_kfree_skb(skb);
} }
/* Check if user (still) wants to be waken up */ /* Check if user (still) wants to be waken up */
if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
tty->ldisc.write_wakeup) tty->ldisc.write_wakeup)
{ {
(tty->ldisc.write_wakeup)(tty); (tty->ldisc.write_wakeup)(tty);
@ -717,12 +717,12 @@ static int ircomm_tty_write(struct tty_struct *tty,
/* Fetch current transmit buffer */ /* Fetch current transmit buffer */
skb = self->tx_skb; skb = self->tx_skb;
/* /*
* Send out all the data we get, possibly as multiple fragmented * Send out all the data we get, possibly as multiple fragmented
* frames, but this will only happen if the data is larger than the * frames, but this will only happen if the data is larger than the
* max data size. The normal case however is just the opposite, and * max data size. The normal case however is just the opposite, and
* this function may be called multiple times, and will then actually * this function may be called multiple times, and will then actually
* defragment the data and send it out as one packet as soon as * defragment the data and send it out as one packet as soon as
* possible, but at a safer point in time * possible, but at a safer point in time
*/ */
while (count) { while (count) {
@ -731,16 +731,16 @@ static int ircomm_tty_write(struct tty_struct *tty,
/* Adjust data size to the max data size */ /* Adjust data size to the max data size */
if (size > self->max_data_size) if (size > self->max_data_size)
size = self->max_data_size; size = self->max_data_size;
/* /*
* Do we already have a buffer ready for transmit, or do * Do we already have a buffer ready for transmit, or do
* we need to allocate a new frame * we need to allocate a new frame
*/ */
if (skb) { if (skb) {
/* /*
* Any room for more data at the end of the current * Any room for more data at the end of the current
* transmit buffer? Cannot use skb_tailroom, since * transmit buffer? Cannot use skb_tailroom, since
* dev_alloc_skb gives us a larger skb than we * dev_alloc_skb gives us a larger skb than we
* requested * requested
* Note : use tx_data_size, because max_data_size * Note : use tx_data_size, because max_data_size
* may have changed and we don't want to overwrite * may have changed and we don't want to overwrite
@ -751,8 +751,8 @@ static int ircomm_tty_write(struct tty_struct *tty,
if (size > tailroom) if (size > tailroom)
size = tailroom; size = tailroom;
} else { } else {
/* /*
* Current transmit frame is full, so break * Current transmit frame is full, so break
* out, so we can send it as soon as possible * out, so we can send it as soon as possible
*/ */
break; break;
@ -782,15 +782,15 @@ static int ircomm_tty_write(struct tty_struct *tty,
spin_unlock_irqrestore(&self->spinlock, flags); spin_unlock_irqrestore(&self->spinlock, flags);
/* /*
* Schedule a new thread which will transmit the frame as soon * Schedule a new thread which will transmit the frame as soon
* as possible, but at a safe point in time. We do this so the * as possible, but at a safe point in time. We do this so the
* "user" can give us data multiple times, as PPP does (because of * "user" can give us data multiple times, as PPP does (because of
* its 256 byte tx buffer). We will then defragment and send out * its 256 byte tx buffer). We will then defragment and send out
* all this data as one single packet. * all this data as one single packet.
*/ */
schedule_work(&self->tqueue); schedule_work(&self->tqueue);
return len; return len;
} }
@ -846,7 +846,7 @@ static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout)
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
unsigned long orig_jiffies, poll_time; unsigned long orig_jiffies, poll_time;
unsigned long flags; unsigned long flags;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
@ -876,7 +876,7 @@ static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout)
* *
* This routine notifies the tty driver that input buffers for the line * This routine notifies the tty driver that input buffers for the line
* discipline are close to full, and it should somehow signal that no * discipline are close to full, and it should somehow signal that no
* more characters should be sent to the tty. * more characters should be sent to the tty.
*/ */
static void ircomm_tty_throttle(struct tty_struct *tty) static void ircomm_tty_throttle(struct tty_struct *tty)
{ {
@ -890,16 +890,16 @@ static void ircomm_tty_throttle(struct tty_struct *tty)
/* Software flow control? */ /* Software flow control? */
if (I_IXOFF(tty)) if (I_IXOFF(tty))
ircomm_tty_send_xchar(tty, STOP_CHAR(tty)); ircomm_tty_send_xchar(tty, STOP_CHAR(tty));
/* Hardware flow control? */ /* Hardware flow control? */
if (tty->termios->c_cflag & CRTSCTS) { if (tty->termios->c_cflag & CRTSCTS) {
self->settings.dte &= ~IRCOMM_RTS; self->settings.dte &= ~IRCOMM_RTS;
self->settings.dte |= IRCOMM_DELTA_RTS; self->settings.dte |= IRCOMM_DELTA_RTS;
ircomm_param_request(self, IRCOMM_DTE, TRUE); ircomm_param_request(self, IRCOMM_DTE, TRUE);
} }
ircomm_flow_request(self->ircomm, FLOW_STOP); ircomm_flow_request(self->ircomm, FLOW_STOP);
} }
/* /*
@ -930,7 +930,7 @@ static void ircomm_tty_unthrottle(struct tty_struct *tty)
ircomm_param_request(self, IRCOMM_DTE, TRUE); ircomm_param_request(self, IRCOMM_DTE, TRUE);
IRDA_DEBUG(1, "%s(), FLOW_START\n", __FUNCTION__ ); IRDA_DEBUG(1, "%s(), FLOW_START\n", __FUNCTION__ );
} }
ircomm_flow_request(self->ircomm, FLOW_START); ircomm_flow_request(self->ircomm, FLOW_START);
} }
/* /*
@ -975,7 +975,7 @@ static void ircomm_tty_shutdown(struct ircomm_tty_cb *self)
spin_lock_irqsave(&self->spinlock, flags); spin_lock_irqsave(&self->spinlock, flags);
del_timer(&self->watchdog_timer); del_timer(&self->watchdog_timer);
/* Free parameter buffer */ /* Free parameter buffer */
if (self->ctrl_skb) { if (self->ctrl_skb) {
dev_kfree_skb(self->ctrl_skb); dev_kfree_skb(self->ctrl_skb);
@ -1001,7 +1001,7 @@ static void ircomm_tty_shutdown(struct ircomm_tty_cb *self)
* *
* This routine notifies the tty driver that it should hangup the tty * This routine notifies the tty driver that it should hangup the tty
* device. * device.
* *
*/ */
static void ircomm_tty_hangup(struct tty_struct *tty) static void ircomm_tty_hangup(struct tty_struct *tty)
{ {
@ -1044,7 +1044,7 @@ static void ircomm_tty_send_xchar(struct tty_struct *tty, char ch)
* Function ircomm_tty_start (tty) * Function ircomm_tty_start (tty)
* *
* This routine notifies the tty driver that it resume sending * This routine notifies the tty driver that it resume sending
* characters to the tty device. * characters to the tty device.
*/ */
void ircomm_tty_start(struct tty_struct *tty) void ircomm_tty_start(struct tty_struct *tty)
{ {
@ -1057,9 +1057,9 @@ void ircomm_tty_start(struct tty_struct *tty)
* Function ircomm_tty_stop (tty) * Function ircomm_tty_stop (tty)
* *
* This routine notifies the tty driver that it should stop outputting * This routine notifies the tty driver that it should stop outputting
* characters to the tty device. * characters to the tty device.
*/ */
static void ircomm_tty_stop(struct tty_struct *tty) static void ircomm_tty_stop(struct tty_struct *tty)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
@ -1094,14 +1094,14 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
/*wake_up_interruptible(&self->delta_msr_wait);*/ /*wake_up_interruptible(&self->delta_msr_wait);*/
} }
if ((self->flags & ASYNC_CHECK_CD) && (status & IRCOMM_DELTA_CD)) { if ((self->flags & ASYNC_CHECK_CD) && (status & IRCOMM_DELTA_CD)) {
IRDA_DEBUG(2, IRDA_DEBUG(2,
"%s(), ircomm%d CD now %s...\n", __FUNCTION__ , self->line, "%s(), ircomm%d CD now %s...\n", __FUNCTION__ , self->line,
(status & IRCOMM_CD) ? "on" : "off"); (status & IRCOMM_CD) ? "on" : "off");
if (status & IRCOMM_CD) { if (status & IRCOMM_CD) {
wake_up_interruptible(&self->open_wait); wake_up_interruptible(&self->open_wait);
} else { } else {
IRDA_DEBUG(2, IRDA_DEBUG(2,
"%s(), Doing serial hangup..\n", __FUNCTION__ ); "%s(), Doing serial hangup..\n", __FUNCTION__ );
if (tty) if (tty)
tty_hangup(tty); tty_hangup(tty);
@ -1113,10 +1113,10 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
if (self->flags & ASYNC_CTS_FLOW) { if (self->flags & ASYNC_CTS_FLOW) {
if (tty->hw_stopped) { if (tty->hw_stopped) {
if (status & IRCOMM_CTS) { if (status & IRCOMM_CTS) {
IRDA_DEBUG(2, IRDA_DEBUG(2,
"%s(), CTS tx start...\n", __FUNCTION__ ); "%s(), CTS tx start...\n", __FUNCTION__ );
tty->hw_stopped = 0; tty->hw_stopped = 0;
/* Wake up processes blocked on open */ /* Wake up processes blocked on open */
wake_up_interruptible(&self->open_wait); wake_up_interruptible(&self->open_wait);
@ -1125,7 +1125,7 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
} }
} else { } else {
if (!(status & IRCOMM_CTS)) { if (!(status & IRCOMM_CTS)) {
IRDA_DEBUG(2, IRDA_DEBUG(2,
"%s(), CTS tx stop...\n", __FUNCTION__ ); "%s(), CTS tx stop...\n", __FUNCTION__ );
tty->hw_stopped = 1; tty->hw_stopped = 1;
} }
@ -1145,7 +1145,7 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
IRDA_ASSERT(skb != NULL, return -1;); IRDA_ASSERT(skb != NULL, return -1;);
@ -1155,10 +1155,10 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
return 0; return 0;
} }
/* /*
* If we receive data when hardware is stopped then something is wrong. * If we receive data when hardware is stopped then something is wrong.
* We try to poll the peers line settings to check if we are up todate. * We try to poll the peers line settings to check if we are up todate.
* Devices like WinCE can do this, and since they don't send any * Devices like WinCE can do this, and since they don't send any
* params, we can just as well declare the hardware for running. * params, we can just as well declare the hardware for running.
*/ */
if (self->tty->hw_stopped && (self->flow == FLOW_START)) { if (self->tty->hw_stopped && (self->flow == FLOW_START)) {
@ -1170,9 +1170,9 @@ static int ircomm_tty_data_indication(void *instance, void *sap,
ircomm_tty_link_established(self); ircomm_tty_link_established(self);
} }
/* /*
* Just give it over to the line discipline. There is no need to * Just give it over to the line discipline. There is no need to
* involve the flip buffers, since we are not running in an interrupt * involve the flip buffers, since we are not running in an interrupt
* handler * handler
*/ */
self->tty->ldisc.receive_buf(self->tty, skb->data, NULL, skb->len); self->tty->ldisc.receive_buf(self->tty, skb->data, NULL, skb->len);
@ -1195,14 +1195,14 @@ static int ircomm_tty_control_indication(void *instance, void *sap,
int clen; int clen;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
IRDA_ASSERT(skb != NULL, return -1;); IRDA_ASSERT(skb != NULL, return -1;);
clen = skb->data[0]; clen = skb->data[0];
irda_param_extract_all(self, skb->data+1, IRDA_MIN(skb->len-1, clen), irda_param_extract_all(self, skb->data+1, IRDA_MIN(skb->len-1, clen),
&ircomm_param_info); &ircomm_param_info);
/* No need to kfree_skb - see ircomm_control_indication() */ /* No need to kfree_skb - see ircomm_control_indication() */
@ -1217,7 +1217,7 @@ static int ircomm_tty_control_indication(void *instance, void *sap,
* transmission of data. We just mark the hardware as stopped, and wait * transmission of data. We just mark the hardware as stopped, and wait
* for IrTTP to notify us that things are OK again. * for IrTTP to notify us that things are OK again.
*/ */
static void ircomm_tty_flow_indication(void *instance, void *sap, static void ircomm_tty_flow_indication(void *instance, void *sap,
LOCAL_FLOW cmd) LOCAL_FLOW cmd)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
@ -1247,7 +1247,7 @@ static void ircomm_tty_flow_indication(void *instance, void *sap,
static int ircomm_tty_line_info(struct ircomm_tty_cb *self, char *buf) static int ircomm_tty_line_info(struct ircomm_tty_cb *self, char *buf)
{ {
int ret=0; int ret=0;
ret += sprintf(buf+ret, "State: %s\n", ircomm_tty_state[self->state]); ret += sprintf(buf+ret, "State: %s\n", ircomm_tty_state[self->state]);
@ -1260,37 +1260,37 @@ static int ircomm_tty_line_info(struct ircomm_tty_cb *self, char *buf)
ret += sprintf(buf+ret, "3_WIRE_RAW"); ret += sprintf(buf+ret, "3_WIRE_RAW");
else else
ret += sprintf(buf+ret, "No common service type!\n"); ret += sprintf(buf+ret, "No common service type!\n");
ret += sprintf(buf+ret, "\n"); ret += sprintf(buf+ret, "\n");
ret += sprintf(buf+ret, "Port name: %s\n", self->settings.port_name); ret += sprintf(buf+ret, "Port name: %s\n", self->settings.port_name);
ret += sprintf(buf+ret, "DTE status: "); ret += sprintf(buf+ret, "DTE status: ");
if (self->settings.dte & IRCOMM_RTS) if (self->settings.dte & IRCOMM_RTS)
ret += sprintf(buf+ret, "RTS|"); ret += sprintf(buf+ret, "RTS|");
if (self->settings.dte & IRCOMM_DTR) if (self->settings.dte & IRCOMM_DTR)
ret += sprintf(buf+ret, "DTR|"); ret += sprintf(buf+ret, "DTR|");
if (self->settings.dte) if (self->settings.dte)
ret--; /* remove the last | */ ret--; /* remove the last | */
ret += sprintf(buf+ret, "\n"); ret += sprintf(buf+ret, "\n");
ret += sprintf(buf+ret, "DCE status: "); ret += sprintf(buf+ret, "DCE status: ");
if (self->settings.dce & IRCOMM_CTS) if (self->settings.dce & IRCOMM_CTS)
ret += sprintf(buf+ret, "CTS|"); ret += sprintf(buf+ret, "CTS|");
if (self->settings.dce & IRCOMM_DSR) if (self->settings.dce & IRCOMM_DSR)
ret += sprintf(buf+ret, "DSR|"); ret += sprintf(buf+ret, "DSR|");
if (self->settings.dce & IRCOMM_CD) if (self->settings.dce & IRCOMM_CD)
ret += sprintf(buf+ret, "CD|"); ret += sprintf(buf+ret, "CD|");
if (self->settings.dce & IRCOMM_RI) if (self->settings.dce & IRCOMM_RI)
ret += sprintf(buf+ret, "RI|"); ret += sprintf(buf+ret, "RI|");
if (self->settings.dce) if (self->settings.dce)
ret--; /* remove the last | */ ret--; /* remove the last | */
ret += sprintf(buf+ret, "\n"); ret += sprintf(buf+ret, "\n");
ret += sprintf(buf+ret, "Configuration: "); ret += sprintf(buf+ret, "Configuration: ");
if (!self->settings.null_modem) if (!self->settings.null_modem)
ret += sprintf(buf+ret, "DTE <-> DCE\n"); ret += sprintf(buf+ret, "DTE <-> DCE\n");
else else
ret += sprintf(buf+ret, ret += sprintf(buf+ret,
"DTE <-> DTE (null modem emulation)\n"); "DTE <-> DTE (null modem emulation)\n");
ret += sprintf(buf+ret, "Data rate: %d\n", self->settings.data_rate); ret += sprintf(buf+ret, "Data rate: %d\n", self->settings.data_rate);
@ -1314,7 +1314,7 @@ static int ircomm_tty_line_info(struct ircomm_tty_cb *self, char *buf)
ret += sprintf(buf+ret, "ENQ_ACK_OUT|"); ret += sprintf(buf+ret, "ENQ_ACK_OUT|");
if (self->settings.flow_control) if (self->settings.flow_control)
ret--; /* remove the last | */ ret--; /* remove the last | */
ret += sprintf(buf+ret, "\n"); ret += sprintf(buf+ret, "\n");
ret += sprintf(buf+ret, "Flags: "); ret += sprintf(buf+ret, "Flags: ");
if (self->flags & ASYNC_CTS_FLOW) if (self->flags & ASYNC_CTS_FLOW)
@ -1333,25 +1333,25 @@ static int ircomm_tty_line_info(struct ircomm_tty_cb *self, char *buf)
ret--; /* remove the last | */ ret--; /* remove the last | */
ret += sprintf(buf+ret, "\n"); ret += sprintf(buf+ret, "\n");
ret += sprintf(buf+ret, "Role: %s\n", self->client ? ret += sprintf(buf+ret, "Role: %s\n", self->client ?
"client" : "server"); "client" : "server");
ret += sprintf(buf+ret, "Open count: %d\n", self->open_count); ret += sprintf(buf+ret, "Open count: %d\n", self->open_count);
ret += sprintf(buf+ret, "Max data size: %d\n", self->max_data_size); ret += sprintf(buf+ret, "Max data size: %d\n", self->max_data_size);
ret += sprintf(buf+ret, "Max header size: %d\n", self->max_header_size); ret += sprintf(buf+ret, "Max header size: %d\n", self->max_header_size);
if (self->tty) if (self->tty)
ret += sprintf(buf+ret, "Hardware: %s\n", ret += sprintf(buf+ret, "Hardware: %s\n",
self->tty->hw_stopped ? "Stopped" : "Running"); self->tty->hw_stopped ? "Stopped" : "Running");
ret += sprintf(buf+ret, "\n"); ret += sprintf(buf+ret, "\n");
return ret; return ret;
} }
/* /*
* Function ircomm_tty_read_proc (buf, start, offset, len, eof, unused) * Function ircomm_tty_read_proc (buf, start, offset, len, eof, unused)
* *
* *
* *
*/ */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
@ -1359,8 +1359,8 @@ static int ircomm_tty_read_proc(char *buf, char **start, off_t offset, int len,
int *eof, void *unused) int *eof, void *unused)
{ {
struct ircomm_tty_cb *self; struct ircomm_tty_cb *self;
int count = 0, l; int count = 0, l;
off_t begin = 0; off_t begin = 0;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&ircomm_tty->hb_spinlock, flags); spin_lock_irqsave(&ircomm_tty->hb_spinlock, flags);
@ -1370,25 +1370,25 @@ static int ircomm_tty_read_proc(char *buf, char **start, off_t offset, int len,
if (self->magic != IRCOMM_TTY_MAGIC) if (self->magic != IRCOMM_TTY_MAGIC)
break; break;
l = ircomm_tty_line_info(self, buf + count); l = ircomm_tty_line_info(self, buf + count);
count += l; count += l;
if (count+begin > offset+len) if (count+begin > offset+len)
goto done; goto done;
if (count+begin < offset) { if (count+begin < offset) {
begin += count; begin += count;
count = 0; count = 0;
} }
self = (struct ircomm_tty_cb *) hashbin_get_next(ircomm_tty); self = (struct ircomm_tty_cb *) hashbin_get_next(ircomm_tty);
} }
*eof = 1; *eof = 1;
done: done:
spin_unlock_irqrestore(&ircomm_tty->hb_spinlock, flags); spin_unlock_irqrestore(&ircomm_tty->hb_spinlock, flags);
if (offset >= count+begin) if (offset >= count+begin)
return 0; return 0;
*start = buf + (offset-begin); *start = buf + (offset-begin);
return ((len < begin+count-offset) ? len : begin+count-offset); return ((len < begin+count-offset) ? len : begin+count-offset);
} }
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */

View file

@ -1,32 +1,32 @@
/********************************************************************* /*********************************************************************
* *
* Filename: ircomm_tty_attach.c * Filename: ircomm_tty_attach.c
* Version: * Version:
* Description: Code for attaching the serial driver to IrCOMM * Description: Code for attaching the serial driver to IrCOMM
* Status: Experimental. * Status: Experimental.
* Author: Dag Brattli <dagb@cs.uit.no> * Author: Dag Brattli <dagb@cs.uit.no>
* Created at: Sat Jun 5 17:42:00 1999 * Created at: Sat Jun 5 17:42:00 1999
* Modified at: Tue Jan 4 14:20:49 2000 * Modified at: Tue Jan 4 14:20:49 2000
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved. * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
* Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com> * Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
********************************************************************/ ********************************************************************/
#include <linux/sched.h> #include <linux/sched.h>
@ -50,35 +50,35 @@ static void ircomm_tty_ias_register(struct ircomm_tty_cb *self);
static void ircomm_tty_discovery_indication(discinfo_t *discovery, static void ircomm_tty_discovery_indication(discinfo_t *discovery,
DISCOVERY_MODE mode, DISCOVERY_MODE mode,
void *priv); void *priv);
static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id, static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
struct ias_value *value, void *priv); struct ias_value *value, void *priv);
static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self, static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
int timeout); int timeout);
static void ircomm_tty_watchdog_timer_expired(void *data); static void ircomm_tty_watchdog_timer_expired(void *data);
static int ircomm_tty_state_idle(struct ircomm_tty_cb *self, static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
IRCOMM_TTY_EVENT event, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct sk_buff *skb,
struct ircomm_tty_info *info); struct ircomm_tty_info *info);
static int ircomm_tty_state_search(struct ircomm_tty_cb *self, static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
IRCOMM_TTY_EVENT event, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct sk_buff *skb,
struct ircomm_tty_info *info); struct ircomm_tty_info *info);
static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self, static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
IRCOMM_TTY_EVENT event, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct sk_buff *skb,
struct ircomm_tty_info *info); struct ircomm_tty_info *info);
static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self, static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self,
IRCOMM_TTY_EVENT event, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct sk_buff *skb,
struct ircomm_tty_info *info); struct ircomm_tty_info *info);
static int ircomm_tty_state_setup(struct ircomm_tty_cb *self, static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
IRCOMM_TTY_EVENT event, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct sk_buff *skb,
struct ircomm_tty_info *info); struct ircomm_tty_info *info);
static int ircomm_tty_state_ready(struct ircomm_tty_cb *self, static int ircomm_tty_state_ready(struct ircomm_tty_cb *self,
IRCOMM_TTY_EVENT event, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct sk_buff *skb,
struct ircomm_tty_info *info); struct ircomm_tty_info *info);
char *ircomm_tty_state[] = { char *ircomm_tty_state[] = {
@ -111,7 +111,7 @@ static char *ircomm_tty_event[] = {
#endif /* CONFIG_IRDA_DEBUG */ #endif /* CONFIG_IRDA_DEBUG */
static int (*state[])(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event, static int (*state[])(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct ircomm_tty_info *info) = struct sk_buff *skb, struct ircomm_tty_info *info) =
{ {
ircomm_tty_state_idle, ircomm_tty_state_idle,
ircomm_tty_state_search, ircomm_tty_state_search,
@ -125,7 +125,7 @@ static int (*state[])(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
* Function ircomm_tty_attach_cable (driver) * Function ircomm_tty_attach_cable (driver)
* *
* Try to attach cable (IrCOMM link). This function will only return * Try to attach cable (IrCOMM link). This function will only return
* when the link has been connected, or if an error condition occurs. * when the link has been connected, or if an error condition occurs.
* If success, the return value is the resulting service type. * If success, the return value is the resulting service type.
*/ */
int ircomm_tty_attach_cable(struct ircomm_tty_cb *self) int ircomm_tty_attach_cable(struct ircomm_tty_cb *self)
@ -135,7 +135,7 @@ int ircomm_tty_attach_cable(struct ircomm_tty_cb *self)
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
/* Check if somebody has already connected to us */ /* Check if somebody has already connected to us */
if (ircomm_is_connected(self->ircomm)) { if (ircomm_is_connected(self->ircomm)) {
IRDA_DEBUG(0, "%s(), already connected!\n", __FUNCTION__ ); IRDA_DEBUG(0, "%s(), already connected!\n", __FUNCTION__ );
return 0; return 0;
@ -177,7 +177,7 @@ void ircomm_tty_detach_cable(struct ircomm_tty_cb *self)
self->skey = NULL; self->skey = NULL;
} }
if (self->iriap) { if (self->iriap) {
iriap_close(self->iriap); iriap_close(self->iriap);
self->iriap = NULL; self->iriap = NULL;
} }
@ -212,7 +212,7 @@ static void ircomm_tty_ias_register(struct ircomm_tty_cb *self)
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
/* Compute hint bits based on service */ /* Compute hint bits based on service */
hints = irlmp_service_to_hint(S_COMM); hints = irlmp_service_to_hint(S_COMM);
if (self->service_type & IRCOMM_3_WIRE_RAW) if (self->service_type & IRCOMM_3_WIRE_RAW)
@ -234,19 +234,19 @@ static void ircomm_tty_ias_register(struct ircomm_tty_cb *self)
if (self->service_type & IRCOMM_3_WIRE_RAW) { if (self->service_type & IRCOMM_3_WIRE_RAW) {
/* Register IrLPT with LM-IAS */ /* Register IrLPT with LM-IAS */
self->obj = irias_new_object("IrLPT", IAS_IRLPT_ID); self->obj = irias_new_object("IrLPT", IAS_IRLPT_ID);
irias_add_integer_attrib(self->obj, "IrDA:IrLMP:LsapSel", irias_add_integer_attrib(self->obj, "IrDA:IrLMP:LsapSel",
self->slsap_sel, IAS_KERNEL_ATTR); self->slsap_sel, IAS_KERNEL_ATTR);
} else { } else {
/* Register IrCOMM with LM-IAS */ /* Register IrCOMM with LM-IAS */
self->obj = irias_new_object("IrDA:IrCOMM", IAS_IRCOMM_ID); self->obj = irias_new_object("IrDA:IrCOMM", IAS_IRCOMM_ID);
irias_add_integer_attrib(self->obj, "IrDA:TinyTP:LsapSel", irias_add_integer_attrib(self->obj, "IrDA:TinyTP:LsapSel",
self->slsap_sel, IAS_KERNEL_ATTR); self->slsap_sel, IAS_KERNEL_ATTR);
/* Code the parameters into the buffer */ /* Code the parameters into the buffer */
irda_param_pack(oct_seq, "bbbbbb", irda_param_pack(oct_seq, "bbbbbb",
IRCOMM_SERVICE_TYPE, 1, self->service_type, IRCOMM_SERVICE_TYPE, 1, self->service_type,
IRCOMM_PORT_TYPE, 1, IRCOMM_SERIAL); IRCOMM_PORT_TYPE, 1, IRCOMM_SERIAL);
/* Register parameters with LM-IAS */ /* Register parameters with LM-IAS */
irias_add_octseq_attrib(self->obj, "Parameters", oct_seq, 6, irias_add_octseq_attrib(self->obj, "Parameters", oct_seq, 6,
IAS_KERNEL_ATTR); IAS_KERNEL_ATTR);
@ -302,23 +302,23 @@ int ircomm_tty_send_initial_parameters(struct ircomm_tty_cb *self)
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
if (self->service_type & IRCOMM_3_WIRE_RAW) if (self->service_type & IRCOMM_3_WIRE_RAW)
return 0; return 0;
/* /*
* Set default values, but only if the application for some reason * Set default values, but only if the application for some reason
* haven't set them already * haven't set them already
*/ */
IRDA_DEBUG(2, "%s(), data-rate = %d\n", __FUNCTION__ , IRDA_DEBUG(2, "%s(), data-rate = %d\n", __FUNCTION__ ,
self->settings.data_rate); self->settings.data_rate);
if (!self->settings.data_rate) if (!self->settings.data_rate)
self->settings.data_rate = 9600; self->settings.data_rate = 9600;
IRDA_DEBUG(2, "%s(), data-format = %d\n", __FUNCTION__ , IRDA_DEBUG(2, "%s(), data-format = %d\n", __FUNCTION__ ,
self->settings.data_format); self->settings.data_format);
if (!self->settings.data_format) if (!self->settings.data_format)
self->settings.data_format = IRCOMM_WSIZE_8; /* 8N1 */ self->settings.data_format = IRCOMM_WSIZE_8; /* 8N1 */
IRDA_DEBUG(2, "%s(), flow-control = %d\n", __FUNCTION__ , IRDA_DEBUG(2, "%s(), flow-control = %d\n", __FUNCTION__ ,
self->settings.flow_control); self->settings.flow_control);
/*self->settings.flow_control = IRCOMM_RTS_CTS_IN|IRCOMM_RTS_CTS_OUT;*/ /*self->settings.flow_control = IRCOMM_RTS_CTS_IN|IRCOMM_RTS_CTS_OUT;*/
@ -330,7 +330,7 @@ int ircomm_tty_send_initial_parameters(struct ircomm_tty_cb *self)
ircomm_param_request(self, IRCOMM_SERVICE_TYPE, FALSE); ircomm_param_request(self, IRCOMM_SERVICE_TYPE, FALSE);
ircomm_param_request(self, IRCOMM_DATA_RATE, FALSE); ircomm_param_request(self, IRCOMM_DATA_RATE, FALSE);
ircomm_param_request(self, IRCOMM_DATA_FORMAT, FALSE); ircomm_param_request(self, IRCOMM_DATA_FORMAT, FALSE);
/* For a 3 wire service, we just flush the last parameter and return */ /* For a 3 wire service, we just flush the last parameter and return */
if (self->settings.service_type == IRCOMM_3_WIRE) { if (self->settings.service_type == IRCOMM_3_WIRE) {
ircomm_param_request(self, IRCOMM_FLOW_CONTROL, TRUE); ircomm_param_request(self, IRCOMM_FLOW_CONTROL, TRUE);
@ -342,10 +342,10 @@ int ircomm_tty_send_initial_parameters(struct ircomm_tty_cb *self)
#if 0 #if 0
ircomm_param_request(self, IRCOMM_XON_XOFF, FALSE); ircomm_param_request(self, IRCOMM_XON_XOFF, FALSE);
ircomm_param_request(self, IRCOMM_ENQ_ACK, FALSE); ircomm_param_request(self, IRCOMM_ENQ_ACK, FALSE);
#endif #endif
/* Notify peer that we are ready to receive data */ /* Notify peer that we are ready to receive data */
ircomm_param_request(self, IRCOMM_DTE, TRUE); ircomm_param_request(self, IRCOMM_DTE, TRUE);
return 0; return 0;
} }
@ -388,8 +388,8 @@ static void ircomm_tty_discovery_indication(discinfo_t *discovery,
self = (struct ircomm_tty_cb *) hashbin_get_first(ircomm_tty); self = (struct ircomm_tty_cb *) hashbin_get_first(ircomm_tty);
while (self != NULL) { while (self != NULL) {
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
ircomm_tty_do_event(self, IRCOMM_TTY_DISCOVERY_INDICATION, ircomm_tty_do_event(self, IRCOMM_TTY_DISCOVERY_INDICATION,
NULL, &info); NULL, &info);
self = (struct ircomm_tty_cb *) hashbin_get_next(ircomm_tty); self = (struct ircomm_tty_cb *) hashbin_get_next(ircomm_tty);
@ -402,7 +402,7 @@ static void ircomm_tty_discovery_indication(discinfo_t *discovery,
* Link disconnected * Link disconnected
* *
*/ */
void ircomm_tty_disconnect_indication(void *instance, void *sap, void ircomm_tty_disconnect_indication(void *instance, void *sap,
LM_REASON reason, LM_REASON reason,
struct sk_buff *skb) struct sk_buff *skb)
{ {
@ -422,7 +422,7 @@ void ircomm_tty_disconnect_indication(void *instance, void *sap,
/* Stop data transfers */ /* Stop data transfers */
self->tty->hw_stopped = 1; self->tty->hw_stopped = 1;
ircomm_tty_do_event(self, IRCOMM_TTY_DISCONNECT_INDICATION, NULL, ircomm_tty_do_event(self, IRCOMM_TTY_DISCONNECT_INDICATION, NULL,
NULL); NULL);
} }
@ -432,8 +432,8 @@ void ircomm_tty_disconnect_indication(void *instance, void *sap,
* Got result from the IAS query we make * Got result from the IAS query we make
* *
*/ */
static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id, static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
struct ias_value *value, struct ias_value *value,
void *priv) void *priv)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) priv; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) priv;
@ -454,18 +454,18 @@ static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
} }
switch (value->type) { switch (value->type) {
case IAS_OCT_SEQ: case IAS_OCT_SEQ:
IRDA_DEBUG(2, "%s(), got octet sequence\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), got octet sequence\n", __FUNCTION__ );
irda_param_extract_all(self, value->t.oct_seq, value->len, irda_param_extract_all(self, value->t.oct_seq, value->len,
&ircomm_param_info); &ircomm_param_info);
ircomm_tty_do_event(self, IRCOMM_TTY_GOT_PARAMETERS, NULL, ircomm_tty_do_event(self, IRCOMM_TTY_GOT_PARAMETERS, NULL,
NULL); NULL);
break; break;
case IAS_INTEGER: case IAS_INTEGER:
/* Got LSAP selector */ /* Got LSAP selector */
IRDA_DEBUG(2, "%s(), got lsapsel = %d\n", __FUNCTION__ , IRDA_DEBUG(2, "%s(), got lsapsel = %d\n", __FUNCTION__ ,
value->t.integer); value->t.integer);
if (value->t.integer == -1) { if (value->t.integer == -1) {
@ -491,10 +491,10 @@ static void ircomm_tty_getvalue_confirm(int result, __u16 obj_id,
* Connection confirmed * Connection confirmed
* *
*/ */
void ircomm_tty_connect_confirm(void *instance, void *sap, void ircomm_tty_connect_confirm(void *instance, void *sap,
struct qos_info *qos, struct qos_info *qos,
__u32 max_data_size, __u32 max_data_size,
__u8 max_header_size, __u8 max_header_size,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
@ -515,16 +515,16 @@ void ircomm_tty_connect_confirm(void *instance, void *sap,
} }
/* /*
* Function ircomm_tty_connect_indication (instance, sap, qos, max_sdu_size, * Function ircomm_tty_connect_indication (instance, sap, qos, max_sdu_size,
* skb) * skb)
* *
* we are discovered and being requested to connect by remote device ! * we are discovered and being requested to connect by remote device !
* *
*/ */
void ircomm_tty_connect_indication(void *instance, void *sap, void ircomm_tty_connect_indication(void *instance, void *sap,
struct qos_info *qos, struct qos_info *qos,
__u32 max_data_size, __u32 max_data_size,
__u8 max_header_size, __u8 max_header_size,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) instance;
@ -542,8 +542,8 @@ void ircomm_tty_connect_indication(void *instance, void *sap,
clen = skb->data[0]; clen = skb->data[0];
if (clen) if (clen)
irda_param_extract_all(self, skb->data+1, irda_param_extract_all(self, skb->data+1,
IRDA_MIN(skb->len, clen), IRDA_MIN(skb->len, clen),
&ircomm_param_info); &ircomm_param_info);
ircomm_tty_do_event(self, IRCOMM_TTY_CONNECT_INDICATION, NULL, NULL); ircomm_tty_do_event(self, IRCOMM_TTY_CONNECT_INDICATION, NULL, NULL);
@ -566,14 +566,14 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self)
if (!self->tty) if (!self->tty)
return; return;
del_timer(&self->watchdog_timer); del_timer(&self->watchdog_timer);
/* /*
* IrCOMM link is now up, and if we are not using hardware * IrCOMM link is now up, and if we are not using hardware
* flow-control, then declare the hardware as running. Otherwise we * flow-control, then declare the hardware as running. Otherwise we
* will have to wait for the peer device (DCE) to raise the CTS * will have to wait for the peer device (DCE) to raise the CTS
* line. * line.
*/ */
if ((self->flags & ASYNC_CTS_FLOW) && ((self->settings.dce & IRCOMM_CTS) == 0)) { if ((self->flags & ASYNC_CTS_FLOW) && ((self->settings.dce & IRCOMM_CTS) == 0)) {
IRDA_DEBUG(0, "%s(), waiting for CTS ...\n", __FUNCTION__ ); IRDA_DEBUG(0, "%s(), waiting for CTS ...\n", __FUNCTION__ );
@ -582,7 +582,7 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self)
IRDA_DEBUG(1, "%s(), starting hardware!\n", __FUNCTION__ ); IRDA_DEBUG(1, "%s(), starting hardware!\n", __FUNCTION__ );
self->tty->hw_stopped = 0; self->tty->hw_stopped = 0;
/* Wake up processes blocked on open */ /* Wake up processes blocked on open */
wake_up_interruptible(&self->open_wait); wake_up_interruptible(&self->open_wait);
} }
@ -593,8 +593,8 @@ void ircomm_tty_link_established(struct ircomm_tty_cb *self)
/* /*
* Function ircomm_tty_start_watchdog_timer (self, timeout) * Function ircomm_tty_start_watchdog_timer (self, timeout)
* *
* Start the watchdog timer. This timer is used to make sure that any * Start the watchdog timer. This timer is used to make sure that any
* connection attempt is successful, and if not, we will retry after * connection attempt is successful, and if not, we will retry after
* the timeout * the timeout
*/ */
static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self, static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
@ -616,7 +616,7 @@ static void ircomm_tty_start_watchdog_timer(struct ircomm_tty_cb *self,
static void ircomm_tty_watchdog_timer_expired(void *data) static void ircomm_tty_watchdog_timer_expired(void *data)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) data; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) data;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
@ -633,14 +633,14 @@ static void ircomm_tty_watchdog_timer_expired(void *data)
* *
*/ */
int ircomm_tty_do_event(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event, int ircomm_tty_do_event(struct ircomm_tty_cb *self, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct ircomm_tty_info *info) struct sk_buff *skb, struct ircomm_tty_info *info)
{ {
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;);
IRDA_DEBUG(2, "%s: state=%s, event=%s\n", __FUNCTION__ , IRDA_DEBUG(2, "%s: state=%s, event=%s\n", __FUNCTION__ ,
ircomm_tty_state[self->state], ircomm_tty_event[event]); ircomm_tty_state[self->state], ircomm_tty_event[event]);
return (*state[self->state])(self, event, skb, info); return (*state[self->state])(self, event, skb, info);
} }
@ -656,7 +656,7 @@ static inline void ircomm_tty_next_state(struct ircomm_tty_cb *self, IRCOMM_TTY_
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
IRDA_DEBUG(2, "%s: next state=%s, service type=%d\n", __FUNCTION__ , IRDA_DEBUG(2, "%s: next state=%s, service type=%d\n", __FUNCTION__ ,
ircomm_tty_state[self->state], self->service_type); ircomm_tty_state[self->state], self->service_type);
*/ */
self->state = state; self->state = state;
@ -668,9 +668,9 @@ static inline void ircomm_tty_next_state(struct ircomm_tty_cb *self, IRCOMM_TTY_
* Just hanging around * Just hanging around
* *
*/ */
static int ircomm_tty_state_idle(struct ircomm_tty_cb *self, static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
IRCOMM_TTY_EVENT event, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct sk_buff *skb,
struct ircomm_tty_info *info) struct ircomm_tty_info *info)
{ {
int ret = 0; int ret = 0;
@ -679,10 +679,10 @@ static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
ircomm_tty_state[self->state], ircomm_tty_event[event]); ircomm_tty_state[self->state], ircomm_tty_event[event]);
switch (event) { switch (event) {
case IRCOMM_TTY_ATTACH_CABLE: case IRCOMM_TTY_ATTACH_CABLE:
/* Try to discover any remote devices */ /* Try to discover any remote devices */
ircomm_tty_start_watchdog_timer(self, 3*HZ); ircomm_tty_start_watchdog_timer(self, 3*HZ);
ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH); ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH);
irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS); irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS);
break; break;
case IRCOMM_TTY_DISCOVERY_INDICATION: case IRCOMM_TTY_DISCOVERY_INDICATION:
@ -701,7 +701,7 @@ static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
iriap_getvaluebyclass_request(self->iriap, iriap_getvaluebyclass_request(self->iriap,
self->saddr, self->daddr, self->saddr, self->daddr,
"IrDA:IrCOMM", "Parameters"); "IrDA:IrCOMM", "Parameters");
ircomm_tty_start_watchdog_timer(self, 3*HZ); ircomm_tty_start_watchdog_timer(self, 3*HZ);
ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_PARAMETERS); ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_PARAMETERS);
break; break;
@ -732,9 +732,9 @@ static int ircomm_tty_state_idle(struct ircomm_tty_cb *self,
* Trying to discover an IrCOMM device * Trying to discover an IrCOMM device
* *
*/ */
static int ircomm_tty_state_search(struct ircomm_tty_cb *self, static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
IRCOMM_TTY_EVENT event, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct sk_buff *skb,
struct ircomm_tty_info *info) struct ircomm_tty_info *info)
{ {
int ret = 0; int ret = 0;
@ -752,19 +752,19 @@ static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
__FUNCTION__); __FUNCTION__);
return -EBUSY; return -EBUSY;
} }
self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self, self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self,
ircomm_tty_getvalue_confirm); ircomm_tty_getvalue_confirm);
if (self->service_type == IRCOMM_3_WIRE_RAW) { if (self->service_type == IRCOMM_3_WIRE_RAW) {
iriap_getvaluebyclass_request(self->iriap, self->saddr, iriap_getvaluebyclass_request(self->iriap, self->saddr,
self->daddr, "IrLPT", self->daddr, "IrLPT",
"IrDA:IrLMP:LsapSel"); "IrDA:IrLMP:LsapSel");
ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_LSAP_SEL); ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_LSAP_SEL);
} else { } else {
iriap_getvaluebyclass_request(self->iriap, self->saddr, iriap_getvaluebyclass_request(self->iriap, self->saddr,
self->daddr, self->daddr,
"IrDA:IrCOMM", "IrDA:IrCOMM",
"Parameters"); "Parameters");
ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_PARAMETERS); ircomm_tty_next_state(self, IRCOMM_TTY_QUERY_PARAMETERS);
@ -783,7 +783,7 @@ static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
#if 1 #if 1
/* Give up */ /* Give up */
#else #else
/* Try to discover any remote devices */ /* Try to discover any remote devices */
ircomm_tty_start_watchdog_timer(self, 3*HZ); ircomm_tty_start_watchdog_timer(self, 3*HZ);
irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS); irlmp_discovery_request(DISCOVERY_DEFAULT_SLOTS);
#endif #endif
@ -805,9 +805,9 @@ static int ircomm_tty_state_search(struct ircomm_tty_cb *self,
* Querying the remote LM-IAS for IrCOMM parameters * Querying the remote LM-IAS for IrCOMM parameters
* *
*/ */
static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self, static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
IRCOMM_TTY_EVENT event, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct sk_buff *skb,
struct ircomm_tty_info *info) struct ircomm_tty_info *info)
{ {
int ret = 0; int ret = 0;
@ -822,12 +822,12 @@ static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
__FUNCTION__); __FUNCTION__);
return -EBUSY; return -EBUSY;
} }
self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self, self->iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self,
ircomm_tty_getvalue_confirm); ircomm_tty_getvalue_confirm);
iriap_getvaluebyclass_request(self->iriap, self->saddr, iriap_getvaluebyclass_request(self->iriap, self->saddr,
self->daddr, "IrDA:IrCOMM", self->daddr, "IrDA:IrCOMM",
"IrDA:TinyTP:LsapSel"); "IrDA:TinyTP:LsapSel");
ircomm_tty_start_watchdog_timer(self, 3*HZ); ircomm_tty_start_watchdog_timer(self, 3*HZ);
@ -836,7 +836,7 @@ static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
case IRCOMM_TTY_WD_TIMER_EXPIRED: case IRCOMM_TTY_WD_TIMER_EXPIRED:
/* Go back to search mode */ /* Go back to search mode */
ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH); ircomm_tty_next_state(self, IRCOMM_TTY_SEARCH);
ircomm_tty_start_watchdog_timer(self, 3*HZ); ircomm_tty_start_watchdog_timer(self, 3*HZ);
break; break;
case IRCOMM_TTY_CONNECT_INDICATION: case IRCOMM_TTY_CONNECT_INDICATION:
del_timer(&self->watchdog_timer); del_timer(&self->watchdog_timer);
@ -863,9 +863,9 @@ static int ircomm_tty_state_query_parameters(struct ircomm_tty_cb *self,
* Query remote LM-IAS for the LSAP selector which we can connect to * Query remote LM-IAS for the LSAP selector which we can connect to
* *
*/ */
static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self, static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self,
IRCOMM_TTY_EVENT event, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct sk_buff *skb,
struct ircomm_tty_info *info) struct ircomm_tty_info *info)
{ {
int ret = 0; int ret = 0;
@ -877,7 +877,7 @@ static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self,
case IRCOMM_TTY_GOT_LSAPSEL: case IRCOMM_TTY_GOT_LSAPSEL:
/* Connect to remote device */ /* Connect to remote device */
ret = ircomm_connect_request(self->ircomm, self->dlsap_sel, ret = ircomm_connect_request(self->ircomm, self->dlsap_sel,
self->saddr, self->daddr, self->saddr, self->daddr,
NULL, self->service_type); NULL, self->service_type);
ircomm_tty_start_watchdog_timer(self, 3*HZ); ircomm_tty_start_watchdog_timer(self, 3*HZ);
ircomm_tty_next_state(self, IRCOMM_TTY_SETUP); ircomm_tty_next_state(self, IRCOMM_TTY_SETUP);
@ -912,9 +912,9 @@ static int ircomm_tty_state_query_lsap_sel(struct ircomm_tty_cb *self,
* Trying to connect * Trying to connect
* *
*/ */
static int ircomm_tty_state_setup(struct ircomm_tty_cb *self, static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
IRCOMM_TTY_EVENT event, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct sk_buff *skb,
struct ircomm_tty_info *info) struct ircomm_tty_info *info)
{ {
int ret = 0; int ret = 0;
@ -926,10 +926,10 @@ static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
case IRCOMM_TTY_CONNECT_CONFIRM: case IRCOMM_TTY_CONNECT_CONFIRM:
del_timer(&self->watchdog_timer); del_timer(&self->watchdog_timer);
ircomm_tty_ias_unregister(self); ircomm_tty_ias_unregister(self);
/* /*
* Send initial parameters. This will also send out queued * Send initial parameters. This will also send out queued
* parameters waiting for the connection to come up * parameters waiting for the connection to come up
*/ */
ircomm_tty_send_initial_parameters(self); ircomm_tty_send_initial_parameters(self);
ircomm_tty_link_established(self); ircomm_tty_link_established(self);
@ -938,7 +938,7 @@ static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
case IRCOMM_TTY_CONNECT_INDICATION: case IRCOMM_TTY_CONNECT_INDICATION:
del_timer(&self->watchdog_timer); del_timer(&self->watchdog_timer);
ircomm_tty_ias_unregister(self); ircomm_tty_ias_unregister(self);
/* Accept connection */ /* Accept connection */
ircomm_connect_response(self->ircomm, NULL); ircomm_connect_response(self->ircomm, NULL);
ircomm_tty_next_state(self, IRCOMM_TTY_READY); ircomm_tty_next_state(self, IRCOMM_TTY_READY);
@ -966,9 +966,9 @@ static int ircomm_tty_state_setup(struct ircomm_tty_cb *self,
* IrCOMM is now connected * IrCOMM is now connected
* *
*/ */
static int ircomm_tty_state_ready(struct ircomm_tty_cb *self, static int ircomm_tty_state_ready(struct ircomm_tty_cb *self,
IRCOMM_TTY_EVENT event, IRCOMM_TTY_EVENT event,
struct sk_buff *skb, struct sk_buff *skb,
struct ircomm_tty_info *info) struct ircomm_tty_info *info)
{ {
int ret = 0; int ret = 0;
@ -976,7 +976,7 @@ static int ircomm_tty_state_ready(struct ircomm_tty_cb *self,
switch (event) { switch (event) {
case IRCOMM_TTY_DATA_REQUEST: case IRCOMM_TTY_DATA_REQUEST:
ret = ircomm_data_request(self->ircomm, skb); ret = ircomm_data_request(self->ircomm, skb);
break; break;
case IRCOMM_TTY_DETACH_CABLE: case IRCOMM_TTY_DETACH_CABLE:
ircomm_disconnect_request(self->ircomm, NULL); ircomm_disconnect_request(self->ircomm, NULL);
ircomm_tty_next_state(self, IRCOMM_TTY_IDLE); ircomm_tty_next_state(self, IRCOMM_TTY_IDLE);

View file

@ -1,31 +1,31 @@
/********************************************************************* /*********************************************************************
* *
* Filename: ircomm_tty_ioctl.c * Filename: ircomm_tty_ioctl.c
* Version: * Version:
* Description: * Description:
* Status: Experimental. * Status: Experimental.
* Author: Dag Brattli <dagb@cs.uit.no> * Author: Dag Brattli <dagb@cs.uit.no>
* Created at: Thu Jun 10 14:39:09 1999 * Created at: Thu Jun 10 14:39:09 1999
* Modified at: Wed Jan 5 14:45:43 2000 * Modified at: Wed Jan 5 14:45:43 2000
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved. * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
********************************************************************/ ********************************************************************/
#include <linux/init.h> #include <linux/init.h>
@ -75,7 +75,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
} }
if (cflag & CSTOPB) if (cflag & CSTOPB)
cval |= IRCOMM_2_STOP_BIT; cval |= IRCOMM_2_STOP_BIT;
if (cflag & PARENB) if (cflag & PARENB)
cval |= IRCOMM_PARITY_ENABLE; cval |= IRCOMM_PARITY_ENABLE;
if (!(cflag & PARODD)) if (!(cflag & PARODD))
@ -88,7 +88,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
self->settings.data_rate = baud; self->settings.data_rate = baud;
ircomm_param_request(self, IRCOMM_DATA_RATE, FALSE); ircomm_param_request(self, IRCOMM_DATA_RATE, FALSE);
/* CTS flow control flag and modem status interrupts */ /* CTS flow control flag and modem status interrupts */
if (cflag & CRTSCTS) { if (cflag & CRTSCTS) {
self->flags |= ASYNC_CTS_FLOW; self->flags |= ASYNC_CTS_FLOW;
@ -104,7 +104,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
self->flags &= ~ASYNC_CHECK_CD; self->flags &= ~ASYNC_CHECK_CD;
else else
self->flags |= ASYNC_CHECK_CD; self->flags |= ASYNC_CHECK_CD;
#if 0 #if 0
/* /*
* Set up parity check flag * Set up parity check flag
*/ */
@ -113,7 +113,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
driver->read_status_mask |= LSR_FE | LSR_PE; driver->read_status_mask |= LSR_FE | LSR_PE;
if (I_BRKINT(driver->tty) || I_PARMRK(driver->tty)) if (I_BRKINT(driver->tty) || I_PARMRK(driver->tty))
driver->read_status_mask |= LSR_BI; driver->read_status_mask |= LSR_BI;
/* /*
* Characters to ignore * Characters to ignore
*/ */
@ -124,17 +124,17 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
if (I_IGNBRK(self->tty)) { if (I_IGNBRK(self->tty)) {
self->ignore_status_mask |= LSR_BI; self->ignore_status_mask |= LSR_BI;
/* /*
* If we're ignore parity and break indicators, ignore * If we're ignore parity and break indicators, ignore
* overruns too. (For real raw support). * overruns too. (For real raw support).
*/ */
if (I_IGNPAR(self->tty)) if (I_IGNPAR(self->tty))
self->ignore_status_mask |= LSR_OE; self->ignore_status_mask |= LSR_OE;
} }
#endif #endif
self->settings.data_format = cval; self->settings.data_format = cval;
ircomm_param_request(self, IRCOMM_DATA_FORMAT, FALSE); ircomm_param_request(self, IRCOMM_DATA_FORMAT, FALSE);
ircomm_param_request(self, IRCOMM_FLOW_CONTROL, TRUE); ircomm_param_request(self, IRCOMM_FLOW_CONTROL, TRUE);
} }
/* /*
@ -145,7 +145,7 @@ static void ircomm_tty_change_speed(struct ircomm_tty_cb *self)
* should be prepared to accept the case where old == NULL, and try to * should be prepared to accept the case where old == NULL, and try to
* do something rational. * do something rational.
*/ */
void ircomm_tty_set_termios(struct tty_struct *tty, void ircomm_tty_set_termios(struct tty_struct *tty,
struct ktermios *old_termios) struct ktermios *old_termios)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
@ -153,8 +153,8 @@ void ircomm_tty_set_termios(struct tty_struct *tty,
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
if ((cflag == old_termios->c_cflag) && if ((cflag == old_termios->c_cflag) &&
(RELEVANT_IFLAG(tty->termios->c_iflag) == (RELEVANT_IFLAG(tty->termios->c_iflag) ==
RELEVANT_IFLAG(old_termios->c_iflag))) RELEVANT_IFLAG(old_termios->c_iflag)))
{ {
return; return;
@ -168,21 +168,21 @@ void ircomm_tty_set_termios(struct tty_struct *tty,
self->settings.dte &= ~(IRCOMM_DTR|IRCOMM_RTS); self->settings.dte &= ~(IRCOMM_DTR|IRCOMM_RTS);
ircomm_param_request(self, IRCOMM_DTE, TRUE); ircomm_param_request(self, IRCOMM_DTE, TRUE);
} }
/* Handle transition away from B0 status */ /* Handle transition away from B0 status */
if (!(old_termios->c_cflag & CBAUD) && if (!(old_termios->c_cflag & CBAUD) &&
(cflag & CBAUD)) { (cflag & CBAUD)) {
self->settings.dte |= IRCOMM_DTR; self->settings.dte |= IRCOMM_DTR;
if (!(tty->termios->c_cflag & CRTSCTS) || if (!(tty->termios->c_cflag & CRTSCTS) ||
!test_bit(TTY_THROTTLED, &tty->flags)) { !test_bit(TTY_THROTTLED, &tty->flags)) {
self->settings.dte |= IRCOMM_RTS; self->settings.dte |= IRCOMM_RTS;
} }
ircomm_param_request(self, IRCOMM_DTE, TRUE); ircomm_param_request(self, IRCOMM_DTE, TRUE);
} }
/* Handle turning off CRTSCTS */ /* Handle turning off CRTSCTS */
if ((old_termios->c_cflag & CRTSCTS) && if ((old_termios->c_cflag & CRTSCTS) &&
!(tty->termios->c_cflag & CRTSCTS)) !(tty->termios->c_cflag & CRTSCTS))
{ {
tty->hw_stopped = 0; tty->hw_stopped = 0;
ircomm_tty_start(tty); ircomm_tty_start(tty);
@ -192,7 +192,7 @@ void ircomm_tty_set_termios(struct tty_struct *tty,
/* /*
* Function ircomm_tty_tiocmget (tty, file) * Function ircomm_tty_tiocmget (tty, file)
* *
* *
* *
*/ */
int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file) int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file)
@ -217,12 +217,12 @@ int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file)
/* /*
* Function ircomm_tty_tiocmset (tty, file, set, clear) * Function ircomm_tty_tiocmset (tty, file, set, clear)
* *
* *
* *
*/ */
int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file, int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file,
unsigned int set, unsigned int clear) unsigned int set, unsigned int clear)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
@ -249,21 +249,21 @@ int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file,
self->settings.dte |= IRCOMM_DELTA_DTR; self->settings.dte |= IRCOMM_DELTA_DTR;
ircomm_param_request(self, IRCOMM_DTE, TRUE); ircomm_param_request(self, IRCOMM_DTE, TRUE);
return 0; return 0;
} }
/* /*
* Function get_serial_info (driver, retinfo) * Function get_serial_info (driver, retinfo)
* *
* *
* *
*/ */
static int ircomm_tty_get_serial_info(struct ircomm_tty_cb *self, static int ircomm_tty_get_serial_info(struct ircomm_tty_cb *self,
struct serial_struct __user *retinfo) struct serial_struct __user *retinfo)
{ {
struct serial_struct info; struct serial_struct info;
if (!retinfo) if (!retinfo)
return -EFAULT; return -EFAULT;
@ -277,11 +277,11 @@ static int ircomm_tty_get_serial_info(struct ircomm_tty_cb *self,
info.closing_wait = self->closing_wait; info.closing_wait = self->closing_wait;
/* For compatibility */ /* For compatibility */
info.type = PORT_16550A; info.type = PORT_16550A;
info.port = 0; info.port = 0;
info.irq = 0; info.irq = 0;
info.xmit_fifo_size = 0; info.xmit_fifo_size = 0;
info.hub6 = 0; info.hub6 = 0;
info.custom_divisor = 0; info.custom_divisor = 0;
if (copy_to_user(retinfo, &info, sizeof(*retinfo))) if (copy_to_user(retinfo, &info, sizeof(*retinfo)))
@ -293,7 +293,7 @@ static int ircomm_tty_get_serial_info(struct ircomm_tty_cb *self,
/* /*
* Function set_serial_info (driver, new_info) * Function set_serial_info (driver, new_info)
* *
* *
* *
*/ */
static int ircomm_tty_set_serial_info(struct ircomm_tty_cb *self, static int ircomm_tty_set_serial_info(struct ircomm_tty_cb *self,
@ -311,7 +311,7 @@ static int ircomm_tty_set_serial_info(struct ircomm_tty_cb *self,
state = self state = self
old_state = *self; old_state = *self;
if (!capable(CAP_SYS_ADMIN)) { if (!capable(CAP_SYS_ADMIN)) {
if ((new_serial.baud_base != state->settings.data_rate) || if ((new_serial.baud_base != state->settings.data_rate) ||
(new_serial.close_delay != state->close_delay) || (new_serial.close_delay != state->close_delay) ||
@ -368,10 +368,10 @@ static int ircomm_tty_set_serial_info(struct ircomm_tty_cb *self,
/* /*
* Function ircomm_tty_ioctl (tty, file, cmd, arg) * Function ircomm_tty_ioctl (tty, file, cmd, arg)
* *
* *
* *
*/ */
int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file, int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data; struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
@ -416,7 +416,7 @@ int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file,
put_user(cnow.brk, &p_cuser->brk) || put_user(cnow.brk, &p_cuser->brk) ||
put_user(cnow.buf_overrun, &p_cuser->buf_overrun)) put_user(cnow.buf_overrun, &p_cuser->buf_overrun))
return -EFAULT; return -EFAULT;
#endif #endif
return 0; return 0;
default: default:
ret = -ENOIOCTLCMD; /* ioctls which we must ignore */ ret = -ENOIOCTLCMD; /* ioctls which we must ignore */

View file

@ -341,11 +341,11 @@ static void irda_task_timer_expired(void *data)
*/ */
static void irda_device_setup(struct net_device *dev) static void irda_device_setup(struct net_device *dev)
{ {
dev->hard_header_len = 0; dev->hard_header_len = 0;
dev->addr_len = LAP_ALEN; dev->addr_len = LAP_ALEN;
dev->type = ARPHRD_IRDA; dev->type = ARPHRD_IRDA;
dev->tx_queue_len = 8; /* Window size + 1 s-frame */ dev->tx_queue_len = 8; /* Window size + 1 s-frame */
memset(dev->broadcast, 0xff, LAP_ALEN); memset(dev->broadcast, 0xff, LAP_ALEN);
@ -354,7 +354,7 @@ static void irda_device_setup(struct net_device *dev)
} }
/* /*
* Funciton alloc_irdadev * Funciton alloc_irdadev
* Allocates and sets up an IRDA device in a manner similar to * Allocates and sets up an IRDA device in a manner similar to
* alloc_etherdev. * alloc_etherdev.
*/ */
@ -386,9 +386,9 @@ dongle_t *irda_device_dongle_init(struct net_device *dev, int type)
/* Try to load the module needed */ /* Try to load the module needed */
if (!reg && capable(CAP_SYS_MODULE)) { if (!reg && capable(CAP_SYS_MODULE)) {
spin_unlock(&dongles->hb_spinlock); spin_unlock(&dongles->hb_spinlock);
request_module("irda-dongle-%d", type); request_module("irda-dongle-%d", type);
spin_lock(&dongles->hb_spinlock); spin_lock(&dongles->hb_spinlock);
reg = hashbin_find(dongles, type, NULL); reg = hashbin_find(dongles, type, NULL);
} }
@ -438,15 +438,15 @@ int irda_device_register_dongle(struct dongle_reg *new)
spin_lock(&dongles->hb_spinlock); spin_lock(&dongles->hb_spinlock);
/* Check if this dongle has been registered before */ /* Check if this dongle has been registered before */
if (hashbin_find(dongles, new->type, NULL)) { if (hashbin_find(dongles, new->type, NULL)) {
IRDA_MESSAGE("%s: Dongle type %x already registered\n", IRDA_MESSAGE("%s: Dongle type %x already registered\n",
__FUNCTION__, new->type); __FUNCTION__, new->type);
} else { } else {
/* Insert IrDA dongle into hashbin */ /* Insert IrDA dongle into hashbin */
hashbin_insert(dongles, (irda_queue_t *) new, new->type, NULL); hashbin_insert(dongles, (irda_queue_t *) new, new->type, NULL);
} }
spin_unlock(&dongles->hb_spinlock); spin_unlock(&dongles->hb_spinlock);
return 0; return 0;
} }
EXPORT_SYMBOL(irda_device_register_dongle); EXPORT_SYMBOL(irda_device_register_dongle);
@ -462,7 +462,7 @@ void irda_device_unregister_dongle(struct dongle_reg *dongle)
spin_lock(&dongles->hb_spinlock); spin_lock(&dongles->hb_spinlock);
node = hashbin_remove(dongles, dongle->type, NULL); node = hashbin_remove(dongles, dongle->type, NULL);
if (!node) if (!node)
IRDA_ERROR("%s: dongle not found!\n", __FUNCTION__); IRDA_ERROR("%s: dongle not found!\n", __FUNCTION__);
spin_unlock(&dongles->hb_spinlock); spin_unlock(&dongles->hb_spinlock);
} }

View file

@ -79,10 +79,10 @@ static int iriap_data_indication(void *instance, void *sap,
static void iriap_watchdog_timer_expired(void *data); static void iriap_watchdog_timer_expired(void *data);
static inline void iriap_start_watchdog_timer(struct iriap_cb *self, static inline void iriap_start_watchdog_timer(struct iriap_cb *self,
int timeout) int timeout)
{ {
irda_start_timer(&self->watchdog_timer, timeout, self, irda_start_timer(&self->watchdog_timer, timeout, self,
iriap_watchdog_timer_expired); iriap_watchdog_timer_expired);
} }
@ -674,7 +674,7 @@ static void iriap_getvaluebyclass_indication(struct iriap_cb *self,
if (attrib == NULL) { if (attrib == NULL) {
IRDA_DEBUG(2, "LM-IAS: Attribute %s not found\n", attr); IRDA_DEBUG(2, "LM-IAS: Attribute %s not found\n", attr);
iriap_getvaluebyclass_response(self, obj->id, iriap_getvaluebyclass_response(self, obj->id,
IAS_ATTRIB_UNKNOWN, IAS_ATTRIB_UNKNOWN,
&irias_missing); &irias_missing);
return; return;
} }
@ -971,7 +971,7 @@ static const char *ias_value_types[] = {
"IAS_STRING" "IAS_STRING"
}; };
static inline struct ias_object *irias_seq_idx(loff_t pos) static inline struct ias_object *irias_seq_idx(loff_t pos)
{ {
struct ias_object *obj; struct ias_object *obj;
@ -980,7 +980,7 @@ static inline struct ias_object *irias_seq_idx(loff_t pos)
if (pos-- == 0) if (pos-- == 0)
break; break;
} }
return obj; return obj;
} }
@ -995,7 +995,7 @@ static void *irias_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{ {
++*pos; ++*pos;
return (v == SEQ_START_TOKEN) return (v == SEQ_START_TOKEN)
? (void *) hashbin_get_first(irias_objects) ? (void *) hashbin_get_first(irias_objects)
: (void *) hashbin_get_next(irias_objects); : (void *) hashbin_get_next(irias_objects);
} }
@ -1027,7 +1027,7 @@ static int irias_seq_show(struct seq_file *seq, void *v)
for (attrib = (struct ias_attrib *) hashbin_get_first(obj->attribs); for (attrib = (struct ias_attrib *) hashbin_get_first(obj->attribs);
attrib != NULL; attrib != NULL;
attrib = (struct ias_attrib *) hashbin_get_next(obj->attribs)) { attrib = (struct ias_attrib *) hashbin_get_next(obj->attribs)) {
IRDA_ASSERT(attrib->magic == IAS_ATTRIB_MAGIC, IRDA_ASSERT(attrib->magic == IAS_ATTRIB_MAGIC,
goto outloop; ); goto outloop; );
@ -1046,14 +1046,14 @@ static int irias_seq_show(struct seq_file *seq, void *v)
attrib->value->t.string); attrib->value->t.string);
break; break;
case IAS_OCT_SEQ: case IAS_OCT_SEQ:
seq_printf(seq, "octet sequence (%d bytes)\n", seq_printf(seq, "octet sequence (%d bytes)\n",
attrib->value->len); attrib->value->len);
break; break;
case IAS_MISSING: case IAS_MISSING:
seq_puts(seq, "missing\n"); seq_puts(seq, "missing\n");
break; break;
default: default:
seq_printf(seq, "type %d?\n", seq_printf(seq, "type %d?\n",
attrib->value->type); attrib->value->type);
} }
seq_putc(seq, '\n'); seq_putc(seq, '\n');

View file

@ -57,8 +57,8 @@ static char *strndup(char *str, size_t max)
len = max; len = max;
/* Allocate new string */ /* Allocate new string */
new_str = kmalloc(len + 1, GFP_ATOMIC); new_str = kmalloc(len + 1, GFP_ATOMIC);
if (new_str == NULL) { if (new_str == NULL) {
IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__); IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__);
return NULL; return NULL;
} }
@ -78,7 +78,7 @@ static char *strndup(char *str, size_t max)
*/ */
struct ias_object *irias_new_object( char *name, int id) struct ias_object *irias_new_object( char *name, int id)
{ {
struct ias_object *obj; struct ias_object *obj;
IRDA_DEBUG( 4, "%s()\n", __FUNCTION__); IRDA_DEBUG( 4, "%s()\n", __FUNCTION__);

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irlan_client.c * Filename: irlan_client.c
* Version: 0.9 * Version: 0.9
* Description: IrDA LAN Access Protocol (IrLAN) Client * Description: IrDA LAN Access Protocol (IrLAN) Client
@ -11,17 +11,17 @@
* Sources: skeleton.c by Donald Becker <becker@CESDIS.gsfc.nasa.gov> * Sources: skeleton.c by Donald Becker <becker@CESDIS.gsfc.nasa.gov>
* slip.c by Laurence Culhane, <loz@holmes.demon.co.uk> * slip.c by Laurence Culhane, <loz@holmes.demon.co.uk>
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* *
* Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>,
* All Rights Reserved. * All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
@ -54,35 +54,35 @@
#undef CONFIG_IRLAN_GRATUITOUS_ARP #undef CONFIG_IRLAN_GRATUITOUS_ARP
static void irlan_client_ctrl_disconnect_indication(void *instance, void *sap, static void irlan_client_ctrl_disconnect_indication(void *instance, void *sap,
LM_REASON reason, LM_REASON reason,
struct sk_buff *); struct sk_buff *);
static int irlan_client_ctrl_data_indication(void *instance, void *sap, static int irlan_client_ctrl_data_indication(void *instance, void *sap,
struct sk_buff *skb); struct sk_buff *skb);
static void irlan_client_ctrl_connect_confirm(void *instance, void *sap, static void irlan_client_ctrl_connect_confirm(void *instance, void *sap,
struct qos_info *qos, struct qos_info *qos,
__u32 max_sdu_size, __u32 max_sdu_size,
__u8 max_header_size, __u8 max_header_size,
struct sk_buff *); struct sk_buff *);
static void irlan_check_response_param(struct irlan_cb *self, char *param, static void irlan_check_response_param(struct irlan_cb *self, char *param,
char *value, int val_len); char *value, int val_len);
static void irlan_client_open_ctrl_tsap(struct irlan_cb *self); static void irlan_client_open_ctrl_tsap(struct irlan_cb *self);
static void irlan_client_kick_timer_expired(void *data) static void irlan_client_kick_timer_expired(void *data)
{ {
struct irlan_cb *self = (struct irlan_cb *) data; struct irlan_cb *self = (struct irlan_cb *) data;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
/* /*
* If we are in peer mode, the client may not have got the discovery * If we are in peer mode, the client may not have got the discovery
* indication it needs to make progress. If the client is still in * indication it needs to make progress. If the client is still in
* IDLE state, we must kick it to, but only if the provider is not IDLE * IDLE state, we must kick it to, but only if the provider is not IDLE
*/ */
if ((self->provider.access_type == ACCESS_PEER) && if ((self->provider.access_type == ACCESS_PEER) &&
(self->client.state == IRLAN_IDLE) && (self->client.state == IRLAN_IDLE) &&
(self->provider.state != IRLAN_IDLE)) { (self->provider.state != IRLAN_IDLE)) {
irlan_client_wakeup(self, self->saddr, self->daddr); irlan_client_wakeup(self, self->saddr, self->daddr);
@ -92,8 +92,8 @@ static void irlan_client_kick_timer_expired(void *data)
static void irlan_client_start_kick_timer(struct irlan_cb *self, int timeout) static void irlan_client_start_kick_timer(struct irlan_cb *self, int timeout)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
irda_start_timer(&self->client.kick_timer, timeout, (void *) self, irda_start_timer(&self->client.kick_timer, timeout, (void *) self,
irlan_client_kick_timer_expired); irlan_client_kick_timer_expired);
} }
@ -110,11 +110,11 @@ void irlan_client_wakeup(struct irlan_cb *self, __u32 saddr, __u32 daddr)
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
/* /*
* Check if we are already awake, or if we are a provider in direct * Check if we are already awake, or if we are a provider in direct
* mode (in that case we must leave the client idle * mode (in that case we must leave the client idle
*/ */
if ((self->client.state != IRLAN_IDLE) || if ((self->client.state != IRLAN_IDLE) ||
(self->provider.access_type == ACCESS_DIRECT)) (self->provider.access_type == ACCESS_DIRECT))
{ {
IRDA_DEBUG(0, "%s(), already awake!\n", __FUNCTION__ ); IRDA_DEBUG(0, "%s(), already awake!\n", __FUNCTION__ );
@ -135,7 +135,7 @@ void irlan_client_wakeup(struct irlan_cb *self, __u32 saddr, __u32 daddr)
irlan_open_data_tsap(self); irlan_open_data_tsap(self);
irlan_do_client_event(self, IRLAN_DISCOVERY_INDICATION, NULL); irlan_do_client_event(self, IRLAN_DISCOVERY_INDICATION, NULL);
/* Start kick timer */ /* Start kick timer */
irlan_client_start_kick_timer(self, 2*HZ); irlan_client_start_kick_timer(self, 2*HZ);
} }
@ -148,11 +148,11 @@ void irlan_client_wakeup(struct irlan_cb *self, __u32 saddr, __u32 daddr)
*/ */
void irlan_client_discovery_indication(discinfo_t *discovery, void irlan_client_discovery_indication(discinfo_t *discovery,
DISCOVERY_MODE mode, DISCOVERY_MODE mode,
void *priv) void *priv)
{ {
struct irlan_cb *self; struct irlan_cb *self;
__u32 saddr, daddr; __u32 saddr, daddr;
IRDA_DEBUG(1, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(1, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(discovery != NULL, return;); IRDA_ASSERT(discovery != NULL, return;);
@ -177,35 +177,35 @@ void irlan_client_discovery_indication(discinfo_t *discovery,
IRDA_DEBUG(1, "%s(), Found instance (%08x)!\n", __FUNCTION__ , IRDA_DEBUG(1, "%s(), Found instance (%08x)!\n", __FUNCTION__ ,
daddr); daddr);
irlan_client_wakeup(self, saddr, daddr); irlan_client_wakeup(self, saddr, daddr);
} }
IRDA_ASSERT_LABEL(out:) IRDA_ASSERT_LABEL(out:)
rcu_read_unlock(); rcu_read_unlock();
} }
/* /*
* Function irlan_client_data_indication (handle, skb) * Function irlan_client_data_indication (handle, skb)
* *
* This function gets the data that is received on the control channel * This function gets the data that is received on the control channel
* *
*/ */
static int irlan_client_ctrl_data_indication(void *instance, void *sap, static int irlan_client_ctrl_data_indication(void *instance, void *sap,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct irlan_cb *self; struct irlan_cb *self;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
self = (struct irlan_cb *) instance; self = (struct irlan_cb *) instance;
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;);
IRDA_ASSERT(skb != NULL, return -1;); IRDA_ASSERT(skb != NULL, return -1;);
irlan_do_client_event(self, IRLAN_DATA_INDICATION, skb);
/* Ready for a new command */ irlan_do_client_event(self, IRLAN_DATA_INDICATION, skb);
/* Ready for a new command */
IRDA_DEBUG(2, "%s(), clearing tx_busy\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), clearing tx_busy\n", __FUNCTION__ );
self->client.tx_busy = FALSE; self->client.tx_busy = FALSE;
@ -215,27 +215,27 @@ static int irlan_client_ctrl_data_indication(void *instance, void *sap,
return 0; return 0;
} }
static void irlan_client_ctrl_disconnect_indication(void *instance, void *sap, static void irlan_client_ctrl_disconnect_indication(void *instance, void *sap,
LM_REASON reason, LM_REASON reason,
struct sk_buff *userdata) struct sk_buff *userdata)
{ {
struct irlan_cb *self; struct irlan_cb *self;
struct tsap_cb *tsap; struct tsap_cb *tsap;
struct sk_buff *skb; struct sk_buff *skb;
IRDA_DEBUG(4, "%s(), reason=%d\n", __FUNCTION__ , reason); IRDA_DEBUG(4, "%s(), reason=%d\n", __FUNCTION__ , reason);
self = (struct irlan_cb *) instance; self = (struct irlan_cb *) instance;
tsap = (struct tsap_cb *) sap; tsap = (struct tsap_cb *) sap;
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
IRDA_ASSERT(tsap != NULL, return;); IRDA_ASSERT(tsap != NULL, return;);
IRDA_ASSERT(tsap->magic == TTP_TSAP_MAGIC, return;); IRDA_ASSERT(tsap->magic == TTP_TSAP_MAGIC, return;);
IRDA_ASSERT(tsap == self->client.tsap_ctrl, return;); IRDA_ASSERT(tsap == self->client.tsap_ctrl, return;);
/* Remove frames queued on the control channel */ /* Remove frames queued on the control channel */
while ((skb = skb_dequeue(&self->client.txq)) != NULL) { while ((skb = skb_dequeue(&self->client.txq)) != NULL) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
} }
@ -272,7 +272,7 @@ static void irlan_client_open_ctrl_tsap(struct irlan_cb *self)
notify.disconnect_indication = irlan_client_ctrl_disconnect_indication; notify.disconnect_indication = irlan_client_ctrl_disconnect_indication;
notify.instance = self; notify.instance = self;
strlcpy(notify.name, "IrLAN ctrl (c)", sizeof(notify.name)); strlcpy(notify.name, "IrLAN ctrl (c)", sizeof(notify.name));
tsap = irttp_open_tsap(LSAP_ANY, DEFAULT_INITIAL_CREDIT, &notify); tsap = irttp_open_tsap(LSAP_ANY, DEFAULT_INITIAL_CREDIT, &notify);
if (!tsap) { if (!tsap) {
IRDA_DEBUG(2, "%s(), Got no tsap!\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), Got no tsap!\n", __FUNCTION__ );
@ -287,11 +287,11 @@ static void irlan_client_open_ctrl_tsap(struct irlan_cb *self)
* Connection to peer IrLAN laye confirmed * Connection to peer IrLAN laye confirmed
* *
*/ */
static void irlan_client_ctrl_connect_confirm(void *instance, void *sap, static void irlan_client_ctrl_connect_confirm(void *instance, void *sap,
struct qos_info *qos, struct qos_info *qos,
__u32 max_sdu_size, __u32 max_sdu_size,
__u8 max_header_size, __u8 max_header_size,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct irlan_cb *self; struct irlan_cb *self;
@ -316,7 +316,7 @@ static void irlan_client_ctrl_connect_confirm(void *instance, void *sap,
* Print return code of request to peer IrLAN layer. * Print return code of request to peer IrLAN layer.
* *
*/ */
static void print_ret_code(__u8 code) static void print_ret_code(__u8 code)
{ {
switch(code) { switch(code) {
case 0: case 0:
@ -358,7 +358,7 @@ static void print_ret_code(__u8 code)
/* /*
* Function irlan_client_parse_response (self, skb) * Function irlan_client_parse_response (self, skb)
* *
* Extract all parameters from received buffer, then feed them to * Extract all parameters from received buffer, then feed them to
* check_params for parsing * check_params for parsing
*/ */
void irlan_client_parse_response(struct irlan_cb *self, struct sk_buff *skb) void irlan_client_parse_response(struct irlan_cb *self, struct sk_buff *skb)
@ -369,30 +369,30 @@ void irlan_client_parse_response(struct irlan_cb *self, struct sk_buff *skb)
int ret; int ret;
__u16 val_len; __u16 val_len;
int i; int i;
char *name; char *name;
char *value; char *value;
IRDA_ASSERT(skb != NULL, return;);
IRDA_ASSERT(skb != NULL, return;);
IRDA_DEBUG(4, "%s() skb->len=%d\n", __FUNCTION__ , (int) skb->len); IRDA_DEBUG(4, "%s() skb->len=%d\n", __FUNCTION__ , (int) skb->len);
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
if (!skb) { if (!skb) {
IRDA_ERROR("%s(), Got NULL skb!\n", __FUNCTION__); IRDA_ERROR("%s(), Got NULL skb!\n", __FUNCTION__);
return; return;
} }
frame = skb->data; frame = skb->data;
/* /*
* Check return code and print it if not success * Check return code and print it if not success
*/ */
if (frame[0]) { if (frame[0]) {
print_ret_code(frame[0]); print_ret_code(frame[0]);
return; return;
} }
name = kmalloc(255, GFP_ATOMIC); name = kmalloc(255, GFP_ATOMIC);
if (!name) if (!name)
return; return;
@ -406,11 +406,11 @@ void irlan_client_parse_response(struct irlan_cb *self, struct sk_buff *skb)
count = frame[1]; count = frame[1];
IRDA_DEBUG(4, "%s(), got %d parameters\n", __FUNCTION__ , count); IRDA_DEBUG(4, "%s(), got %d parameters\n", __FUNCTION__ , count);
ptr = frame+2; ptr = frame+2;
/* For all parameters */ /* For all parameters */
for (i=0; i<count;i++) { for (i=0; i<count;i++) {
ret = irlan_extract_param(ptr, name, value, &val_len); ret = irlan_extract_param(ptr, name, value, &val_len);
if (ret < 0) { if (ret < 0) {
IRDA_DEBUG(2, "%s(), IrLAN, Error!\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), IrLAN, Error!\n", __FUNCTION__ );
@ -418,7 +418,7 @@ void irlan_client_parse_response(struct irlan_cb *self, struct sk_buff *skb)
} }
ptr += ret; ptr += ret;
irlan_check_response_param(self, name, value, val_len); irlan_check_response_param(self, name, value, val_len);
} }
/* Cleanup */ /* Cleanup */
kfree(name); kfree(name);
kfree(value); kfree(value);
@ -430,8 +430,8 @@ void irlan_client_parse_response(struct irlan_cb *self, struct sk_buff *skb)
* Check which parameter is received and update local variables * Check which parameter is received and update local variables
* *
*/ */
static void irlan_check_response_param(struct irlan_cb *self, char *param, static void irlan_check_response_param(struct irlan_cb *self, char *param,
char *value, int val_len) char *value, int val_len)
{ {
__u16 tmp_cpu; /* Temporary value in host order */ __u16 tmp_cpu; /* Temporary value in host order */
__u8 *bytes; __u8 *bytes;
@ -465,7 +465,7 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
self->client.filter_type |= IRLAN_BROADCAST; self->client.filter_type |= IRLAN_BROADCAST;
else if (strcmp(value, "IPX_SOCKET") == 0) else if (strcmp(value, "IPX_SOCKET") == 0)
self->client.filter_type |= IRLAN_IPX_SOCKET; self->client.filter_type |= IRLAN_IPX_SOCKET;
} }
if (strcmp(param, "ACCESS_TYPE") == 0) { if (strcmp(param, "ACCESS_TYPE") == 0) {
if (strcmp(value, "DIRECT") == 0) if (strcmp(value, "DIRECT") == 0)
@ -480,7 +480,7 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
} }
/* IRLAN version */ /* IRLAN version */
if (strcmp(param, "IRLAN_VER") == 0) { if (strcmp(param, "IRLAN_VER") == 0) {
IRDA_DEBUG(4, "IrLAN version %d.%d\n", (__u8) value[0], IRDA_DEBUG(4, "IrLAN version %d.%d\n", (__u8) value[0],
(__u8) value[1]); (__u8) value[1]);
self->version[0] = value[0]; self->version[0] = value[0];
@ -497,17 +497,17 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
memcpy(&tmp_cpu, value, 2); /* Align value */ memcpy(&tmp_cpu, value, 2); /* Align value */
le16_to_cpus(&tmp_cpu); /* Convert to host order */ le16_to_cpus(&tmp_cpu); /* Convert to host order */
self->client.recv_arb_val = tmp_cpu; self->client.recv_arb_val = tmp_cpu;
IRDA_DEBUG(2, "%s(), receive arb val=%d\n", __FUNCTION__ , IRDA_DEBUG(2, "%s(), receive arb val=%d\n", __FUNCTION__ ,
self->client.recv_arb_val); self->client.recv_arb_val);
} }
if (strcmp(param, "MAX_FRAME") == 0) { if (strcmp(param, "MAX_FRAME") == 0) {
memcpy(&tmp_cpu, value, 2); /* Align value */ memcpy(&tmp_cpu, value, 2); /* Align value */
le16_to_cpus(&tmp_cpu); /* Convert to host order */ le16_to_cpus(&tmp_cpu); /* Convert to host order */
self->client.max_frame = tmp_cpu; self->client.max_frame = tmp_cpu;
IRDA_DEBUG(4, "%s(), max frame=%d\n", __FUNCTION__ , IRDA_DEBUG(4, "%s(), max frame=%d\n", __FUNCTION__ ,
self->client.max_frame); self->client.max_frame);
} }
/* RECONNECT_KEY, in case the link goes down! */ /* RECONNECT_KEY, in case the link goes down! */
if (strcmp(param, "RECONNECT_KEY") == 0) { if (strcmp(param, "RECONNECT_KEY") == 0) {
IRDA_DEBUG(4, "Got reconnect key: "); IRDA_DEBUG(4, "Got reconnect key: ");
@ -521,9 +521,9 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
if (strcmp(param, "FILTER_ENTRY") == 0) { if (strcmp(param, "FILTER_ENTRY") == 0) {
bytes = value; bytes = value;
IRDA_DEBUG(4, "Ethernet address = %02x:%02x:%02x:%02x:%02x:%02x\n", IRDA_DEBUG(4, "Ethernet address = %02x:%02x:%02x:%02x:%02x:%02x\n",
bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[0], bytes[1], bytes[2], bytes[3], bytes[4],
bytes[5]); bytes[5]);
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
self->dev->dev_addr[i] = bytes[i]; self->dev->dev_addr[i] = bytes[i];
} }
} }
@ -534,11 +534,11 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
* Got results from remote LM-IAS * Got results from remote LM-IAS
* *
*/ */
void irlan_client_get_value_confirm(int result, __u16 obj_id, void irlan_client_get_value_confirm(int result, __u16 obj_id,
struct ias_value *value, void *priv) struct ias_value *value, void *priv)
{ {
struct irlan_cb *self; struct irlan_cb *self;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(priv != NULL, return;); IRDA_ASSERT(priv != NULL, return;);
@ -553,7 +553,7 @@ void irlan_client_get_value_confirm(int result, __u16 obj_id,
/* Check if request succeeded */ /* Check if request succeeded */
if (result != IAS_SUCCESS) { if (result != IAS_SUCCESS) {
IRDA_DEBUG(2, "%s(), got NULL value!\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), got NULL value!\n", __FUNCTION__ );
irlan_do_client_event(self, IRLAN_IAS_PROVIDER_NOT_AVAIL, irlan_do_client_event(self, IRLAN_IAS_PROVIDER_NOT_AVAIL,
NULL); NULL);
return; return;
} }

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irlan_client_event.c * Filename: irlan_client_event.c
* Version: 0.9 * Version: 0.9
* Description: IrLAN client state machine * Description: IrLAN client state machine
@ -8,17 +8,17 @@
* Created at: Sun Aug 31 20:14:37 1997 * Created at: Sun Aug 31 20:14:37 1997
* Modified at: Sun Dec 26 21:52:24 1999 * Modified at: Sun Dec 26 21:52:24 1999
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>,
* All Rights Reserved. * All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
@ -36,31 +36,31 @@
#include <net/irda/irlan_client.h> #include <net/irda/irlan_client.h>
#include <net/irda/irlan_event.h> #include <net/irda/irlan_event.h>
static int irlan_client_state_idle (struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_idle (struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int irlan_client_state_conn (struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_conn (struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int irlan_client_state_info (struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_info (struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int irlan_client_state_media(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_media(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int irlan_client_state_open (struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_open (struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int irlan_client_state_wait (struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_wait (struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int irlan_client_state_arb (struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_arb (struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int irlan_client_state_data (struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_data (struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int irlan_client_state_close(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_close(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int irlan_client_state_sync (struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_sync (struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int (*state[])(struct irlan_cb *, IRLAN_EVENT event, struct sk_buff *) = static int (*state[])(struct irlan_cb *, IRLAN_EVENT event, struct sk_buff *) =
{ {
irlan_client_state_idle, irlan_client_state_idle,
irlan_client_state_query, irlan_client_state_query,
irlan_client_state_conn, irlan_client_state_conn,
@ -74,8 +74,8 @@ static int (*state[])(struct irlan_cb *, IRLAN_EVENT event, struct sk_buff *) =
irlan_client_state_sync irlan_client_state_sync
}; };
void irlan_do_client_event(struct irlan_cb *self, IRLAN_EVENT event, void irlan_do_client_event(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
@ -89,14 +89,14 @@ void irlan_do_client_event(struct irlan_cb *self, IRLAN_EVENT event,
* IDLE, We are waiting for an indication that there is a provider * IDLE, We are waiting for an indication that there is a provider
* available. * available.
*/ */
static int irlan_client_state_idle(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;);
switch (event) { switch (event) {
case IRLAN_DISCOVERY_INDICATION: case IRLAN_DISCOVERY_INDICATION:
if (self->client.iriap) { if (self->client.iriap) {
@ -104,7 +104,7 @@ static int irlan_client_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
__FUNCTION__); __FUNCTION__);
return -EBUSY; return -EBUSY;
} }
self->client.iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self, self->client.iriap = iriap_open(LSAP_ANY, IAS_CLIENT, self,
irlan_client_get_value_confirm); irlan_client_get_value_confirm);
/* Get some values from peer IAS */ /* Get some values from peer IAS */
@ -120,7 +120,7 @@ static int irlan_client_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
IRDA_DEBUG(4, "%s(), Unknown event %d\n", __FUNCTION__ , event); IRDA_DEBUG(4, "%s(), Unknown event %d\n", __FUNCTION__ , event);
break; break;
} }
if (skb) if (skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
@ -133,23 +133,23 @@ static int irlan_client_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
* to provider, just waiting for the confirm. * to provider, just waiting for the confirm.
* *
*/ */
static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;);
switch(event) { switch(event) {
case IRLAN_IAS_PROVIDER_AVAIL: case IRLAN_IAS_PROVIDER_AVAIL:
IRDA_ASSERT(self->dtsap_sel_ctrl != 0, return -1;); IRDA_ASSERT(self->dtsap_sel_ctrl != 0, return -1;);
self->client.open_retries = 0; self->client.open_retries = 0;
irttp_connect_request(self->client.tsap_ctrl, irttp_connect_request(self->client.tsap_ctrl,
self->dtsap_sel_ctrl, self->dtsap_sel_ctrl,
self->saddr, self->daddr, NULL, self->saddr, self->daddr, NULL,
IRLAN_MTU, NULL); IRLAN_MTU, NULL);
irlan_next_client_state(self, IRLAN_CONN); irlan_next_client_state(self, IRLAN_CONN);
break; break;
@ -158,7 +158,7 @@ static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event,
irlan_next_client_state(self, IRLAN_IDLE); irlan_next_client_state(self, IRLAN_IDLE);
/* Give the client a kick! */ /* Give the client a kick! */
if ((self->provider.access_type == ACCESS_PEER) && if ((self->provider.access_type == ACCESS_PEER) &&
(self->provider.state != IRLAN_IDLE)) (self->provider.state != IRLAN_IDLE))
irlan_client_wakeup(self, self->saddr, self->daddr); irlan_client_wakeup(self, self->saddr, self->daddr);
break; break;
@ -175,7 +175,7 @@ static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event,
} }
if (skb) if (skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
} }
@ -186,13 +186,13 @@ static int irlan_client_state_query(struct irlan_cb *self, IRLAN_EVENT event,
* commands yet. * commands yet.
* *
*/ */
static int irlan_client_state_conn(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_conn(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
switch (event) { switch (event) {
case IRLAN_CONNECT_COMPLETE: case IRLAN_CONNECT_COMPLETE:
/* Send getinfo cmd */ /* Send getinfo cmd */
@ -212,7 +212,7 @@ static int irlan_client_state_conn(struct irlan_cb *self, IRLAN_EVENT event,
} }
if (skb) if (skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
} }
@ -221,24 +221,24 @@ static int irlan_client_state_conn(struct irlan_cb *self, IRLAN_EVENT event,
* *
* INFO, We have issued a GetInfo command and is awaiting a reply. * INFO, We have issued a GetInfo command and is awaiting a reply.
*/ */
static int irlan_client_state_info(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_info(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
switch (event) { switch (event) {
case IRLAN_DATA_INDICATION: case IRLAN_DATA_INDICATION:
IRDA_ASSERT(skb != NULL, return -1;); IRDA_ASSERT(skb != NULL, return -1;);
irlan_client_parse_response(self, skb); irlan_client_parse_response(self, skb);
irlan_next_client_state(self, IRLAN_MEDIA); irlan_next_client_state(self, IRLAN_MEDIA);
irlan_get_media_char(self); irlan_get_media_char(self);
break; break;
case IRLAN_LMP_DISCONNECT: case IRLAN_LMP_DISCONNECT:
case IRLAN_LAP_DISCONNECT: case IRLAN_LAP_DISCONNECT:
irlan_next_client_state(self, IRLAN_IDLE); irlan_next_client_state(self, IRLAN_IDLE);
@ -252,7 +252,7 @@ static int irlan_client_state_info(struct irlan_cb *self, IRLAN_EVENT event,
} }
if (skb) if (skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
} }
@ -263,11 +263,11 @@ static int irlan_client_state_info(struct irlan_cb *self, IRLAN_EVENT event,
* reply. * reply.
* *
*/ */
static int irlan_client_state_media(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_media(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
switch(event) { switch(event) {
@ -289,7 +289,7 @@ static int irlan_client_state_media(struct irlan_cb *self, IRLAN_EVENT event,
} }
if (skb) if (skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
} }
@ -300,47 +300,47 @@ static int irlan_client_state_media(struct irlan_cb *self, IRLAN_EVENT event,
* reply * reply
* *
*/ */
static int irlan_client_state_open(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_open(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct qos_info qos; struct qos_info qos;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
switch(event) { switch(event) {
case IRLAN_DATA_INDICATION: case IRLAN_DATA_INDICATION:
irlan_client_parse_response(self, skb); irlan_client_parse_response(self, skb);
/* /*
* Check if we have got the remote TSAP for data * Check if we have got the remote TSAP for data
* communications * communications
*/ */
IRDA_ASSERT(self->dtsap_sel_data != 0, return -1;); IRDA_ASSERT(self->dtsap_sel_data != 0, return -1;);
/* Check which access type we are dealing with */ /* Check which access type we are dealing with */
switch (self->client.access_type) { switch (self->client.access_type) {
case ACCESS_PEER: case ACCESS_PEER:
if (self->provider.state == IRLAN_OPEN) { if (self->provider.state == IRLAN_OPEN) {
irlan_next_client_state(self, IRLAN_ARB); irlan_next_client_state(self, IRLAN_ARB);
irlan_do_client_event(self, IRLAN_CHECK_CON_ARB, irlan_do_client_event(self, IRLAN_CHECK_CON_ARB,
NULL); NULL);
} else { } else {
irlan_next_client_state(self, IRLAN_WAIT); irlan_next_client_state(self, IRLAN_WAIT);
} }
break; break;
case ACCESS_DIRECT: case ACCESS_DIRECT:
case ACCESS_HOSTED: case ACCESS_HOSTED:
qos.link_disc_time.bits = 0x01; /* 3 secs */ qos.link_disc_time.bits = 0x01; /* 3 secs */
irttp_connect_request(self->tsap_data, irttp_connect_request(self->tsap_data,
self->dtsap_sel_data, self->dtsap_sel_data,
self->saddr, self->daddr, &qos, self->saddr, self->daddr, &qos,
IRLAN_MTU, NULL); IRLAN_MTU, NULL);
irlan_next_client_state(self, IRLAN_DATA); irlan_next_client_state(self, IRLAN_DATA);
break; break;
default: default:
@ -359,7 +359,7 @@ static int irlan_client_state_open(struct irlan_cb *self, IRLAN_EVENT event,
IRDA_DEBUG(2, "%s(), Unknown event %d\n", __FUNCTION__ , event); IRDA_DEBUG(2, "%s(), Unknown event %d\n", __FUNCTION__ , event);
break; break;
} }
if (skb) if (skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
@ -373,13 +373,13 @@ static int irlan_client_state_open(struct irlan_cb *self, IRLAN_EVENT event,
* provider OPEN state. * provider OPEN state.
* *
*/ */
static int irlan_client_state_wait(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_wait(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
switch(event) { switch(event) {
case IRLAN_PROVIDER_SIGNAL: case IRLAN_PROVIDER_SIGNAL:
irlan_next_client_state(self, IRLAN_ARB); irlan_next_client_state(self, IRLAN_ARB);
@ -398,36 +398,36 @@ static int irlan_client_state_wait(struct irlan_cb *self, IRLAN_EVENT event,
} }
if (skb) if (skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
} }
static int irlan_client_state_arb(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_arb(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct qos_info qos; struct qos_info qos;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
switch(event) { switch(event) {
case IRLAN_CHECK_CON_ARB: case IRLAN_CHECK_CON_ARB:
if (self->client.recv_arb_val == self->provider.send_arb_val) { if (self->client.recv_arb_val == self->provider.send_arb_val) {
irlan_next_client_state(self, IRLAN_CLOSE); irlan_next_client_state(self, IRLAN_CLOSE);
irlan_close_data_channel(self); irlan_close_data_channel(self);
} else if (self->client.recv_arb_val < } else if (self->client.recv_arb_val <
self->provider.send_arb_val) self->provider.send_arb_val)
{ {
qos.link_disc_time.bits = 0x01; /* 3 secs */ qos.link_disc_time.bits = 0x01; /* 3 secs */
irlan_next_client_state(self, IRLAN_DATA); irlan_next_client_state(self, IRLAN_DATA);
irttp_connect_request(self->tsap_data, irttp_connect_request(self->tsap_data,
self->dtsap_sel_data, self->dtsap_sel_data,
self->saddr, self->daddr, &qos, self->saddr, self->daddr, &qos,
IRLAN_MTU, NULL); IRLAN_MTU, NULL);
} else if (self->client.recv_arb_val > } else if (self->client.recv_arb_val >
self->provider.send_arb_val) self->provider.send_arb_val)
{ {
IRDA_DEBUG(2, "%s(), lost the battle :-(\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), lost the battle :-(\n", __FUNCTION__ );
} }
@ -448,7 +448,7 @@ static int irlan_client_state_arb(struct irlan_cb *self, IRLAN_EVENT event,
} }
if (skb) if (skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
} }
@ -459,8 +459,8 @@ static int irlan_client_state_arb(struct irlan_cb *self, IRLAN_EVENT event,
* the local and remote machines. * the local and remote machines.
* *
*/ */
static int irlan_client_state_data(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_data(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
@ -470,7 +470,7 @@ static int irlan_client_state_data(struct irlan_cb *self, IRLAN_EVENT event,
switch(event) { switch(event) {
case IRLAN_DATA_INDICATION: case IRLAN_DATA_INDICATION:
irlan_client_parse_response(self, skb); irlan_client_parse_response(self, skb);
break; break;
case IRLAN_LMP_DISCONNECT: /* FALLTHROUGH */ case IRLAN_LMP_DISCONNECT: /* FALLTHROUGH */
case IRLAN_LAP_DISCONNECT: case IRLAN_LAP_DISCONNECT:
irlan_next_client_state(self, IRLAN_IDLE); irlan_next_client_state(self, IRLAN_IDLE);
@ -481,18 +481,18 @@ static int irlan_client_state_data(struct irlan_cb *self, IRLAN_EVENT event,
} }
if (skb) if (skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
} }
/* /*
* Function irlan_client_state_close (self, event, skb, info) * Function irlan_client_state_close (self, event, skb, info)
* *
* *
* *
*/ */
static int irlan_client_state_close(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_close(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
@ -505,17 +505,17 @@ static int irlan_client_state_close(struct irlan_cb *self, IRLAN_EVENT event,
/* /*
* Function irlan_client_state_sync (self, event, skb, info) * Function irlan_client_state_sync (self, event, skb, info)
* *
* *
* *
*/ */
static int irlan_client_state_sync(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_client_state_sync(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
if (skb) if (skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
} }

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irlan_common.c * Filename: irlan_common.c
* Version: 0.9 * Version: 0.9
* Description: IrDA LAN Access Protocol Implementation * Description: IrDA LAN Access Protocol Implementation
@ -8,17 +8,17 @@
* Created at: Sun Aug 31 20:14:37 1997 * Created at: Sun Aug 31 20:14:37 1997
* Modified at: Sun Dec 26 21:53:10 1999 * Modified at: Sun Dec 26 21:53:10 1999
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>, * Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>,
* All Rights Reserved. * All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
@ -49,12 +49,12 @@
#include <net/irda/irlan_common.h> #include <net/irda/irlan_common.h>
#include <net/irda/irlan_client.h> #include <net/irda/irlan_client.h>
#include <net/irda/irlan_provider.h> #include <net/irda/irlan_provider.h>
#include <net/irda/irlan_eth.h> #include <net/irda/irlan_eth.h>
#include <net/irda/irlan_filter.h> #include <net/irda/irlan_filter.h>
/* /*
* Send gratuitous ARP when connected to a new AP or not. May be a clever * Send gratuitous ARP when connected to a new AP or not. May be a clever
* thing to do, but for some reason the machine crashes if you use DHCP. So * thing to do, but for some reason the machine crashes if you use DHCP. So
* lets not use it by default. * lets not use it by default.
@ -106,8 +106,8 @@ extern struct proc_dir_entry *proc_irda;
static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr); static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr);
static void __irlan_close(struct irlan_cb *self); static void __irlan_close(struct irlan_cb *self);
static int __irlan_insert_param(struct sk_buff *skb, char *param, int type, static int __irlan_insert_param(struct sk_buff *skb, char *param, int type,
__u8 value_byte, __u16 value_short, __u8 value_byte, __u16 value_short,
__u8 *value_array, __u16 value_len); __u8 *value_array, __u16 value_len);
static void irlan_open_unicast_addr(struct irlan_cb *self); static void irlan_open_unicast_addr(struct irlan_cb *self);
static void irlan_get_unicast_addr(struct irlan_cb *self); static void irlan_get_unicast_addr(struct irlan_cb *self);
@ -177,7 +177,7 @@ err_ckey:
return -ENOMEM; return -ENOMEM;
} }
static void __exit irlan_cleanup(void) static void __exit irlan_cleanup(void)
{ {
struct irlan_cb *self, *next; struct irlan_cb *self, *next;
@ -201,7 +201,7 @@ static void __exit irlan_cleanup(void)
/* /*
* Function irlan_open (void) * Function irlan_open (void)
* *
* Open new instance of a client/provider, we should only register the * Open new instance of a client/provider, we should only register the
* network device if this instance is ment for a particular client/provider * network device if this instance is ment for a particular client/provider
*/ */
static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr) static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
@ -229,9 +229,9 @@ static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
/* Provider access can only be PEER, DIRECT, or HOSTED */ /* Provider access can only be PEER, DIRECT, or HOSTED */
self->provider.access_type = access; self->provider.access_type = access;
if (access == ACCESS_DIRECT) { if (access == ACCESS_DIRECT) {
/* /*
* Since we are emulating an IrLAN sever we will have to * Since we are emulating an IrLAN sever we will have to
* give ourself an ethernet address! * give ourself an ethernet address!
*/ */
dev->dev_addr[0] = 0x40; dev->dev_addr[0] = 0x40;
dev->dev_addr[1] = 0x00; dev->dev_addr[1] = 0x00;
@ -245,15 +245,15 @@ static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
self->disconnect_reason = LM_USER_REQUEST; self->disconnect_reason = LM_USER_REQUEST;
init_timer(&self->watchdog_timer); init_timer(&self->watchdog_timer);
init_timer(&self->client.kick_timer); init_timer(&self->client.kick_timer);
init_waitqueue_head(&self->open_wait); init_waitqueue_head(&self->open_wait);
skb_queue_head_init(&self->client.txq); skb_queue_head_init(&self->client.txq);
irlan_next_client_state(self, IRLAN_IDLE); irlan_next_client_state(self, IRLAN_IDLE);
irlan_next_provider_state(self, IRLAN_IDLE); irlan_next_provider_state(self, IRLAN_IDLE);
if (register_netdev(dev)) { if (register_netdev(dev)) {
IRDA_DEBUG(2, "%s(), register_netdev() failed!\n", IRDA_DEBUG(2, "%s(), register_netdev() failed!\n",
__FUNCTION__ ); __FUNCTION__ );
self = NULL; self = NULL;
free_netdev(dev); free_netdev(dev);
@ -268,14 +268,14 @@ static struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
/* /*
* Function __irlan_close (self) * Function __irlan_close (self)
* *
* This function closes and deallocates the IrLAN client instances. Be * This function closes and deallocates the IrLAN client instances. Be
* aware that other functions which calls client_close() must * aware that other functions which calls client_close() must
* remove self from irlans list first. * remove self from irlans list first.
*/ */
static void __irlan_close(struct irlan_cb *self) static void __irlan_close(struct irlan_cb *self)
{ {
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
ASSERT_RTNL(); ASSERT_RTNL();
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
@ -285,8 +285,8 @@ static void __irlan_close(struct irlan_cb *self)
/* Close all open connections and remove TSAPs */ /* Close all open connections and remove TSAPs */
irlan_close_tsaps(self); irlan_close_tsaps(self);
if (self->client.iriap) if (self->client.iriap)
iriap_close(self->client.iriap); iriap_close(self->client.iriap);
/* Remove frames queued on the control channel */ /* Remove frames queued on the control channel */
@ -316,17 +316,17 @@ struct irlan_cb *irlan_get_any(void)
static void irlan_connect_indication(void *instance, void *sap, static void irlan_connect_indication(void *instance, void *sap,
struct qos_info *qos, struct qos_info *qos,
__u32 max_sdu_size, __u32 max_sdu_size,
__u8 max_header_size, __u8 max_header_size,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct irlan_cb *self; struct irlan_cb *self;
struct tsap_cb *tsap; struct tsap_cb *tsap;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
self = (struct irlan_cb *) instance; self = (struct irlan_cb *) instance;
tsap = (struct tsap_cb *) sap; tsap = (struct tsap_cb *) sap;
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
IRDA_ASSERT(tsap == self->tsap_data,return;); IRDA_ASSERT(tsap == self->tsap_data,return;);
@ -349,9 +349,9 @@ static void irlan_connect_indication(void *instance, void *sap,
irlan_do_client_event(self, IRLAN_DATA_CONNECT_INDICATION, NULL); irlan_do_client_event(self, IRLAN_DATA_CONNECT_INDICATION, NULL);
if (self->provider.access_type == ACCESS_PEER) { if (self->provider.access_type == ACCESS_PEER) {
/* /*
* Data channel is open, so we are now allowed to * Data channel is open, so we are now allowed to
* configure the remote filter * configure the remote filter
*/ */
irlan_get_unicast_addr(self); irlan_get_unicast_addr(self);
irlan_open_unicast_addr(self); irlan_open_unicast_addr(self);
@ -361,10 +361,10 @@ static void irlan_connect_indication(void *instance, void *sap,
} }
static void irlan_connect_confirm(void *instance, void *sap, static void irlan_connect_confirm(void *instance, void *sap,
struct qos_info *qos, struct qos_info *qos,
__u32 max_sdu_size, __u32 max_sdu_size,
__u8 max_header_size, __u8 max_header_size,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct irlan_cb *self; struct irlan_cb *self;
@ -381,16 +381,16 @@ static void irlan_connect_confirm(void *instance, void *sap,
IRDA_DEBUG(0, "%s: We are now connected!\n", __FUNCTION__); IRDA_DEBUG(0, "%s: We are now connected!\n", __FUNCTION__);
del_timer(&self->watchdog_timer); del_timer(&self->watchdog_timer);
/* /*
* Data channel is open, so we are now allowed to configure the remote * Data channel is open, so we are now allowed to configure the remote
* filter * filter
*/ */
irlan_get_unicast_addr(self); irlan_get_unicast_addr(self);
irlan_open_unicast_addr(self); irlan_open_unicast_addr(self);
/* Open broadcast and multicast filter by default */ /* Open broadcast and multicast filter by default */
irlan_set_broadcast_filter(self, TRUE); irlan_set_broadcast_filter(self, TRUE);
irlan_set_multicast_filter(self, TRUE); irlan_set_multicast_filter(self, TRUE);
/* Ready to transfer Ethernet frames */ /* Ready to transfer Ethernet frames */
netif_start_queue(self->dev); netif_start_queue(self->dev);
@ -408,29 +408,29 @@ static void irlan_connect_confirm(void *instance, void *sap,
* the specified connection (handle) * the specified connection (handle)
*/ */
static void irlan_disconnect_indication(void *instance, static void irlan_disconnect_indication(void *instance,
void *sap, LM_REASON reason, void *sap, LM_REASON reason,
struct sk_buff *userdata) struct sk_buff *userdata)
{ {
struct irlan_cb *self; struct irlan_cb *self;
struct tsap_cb *tsap; struct tsap_cb *tsap;
IRDA_DEBUG(0, "%s(), reason=%d\n", __FUNCTION__ , reason); IRDA_DEBUG(0, "%s(), reason=%d\n", __FUNCTION__ , reason);
self = (struct irlan_cb *) instance; self = (struct irlan_cb *) instance;
tsap = (struct tsap_cb *) sap; tsap = (struct tsap_cb *) sap;
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
IRDA_ASSERT(tsap != NULL, return;); IRDA_ASSERT(tsap != NULL, return;);
IRDA_ASSERT(tsap->magic == TTP_TSAP_MAGIC, return;); IRDA_ASSERT(tsap->magic == TTP_TSAP_MAGIC, return;);
IRDA_ASSERT(tsap == self->tsap_data, return;); IRDA_ASSERT(tsap == self->tsap_data, return;);
IRDA_DEBUG(2, "IrLAN, data channel disconnected by peer!\n"); IRDA_DEBUG(2, "IrLAN, data channel disconnected by peer!\n");
/* Save reason so we know if we should try to reconnect or not */ /* Save reason so we know if we should try to reconnect or not */
self->disconnect_reason = reason; self->disconnect_reason = reason;
switch (reason) { switch (reason) {
case LM_USER_REQUEST: /* User request */ case LM_USER_REQUEST: /* User request */
IRDA_DEBUG(2, "%s(), User requested\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), User requested\n", __FUNCTION__ );
@ -451,7 +451,7 @@ static void irlan_disconnect_indication(void *instance,
IRDA_ERROR("%s(), Unknown disconnect reason\n", __FUNCTION__); IRDA_ERROR("%s(), Unknown disconnect reason\n", __FUNCTION__);
break; break;
} }
/* If you want to pass the skb to *both* state machines, you will /* If you want to pass the skb to *both* state machines, you will
* need to skb_clone() it, so that you don't free it twice. * need to skb_clone() it, so that you don't free it twice.
* As the state machines don't need it, git rid of it here... * As the state machines don't need it, git rid of it here...
@ -461,7 +461,7 @@ static void irlan_disconnect_indication(void *instance,
irlan_do_client_event(self, IRLAN_LMP_DISCONNECT, NULL); irlan_do_client_event(self, IRLAN_LMP_DISCONNECT, NULL);
irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL); irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL);
wake_up_interruptible(&self->open_wait); wake_up_interruptible(&self->open_wait);
} }
@ -480,12 +480,12 @@ void irlan_open_data_tsap(struct irlan_cb *self)
return; return;
irda_notify_init(&notify); irda_notify_init(&notify);
notify.data_indication = irlan_eth_receive; notify.data_indication = irlan_eth_receive;
notify.udata_indication = irlan_eth_receive; notify.udata_indication = irlan_eth_receive;
notify.connect_indication = irlan_connect_indication; notify.connect_indication = irlan_connect_indication;
notify.connect_confirm = irlan_connect_confirm; notify.connect_confirm = irlan_connect_confirm;
notify.flow_indication = irlan_eth_flow_indication; notify.flow_indication = irlan_eth_flow_indication;
notify.disconnect_indication = irlan_disconnect_indication; notify.disconnect_indication = irlan_disconnect_indication;
notify.instance = self; notify.instance = self;
strlcpy(notify.name, "IrLAN data", sizeof(notify.name)); strlcpy(notify.name, "IrLAN data", sizeof(notify.name));
@ -497,7 +497,7 @@ void irlan_open_data_tsap(struct irlan_cb *self)
} }
self->tsap_data = tsap; self->tsap_data = tsap;
/* /*
* This is the data TSAP selector which we will pass to the client * This is the data TSAP selector which we will pass to the client
* when the client ask for it. * when the client ask for it.
*/ */
@ -518,13 +518,13 @@ void irlan_close_tsaps(struct irlan_cb *self)
self->tsap_data = NULL; self->tsap_data = NULL;
} }
if (self->client.tsap_ctrl) { if (self->client.tsap_ctrl) {
irttp_disconnect_request(self->client.tsap_ctrl, NULL, irttp_disconnect_request(self->client.tsap_ctrl, NULL,
P_NORMAL); P_NORMAL);
irttp_close_tsap(self->client.tsap_ctrl); irttp_close_tsap(self->client.tsap_ctrl);
self->client.tsap_ctrl = NULL; self->client.tsap_ctrl = NULL;
} }
if (self->provider.tsap_ctrl) { if (self->provider.tsap_ctrl) {
irttp_disconnect_request(self->provider.tsap_ctrl, NULL, irttp_disconnect_request(self->provider.tsap_ctrl, NULL,
P_NORMAL); P_NORMAL);
irttp_close_tsap(self->provider.tsap_ctrl); irttp_close_tsap(self->provider.tsap_ctrl);
self->provider.tsap_ctrl = NULL; self->provider.tsap_ctrl = NULL;
@ -545,8 +545,8 @@ void irlan_ias_register(struct irlan_cb *self, __u8 tsap_sel)
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
/* /*
* Check if object has already been registered by a previous provider. * Check if object has already been registered by a previous provider.
* If that is the case, we just change the value of the attribute * If that is the case, we just change the value of the attribute
*/ */
@ -560,9 +560,9 @@ void irlan_ias_register(struct irlan_cb *self, __u8 tsap_sel)
irias_object_change_attribute("IrLAN", "IrDA:TinyTP:LsapSel", irias_object_change_attribute("IrLAN", "IrDA:TinyTP:LsapSel",
new_value); new_value);
} }
/* Register PnP object only if not registered before */ /* Register PnP object only if not registered before */
if (!irias_find_object("PnP")) { if (!irias_find_object("PnP")) {
obj = irias_new_object("PnP", IAS_PNP_ID); obj = irias_new_object("PnP", IAS_PNP_ID);
#if 0 #if 0
irias_add_string_attrib(obj, "Name", sysctl_devname, irias_add_string_attrib(obj, "Name", sysctl_devname,
@ -606,10 +606,10 @@ int irlan_run_ctrl_tx_queue(struct irlan_cb *self)
self->client.tx_busy = FALSE; self->client.tx_busy = FALSE;
return 0; return 0;
} }
/* Check that it's really possible to send commands */ /* Check that it's really possible to send commands */
if ((self->client.tsap_ctrl == NULL) || if ((self->client.tsap_ctrl == NULL) ||
(self->client.state == IRLAN_IDLE)) (self->client.state == IRLAN_IDLE))
{ {
self->client.tx_busy = FALSE; self->client.tx_busy = FALSE;
dev_kfree_skb(skb); dev_kfree_skb(skb);
@ -649,7 +649,7 @@ void irlan_get_provider_info(struct irlan_cb *self)
__u8 *frame; __u8 *frame;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
@ -661,12 +661,12 @@ void irlan_get_provider_info(struct irlan_cb *self)
/* Reserve space for TTP, LMP, and LAP header */ /* Reserve space for TTP, LMP, and LAP header */
skb_reserve(skb, self->client.max_header_size); skb_reserve(skb, self->client.max_header_size);
skb_put(skb, 2); skb_put(skb, 2);
frame = skb->data; frame = skb->data;
frame[0] = CMD_GET_PROVIDER_INFO; frame[0] = CMD_GET_PROVIDER_INFO;
frame[1] = 0x00; /* Zero parameters */ frame[1] = 0x00; /* Zero parameters */
irlan_ctrl_data_request(self, skb); irlan_ctrl_data_request(self, skb);
} }
@ -676,16 +676,16 @@ void irlan_get_provider_info(struct irlan_cb *self)
* Send an Open Data Command to provider * Send an Open Data Command to provider
* *
*/ */
void irlan_open_data_channel(struct irlan_cb *self) void irlan_open_data_channel(struct irlan_cb *self)
{ {
struct sk_buff *skb; struct sk_buff *skb;
__u8 *frame; __u8 *frame;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3") + IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3") +
IRLAN_STRING_PARAMETER_LEN("ACCESS_TYPE", "DIRECT"), IRLAN_STRING_PARAMETER_LEN("ACCESS_TYPE", "DIRECT"),
@ -695,11 +695,11 @@ void irlan_open_data_channel(struct irlan_cb *self)
skb_reserve(skb, self->client.max_header_size); skb_reserve(skb, self->client.max_header_size);
skb_put(skb, 2); skb_put(skb, 2);
frame = skb->data; frame = skb->data;
/* Build frame */ /* Build frame */
frame[0] = CMD_OPEN_DATA_CHANNEL; frame[0] = CMD_OPEN_DATA_CHANNEL;
frame[1] = 0x02; /* Two parameters */ frame[1] = 0x02; /* Two parameters */
irlan_insert_string_param(skb, "MEDIA", "802.3"); irlan_insert_string_param(skb, "MEDIA", "802.3");
@ -711,11 +711,11 @@ void irlan_open_data_channel(struct irlan_cb *self)
irlan_ctrl_data_request(self, skb); irlan_ctrl_data_request(self, skb);
} }
void irlan_close_data_channel(struct irlan_cb *self) void irlan_close_data_channel(struct irlan_cb *self)
{ {
struct sk_buff *skb; struct sk_buff *skb;
__u8 *frame; __u8 *frame;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
@ -733,11 +733,11 @@ void irlan_close_data_channel(struct irlan_cb *self)
skb_reserve(skb, self->client.max_header_size); skb_reserve(skb, self->client.max_header_size);
skb_put(skb, 2); skb_put(skb, 2);
frame = skb->data; frame = skb->data;
/* Build frame */ /* Build frame */
frame[0] = CMD_CLOSE_DATA_CHAN; frame[0] = CMD_CLOSE_DATA_CHAN;
frame[1] = 0x01; /* One parameter */ frame[1] = 0x01; /* One parameter */
irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data); irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
@ -748,7 +748,7 @@ void irlan_close_data_channel(struct irlan_cb *self)
/* /*
* Function irlan_open_unicast_addr (self) * Function irlan_open_unicast_addr (self)
* *
* Make IrLAN provider accept ethernet frames addressed to the unicast * Make IrLAN provider accept ethernet frames addressed to the unicast
* address. * address.
* *
*/ */
@ -756,12 +756,12 @@ static void irlan_open_unicast_addr(struct irlan_cb *self)
{ {
struct sk_buff *skb; struct sk_buff *skb;
__u8 *frame; __u8 *frame;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") + IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") + IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") +
@ -773,15 +773,15 @@ static void irlan_open_unicast_addr(struct irlan_cb *self)
/* Reserve space for TTP, LMP, and LAP header */ /* Reserve space for TTP, LMP, and LAP header */
skb_reserve(skb, self->max_header_size); skb_reserve(skb, self->max_header_size);
skb_put(skb, 2); skb_put(skb, 2);
frame = skb->data; frame = skb->data;
frame[0] = CMD_FILTER_OPERATION; frame[0] = CMD_FILTER_OPERATION;
frame[1] = 0x03; /* Three parameters */ frame[1] = 0x03; /* Three parameters */
irlan_insert_byte_param(skb, "DATA_CHAN" , self->dtsap_sel_data); irlan_insert_byte_param(skb, "DATA_CHAN" , self->dtsap_sel_data);
irlan_insert_string_param(skb, "FILTER_TYPE", "DIRECTED"); irlan_insert_string_param(skb, "FILTER_TYPE", "DIRECTED");
irlan_insert_string_param(skb, "FILTER_MODE", "FILTER"); irlan_insert_string_param(skb, "FILTER_MODE", "FILTER");
irlan_ctrl_data_request(self, skb); irlan_ctrl_data_request(self, skb);
} }
@ -794,17 +794,17 @@ static void irlan_open_unicast_addr(struct irlan_cb *self)
* one but then _we_ have to initiate all communication with other * one but then _we_ have to initiate all communication with other
* hosts, since ARP request for this host will not be answered. * hosts, since ARP request for this host will not be answered.
*/ */
void irlan_set_broadcast_filter(struct irlan_cb *self, int status) void irlan_set_broadcast_filter(struct irlan_cb *self, int status)
{ {
struct sk_buff *skb; struct sk_buff *skb;
__u8 *frame; __u8 *frame;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") + IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "BROADCAST") + IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "BROADCAST") +
/* We may waste one byte here...*/ /* We may waste one byte here...*/
@ -816,17 +816,17 @@ void irlan_set_broadcast_filter(struct irlan_cb *self, int status)
/* Reserve space for TTP, LMP, and LAP header */ /* Reserve space for TTP, LMP, and LAP header */
skb_reserve(skb, self->client.max_header_size); skb_reserve(skb, self->client.max_header_size);
skb_put(skb, 2); skb_put(skb, 2);
frame = skb->data; frame = skb->data;
frame[0] = CMD_FILTER_OPERATION; frame[0] = CMD_FILTER_OPERATION;
frame[1] = 0x03; /* Three parameters */ frame[1] = 0x03; /* Three parameters */
irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data); irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
irlan_insert_string_param(skb, "FILTER_TYPE", "BROADCAST"); irlan_insert_string_param(skb, "FILTER_TYPE", "BROADCAST");
if (status) if (status)
irlan_insert_string_param(skb, "FILTER_MODE", "FILTER"); irlan_insert_string_param(skb, "FILTER_MODE", "FILTER");
else else
irlan_insert_string_param(skb, "FILTER_MODE", "NONE"); irlan_insert_string_param(skb, "FILTER_MODE", "NONE");
irlan_ctrl_data_request(self, skb); irlan_ctrl_data_request(self, skb);
} }
@ -835,14 +835,14 @@ void irlan_set_broadcast_filter(struct irlan_cb *self, int status)
* Function irlan_set_multicast_filter (self, status) * Function irlan_set_multicast_filter (self, status)
* *
* Make IrLAN provider accept ethernet frames addressed to the multicast * Make IrLAN provider accept ethernet frames addressed to the multicast
* address. * address.
* *
*/ */
void irlan_set_multicast_filter(struct irlan_cb *self, int status) void irlan_set_multicast_filter(struct irlan_cb *self, int status)
{ {
struct sk_buff *skb; struct sk_buff *skb;
__u8 *frame; __u8 *frame;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
@ -856,21 +856,21 @@ void irlan_set_multicast_filter(struct irlan_cb *self, int status)
GFP_ATOMIC); GFP_ATOMIC);
if (!skb) if (!skb)
return; return;
/* Reserve space for TTP, LMP, and LAP header */ /* Reserve space for TTP, LMP, and LAP header */
skb_reserve(skb, self->client.max_header_size); skb_reserve(skb, self->client.max_header_size);
skb_put(skb, 2); skb_put(skb, 2);
frame = skb->data; frame = skb->data;
frame[0] = CMD_FILTER_OPERATION; frame[0] = CMD_FILTER_OPERATION;
frame[1] = 0x03; /* Three parameters */ frame[1] = 0x03; /* Three parameters */
irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data); irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
irlan_insert_string_param(skb, "FILTER_TYPE", "MULTICAST"); irlan_insert_string_param(skb, "FILTER_TYPE", "MULTICAST");
if (status) if (status)
irlan_insert_string_param(skb, "FILTER_MODE", "ALL"); irlan_insert_string_param(skb, "FILTER_MODE", "ALL");
else else
irlan_insert_string_param(skb, "FILTER_MODE", "NONE"); irlan_insert_string_param(skb, "FILTER_MODE", "NONE");
irlan_ctrl_data_request(self, skb); irlan_ctrl_data_request(self, skb);
} }
@ -887,12 +887,12 @@ static void irlan_get_unicast_addr(struct irlan_cb *self)
{ {
struct sk_buff *skb; struct sk_buff *skb;
__u8 *frame; __u8 *frame;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") + IRLAN_BYTE_PARAMETER_LEN("DATA_CHAN") +
IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") + IRLAN_STRING_PARAMETER_LEN("FILTER_TYPE", "DIRECTED") +
@ -905,34 +905,34 @@ static void irlan_get_unicast_addr(struct irlan_cb *self)
/* Reserve space for TTP, LMP, and LAP header */ /* Reserve space for TTP, LMP, and LAP header */
skb_reserve(skb, self->client.max_header_size); skb_reserve(skb, self->client.max_header_size);
skb_put(skb, 2); skb_put(skb, 2);
frame = skb->data; frame = skb->data;
frame[0] = CMD_FILTER_OPERATION; frame[0] = CMD_FILTER_OPERATION;
frame[1] = 0x03; /* Three parameters */ frame[1] = 0x03; /* Three parameters */
irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data); irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
irlan_insert_string_param(skb, "FILTER_TYPE", "DIRECTED"); irlan_insert_string_param(skb, "FILTER_TYPE", "DIRECTED");
irlan_insert_string_param(skb, "FILTER_OPERATION", "DYNAMIC"); irlan_insert_string_param(skb, "FILTER_OPERATION", "DYNAMIC");
irlan_ctrl_data_request(self, skb); irlan_ctrl_data_request(self, skb);
} }
/* /*
* Function irlan_get_media_char (self) * Function irlan_get_media_char (self)
* *
* *
* *
*/ */
void irlan_get_media_char(struct irlan_cb *self) void irlan_get_media_char(struct irlan_cb *self)
{ {
struct sk_buff *skb; struct sk_buff *skb;
__u8 *frame; __u8 *frame;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER + skb = alloc_skb(IRLAN_MAX_HEADER + IRLAN_CMD_HEADER +
IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3"), IRLAN_STRING_PARAMETER_LEN("MEDIA", "802.3"),
GFP_ATOMIC); GFP_ATOMIC);
@ -943,13 +943,13 @@ void irlan_get_media_char(struct irlan_cb *self)
/* Reserve space for TTP, LMP, and LAP header */ /* Reserve space for TTP, LMP, and LAP header */
skb_reserve(skb, self->client.max_header_size); skb_reserve(skb, self->client.max_header_size);
skb_put(skb, 2); skb_put(skb, 2);
frame = skb->data; frame = skb->data;
/* Build frame */ /* Build frame */
frame[0] = CMD_GET_MEDIA_CHAR; frame[0] = CMD_GET_MEDIA_CHAR;
frame[1] = 0x01; /* One parameter */ frame[1] = 0x01; /* One parameter */
irlan_insert_string_param(skb, "MEDIA", "802.3"); irlan_insert_string_param(skb, "MEDIA", "802.3");
irlan_ctrl_data_request(self, skb); irlan_ctrl_data_request(self, skb);
} }
@ -980,7 +980,7 @@ int irlan_insert_string_param(struct sk_buff *skb, char *param, char *string)
{ {
int string_len = strlen(string); int string_len = strlen(string);
return __irlan_insert_param(skb, param, IRLAN_ARRAY, 0, 0, string, return __irlan_insert_param(skb, param, IRLAN_ARRAY, 0, 0, string,
string_len); string_len);
} }
@ -993,7 +993,7 @@ int irlan_insert_string_param(struct sk_buff *skb, char *param, char *string)
int irlan_insert_array_param(struct sk_buff *skb, char *name, __u8 *array, int irlan_insert_array_param(struct sk_buff *skb, char *name, __u8 *array,
__u16 array_len) __u16 array_len)
{ {
return __irlan_insert_param(skb, name, IRLAN_ARRAY, 0, 0, array, return __irlan_insert_param(skb, name, IRLAN_ARRAY, 0, 0, array,
array_len); array_len);
} }
@ -1006,19 +1006,19 @@ int irlan_insert_array_param(struct sk_buff *skb, char *name, __u8 *array,
* | Name Length[1] | Param Name[1..255] | Val Length[2] | Value[0..1016]| * | Name Length[1] | Param Name[1..255] | Val Length[2] | Value[0..1016]|
* ----------------------------------------------------------------------- * -----------------------------------------------------------------------
*/ */
static int __irlan_insert_param(struct sk_buff *skb, char *param, int type, static int __irlan_insert_param(struct sk_buff *skb, char *param, int type,
__u8 value_byte, __u16 value_short, __u8 value_byte, __u16 value_short,
__u8 *value_array, __u16 value_len) __u8 *value_array, __u16 value_len)
{ {
__u8 *frame; __u8 *frame;
__u8 param_len; __u8 param_len;
__le16 tmp_le; /* Temporary value in little endian format */ __le16 tmp_le; /* Temporary value in little endian format */
int n=0; int n=0;
if (skb == NULL) { if (skb == NULL) {
IRDA_DEBUG(2, "%s(), Got NULL skb\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), Got NULL skb\n", __FUNCTION__ );
return 0; return 0;
} }
param_len = strlen(param); param_len = strlen(param);
switch (type) { switch (type) {
@ -1037,7 +1037,7 @@ static int __irlan_insert_param(struct sk_buff *skb, char *param, int type,
return 0; return 0;
break; break;
} }
/* Insert at end of sk-buffer */ /* Insert at end of sk-buffer */
frame = skb->tail; frame = skb->tail;
@ -1045,15 +1045,15 @@ static int __irlan_insert_param(struct sk_buff *skb, char *param, int type,
if (skb_tailroom(skb) < (param_len+value_len+3)) { if (skb_tailroom(skb) < (param_len+value_len+3)) {
IRDA_DEBUG(2, "%s(), No more space at end of skb\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), No more space at end of skb\n", __FUNCTION__ );
return 0; return 0;
} }
skb_put(skb, param_len+value_len+3); skb_put(skb, param_len+value_len+3);
/* Insert parameter length */ /* Insert parameter length */
frame[n++] = param_len; frame[n++] = param_len;
/* Insert parameter */ /* Insert parameter */
memcpy(frame+n, param, param_len); n += param_len; memcpy(frame+n, param, param_len); n += param_len;
/* Insert value length (2 byte little endian format, LSB first) */ /* Insert value length (2 byte little endian format, LSB first) */
tmp_le = cpu_to_le16(value_len); tmp_le = cpu_to_le16(value_len);
memcpy(frame+n, &tmp_le, 2); n += 2; /* To avoid alignment problems */ memcpy(frame+n, &tmp_le, 2); n += 2; /* To avoid alignment problems */
@ -1082,36 +1082,36 @@ static int __irlan_insert_param(struct sk_buff *skb, char *param, int type,
* Function irlan_extract_param (buf, name, value, len) * Function irlan_extract_param (buf, name, value, len)
* *
* Extracts a single parameter name/value pair from buffer and updates * Extracts a single parameter name/value pair from buffer and updates
* the buffer pointer to point to the next name/value pair. * the buffer pointer to point to the next name/value pair.
*/ */
int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len) int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len)
{ {
__u8 name_len; __u8 name_len;
__u16 val_len; __u16 val_len;
int n=0; int n=0;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
/* get length of parameter name (1 byte) */ /* get length of parameter name (1 byte) */
name_len = buf[n++]; name_len = buf[n++];
if (name_len > 254) { if (name_len > 254) {
IRDA_DEBUG(2, "%s(), name_len > 254\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), name_len > 254\n", __FUNCTION__ );
return -RSP_INVALID_COMMAND_FORMAT; return -RSP_INVALID_COMMAND_FORMAT;
} }
/* get parameter name */ /* get parameter name */
memcpy(name, buf+n, name_len); memcpy(name, buf+n, name_len);
name[name_len] = '\0'; name[name_len] = '\0';
n+=name_len; n+=name_len;
/* /*
* Get length of parameter value (2 bytes in little endian * Get length of parameter value (2 bytes in little endian
* format) * format)
*/ */
memcpy(&val_len, buf+n, 2); /* To avoid alignment problems */ memcpy(&val_len, buf+n, 2); /* To avoid alignment problems */
le16_to_cpus(&val_len); n+=2; le16_to_cpus(&val_len); n+=2;
if (val_len > 1016) { if (val_len > 1016) {
IRDA_DEBUG(2, "%s(), parameter length to long\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), parameter length to long\n", __FUNCTION__ );
return -RSP_INVALID_COMMAND_FORMAT; return -RSP_INVALID_COMMAND_FORMAT;
@ -1122,9 +1122,9 @@ int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len)
memcpy(value, buf+n, val_len); memcpy(value, buf+n, val_len);
value[val_len] = '\0'; value[val_len] = '\0';
n+=val_len; n+=val_len;
IRDA_DEBUG(4, "Parameter: %s ", name); IRDA_DEBUG(4, "Parameter: %s ", name);
IRDA_DEBUG(4, "Value: %s\n", value); IRDA_DEBUG(4, "Value: %s\n", value);
return n; return n;
} }
@ -1133,7 +1133,7 @@ int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len)
/* /*
* Start of reading /proc entries. * Start of reading /proc entries.
* Return entry at pos, * Return entry at pos,
* or start_token to indicate print header line * or start_token to indicate print header line
* or NULL if end of file * or NULL if end of file
*/ */
@ -1147,7 +1147,7 @@ static void *irlan_seq_start(struct seq_file *seq, loff_t *pos)
return SEQ_START_TOKEN; return SEQ_START_TOKEN;
list_for_each_entry(self, &irlans, dev_list) { list_for_each_entry(self, &irlans, dev_list) {
if (*pos == i) if (*pos == i)
return self; return self;
++i; ++i;
} }
@ -1160,12 +1160,12 @@ static void *irlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
struct list_head *nxt; struct list_head *nxt;
++*pos; ++*pos;
if (v == SEQ_START_TOKEN) if (v == SEQ_START_TOKEN)
nxt = irlans.next; nxt = irlans.next;
else else
nxt = ((struct irlan_cb *)v)->dev_list.next; nxt = ((struct irlan_cb *)v)->dev_list.next;
return (nxt == &irlans) ? NULL return (nxt == &irlans) ? NULL
: list_entry(nxt, struct irlan_cb, dev_list); : list_entry(nxt, struct irlan_cb, dev_list);
} }
@ -1185,7 +1185,7 @@ static int irlan_seq_show(struct seq_file *seq, void *v)
seq_puts(seq, "IrLAN instances:\n"); seq_puts(seq, "IrLAN instances:\n");
else { else {
struct irlan_cb *self = v; struct irlan_cb *self = v;
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;);
@ -1201,17 +1201,17 @@ static int irlan_seq_show(struct seq_file *seq, void *v)
self->daddr); self->daddr);
seq_printf(seq,"version: %d.%d,\n", seq_printf(seq,"version: %d.%d,\n",
self->version[1], self->version[0]); self->version[1], self->version[0]);
seq_printf(seq,"access type: %s\n", seq_printf(seq,"access type: %s\n",
irlan_access[self->client.access_type]); irlan_access[self->client.access_type]);
seq_printf(seq,"media: %s\n", seq_printf(seq,"media: %s\n",
irlan_media[self->media]); irlan_media[self->media]);
seq_printf(seq,"local filter:\n"); seq_printf(seq,"local filter:\n");
seq_printf(seq,"remote filter: "); seq_printf(seq,"remote filter: ");
irlan_print_filter(seq, self->client.filter_type); irlan_print_filter(seq, self->client.filter_type);
seq_printf(seq,"tx busy: %s\n", seq_printf(seq,"tx busy: %s\n",
netif_queue_stopped(self->dev) ? "TRUE" : "FALSE"); netif_queue_stopped(self->dev) ? "TRUE" : "FALSE");
seq_putc(seq,'\n'); seq_putc(seq,'\n');
} }
return 0; return 0;
@ -1231,7 +1231,7 @@ static int irlan_seq_open(struct inode *inode, struct file *file)
#endif #endif
MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>"); MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
MODULE_DESCRIPTION("The Linux IrDA LAN protocol"); MODULE_DESCRIPTION("The Linux IrDA LAN protocol");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
module_param(eth, bool, 0); module_param(eth, bool, 0);

View file

@ -1,8 +1,8 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irlan_eth.c * Filename: irlan_eth.c
* Version: * Version:
* Description: * Description:
* Status: Experimental. * Status: Experimental.
* Author: Dag Brattli <dagb@cs.uit.no> * Author: Dag Brattli <dagb@cs.uit.no>
* Created at: Thu Oct 15 08:37:58 1998 * Created at: Thu Oct 15 08:37:58 1998
@ -11,18 +11,18 @@
* Sources: skeleton.c by Donald Becker <becker@CESDIS.gsfc.nasa.gov> * Sources: skeleton.c by Donald Becker <becker@CESDIS.gsfc.nasa.gov>
* slip.c by Laurence Culhane, <loz@holmes.demon.co.uk> * slip.c by Laurence Culhane, <loz@holmes.demon.co.uk>
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* *
* Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved. * Copyright (c) 1998-2000 Dag Brattli, All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
#include <linux/netdevice.h> #include <linux/netdevice.h>
@ -55,7 +55,7 @@ static void irlan_eth_setup(struct net_device *dev)
{ {
dev->open = irlan_eth_open; dev->open = irlan_eth_open;
dev->stop = irlan_eth_close; dev->stop = irlan_eth_close;
dev->hard_start_xmit = irlan_eth_xmit; dev->hard_start_xmit = irlan_eth_xmit;
dev->get_stats = irlan_eth_get_stats; dev->get_stats = irlan_eth_get_stats;
dev->set_multicast_list = irlan_eth_set_multicast_list; dev->set_multicast_list = irlan_eth_set_multicast_list;
dev->destructor = free_netdev; dev->destructor = free_netdev;
@ -63,8 +63,8 @@ static void irlan_eth_setup(struct net_device *dev)
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
ether_setup(dev); ether_setup(dev);
/* /*
* Lets do all queueing in IrTTP instead of this device driver. * Lets do all queueing in IrTTP instead of this device driver.
* Queueing here as well can introduce some strange latency * Queueing here as well can introduce some strange latency
* problems, which we will avoid by setting the queue size to 0. * problems, which we will avoid by setting the queue size to 0.
@ -104,17 +104,17 @@ struct net_device *alloc_irlandev(const char *name)
static int irlan_eth_open(struct net_device *dev) static int irlan_eth_open(struct net_device *dev)
{ {
struct irlan_cb *self = netdev_priv(dev); struct irlan_cb *self = netdev_priv(dev);
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
/* Ready to play! */ /* Ready to play! */
netif_stop_queue(dev); /* Wait until data link is ready */ netif_stop_queue(dev); /* Wait until data link is ready */
/* We are now open, so time to do some work */ /* We are now open, so time to do some work */
self->disconnect_reason = 0; self->disconnect_reason = 0;
irlan_client_wakeup(self, self->saddr, self->daddr); irlan_client_wakeup(self, self->saddr, self->daddr);
/* Make sure we have a hardware address before we return, /* Make sure we have a hardware address before we return,
so DHCP clients gets happy */ so DHCP clients gets happy */
return wait_event_interruptible(self->open_wait, return wait_event_interruptible(self->open_wait,
!self->tsap_data->connected); !self->tsap_data->connected);
@ -124,30 +124,30 @@ static int irlan_eth_open(struct net_device *dev)
* Function irlan_eth_close (dev) * Function irlan_eth_close (dev)
* *
* Stop the ether network device, his function will usually be called by * Stop the ether network device, his function will usually be called by
* ifconfig down. We should now disconnect the link, We start the * ifconfig down. We should now disconnect the link, We start the
* close timer, so that the instance will be removed if we are unable * close timer, so that the instance will be removed if we are unable
* to discover the remote device after the disconnect. * to discover the remote device after the disconnect.
*/ */
static int irlan_eth_close(struct net_device *dev) static int irlan_eth_close(struct net_device *dev)
{ {
struct irlan_cb *self = netdev_priv(dev); struct irlan_cb *self = netdev_priv(dev);
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
/* Stop device */ /* Stop device */
netif_stop_queue(dev); netif_stop_queue(dev);
irlan_close_data_channel(self); irlan_close_data_channel(self);
irlan_close_tsaps(self); irlan_close_tsaps(self);
irlan_do_client_event(self, IRLAN_LMP_DISCONNECT, NULL); irlan_do_client_event(self, IRLAN_LMP_DISCONNECT, NULL);
irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL); irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL);
/* Remove frames queued on the control channel */ /* Remove frames queued on the control channel */
skb_queue_purge(&self->client.txq); skb_queue_purge(&self->client.txq);
self->client.tx_busy = 0; self->client.tx_busy = 0;
return 0; return 0;
} }
@ -164,7 +164,7 @@ static int irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev)
/* skb headroom large enough to contain all IrDA-headers? */ /* skb headroom large enough to contain all IrDA-headers? */
if ((skb_headroom(skb) < self->max_header_size) || (skb_shared(skb))) { if ((skb_headroom(skb) < self->max_header_size) || (skb_shared(skb))) {
struct sk_buff *new_skb = struct sk_buff *new_skb =
skb_realloc_headroom(skb, self->max_header_size); skb_realloc_headroom(skb, self->max_header_size);
/* We have to free the original skb anyway */ /* We have to free the original skb anyway */
@ -176,7 +176,7 @@ static int irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev)
/* Use the new skb instead */ /* Use the new skb instead */
skb = new_skb; skb = new_skb;
} }
dev->trans_start = jiffies; dev->trans_start = jiffies;
@ -187,7 +187,7 @@ static int irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev)
ret = irttp_data_request(self->tsap_data, skb); ret = irttp_data_request(self->tsap_data, skb);
if (ret < 0) { if (ret < 0) {
/* /*
* IrTTPs tx queue is full, so we just have to * IrTTPs tx queue is full, so we just have to
* drop the frame! You might think that we should * drop the frame! You might think that we should
* just return -1 and don't deallocate the frame, * just return -1 and don't deallocate the frame,
@ -195,15 +195,15 @@ static int irlan_eth_xmit(struct sk_buff *skb, struct net_device *dev)
* we have replaced the original skb with a new * we have replaced the original skb with a new
* one with larger headroom, and that would really * one with larger headroom, and that would really
* confuse do_dev_queue_xmit() in dev.c! I have * confuse do_dev_queue_xmit() in dev.c! I have
* tried :-) DB * tried :-) DB
*/ */
/* irttp_data_request already free the packet */ /* irttp_data_request already free the packet */
self->stats.tx_dropped++; self->stats.tx_dropped++;
} else { } else {
self->stats.tx_packets++; self->stats.tx_packets++;
self->stats.tx_bytes += skb->len; self->stats.tx_bytes += skb->len;
} }
return 0; return 0;
} }
@ -218,37 +218,37 @@ int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb)
struct irlan_cb *self = instance; struct irlan_cb *self = instance;
if (skb == NULL) { if (skb == NULL) {
++self->stats.rx_dropped; ++self->stats.rx_dropped;
return 0; return 0;
} }
if (skb->len < ETH_HLEN) { if (skb->len < ETH_HLEN) {
IRDA_DEBUG(0, "%s() : IrLAN frame too short (%d)\n", IRDA_DEBUG(0, "%s() : IrLAN frame too short (%d)\n",
__FUNCTION__, skb->len); __FUNCTION__, skb->len);
++self->stats.rx_dropped; ++self->stats.rx_dropped;
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
} }
/* /*
* Adopt this frame! Important to set all these fields since they * Adopt this frame! Important to set all these fields since they
* might have been previously set by the low level IrDA network * might have been previously set by the low level IrDA network
* device driver * device driver
*/ */
skb->dev = self->dev; skb->dev = self->dev;
skb->protocol=eth_type_trans(skb, skb->dev); /* Remove eth header */ skb->protocol=eth_type_trans(skb, skb->dev); /* Remove eth header */
self->stats.rx_packets++; self->stats.rx_packets++;
self->stats.rx_bytes += skb->len; self->stats.rx_bytes += skb->len;
netif_rx(skb); /* Eat it! */ netif_rx(skb); /* Eat it! */
return 0; return 0;
} }
/* /*
* Function irlan_eth_flow (status) * Function irlan_eth_flow (status)
* *
* Do flow control between IP/Ethernet and IrLAN/IrTTP. This is done by * Do flow control between IP/Ethernet and IrLAN/IrTTP. This is done by
* controlling the queue stop/start. * controlling the queue stop/start.
* *
* The IrDA link layer has the advantage to have flow control, and * The IrDA link layer has the advantage to have flow control, and
@ -268,11 +268,11 @@ void irlan_eth_flow_indication(void *instance, void *sap, LOCAL_FLOW flow)
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
dev = self->dev; dev = self->dev;
IRDA_ASSERT(dev != NULL, return;); IRDA_ASSERT(dev != NULL, return;);
IRDA_DEBUG(0, "%s() : flow %s ; running %d\n", __FUNCTION__, IRDA_DEBUG(0, "%s() : flow %s ; running %d\n", __FUNCTION__,
flow == FLOW_STOP ? "FLOW_STOP" : "FLOW_START", flow == FLOW_STOP ? "FLOW_STOP" : "FLOW_START",
netif_running(dev)); netif_running(dev));
@ -301,10 +301,10 @@ void irlan_eth_send_gratuitous_arp(struct net_device *dev)
{ {
struct in_device *in_dev; struct in_device *in_dev;
/* /*
* When we get a new MAC address do a gratuitous ARP. This * When we get a new MAC address do a gratuitous ARP. This
* is useful if we have changed access points on the same * is useful if we have changed access points on the same
* subnet. * subnet.
*/ */
#ifdef CONFIG_INET #ifdef CONFIG_INET
IRDA_DEBUG(4, "IrLAN: Sending gratuitous ARP\n"); IRDA_DEBUG(4, "IrLAN: Sending gratuitous ARP\n");
@ -313,10 +313,10 @@ void irlan_eth_send_gratuitous_arp(struct net_device *dev)
if (in_dev == NULL) if (in_dev == NULL)
goto out; goto out;
if (in_dev->ifa_list) if (in_dev->ifa_list)
arp_send(ARPOP_REQUEST, ETH_P_ARP, arp_send(ARPOP_REQUEST, ETH_P_ARP,
in_dev->ifa_list->ifa_address, in_dev->ifa_list->ifa_address,
dev, dev,
in_dev->ifa_list->ifa_address, in_dev->ifa_list->ifa_address,
NULL, dev->dev_addr, NULL); NULL, dev->dev_addr, NULL);
out: out:
@ -331,9 +331,9 @@ out:
* *
*/ */
#define HW_MAX_ADDRS 4 /* Must query to get it! */ #define HW_MAX_ADDRS 4 /* Must query to get it! */
static void irlan_eth_set_multicast_list(struct net_device *dev) static void irlan_eth_set_multicast_list(struct net_device *dev)
{ {
struct irlan_cb *self = netdev_priv(dev); struct irlan_cb *self = netdev_priv(dev);
IRDA_DEBUG(2, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s()\n", __FUNCTION__ );
@ -346,7 +346,7 @@ static void irlan_eth_set_multicast_list(struct net_device *dev)
if (dev->flags & IFF_PROMISC) { if (dev->flags & IFF_PROMISC) {
/* Enable promiscuous mode */ /* Enable promiscuous mode */
IRDA_WARNING("Promiscous mode not implemented by IrLAN!\n"); IRDA_WARNING("Promiscous mode not implemented by IrLAN!\n");
} }
else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > HW_MAX_ADDRS) { else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > HW_MAX_ADDRS) {
/* Disable promiscuous mode, use normal mode. */ /* Disable promiscuous mode, use normal mode. */
IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __FUNCTION__ );
@ -378,7 +378,7 @@ static void irlan_eth_set_multicast_list(struct net_device *dev)
* Get the current statistics for this device * Get the current statistics for this device
* *
*/ */
static struct net_device_stats *irlan_eth_get_stats(struct net_device *dev) static struct net_device_stats *irlan_eth_get_stats(struct net_device *dev)
{ {
struct irlan_cb *self = netdev_priv(dev); struct irlan_cb *self = netdev_priv(dev);

View file

@ -1,25 +1,25 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irlan_event.c * Filename: irlan_event.c
* Version: * Version:
* Description: * Description:
* Status: Experimental. * Status: Experimental.
* Author: Dag Brattli <dagb@cs.uit.no> * Author: Dag Brattli <dagb@cs.uit.no>
* Created at: Tue Oct 20 09:10:16 1998 * Created at: Tue Oct 20 09:10:16 1998
* Modified at: Sat Oct 30 12:59:01 1999 * Modified at: Sat Oct 30 12:59:01 1999
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved. * Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
#include <net/irda/irlan_event.h> #include <net/irda/irlan_event.h>
@ -38,7 +38,7 @@ char *irlan_state[] = {
"IRLAN_SYNC", "IRLAN_SYNC",
}; };
void irlan_next_client_state(struct irlan_cb *self, IRLAN_STATE state) void irlan_next_client_state(struct irlan_cb *self, IRLAN_STATE state)
{ {
IRDA_DEBUG(2, "%s(), %s\n", __FUNCTION__ , irlan_state[state]); IRDA_DEBUG(2, "%s(), %s\n", __FUNCTION__ , irlan_state[state]);
@ -48,7 +48,7 @@ void irlan_next_client_state(struct irlan_cb *self, IRLAN_STATE state)
self->client.state = state; self->client.state = state;
} }
void irlan_next_provider_state(struct irlan_cb *self, IRLAN_STATE state) void irlan_next_provider_state(struct irlan_cb *self, IRLAN_STATE state)
{ {
IRDA_DEBUG(2, "%s(), %s\n", __FUNCTION__ , irlan_state[state]); IRDA_DEBUG(2, "%s(), %s\n", __FUNCTION__ , irlan_state[state]);

View file

@ -1,25 +1,25 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irlan_filter.c * Filename: irlan_filter.c
* Version: * Version:
* Description: * Description:
* Status: Experimental. * Status: Experimental.
* Author: Dag Brattli <dagb@cs.uit.no> * Author: Dag Brattli <dagb@cs.uit.no>
* Created at: Fri Jan 29 11:16:38 1999 * Created at: Fri Jan 29 11:16:38 1999
* Modified at: Sat Oct 30 12:58:45 1999 * Modified at: Sat Oct 30 12:58:45 1999
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved. * Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
#include <linux/skbuff.h> #include <linux/skbuff.h>
@ -40,7 +40,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
if ((self->provider.filter_type == IRLAN_DIRECTED) && if ((self->provider.filter_type == IRLAN_DIRECTED) &&
(self->provider.filter_operation == DYNAMIC)) (self->provider.filter_operation == DYNAMIC))
{ {
IRDA_DEBUG(0, "Giving peer a dynamic Ethernet address\n"); IRDA_DEBUG(0, "Giving peer a dynamic Ethernet address\n");
@ -48,12 +48,12 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
self->provider.mac_address[1] = 0x00; self->provider.mac_address[1] = 0x00;
self->provider.mac_address[2] = 0x00; self->provider.mac_address[2] = 0x00;
self->provider.mac_address[3] = 0x00; self->provider.mac_address[3] = 0x00;
/* Use arbitration value to generate MAC address */ /* Use arbitration value to generate MAC address */
if (self->provider.access_type == ACCESS_PEER) { if (self->provider.access_type == ACCESS_PEER) {
self->provider.mac_address[4] = self->provider.mac_address[4] =
self->provider.send_arb_val & 0xff; self->provider.send_arb_val & 0xff;
self->provider.mac_address[5] = self->provider.mac_address[5] =
(self->provider.send_arb_val >> 8) & 0xff; (self->provider.send_arb_val >> 8) & 0xff;
} else { } else {
/* Just generate something for now */ /* Just generate something for now */
@ -65,12 +65,12 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
skb->data[1] = 0x03; skb->data[1] = 0x03;
irlan_insert_string_param(skb, "FILTER_MODE", "NONE"); irlan_insert_string_param(skb, "FILTER_MODE", "NONE");
irlan_insert_short_param(skb, "MAX_ENTRY", 0x0001); irlan_insert_short_param(skb, "MAX_ENTRY", 0x0001);
irlan_insert_array_param(skb, "FILTER_ENTRY", irlan_insert_array_param(skb, "FILTER_ENTRY",
self->provider.mac_address, 6); self->provider.mac_address, 6);
return; return;
} }
if ((self->provider.filter_type == IRLAN_DIRECTED) && if ((self->provider.filter_type == IRLAN_DIRECTED) &&
(self->provider.filter_mode == FILTER)) (self->provider.filter_mode == FILTER))
{ {
IRDA_DEBUG(0, "Directed filter on\n"); IRDA_DEBUG(0, "Directed filter on\n");
@ -78,7 +78,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
skb->data[1] = 0x00; skb->data[1] = 0x00;
return; return;
} }
if ((self->provider.filter_type == IRLAN_DIRECTED) && if ((self->provider.filter_type == IRLAN_DIRECTED) &&
(self->provider.filter_mode == NONE)) (self->provider.filter_mode == NONE))
{ {
IRDA_DEBUG(0, "Directed filter off\n"); IRDA_DEBUG(0, "Directed filter off\n");
@ -87,7 +87,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
return; return;
} }
if ((self->provider.filter_type == IRLAN_BROADCAST) && if ((self->provider.filter_type == IRLAN_BROADCAST) &&
(self->provider.filter_mode == FILTER)) (self->provider.filter_mode == FILTER))
{ {
IRDA_DEBUG(0, "Broadcast filter on\n"); IRDA_DEBUG(0, "Broadcast filter on\n");
@ -95,7 +95,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
skb->data[1] = 0x00; skb->data[1] = 0x00;
return; return;
} }
if ((self->provider.filter_type == IRLAN_BROADCAST) && if ((self->provider.filter_type == IRLAN_BROADCAST) &&
(self->provider.filter_mode == NONE)) (self->provider.filter_mode == NONE))
{ {
IRDA_DEBUG(0, "Broadcast filter off\n"); IRDA_DEBUG(0, "Broadcast filter off\n");
@ -103,7 +103,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
skb->data[1] = 0x00; skb->data[1] = 0x00;
return; return;
} }
if ((self->provider.filter_type == IRLAN_MULTICAST) && if ((self->provider.filter_type == IRLAN_MULTICAST) &&
(self->provider.filter_mode == FILTER)) (self->provider.filter_mode == FILTER))
{ {
IRDA_DEBUG(0, "Multicast filter on\n"); IRDA_DEBUG(0, "Multicast filter on\n");
@ -111,7 +111,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
skb->data[1] = 0x00; skb->data[1] = 0x00;
return; return;
} }
if ((self->provider.filter_type == IRLAN_MULTICAST) && if ((self->provider.filter_type == IRLAN_MULTICAST) &&
(self->provider.filter_mode == NONE)) (self->provider.filter_mode == NONE))
{ {
IRDA_DEBUG(0, "Multicast filter off\n"); IRDA_DEBUG(0, "Multicast filter off\n");
@ -119,7 +119,7 @@ void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb)
skb->data[1] = 0x00; skb->data[1] = 0x00;
return; return;
} }
if ((self->provider.filter_type == IRLAN_MULTICAST) && if ((self->provider.filter_type == IRLAN_MULTICAST) &&
(self->provider.filter_operation == GET)) (self->provider.filter_operation == GET))
{ {
IRDA_DEBUG(0, "Multicast filter get\n"); IRDA_DEBUG(0, "Multicast filter get\n");

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irlan_provider.c * Filename: irlan_provider.c
* Version: 0.9 * Version: 0.9
* Description: IrDA LAN Access Protocol Implementation * Description: IrDA LAN Access Protocol Implementation
@ -11,17 +11,17 @@
* Sources: skeleton.c by Donald Becker <becker@CESDIS.gsfc.nasa.gov> * Sources: skeleton.c by Donald Becker <becker@CESDIS.gsfc.nasa.gov>
* slip.c by Laurence Culhane, <loz@holmes.demon.co.uk> * slip.c by Laurence Culhane, <loz@holmes.demon.co.uk>
* Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
* *
* Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>,
* All Rights Reserved. * All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
@ -52,8 +52,8 @@
#include <net/irda/irlan_filter.h> #include <net/irda/irlan_filter.h>
#include <net/irda/irlan_client.h> #include <net/irda/irlan_client.h>
static void irlan_provider_connect_indication(void *instance, void *sap, static void irlan_provider_connect_indication(void *instance, void *sap,
struct qos_info *qos, struct qos_info *qos,
__u32 max_sdu_size, __u32 max_sdu_size,
__u8 max_header_size, __u8 max_header_size,
struct sk_buff *skb); struct sk_buff *skb);
@ -64,14 +64,14 @@ static void irlan_provider_connect_indication(void *instance, void *sap,
* This function gets the data that is received on the control channel * This function gets the data that is received on the control channel
* *
*/ */
static int irlan_provider_data_indication(void *instance, void *sap, static int irlan_provider_data_indication(void *instance, void *sap,
struct sk_buff *skb) struct sk_buff *skb)
{ {
struct irlan_cb *self; struct irlan_cb *self;
__u8 code; __u8 code;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
self = (struct irlan_cb *) instance; self = (struct irlan_cb *) instance;
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
@ -83,16 +83,16 @@ static int irlan_provider_data_indication(void *instance, void *sap,
switch(code) { switch(code) {
case CMD_GET_PROVIDER_INFO: case CMD_GET_PROVIDER_INFO:
IRDA_DEBUG(4, "Got GET_PROVIDER_INFO command!\n"); IRDA_DEBUG(4, "Got GET_PROVIDER_INFO command!\n");
irlan_do_provider_event(self, IRLAN_GET_INFO_CMD, skb); irlan_do_provider_event(self, IRLAN_GET_INFO_CMD, skb);
break; break;
case CMD_GET_MEDIA_CHAR: case CMD_GET_MEDIA_CHAR:
IRDA_DEBUG(4, "Got GET_MEDIA_CHAR command!\n"); IRDA_DEBUG(4, "Got GET_MEDIA_CHAR command!\n");
irlan_do_provider_event(self, IRLAN_GET_MEDIA_CMD, skb); irlan_do_provider_event(self, IRLAN_GET_MEDIA_CMD, skb);
break; break;
case CMD_OPEN_DATA_CHANNEL: case CMD_OPEN_DATA_CHANNEL:
IRDA_DEBUG(4, "Got OPEN_DATA_CHANNEL command!\n"); IRDA_DEBUG(4, "Got OPEN_DATA_CHANNEL command!\n");
irlan_do_provider_event(self, IRLAN_OPEN_DATA_CMD, skb); irlan_do_provider_event(self, IRLAN_OPEN_DATA_CMD, skb);
break; break;
case CMD_FILTER_OPERATION: case CMD_FILTER_OPERATION:
IRDA_DEBUG(4, "Got FILTER_OPERATION command!\n"); IRDA_DEBUG(4, "Got FILTER_OPERATION command!\n");
@ -119,9 +119,9 @@ static int irlan_provider_data_indication(void *instance, void *sap,
* Got connection from peer IrLAN client * Got connection from peer IrLAN client
* *
*/ */
static void irlan_provider_connect_indication(void *instance, void *sap, static void irlan_provider_connect_indication(void *instance, void *sap,
struct qos_info *qos, struct qos_info *qos,
__u32 max_sdu_size, __u32 max_sdu_size,
__u8 max_header_size, __u8 max_header_size,
struct sk_buff *skb) struct sk_buff *skb)
{ {
@ -130,13 +130,13 @@ static void irlan_provider_connect_indication(void *instance, void *sap,
__u32 saddr, daddr; __u32 saddr, daddr;
IRDA_DEBUG(0, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
self = (struct irlan_cb *) instance; self = (struct irlan_cb *) instance;
tsap = (struct tsap_cb *) sap; tsap = (struct tsap_cb *) sap;
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
IRDA_ASSERT(tsap == self->provider.tsap_ctrl,return;); IRDA_ASSERT(tsap == self->provider.tsap_ctrl,return;);
IRDA_ASSERT(self->provider.state == IRLAN_IDLE, return;); IRDA_ASSERT(self->provider.state == IRLAN_IDLE, return;);
@ -147,13 +147,13 @@ static void irlan_provider_connect_indication(void *instance, void *sap,
irlan_do_provider_event(self, IRLAN_CONNECT_INDICATION, NULL); irlan_do_provider_event(self, IRLAN_CONNECT_INDICATION, NULL);
/* /*
* If we are in peer mode, the client may not have got the discovery * If we are in peer mode, the client may not have got the discovery
* indication it needs to make progress. If the client is still in * indication it needs to make progress. If the client is still in
* IDLE state, we must kick it. * IDLE state, we must kick it.
*/ */
if ((self->provider.access_type == ACCESS_PEER) && if ((self->provider.access_type == ACCESS_PEER) &&
(self->client.state == IRLAN_IDLE)) (self->client.state == IRLAN_IDLE))
{ {
irlan_client_wakeup(self, self->saddr, self->daddr); irlan_client_wakeup(self, self->saddr, self->daddr);
} }
@ -175,38 +175,38 @@ void irlan_provider_connect_response(struct irlan_cb *self,
irttp_connect_response(tsap, IRLAN_MTU, NULL); irttp_connect_response(tsap, IRLAN_MTU, NULL);
} }
static void irlan_provider_disconnect_indication(void *instance, void *sap, static void irlan_provider_disconnect_indication(void *instance, void *sap,
LM_REASON reason, LM_REASON reason,
struct sk_buff *userdata) struct sk_buff *userdata)
{ {
struct irlan_cb *self; struct irlan_cb *self;
struct tsap_cb *tsap; struct tsap_cb *tsap;
IRDA_DEBUG(4, "%s(), reason=%d\n", __FUNCTION__ , reason); IRDA_DEBUG(4, "%s(), reason=%d\n", __FUNCTION__ , reason);
self = (struct irlan_cb *) instance; self = (struct irlan_cb *) instance;
tsap = (struct tsap_cb *) sap; tsap = (struct tsap_cb *) sap;
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return;);
IRDA_ASSERT(tsap != NULL, return;); IRDA_ASSERT(tsap != NULL, return;);
IRDA_ASSERT(tsap->magic == TTP_TSAP_MAGIC, return;); IRDA_ASSERT(tsap->magic == TTP_TSAP_MAGIC, return;);
IRDA_ASSERT(tsap == self->provider.tsap_ctrl, return;); IRDA_ASSERT(tsap == self->provider.tsap_ctrl, return;);
irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL); irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL);
} }
/* /*
* Function irlan_parse_open_data_cmd (self, skb) * Function irlan_parse_open_data_cmd (self, skb)
* *
* *
* *
*/ */
int irlan_parse_open_data_cmd(struct irlan_cb *self, struct sk_buff *skb) int irlan_parse_open_data_cmd(struct irlan_cb *self, struct sk_buff *skb)
{ {
int ret; int ret;
ret = irlan_provider_parse_command(self, CMD_OPEN_DATA_CHANNEL, skb); ret = irlan_provider_parse_command(self, CMD_OPEN_DATA_CHANNEL, skb);
/* Open data channel */ /* Open data channel */
@ -218,12 +218,12 @@ int irlan_parse_open_data_cmd(struct irlan_cb *self, struct sk_buff *skb)
/* /*
* Function parse_command (skb) * Function parse_command (skb)
* *
* Extract all parameters from received buffer, then feed them to * Extract all parameters from received buffer, then feed them to
* check_params for parsing * check_params for parsing
* *
*/ */
int irlan_provider_parse_command(struct irlan_cb *self, int cmd, int irlan_provider_parse_command(struct irlan_cb *self, int cmd,
struct sk_buff *skb) struct sk_buff *skb)
{ {
__u8 *frame; __u8 *frame;
__u8 *ptr; __u8 *ptr;
@ -231,16 +231,16 @@ int irlan_provider_parse_command(struct irlan_cb *self, int cmd,
__u16 val_len; __u16 val_len;
int i; int i;
char *name; char *name;
char *value; char *value;
int ret = RSP_SUCCESS; int ret = RSP_SUCCESS;
IRDA_ASSERT(skb != NULL, return -RSP_PROTOCOL_ERROR;); IRDA_ASSERT(skb != NULL, return -RSP_PROTOCOL_ERROR;);
IRDA_DEBUG(4, "%s(), skb->len=%d\n", __FUNCTION__ , (int)skb->len); IRDA_DEBUG(4, "%s(), skb->len=%d\n", __FUNCTION__ , (int)skb->len);
IRDA_ASSERT(self != NULL, return -RSP_PROTOCOL_ERROR;); IRDA_ASSERT(self != NULL, return -RSP_PROTOCOL_ERROR;);
IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -RSP_PROTOCOL_ERROR;); IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -RSP_PROTOCOL_ERROR;);
if (!skb) if (!skb)
return -RSP_PROTOCOL_ERROR; return -RSP_PROTOCOL_ERROR;
@ -259,11 +259,11 @@ int irlan_provider_parse_command(struct irlan_cb *self, int cmd,
count = frame[1]; count = frame[1];
IRDA_DEBUG(4, "Got %d parameters\n", count); IRDA_DEBUG(4, "Got %d parameters\n", count);
ptr = frame+2; ptr = frame+2;
/* For all parameters */ /* For all parameters */
for (i=0; i<count;i++) { for (i=0; i<count;i++) {
ret = irlan_extract_param(ptr, name, value, &val_len); ret = irlan_extract_param(ptr, name, value, &val_len);
if (ret < 0) { if (ret < 0) {
IRDA_DEBUG(2, "%s(), IrLAN, Error!\n", __FUNCTION__ ); IRDA_DEBUG(2, "%s(), IrLAN, Error!\n", __FUNCTION__ );
@ -286,7 +286,7 @@ int irlan_provider_parse_command(struct irlan_cb *self, int cmd,
* Send reply to query to peer IrLAN layer * Send reply to query to peer IrLAN layer
* *
*/ */
void irlan_provider_send_reply(struct irlan_cb *self, int command, void irlan_provider_send_reply(struct irlan_cb *self, int command,
int ret_code) int ret_code)
{ {
struct sk_buff *skb; struct sk_buff *skb;
@ -310,7 +310,7 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command,
/* Reserve space for TTP, LMP, and LAP header */ /* Reserve space for TTP, LMP, and LAP header */
skb_reserve(skb, self->provider.max_header_size); skb_reserve(skb, self->provider.max_header_size);
skb_put(skb, 2); skb_put(skb, 2);
switch (command) { switch (command) {
case CMD_GET_PROVIDER_INFO: case CMD_GET_PROVIDER_INFO:
skb->data[0] = 0x00; /* Success */ skb->data[0] = 0x00; /* Success */
@ -356,7 +356,7 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command,
skb->data[0] = 0x00; /* Success */ skb->data[0] = 0x00; /* Success */
if (self->provider.send_arb_val) { if (self->provider.send_arb_val) {
skb->data[1] = 0x03; /* 3 parameters */ skb->data[1] = 0x03; /* 3 parameters */
irlan_insert_short_param(skb, "CON_ARB", irlan_insert_short_param(skb, "CON_ARB",
self->provider.send_arb_val); self->provider.send_arb_val);
} else } else
skb->data[1] = 0x02; /* 2 parameters */ skb->data[1] = 0x02; /* 2 parameters */
@ -378,13 +378,13 @@ void irlan_provider_send_reply(struct irlan_cb *self, int command,
* Function irlan_provider_register(void) * Function irlan_provider_register(void)
* *
* Register provider support so we can accept incoming connections. * Register provider support so we can accept incoming connections.
* *
*/ */
int irlan_provider_open_ctrl_tsap(struct irlan_cb *self) int irlan_provider_open_ctrl_tsap(struct irlan_cb *self)
{ {
struct tsap_cb *tsap; struct tsap_cb *tsap;
notify_t notify; notify_t notify;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
@ -393,7 +393,7 @@ int irlan_provider_open_ctrl_tsap(struct irlan_cb *self)
/* Check if already open */ /* Check if already open */
if (self->provider.tsap_ctrl) if (self->provider.tsap_ctrl)
return -1; return -1;
/* /*
* First register well known control TSAP * First register well known control TSAP
*/ */

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irlan_provider_event.c * Filename: irlan_provider_event.c
* Version: 0.9 * Version: 0.9
* Description: IrLAN provider state machine) * Description: IrLAN provider state machine)
@ -8,16 +8,16 @@
* Created at: Sun Aug 31 20:14:37 1997 * Created at: Sun Aug 31 20:14:37 1997
* Modified at: Sat Oct 30 12:52:41 1999 * Modified at: Sat Oct 30 12:52:41 1999
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved. * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
@ -30,18 +30,18 @@
#include <net/irda/irlan_provider.h> #include <net/irda/irlan_provider.h>
#include <net/irda/irlan_event.h> #include <net/irda/irlan_event.h>
static int irlan_provider_state_idle(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_provider_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int irlan_provider_state_open(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_provider_state_open(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int irlan_provider_state_data(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_provider_state_data(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb); struct sk_buff *skb);
static int (*state[])(struct irlan_cb *self, IRLAN_EVENT event, static int (*state[])(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) = struct sk_buff *skb) =
{ {
irlan_provider_state_idle, irlan_provider_state_idle,
NULL, /* Query */ NULL, /* Query */
NULL, /* Info */ NULL, /* Info */
@ -55,8 +55,8 @@ static int (*state[])(struct irlan_cb *self, IRLAN_EVENT event,
NULL, /* Sync */ NULL, /* Sync */
}; };
void irlan_do_provider_event(struct irlan_cb *self, IRLAN_EVENT event, void irlan_do_provider_event(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_ASSERT(*state[ self->provider.state] != NULL, return;); IRDA_ASSERT(*state[ self->provider.state] != NULL, return;);
@ -73,9 +73,9 @@ static int irlan_provider_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
switch(event) { switch(event) {
case IRLAN_CONNECT_INDICATION: case IRLAN_CONNECT_INDICATION:
irlan_provider_connect_response( self, self->provider.tsap_ctrl); irlan_provider_connect_response( self, self->provider.tsap_ctrl);
@ -96,13 +96,13 @@ static int irlan_provider_state_idle(struct irlan_cb *self, IRLAN_EVENT event,
* *
* INFO, We have issued a GetInfo command and is awaiting a reply. * INFO, We have issued a GetInfo command and is awaiting a reply.
*/ */
static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
int ret; int ret;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
switch(event) { switch(event) {
@ -110,7 +110,7 @@ static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event,
/* Be sure to use 802.3 in case of peer mode */ /* Be sure to use 802.3 in case of peer mode */
if (self->provider.access_type == ACCESS_PEER) { if (self->provider.access_type == ACCESS_PEER) {
self->media = MEDIA_802_3; self->media = MEDIA_802_3;
/* Check if client has started yet */ /* Check if client has started yet */
if (self->client.state == IRLAN_IDLE) { if (self->client.state == IRLAN_IDLE) {
/* This should get the client going */ /* This should get the client going */
@ -118,15 +118,15 @@ static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event,
} }
} }
irlan_provider_send_reply(self, CMD_GET_PROVIDER_INFO, irlan_provider_send_reply(self, CMD_GET_PROVIDER_INFO,
RSP_SUCCESS); RSP_SUCCESS);
/* Keep state */ /* Keep state */
break; break;
case IRLAN_GET_MEDIA_CMD: case IRLAN_GET_MEDIA_CMD:
irlan_provider_send_reply(self, CMD_GET_MEDIA_CHAR, irlan_provider_send_reply(self, CMD_GET_MEDIA_CHAR,
RSP_SUCCESS); RSP_SUCCESS);
/* Keep state */ /* Keep state */
break; break;
case IRLAN_OPEN_DATA_CMD: case IRLAN_OPEN_DATA_CMD:
ret = irlan_parse_open_data_cmd(self, skb); ret = irlan_parse_open_data_cmd(self, skb);
if (self->provider.access_type == ACCESS_PEER) { if (self->provider.access_type == ACCESS_PEER) {
@ -152,7 +152,7 @@ static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event,
} }
if (skb) if (skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
} }
@ -163,7 +163,7 @@ static int irlan_provider_state_info(struct irlan_cb *self, IRLAN_EVENT event,
* reply * reply
* *
*/ */
static int irlan_provider_state_open(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_provider_state_open(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
@ -173,11 +173,11 @@ static int irlan_provider_state_open(struct irlan_cb *self, IRLAN_EVENT event,
switch(event) { switch(event) {
case IRLAN_FILTER_CONFIG_CMD: case IRLAN_FILTER_CONFIG_CMD:
irlan_provider_parse_command(self, CMD_FILTER_OPERATION, skb); irlan_provider_parse_command(self, CMD_FILTER_OPERATION, skb);
irlan_provider_send_reply(self, CMD_FILTER_OPERATION, irlan_provider_send_reply(self, CMD_FILTER_OPERATION,
RSP_SUCCESS); RSP_SUCCESS);
/* Keep state */ /* Keep state */
break; break;
case IRLAN_DATA_CONNECT_INDICATION: case IRLAN_DATA_CONNECT_INDICATION:
irlan_next_provider_state(self, IRLAN_DATA); irlan_next_provider_state(self, IRLAN_DATA);
irlan_provider_connect_response(self, self->tsap_data); irlan_provider_connect_response(self, self->tsap_data);
break; break;
@ -202,8 +202,8 @@ static int irlan_provider_state_open(struct irlan_cb *self, IRLAN_EVENT event,
* the local and remote machines. * the local and remote machines.
* *
*/ */
static int irlan_provider_state_data(struct irlan_cb *self, IRLAN_EVENT event, static int irlan_provider_state_data(struct irlan_cb *self, IRLAN_EVENT event,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__ ); IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
@ -213,7 +213,7 @@ static int irlan_provider_state_data(struct irlan_cb *self, IRLAN_EVENT event,
switch(event) { switch(event) {
case IRLAN_FILTER_CONFIG_CMD: case IRLAN_FILTER_CONFIG_CMD:
irlan_provider_parse_command(self, CMD_FILTER_OPERATION, skb); irlan_provider_parse_command(self, CMD_FILTER_OPERATION, skb);
irlan_provider_send_reply(self, CMD_FILTER_OPERATION, irlan_provider_send_reply(self, CMD_FILTER_OPERATION,
RSP_SUCCESS); RSP_SUCCESS);
break; break;
case IRLAN_LMP_DISCONNECT: /* FALLTHROUGH */ case IRLAN_LMP_DISCONNECT: /* FALLTHROUGH */
@ -226,7 +226,7 @@ static int irlan_provider_state_data(struct irlan_cb *self, IRLAN_EVENT event,
} }
if (skb) if (skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
return 0; return 0;
} }

View file

@ -87,7 +87,7 @@ int __init irlap_init(void)
/* Allocate master array */ /* Allocate master array */
irlap = hashbin_new(HB_LOCK); irlap = hashbin_new(HB_LOCK);
if (irlap == NULL) { if (irlap == NULL) {
IRDA_ERROR("%s: can't allocate irlap hashbin!\n", IRDA_ERROR("%s: can't allocate irlap hashbin!\n",
__FUNCTION__); __FUNCTION__);
return -ENOMEM; return -ENOMEM;
} }
@ -701,8 +701,8 @@ void irlap_update_nr_received(struct irlap_cb *self, int nr)
int count = 0; int count = 0;
/* /*
* Remove all the ack-ed frames from the window queue. * Remove all the ack-ed frames from the window queue.
*/ */
/* /*
* Optimize for the common case. It is most likely that the receiver * Optimize for the common case. It is most likely that the receiver
@ -1109,13 +1109,13 @@ static void *irlap_seq_start(struct seq_file *seq, loff_t *pos)
spin_lock_irq(&irlap->hb_spinlock); spin_lock_irq(&irlap->hb_spinlock);
iter->id = 0; iter->id = 0;
for (self = (struct irlap_cb *) hashbin_get_first(irlap); for (self = (struct irlap_cb *) hashbin_get_first(irlap);
self; self = (struct irlap_cb *) hashbin_get_next(irlap)) { self; self = (struct irlap_cb *) hashbin_get_next(irlap)) {
if (iter->id == *pos) if (iter->id == *pos)
break; break;
++iter->id; ++iter->id;
} }
return self; return self;
} }
@ -1137,7 +1137,7 @@ static int irlap_seq_show(struct seq_file *seq, void *v)
{ {
const struct irlap_iter_state *iter = seq->private; const struct irlap_iter_state *iter = seq->private;
const struct irlap_cb *self = v; const struct irlap_cb *self = v;
IRDA_ASSERT(self->magic == LAP_MAGIC, return -EINVAL;); IRDA_ASSERT(self->magic == LAP_MAGIC, return -EINVAL;);
seq_printf(seq, "irlap%d ", iter->id); seq_printf(seq, "irlap%d ", iter->id);
@ -1222,7 +1222,7 @@ static int irlap_seq_open(struct inode *inode, struct file *file)
struct seq_file *seq; struct seq_file *seq;
int rc = -ENOMEM; int rc = -ENOMEM;
struct irlap_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL); struct irlap_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
if (!s) if (!s)
goto out; goto out;

View file

@ -827,7 +827,7 @@ static int irlap_state_conn(struct irlap_cb *self, IRLAP_EVENT event,
irlap_disconnect_indication(self, LAP_DISC_INDICATION); irlap_disconnect_indication(self, LAP_DISC_INDICATION);
break; break;
default: default:
IRDA_DEBUG(1, "%s(), Unknown event %d, %s\n", __FUNCTION__, IRDA_DEBUG(1, "%s(), Unknown event %d, %s\n", __FUNCTION__,
event, irlap_event[event]); event, irlap_event[event]);
ret = -1; ret = -1;
@ -864,7 +864,7 @@ static int irlap_state_setup(struct irlap_cb *self, IRLAP_EVENT event,
* between 15 msecs and 45 msecs. * 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))); (jiffies % 30)));
} else { } else {
/* Always switch state before calling upper layers */ /* Always switch state before calling upper layers */
irlap_next_state(self, LAP_NDM); irlap_next_state(self, LAP_NDM);
@ -1377,7 +1377,7 @@ static int irlap_state_nrm_p(struct irlap_cb *self, IRLAP_EVENT event,
/* Resend rejected frames */ /* Resend rejected frames */
irlap_resend_rejected_frames(self, CMD_FRAME); irlap_resend_rejected_frames(self, CMD_FRAME);
/* Give peer some time to retransmit! /* Give peer some time to retransmit!
* But account for our own Tx. */ * But account for our own Tx. */
irlap_start_final_timer(self, 2 * self->final_timeout); irlap_start_final_timer(self, 2 * self->final_timeout);

View file

@ -414,7 +414,7 @@ static void irlap_recv_discovery_xid_rsp(struct irlap_cb *self,
IRDA_ERROR("%s: frame to short!\n", __FUNCTION__); IRDA_ERROR("%s: frame to short!\n", __FUNCTION__);
return; return;
} }
xid = (struct xid_frame *) skb->data; xid = (struct xid_frame *) skb->data;
info->daddr = le32_to_cpu(xid->saddr); info->daddr = le32_to_cpu(xid->saddr);
@ -485,7 +485,7 @@ static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
IRDA_ERROR("%s: frame to short!\n", __FUNCTION__); IRDA_ERROR("%s: frame to short!\n", __FUNCTION__);
return; return;
} }
xid = (struct xid_frame *) skb->data; xid = (struct xid_frame *) skb->data;
info->daddr = le32_to_cpu(xid->saddr); info->daddr = le32_to_cpu(xid->saddr);
@ -524,7 +524,7 @@ static void irlap_recv_discovery_xid_cmd(struct irlap_cb *self,
*/ */
if (info->s == 0xff) { if (info->s == 0xff) {
/* Check if things are sane at this point... */ /* Check if things are sane at this point... */
if((discovery_info == NULL) || if((discovery_info == NULL) ||
!pskb_may_pull(skb, 3)) { !pskb_may_pull(skb, 3)) {
IRDA_ERROR("%s: discovery frame to short!\n", IRDA_ERROR("%s: discovery frame to short!\n",
__FUNCTION__); __FUNCTION__);

View file

@ -116,7 +116,7 @@ int __init irlmp_init(void)
* Remove IrLMP layer * Remove IrLMP layer
* *
*/ */
void __exit irlmp_cleanup(void) void __exit irlmp_cleanup(void)
{ {
/* Check for main structure */ /* Check for main structure */
IRDA_ASSERT(irlmp != NULL, return;); IRDA_ASSERT(irlmp != NULL, return;);
@ -892,7 +892,7 @@ void irlmp_discovery_request(int nslots)
/* /*
* Start a single discovery operation if discovery is not already * Start a single discovery operation if discovery is not already
* running * running
*/ */
if (!sysctl_discovery) { if (!sysctl_discovery) {
/* Check if user wants to override the default */ /* Check if user wants to override the default */
@ -1528,12 +1528,12 @@ int irlmp_unregister_service(void *handle)
/* Refresh current hint bits */ /* Refresh current hint bits */
spin_lock_irqsave(&irlmp->services->hb_spinlock, flags); spin_lock_irqsave(&irlmp->services->hb_spinlock, flags);
service = (irlmp_service_t *) hashbin_get_first(irlmp->services); service = (irlmp_service_t *) hashbin_get_first(irlmp->services);
while (service) { while (service) {
irlmp->hints.word |= service->hints.word; irlmp->hints.word |= service->hints.word;
service = (irlmp_service_t *)hashbin_get_next(irlmp->services); service = (irlmp_service_t *)hashbin_get_next(irlmp->services);
} }
spin_unlock_irqrestore(&irlmp->services->hb_spinlock, flags); spin_unlock_irqrestore(&irlmp->services->hb_spinlock, flags);
return 0; return 0;
} }
@ -1861,7 +1861,7 @@ static void *irlmp_seq_hb_idx(struct irlmp_iter_state *iter, loff_t *off)
spin_lock_irq(&iter->hashbin->hb_spinlock); spin_lock_irq(&iter->hashbin->hb_spinlock);
for (element = hashbin_get_first(iter->hashbin); for (element = hashbin_get_first(iter->hashbin);
element != NULL; element != NULL;
element = hashbin_get_next(iter->hashbin)) { element = hashbin_get_next(iter->hashbin)) {
if (!off || *off-- == 0) { if (!off || *off-- == 0) {
/* NB: hashbin left locked */ /* NB: hashbin left locked */
@ -1918,7 +1918,7 @@ static void *irlmp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
if (v == NULL) { /* no more in this hash bin */ if (v == NULL) { /* no more in this hash bin */
spin_unlock_irq(&iter->hashbin->hb_spinlock); spin_unlock_irq(&iter->hashbin->hb_spinlock);
if (iter->hashbin == irlmp->unconnected_lsaps) if (iter->hashbin == irlmp->unconnected_lsaps)
v = LINK_START_TOKEN; v = LINK_START_TOKEN;
iter->hashbin = NULL; iter->hashbin = NULL;

View file

@ -615,7 +615,7 @@ static int irlmp_state_connect(struct lsap_cb *self, IRLMP_EVENT event,
default: default:
/* LM_LAP_DISCONNECT_INDICATION : Should never happen, we /* LM_LAP_DISCONNECT_INDICATION : Should never happen, we
* are *not* yet bound to the IrLAP link. Jean II */ * are *not* yet bound to the IrLAP link. Jean II */
IRDA_DEBUG(0, "%s(), Unknown event %s on LSAP %#02x\n", IRDA_DEBUG(0, "%s(), Unknown event %s on LSAP %#02x\n",
__FUNCTION__, irlmp_event[event], self->slsap_sel); __FUNCTION__, irlmp_event[event], self->slsap_sel);
break; break;
} }

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irlmp_frame.c * Filename: irlmp_frame.c
* Version: 0.9 * Version: 0.9
* Description: IrLMP frame implementation * Description: IrLMP frame implementation
@ -8,18 +8,18 @@
* Created at: Tue Aug 19 02:09:59 1997 * Created at: Tue Aug 19 02:09:59 1997
* Modified at: Mon Dec 13 13:41:12 1999 * Modified at: Mon Dec 13 13:41:12 1999
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no> * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>
* All Rights Reserved. * All Rights Reserved.
* Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com> * Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
@ -34,7 +34,7 @@
#include <net/irda/irlmp_frame.h> #include <net/irda/irlmp_frame.h>
#include <net/irda/discovery.h> #include <net/irda/discovery.h>
static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap, static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap,
__u8 slsap, int status, hashbin_t *); __u8 slsap, int status, hashbin_t *);
inline void irlmp_send_data_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap, inline void irlmp_send_data_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap,
@ -56,18 +56,18 @@ inline void irlmp_send_data_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap,
* Send Link Control Frame to IrLAP * Send Link Control Frame to IrLAP
*/ */
void irlmp_send_lcf_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap, void irlmp_send_lcf_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap,
__u8 opcode, struct sk_buff *skb) __u8 opcode, struct sk_buff *skb)
{ {
__u8 *frame; __u8 *frame;
IRDA_DEBUG(2, "%s()\n", __FUNCTION__); IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == LMP_LAP_MAGIC, return;); IRDA_ASSERT(self->magic == LMP_LAP_MAGIC, return;);
IRDA_ASSERT(skb != NULL, return;); IRDA_ASSERT(skb != NULL, return;);
frame = skb->data; frame = skb->data;
frame[0] = dlsap | CONTROL_BIT; frame[0] = dlsap | CONTROL_BIT;
frame[1] = slsap; frame[1] = slsap;
@ -87,14 +87,14 @@ void irlmp_send_lcf_pdu(struct lap_cb *self, __u8 dlsap, __u8 slsap,
* Used by IrLAP to pass received data frames to IrLMP layer * Used by IrLAP to pass received data frames to IrLMP layer
* *
*/ */
void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb, void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
int unreliable) int unreliable)
{ {
struct lsap_cb *lsap; struct lsap_cb *lsap;
__u8 slsap_sel; /* Source (this) LSAP address */ __u8 slsap_sel; /* Source (this) LSAP address */
__u8 dlsap_sel; /* Destination LSAP address */ __u8 dlsap_sel; /* Destination LSAP address */
__u8 *fp; __u8 *fp;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__); IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
@ -104,11 +104,11 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
fp = skb->data; fp = skb->data;
/* /*
* The next statements may be confusing, but we do this so that * The next statements may be confusing, but we do this so that
* destination LSAP of received frame is source LSAP in our view * destination LSAP of received frame is source LSAP in our view
*/ */
slsap_sel = fp[0] & LSAP_MASK; slsap_sel = fp[0] & LSAP_MASK;
dlsap_sel = fp[1]; dlsap_sel = fp[1];
/* /*
* Check if this is an incoming connection, since we must deal with * Check if this is an incoming connection, since we must deal with
@ -118,11 +118,11 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
IRDA_DEBUG(3, "%s(), incoming connection, " IRDA_DEBUG(3, "%s(), incoming connection, "
"source LSAP=%d, dest LSAP=%d\n", "source LSAP=%d, dest LSAP=%d\n",
__FUNCTION__, slsap_sel, dlsap_sel); __FUNCTION__, slsap_sel, dlsap_sel);
/* Try to find LSAP among the unconnected LSAPs */ /* Try to find LSAP among the unconnected LSAPs */
lsap = irlmp_find_lsap(self, dlsap_sel, slsap_sel, CONNECT_CMD, lsap = irlmp_find_lsap(self, dlsap_sel, slsap_sel, CONNECT_CMD,
irlmp->unconnected_lsaps); irlmp->unconnected_lsaps);
/* Maybe LSAP was already connected, so try one more time */ /* Maybe LSAP was already connected, so try one more time */
if (!lsap) { if (!lsap) {
IRDA_DEBUG(1, "%s(), incoming connection for LSAP already connected\n", __FUNCTION__); IRDA_DEBUG(1, "%s(), incoming connection for LSAP already connected\n", __FUNCTION__);
@ -130,9 +130,9 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
self->lsaps); self->lsaps);
} }
} else } else
lsap = irlmp_find_lsap(self, dlsap_sel, slsap_sel, 0, lsap = irlmp_find_lsap(self, dlsap_sel, slsap_sel, 0,
self->lsaps); self->lsaps);
if (lsap == NULL) { if (lsap == NULL) {
IRDA_DEBUG(2, "IrLMP, Sorry, no LSAP for received frame!\n"); IRDA_DEBUG(2, "IrLMP, Sorry, no LSAP for received frame!\n");
IRDA_DEBUG(2, "%s(), slsap_sel = %02x, dlsap_sel = %02x\n", IRDA_DEBUG(2, "%s(), slsap_sel = %02x, dlsap_sel = %02x\n",
@ -146,8 +146,8 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
return; return;
} }
/* /*
* Check if we received a control frame? * Check if we received a control frame?
*/ */
if (fp[0] & CONTROL_BIT) { if (fp[0] & CONTROL_BIT) {
switch (fp[2]) { switch (fp[2]) {
@ -161,7 +161,7 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
case DISCONNECT: case DISCONNECT:
IRDA_DEBUG(4, "%s(), Disconnect indication!\n", IRDA_DEBUG(4, "%s(), Disconnect indication!\n",
__FUNCTION__); __FUNCTION__);
irlmp_do_lsap_event(lsap, LM_DISCONNECT_INDICATION, irlmp_do_lsap_event(lsap, LM_DISCONNECT_INDICATION,
skb); skb);
break; break;
case ACCESSMODE_CMD: case ACCESSMODE_CMD:
@ -181,7 +181,7 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
irlmp_udata_indication(lsap, skb); irlmp_udata_indication(lsap, skb);
else else
irlmp_do_lsap_event(lsap, LM_UDATA_INDICATION, skb); irlmp_do_lsap_event(lsap, LM_UDATA_INDICATION, skb);
} else { } else {
/* Optimize and bypass the state machine if possible */ /* Optimize and bypass the state machine if possible */
if (lsap->lsap_state == LSAP_DATA_TRANSFER_READY) if (lsap->lsap_state == LSAP_DATA_TRANSFER_READY)
irlmp_data_indication(lsap, skb); irlmp_data_indication(lsap, skb);
@ -193,7 +193,7 @@ void irlmp_link_data_indication(struct lap_cb *self, struct sk_buff *skb,
/* /*
* Function irlmp_link_unitdata_indication (self, skb) * Function irlmp_link_unitdata_indication (self, skb)
* *
* *
* *
*/ */
#ifdef CONFIG_IRDA_ULTRA #ifdef CONFIG_IRDA_ULTRA
@ -205,7 +205,7 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
__u8 pid; /* Protocol identifier */ __u8 pid; /* Protocol identifier */
__u8 *fp; __u8 *fp;
unsigned long flags; unsigned long flags;
IRDA_DEBUG(4, "%s()\n", __FUNCTION__); IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
@ -215,13 +215,13 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
fp = skb->data; fp = skb->data;
/* /*
* The next statements may be confusing, but we do this so that * The next statements may be confusing, but we do this so that
* destination LSAP of received frame is source LSAP in our view * destination LSAP of received frame is source LSAP in our view
*/ */
slsap_sel = fp[0] & LSAP_MASK; slsap_sel = fp[0] & LSAP_MASK;
dlsap_sel = fp[1]; dlsap_sel = fp[1];
pid = fp[2]; pid = fp[2];
if (pid & 0x80) { if (pid & 0x80) {
IRDA_DEBUG(0, "%s(), extension in PID not supp!\n", IRDA_DEBUG(0, "%s(), extension in PID not supp!\n",
__FUNCTION__); __FUNCTION__);
@ -233,7 +233,7 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
IRDA_DEBUG(0, "%s(), dropping frame!\n", __FUNCTION__); IRDA_DEBUG(0, "%s(), dropping frame!\n", __FUNCTION__);
return; return;
} }
/* Search the connectionless LSAP */ /* Search the connectionless LSAP */
spin_lock_irqsave(&irlmp->unconnected_lsaps->hb_spinlock, flags); spin_lock_irqsave(&irlmp->unconnected_lsaps->hb_spinlock, flags);
lsap = (struct lsap_cb *) hashbin_get_first(irlmp->unconnected_lsaps); lsap = (struct lsap_cb *) hashbin_get_first(irlmp->unconnected_lsaps);
@ -241,10 +241,10 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
/* /*
* Check if source LSAP and dest LSAP selectors and PID match. * Check if source LSAP and dest LSAP selectors and PID match.
*/ */
if ((lsap->slsap_sel == slsap_sel) && if ((lsap->slsap_sel == slsap_sel) &&
(lsap->dlsap_sel == dlsap_sel) && (lsap->dlsap_sel == dlsap_sel) &&
(lsap->pid == pid)) (lsap->pid == pid))
{ {
break; break;
} }
lsap = (struct lsap_cb *) hashbin_get_next(irlmp->unconnected_lsaps); lsap = (struct lsap_cb *) hashbin_get_next(irlmp->unconnected_lsaps);
@ -262,12 +262,12 @@ void irlmp_link_unitdata_indication(struct lap_cb *self, struct sk_buff *skb)
/* /*
* Function irlmp_link_disconnect_indication (reason, userdata) * Function irlmp_link_disconnect_indication (reason, userdata)
* *
* IrLAP has disconnected * IrLAP has disconnected
* *
*/ */
void irlmp_link_disconnect_indication(struct lap_cb *lap, void irlmp_link_disconnect_indication(struct lap_cb *lap,
struct irlap_cb *irlap, struct irlap_cb *irlap,
LAP_REASON reason, LAP_REASON reason,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(2, "%s()\n", __FUNCTION__); IRDA_DEBUG(2, "%s()\n", __FUNCTION__);
@ -278,8 +278,8 @@ void irlmp_link_disconnect_indication(struct lap_cb *lap,
lap->reason = reason; lap->reason = reason;
lap->daddr = DEV_ADDR_ANY; lap->daddr = DEV_ADDR_ANY;
/* FIXME: must do something with the skb if any */ /* FIXME: must do something with the skb if any */
/* /*
* Inform station state machine * Inform station state machine
*/ */
@ -292,9 +292,9 @@ void irlmp_link_disconnect_indication(struct lap_cb *lap,
* Incoming LAP connection! * Incoming LAP connection!
* *
*/ */
void irlmp_link_connect_indication(struct lap_cb *self, __u32 saddr, void irlmp_link_connect_indication(struct lap_cb *self, __u32 saddr,
__u32 daddr, struct qos_info *qos, __u32 daddr, struct qos_info *qos,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__); IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
@ -314,7 +314,7 @@ void irlmp_link_connect_indication(struct lap_cb *self, __u32 saddr,
* LAP connection confirmed! * LAP connection confirmed!
* *
*/ */
void irlmp_link_connect_confirm(struct lap_cb *self, struct qos_info *qos, void irlmp_link_connect_confirm(struct lap_cb *self, struct qos_info *qos,
struct sk_buff *skb) struct sk_buff *skb)
{ {
IRDA_DEBUG(4, "%s()\n", __FUNCTION__); IRDA_DEBUG(4, "%s()\n", __FUNCTION__);
@ -359,7 +359,7 @@ void irlmp_link_connect_confirm(struct lap_cb *self, struct qos_info *qos,
* *
* Jean II * Jean II
*/ */
void irlmp_link_discovery_indication(struct lap_cb *self, void irlmp_link_discovery_indication(struct lap_cb *self,
discovery_t *discovery) discovery_t *discovery)
{ {
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
@ -367,7 +367,7 @@ void irlmp_link_discovery_indication(struct lap_cb *self,
/* Add to main log, cleanup */ /* Add to main log, cleanup */
irlmp_add_discovery(irlmp->cachelog, discovery); irlmp_add_discovery(irlmp->cachelog, discovery);
/* Just handle it the same way as a discovery confirm, /* Just handle it the same way as a discovery confirm,
* bypass the LM_LAP state machine (see below) */ * bypass the LM_LAP state machine (see below) */
irlmp_discovery_confirm(irlmp->cachelog, DISCOVERY_PASSIVE); irlmp_discovery_confirm(irlmp->cachelog, DISCOVERY_PASSIVE);
@ -387,7 +387,7 @@ void irlmp_link_discovery_confirm(struct lap_cb *self, hashbin_t *log)
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == LMP_LAP_MAGIC, return;); IRDA_ASSERT(self->magic == LMP_LAP_MAGIC, return;);
/* Add to main log, cleanup */ /* Add to main log, cleanup */
irlmp_add_discovery_log(irlmp->cachelog, log); irlmp_add_discovery_log(irlmp->cachelog, log);
@ -420,7 +420,7 @@ static inline void irlmp_update_cache(struct lap_cb *lap,
* Find handle associated with destination and source LSAP * Find handle associated with destination and source LSAP
* *
* Any IrDA connection (LSAP/TSAP) is uniquely identified by * Any IrDA connection (LSAP/TSAP) is uniquely identified by
* 3 parameters, the local lsap, the remote lsap and the remote address. * 3 parameters, the local lsap, the remote lsap and the remote address.
* We may initiate multiple connections to the same remote service * We may initiate multiple connections to the same remote service
* (they will have different local lsap), a remote device may initiate * (they will have different local lsap), a remote device may initiate
* multiple connections to the same local service (they will have * multiple connections to the same local service (they will have
@ -433,20 +433,20 @@ static inline void irlmp_update_cache(struct lap_cb *lap,
*/ */
static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap_sel, static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap_sel,
__u8 slsap_sel, int status, __u8 slsap_sel, int status,
hashbin_t *queue) hashbin_t *queue)
{ {
struct lsap_cb *lsap; struct lsap_cb *lsap;
unsigned long flags; unsigned long flags;
/* /*
* Optimize for the common case. We assume that the last frame * Optimize for the common case. We assume that the last frame
* received is in the same connection as the last one, so check in * received is in the same connection as the last one, so check in
* cache first to avoid the linear search * cache first to avoid the linear search
*/ */
#ifdef CONFIG_IRDA_CACHE_LAST_LSAP #ifdef CONFIG_IRDA_CACHE_LAST_LSAP
if ((self->cache.valid) && if ((self->cache.valid) &&
(self->cache.slsap_sel == slsap_sel) && (self->cache.slsap_sel == slsap_sel) &&
(self->cache.dlsap_sel == dlsap_sel)) (self->cache.dlsap_sel == dlsap_sel))
{ {
return (self->cache.lsap); return (self->cache.lsap);
} }
@ -456,14 +456,14 @@ static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap_sel,
lsap = (struct lsap_cb *) hashbin_get_first(queue); lsap = (struct lsap_cb *) hashbin_get_first(queue);
while (lsap != NULL) { while (lsap != NULL) {
/* /*
* If this is an incoming connection, then the destination * If this is an incoming connection, then the destination
* LSAP selector may have been specified as LM_ANY so that * LSAP selector may have been specified as LM_ANY so that
* any client can connect. In that case we only need to check * any client can connect. In that case we only need to check
* if the source LSAP (in our view!) match! * if the source LSAP (in our view!) match!
*/ */
if ((status == CONNECT_CMD) && if ((status == CONNECT_CMD) &&
(lsap->slsap_sel == slsap_sel) && (lsap->slsap_sel == slsap_sel) &&
(lsap->dlsap_sel == LSAP_ANY)) { (lsap->dlsap_sel == LSAP_ANY)) {
/* This is where the dest lsap sel is set on incoming /* This is where the dest lsap sel is set on incoming
* lsaps */ * lsaps */
@ -473,8 +473,8 @@ static struct lsap_cb *irlmp_find_lsap(struct lap_cb *self, __u8 dlsap_sel,
/* /*
* Check if source LSAP and dest LSAP selectors match. * Check if source LSAP and dest LSAP selectors match.
*/ */
if ((lsap->slsap_sel == slsap_sel) && if ((lsap->slsap_sel == slsap_sel) &&
(lsap->dlsap_sel == dlsap_sel)) (lsap->dlsap_sel == dlsap_sel))
break; break;
lsap = (struct lsap_cb *) hashbin_get_next(queue); lsap = (struct lsap_cb *) hashbin_get_next(queue);

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irmod.c * Filename: irmod.c
* Version: 0.9 * Version: 0.9
* Description: IrDA stack main entry points * Description: IrDA stack main entry points
@ -8,19 +8,19 @@
* Created at: Mon Dec 15 13:55:39 1997 * Created at: Mon Dec 15 13:55:39 1997
* Modified at: Wed Jan 5 15:12:41 2000 * Modified at: Wed Jan 5 15:12:41 2000
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1997, 1999-2000 Dag Brattli, All Rights Reserved. * Copyright (c) 1997, 1999-2000 Dag Brattli, All Rights Reserved.
* Copyright (c) 2000-2004 Jean Tourrilhes <jt@hpl.hp.com> * Copyright (c) 2000-2004 Jean Tourrilhes <jt@hpl.hp.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
/* /*
@ -52,7 +52,7 @@ extern void irda_sysctl_unregister(void);
extern int irsock_init(void); extern int irsock_init(void);
extern void irsock_cleanup(void); extern void irsock_cleanup(void);
/* irlap_frame.c */ /* irlap_frame.c */
extern int irlap_driver_rcv(struct sk_buff *, struct net_device *, extern int irlap_driver_rcv(struct sk_buff *, struct net_device *,
struct packet_type *, struct net_device *); struct packet_type *, struct net_device *);
/* /*
@ -104,16 +104,16 @@ static int __init irda_init(void)
IRDA_DEBUG(0, "%s()\n", __FUNCTION__); IRDA_DEBUG(0, "%s()\n", __FUNCTION__);
/* Lower layer of the stack */ /* Lower layer of the stack */
irlmp_init(); irlmp_init();
irlap_init(); irlap_init();
/* Higher layers of the stack */ /* Higher layers of the stack */
iriap_init(); iriap_init();
irttp_init(); irttp_init();
irsock_init(); irsock_init();
/* Add IrDA packet type (Start receiving packets) */ /* Add IrDA packet type (Start receiving packets) */
dev_add_pack(&irda_packet_type); dev_add_pack(&irda_packet_type);
/* External APIs */ /* External APIs */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
@ -124,7 +124,7 @@ static int __init irda_init(void)
#endif #endif
/* Driver/dongle support */ /* Driver/dongle support */
irda_device_init(); irda_device_init();
return 0; return 0;
} }
@ -140,14 +140,14 @@ static void __exit irda_cleanup(void)
/* Remove External APIs */ /* Remove External APIs */
#ifdef CONFIG_SYSCTL #ifdef CONFIG_SYSCTL
irda_sysctl_unregister(); irda_sysctl_unregister();
#endif #endif
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
irda_proc_unregister(); irda_proc_unregister();
#endif #endif
/* Remove IrDA packet type (stop receiving packets) */ /* Remove IrDA packet type (stop receiving packets) */
dev_remove_pack(&irda_packet_type); dev_remove_pack(&irda_packet_type);
/* Remove higher layers */ /* Remove higher layers */
irsock_cleanup(); irsock_cleanup();
irttp_cleanup(); irttp_cleanup();
@ -177,8 +177,8 @@ static void __exit irda_cleanup(void)
*/ */
subsys_initcall(irda_init); subsys_initcall(irda_init);
module_exit(irda_cleanup); module_exit(irda_cleanup);
MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no> & Jean Tourrilhes <jt@hpl.hp.com>"); MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no> & Jean Tourrilhes <jt@hpl.hp.com>");
MODULE_DESCRIPTION("The Linux IrDA Protocol Stack"); MODULE_DESCRIPTION("The Linux IrDA Protocol Stack");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS_NETPROTO(PF_IRDA); MODULE_ALIAS_NETPROTO(PF_IRDA);

View file

@ -44,7 +44,7 @@
* the generic Linux PPP driver. Because IrNET depend on recent * the generic Linux PPP driver. Because IrNET depend on recent
* changes of the PPP driver interface, IrNET will work only with very * changes of the PPP driver interface, IrNET will work only with very
* recent kernel (2.3.99-pre6 and up). * recent kernel (2.3.99-pre6 and up).
* *
* The present implementation offer the following features : * The present implementation offer the following features :
* o simple user interface using pppd * o simple user interface using pppd
* o efficient implementation (interface directly to PPP and IrTTP) * o efficient implementation (interface directly to PPP and IrTTP)
@ -327,7 +327,7 @@
#define DEBUG_ASSERT 0 /* Verify all assertions */ #define DEBUG_ASSERT 0 /* Verify all assertions */
/* /*
* These are the macros we are using to actually print the debug * These are the macros we are using to actually print the debug
* statements. Don't look at it, it's ugly... * statements. Don't look at it, it's ugly...
* *

View file

@ -118,7 +118,7 @@ irnet_open_tsap(irnet_socket * self)
/* Open an IrTTP instance */ /* Open an IrTTP instance */
self->tsap = irttp_open_tsap(LSAP_ANY, DEFAULT_INITIAL_CREDIT, self->tsap = irttp_open_tsap(LSAP_ANY, DEFAULT_INITIAL_CREDIT,
&notify); &notify);
DABORT(self->tsap == NULL, -ENOMEM, DABORT(self->tsap == NULL, -ENOMEM,
IRDA_SR_ERROR, "Unable to allocate TSAP !\n"); IRDA_SR_ERROR, "Unable to allocate TSAP !\n");
@ -188,7 +188,7 @@ irnet_ias_to_tsap(irnet_socket * self,
if(value->t.integer != -1) if(value->t.integer != -1)
/* Get the remote TSAP selector */ /* Get the remote TSAP selector */
dtsap_sel = value->t.integer; dtsap_sel = value->t.integer;
else else
self->errno = -EADDRNOTAVAIL; self->errno = -EADDRNOTAVAIL;
break; break;
default: default:
@ -280,8 +280,8 @@ irnet_connect_tsap(irnet_socket * self)
} }
/* Connect to remote device */ /* Connect to remote device */
err = irttp_connect_request(self->tsap, self->dtsap_sel, err = irttp_connect_request(self->tsap, self->dtsap_sel,
self->rsaddr, self->daddr, NULL, self->rsaddr, self->daddr, NULL,
self->max_sdu_size_rx, NULL); self->max_sdu_size_rx, NULL);
if(err != 0) if(err != 0)
{ {
@ -438,7 +438,7 @@ irnet_dname_to_daddr(irnet_socket * self)
if(discoveries == NULL) if(discoveries == NULL)
DRETURN(-ENETUNREACH, IRDA_SR_INFO, "Cachelog empty...\n"); DRETURN(-ENETUNREACH, IRDA_SR_INFO, "Cachelog empty...\n");
/* /*
* Now, check all discovered devices (if any), and connect * Now, check all discovered devices (if any), and connect
* client only about the services that the client is * client only about the services that the client is
* interested in... * interested in...
@ -627,7 +627,7 @@ irda_irnet_destroy(irnet_socket * self)
/* Unregister with LM-IAS */ /* Unregister with LM-IAS */
if(self->iriap) if(self->iriap)
{ {
iriap_close(self->iriap); iriap_close(self->iriap);
self->iriap = NULL; self->iriap = NULL;
} }
@ -945,7 +945,7 @@ irnet_setup_server(void)
/* Register with LM-IAS (so that people can connect to us) */ /* Register with LM-IAS (so that people can connect to us) */
irnet_server.ias_obj = irias_new_object(IRNET_SERVICE_NAME, jiffies); irnet_server.ias_obj = irias_new_object(IRNET_SERVICE_NAME, jiffies);
irias_add_integer_attrib(irnet_server.ias_obj, IRNET_IAS_VALUE, irias_add_integer_attrib(irnet_server.ias_obj, IRNET_IAS_VALUE,
irnet_server.s.stsap_sel, IAS_KERNEL_ATTR); irnet_server.s.stsap_sel, IAS_KERNEL_ATTR);
irias_insert_object(irnet_server.ias_obj); irias_insert_object(irnet_server.ias_obj);
@ -1076,7 +1076,7 @@ irnet_data_indication(void * instance,
*/ */
static void static void
irnet_disconnect_indication(void * instance, irnet_disconnect_indication(void * instance,
void * sap, void * sap,
LM_REASON reason, LM_REASON reason,
struct sk_buff *skb) struct sk_buff *skb)
{ {
@ -1166,10 +1166,10 @@ irnet_disconnect_indication(void * instance,
*/ */
static void static void
irnet_connect_confirm(void * instance, irnet_connect_confirm(void * instance,
void * sap, void * sap,
struct qos_info *qos, struct qos_info *qos,
__u32 max_sdu_size, __u32 max_sdu_size,
__u8 max_header_size, __u8 max_header_size,
struct sk_buff *skb) struct sk_buff *skb)
{ {
irnet_socket * self = (irnet_socket *) instance; irnet_socket * self = (irnet_socket *) instance;
@ -1235,7 +1235,7 @@ irnet_connect_confirm(void * instance,
static void static void
irnet_flow_indication(void * instance, irnet_flow_indication(void * instance,
void * sap, void * sap,
LOCAL_FLOW flow) LOCAL_FLOW flow)
{ {
irnet_socket * self = (irnet_socket *) instance; irnet_socket * self = (irnet_socket *) instance;
LOCAL_FLOW oldflow = self->tx_flow; LOCAL_FLOW oldflow = self->tx_flow;
@ -1308,13 +1308,13 @@ irnet_status_indication(void * instance,
* Some other node is attempting to connect to the IrNET service, and has * Some other node is attempting to connect to the IrNET service, and has
* sent a connection request on our server socket. * sent a connection request on our server socket.
* We just redirect the connection to the relevant IrNET socket. * We just redirect the connection to the relevant IrNET socket.
* *
* Note : we also make sure that between 2 irnet nodes, there can * Note : we also make sure that between 2 irnet nodes, there can
* exist only one irnet connection. * exist only one irnet connection.
*/ */
static void static void
irnet_connect_indication(void * instance, irnet_connect_indication(void * instance,
void * sap, void * sap,
struct qos_info *qos, struct qos_info *qos,
__u32 max_sdu_size, __u32 max_sdu_size,
__u8 max_header_size, __u8 max_header_size,
@ -1463,7 +1463,7 @@ irnet_connect_indication(void * instance,
*/ */
static void static void
irnet_getvalue_confirm(int result, irnet_getvalue_confirm(int result,
__u16 obj_id, __u16 obj_id,
struct ias_value *value, struct ias_value *value,
void * priv) void * priv)
{ {
@ -1526,7 +1526,7 @@ irnet_getvalue_confirm(int result,
*/ */
static void static void
irnet_discovervalue_confirm(int result, irnet_discovervalue_confirm(int result,
__u16 obj_id, __u16 obj_id,
struct ias_value *value, struct ias_value *value,
void * priv) void * priv)
{ {
@ -1645,7 +1645,7 @@ irnet_discovery_indication(discinfo_t * discovery,
void * priv) void * priv)
{ {
irnet_socket * self = &irnet_server.s; irnet_socket * self = &irnet_server.s;
DENTER(IRDA_OCB_TRACE, "(self=0x%p)\n", self); DENTER(IRDA_OCB_TRACE, "(self=0x%p)\n", self);
DASSERT(priv == &irnet_server, , IRDA_OCB_ERROR, DASSERT(priv == &irnet_server, , IRDA_OCB_ERROR,
"Invalid instance (0x%p) !!!\n", priv); "Invalid instance (0x%p) !!!\n", priv);
@ -1676,7 +1676,7 @@ irnet_expiry_indication(discinfo_t * expiry,
void * priv) void * priv)
{ {
irnet_socket * self = &irnet_server.s; irnet_socket * self = &irnet_server.s;
DENTER(IRDA_OCB_TRACE, "(self=0x%p)\n", self); DENTER(IRDA_OCB_TRACE, "(self=0x%p)\n", self);
DASSERT(priv == &irnet_server, , IRDA_OCB_ERROR, DASSERT(priv == &irnet_server, , IRDA_OCB_ERROR,
"Invalid instance (0x%p) !!!\n", priv); "Invalid instance (0x%p) !!!\n", priv);
@ -1718,7 +1718,7 @@ irnet_proc_read(char * buf,
int i = 0; int i = 0;
len = 0; len = 0;
/* Get the IrNET server information... */ /* Get the IrNET server information... */
len += sprintf(buf+len, "IrNET server - "); len += sprintf(buf+len, "IrNET server - ");
len += sprintf(buf+len, "IrDA state: %s, ", len += sprintf(buf+len, "IrDA state: %s, ",
@ -1811,7 +1811,7 @@ irda_irnet_init(void)
memset(&irnet_server, 0, sizeof(struct irnet_root)); memset(&irnet_server, 0, sizeof(struct irnet_root));
/* Setup start of irnet instance list */ /* Setup start of irnet instance list */
irnet_server.list = hashbin_new(HB_NOLOCK); irnet_server.list = hashbin_new(HB_NOLOCK);
DABORT(irnet_server.list == NULL, -ENOMEM, DABORT(irnet_server.list == NULL, -ENOMEM,
MODULE_ERROR, "Can't allocate hashbin!\n"); MODULE_ERROR, "Can't allocate hashbin!\n");
/* Init spinlock for instance list */ /* Init spinlock for instance list */

View file

@ -146,7 +146,7 @@ static void
void *); void *);
static void static void
irnet_discovervalue_confirm(int, irnet_discovervalue_confirm(int,
__u16, __u16,
struct ias_value *, struct ias_value *,
void *); void *);
#ifdef DISCOVERY_EVENTS #ifdef DISCOVERY_EVENTS

View file

@ -93,7 +93,7 @@ irnet_ctrl_write(irnet_socket * ap,
/* Check if we recognised one of the known command /* Check if we recognised one of the known command
* We can't use "switch" with strings, so hack with "continue" */ * We can't use "switch" with strings, so hack with "continue" */
/* First command : name -> Requested IrDA nickname */ /* First command : name -> Requested IrDA nickname */
if(!strncmp(start, "name", 4)) if(!strncmp(start, "name", 4))
{ {
@ -744,7 +744,7 @@ dev_irnet_ioctl(struct inode * inode,
break; break;
/* Set DTR/RTS */ /* Set DTR/RTS */
case TIOCMBIS: case TIOCMBIS:
case TIOCMBIC: case TIOCMBIC:
/* Set exclusive/non-exclusive mode */ /* Set exclusive/non-exclusive mode */
case TIOCEXCL: case TIOCEXCL:
@ -941,7 +941,7 @@ ppp_irnet_send(struct ppp_channel * chan,
ret = irttp_data_request(self->tsap, skb); ret = irttp_data_request(self->tsap, skb);
if(ret < 0) if(ret < 0)
{ {
/* /*
* > IrTTPs tx queue is full, so we just have to * > IrTTPs tx queue is full, so we just have to
* > drop the frame! You might think that we should * > drop the frame! You might think that we should
* > just return -1 and don't deallocate the frame, * > just return -1 and don't deallocate the frame,
@ -949,7 +949,7 @@ ppp_irnet_send(struct ppp_channel * chan,
* > we have replaced the original skb with a new * > we have replaced the original skb with a new
* > one with larger headroom, and that would really * > one with larger headroom, and that would really
* > confuse do_dev_queue_xmit() in dev.c! I have * > confuse do_dev_queue_xmit() in dev.c! I have
* > tried :-) DB * > tried :-) DB
* Correction : we verify the flow control above (self->tx_flow), * Correction : we verify the flow control above (self->tx_flow),
* so we come here only if IrTTP doesn't like the packet (empty, * so we come here only if IrTTP doesn't like the packet (empty,
* too large, IrTTP not connected). In those rare cases, it's ok * too large, IrTTP not connected). In those rare cases, it's ok
@ -1136,6 +1136,6 @@ irnet_cleanup(void)
module_init(irnet_init); module_init(irnet_init);
module_exit(irnet_cleanup); module_exit(irnet_cleanup);
MODULE_AUTHOR("Jean Tourrilhes <jt@hpl.hp.com>"); MODULE_AUTHOR("Jean Tourrilhes <jt@hpl.hp.com>");
MODULE_DESCRIPTION("IrNET : Synchronous PPP over IrDA"); MODULE_DESCRIPTION("IrNET : Synchronous PPP over IrDA");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS_CHARDEV(10, 187); MODULE_ALIAS_CHARDEV(10, 187);

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irproc.c * Filename: irproc.c
* Version: 1.0 * Version: 1.0
* Description: Various entries in the /proc file system * Description: Various entries in the /proc file system
@ -10,17 +10,17 @@
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1998-1999, Dag Brattli <dagb@cs.uit.no> * Copyright (c) 1998-1999, Dag Brattli <dagb@cs.uit.no>
* Copyright (c) 1998, Thomas Davis, <ratbert@radiks.net>, * Copyright (c) 1998, Thomas Davis, <ratbert@radiks.net>,
* All Rights Reserved. * All Rights Reserved.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* I, Thomas Davis, provide no warranty for any of this software. * I, Thomas Davis, provide no warranty for any of this software.
* This material is provided "AS-IS" and at no charge. * This material is provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
@ -46,7 +46,7 @@ struct irda_entry {
struct proc_dir_entry *proc_irda; struct proc_dir_entry *proc_irda;
EXPORT_SYMBOL(proc_irda); EXPORT_SYMBOL(proc_irda);
static struct irda_entry irda_dirs[] = { static struct irda_entry irda_dirs[] = {
{"discovery", &discovery_seq_fops}, {"discovery", &discovery_seq_fops},
{"irttp", &irttp_seq_fops}, {"irttp", &irttp_seq_fops},
@ -61,7 +61,7 @@ static struct irda_entry irda_dirs[] = {
* Register irda entry in /proc file system * Register irda entry in /proc file system
* *
*/ */
void __init irda_proc_register(void) void __init irda_proc_register(void)
{ {
int i; int i;
struct proc_dir_entry *d; struct proc_dir_entry *d;
@ -73,7 +73,7 @@ void __init irda_proc_register(void)
for (i=0; i<ARRAY_SIZE(irda_dirs); i++) { for (i=0; i<ARRAY_SIZE(irda_dirs); i++) {
d = create_proc_entry(irda_dirs[i].name, 0, proc_irda); d = create_proc_entry(irda_dirs[i].name, 0, proc_irda);
if (d) if (d)
d->proc_fops = irda_dirs[i].fops; d->proc_fops = irda_dirs[i].fops;
} }
} }
@ -84,17 +84,17 @@ void __init irda_proc_register(void)
* Unregister irda entry in /proc file system * Unregister irda entry in /proc file system
* *
*/ */
void __exit irda_proc_unregister(void) void __exit irda_proc_unregister(void)
{ {
int i; int i;
if (proc_irda) { if (proc_irda) {
for (i=0; i<ARRAY_SIZE(irda_dirs); i++) for (i=0; i<ARRAY_SIZE(irda_dirs); i++)
remove_proc_entry(irda_dirs[i].name, proc_irda); remove_proc_entry(irda_dirs[i].name, proc_irda);
remove_proc_entry("irda", proc_net); remove_proc_entry("irda", proc_net);
proc_irda = NULL; proc_irda = NULL;
} }
} }

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irqueue.c * Filename: irqueue.c
* Version: 0.3 * Version: 0.3
* Description: General queue implementation * Description: General queue implementation
@ -10,28 +10,28 @@
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* Modified at: Thu Jan 4 14:29:10 CET 2001 * Modified at: Thu Jan 4 14:29:10 CET 2001
* Modified by: Marc Zyngier <mzyngier@freesurf.fr> * Modified by: Marc Zyngier <mzyngier@freesurf.fr>
* *
* Copyright (C) 1998-1999, Aage Kvalnes <aage@cs.uit.no> * Copyright (C) 1998-1999, Aage Kvalnes <aage@cs.uit.no>
* Copyright (C) 1998, Dag Brattli, * Copyright (C) 1998, Dag Brattli,
* All Rights Reserved. * All Rights Reserved.
* *
* This code is taken from the Vortex Operating System written by Aage * This code is taken from the Vortex Operating System written by Aage
* Kvalnes. Aage has agreed that this code can use the GPL licence, * Kvalnes. Aage has agreed that this code can use the GPL licence,
* although he does not use that licence in his own code. * although he does not use that licence in his own code.
* *
* This copyright does however _not_ include the ELF hash() function * This copyright does however _not_ include the ELF hash() function
* which I currently don't know which licence or copyright it * which I currently don't know which licence or copyright it
* has. Please inform me if you know. * has. Please inform me if you know.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
/* /*
@ -213,7 +213,7 @@ static __u32 hash( const char* name)
{ {
__u32 h = 0; __u32 h = 0;
__u32 g; __u32 g;
while(*name) { while(*name) {
h = (h<<4) + *name++; h = (h<<4) + *name++;
if ((g = (h & 0xf0000000))) if ((g = (h & 0xf0000000)))
@ -231,7 +231,7 @@ static __u32 hash( const char* name)
*/ */
static void enqueue_first(irda_queue_t **queue, irda_queue_t* element) static void enqueue_first(irda_queue_t **queue, irda_queue_t* element)
{ {
IRDA_DEBUG( 4, "%s()\n", __FUNCTION__); IRDA_DEBUG( 4, "%s()\n", __FUNCTION__);
/* /*
@ -242,7 +242,7 @@ static void enqueue_first(irda_queue_t **queue, irda_queue_t* element)
* Queue is empty. Insert one element into the queue. * Queue is empty. Insert one element into the queue.
*/ */
element->q_next = element->q_prev = *queue = element; element->q_next = element->q_prev = *queue = element;
} else { } else {
/* /*
* Queue is not empty. Insert element into front of queue. * Queue is not empty. Insert element into front of queue.
@ -267,20 +267,20 @@ static irda_queue_t *dequeue_first(irda_queue_t **queue)
irda_queue_t *ret; irda_queue_t *ret;
IRDA_DEBUG( 4, "dequeue_first()\n"); IRDA_DEBUG( 4, "dequeue_first()\n");
/* /*
* Set return value * Set return value
*/ */
ret = *queue; ret = *queue;
if ( *queue == NULL ) { if ( *queue == NULL ) {
/* /*
* Queue was empty. * Queue was empty.
*/ */
} else if ( (*queue)->q_next == *queue ) { } else if ( (*queue)->q_next == *queue ) {
/* /*
* Queue only contained a single element. It will now be * Queue only contained a single element. It will now be
* empty. * empty.
*/ */
*queue = NULL; *queue = NULL;
} else { } else {
@ -291,7 +291,7 @@ static irda_queue_t *dequeue_first(irda_queue_t **queue)
(*queue)->q_next->q_prev = (*queue)->q_prev; (*queue)->q_next->q_prev = (*queue)->q_prev;
*queue = (*queue)->q_next; *queue = (*queue)->q_next;
} }
/* /*
* Return the removed entry (or NULL of queue was empty). * Return the removed entry (or NULL of queue was empty).
*/ */
@ -306,25 +306,25 @@ static irda_queue_t *dequeue_first(irda_queue_t **queue)
static irda_queue_t *dequeue_general(irda_queue_t **queue, irda_queue_t* element) static irda_queue_t *dequeue_general(irda_queue_t **queue, irda_queue_t* element)
{ {
irda_queue_t *ret; irda_queue_t *ret;
IRDA_DEBUG( 4, "dequeue_general()\n"); IRDA_DEBUG( 4, "dequeue_general()\n");
/* /*
* Set return value * Set return value
*/ */
ret = *queue; ret = *queue;
if ( *queue == NULL ) { if ( *queue == NULL ) {
/* /*
* Queue was empty. * Queue was empty.
*/ */
} else if ( (*queue)->q_next == *queue ) { } else if ( (*queue)->q_next == *queue ) {
/* /*
* Queue only contained a single element. It will now be * Queue only contained a single element. It will now be
* empty. * empty.
*/ */
*queue = NULL; *queue = NULL;
} else { } else {
/* /*
* Remove specific element. * Remove specific element.
@ -334,7 +334,7 @@ static irda_queue_t *dequeue_general(irda_queue_t **queue, irda_queue_t* element
if ( (*queue) == element) if ( (*queue) == element)
(*queue) = element->q_next; (*queue) = element->q_next;
} }
/* /*
* Return the removed entry (or NULL of queue was empty). * Return the removed entry (or NULL of queue was empty).
*/ */
@ -352,7 +352,7 @@ static irda_queue_t *dequeue_general(irda_queue_t **queue, irda_queue_t* element
hashbin_t *hashbin_new(int type) hashbin_t *hashbin_new(int type)
{ {
hashbin_t* hashbin; hashbin_t* hashbin;
/* /*
* Allocate new hashbin * Allocate new hashbin
*/ */
@ -380,8 +380,8 @@ EXPORT_SYMBOL(hashbin_new);
/* /*
* Function hashbin_delete (hashbin, free_func) * Function hashbin_delete (hashbin, free_func)
* *
* Destroy hashbin, the free_func can be a user supplied special routine * Destroy hashbin, the free_func can be a user supplied special routine
* for deallocating this structure if it's complex. If not the user can * for deallocating this structure if it's complex. If not the user can
* just supply kfree, which should take care of the job. * just supply kfree, which should take care of the job.
*/ */
int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func) int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
@ -392,7 +392,7 @@ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
IRDA_ASSERT(hashbin != NULL, return -1;); IRDA_ASSERT(hashbin != NULL, return -1;);
IRDA_ASSERT(hashbin->magic == HB_MAGIC, return -1;); IRDA_ASSERT(hashbin->magic == HB_MAGIC, return -1;);
/* Synchronize */ /* Synchronize */
if ( hashbin->hb_type & HB_LOCK ) { if ( hashbin->hb_type & HB_LOCK ) {
spin_lock_irqsave(&hashbin->hb_spinlock, flags); spin_lock_irqsave(&hashbin->hb_spinlock, flags);
@ -407,11 +407,11 @@ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
while (queue ) { while (queue ) {
if (free_func) if (free_func)
(*free_func)(queue); (*free_func)(queue);
queue = dequeue_first( queue = dequeue_first(
(irda_queue_t**) &hashbin->hb_queue[i]); (irda_queue_t**) &hashbin->hb_queue[i]);
} }
} }
/* Cleanup local data */ /* Cleanup local data */
hashbin->hb_current = NULL; hashbin->hb_current = NULL;
hashbin->magic = ~HB_MAGIC; hashbin->magic = ~HB_MAGIC;
@ -438,7 +438,7 @@ EXPORT_SYMBOL(hashbin_delete);
* Insert an entry into the hashbin * Insert an entry into the hashbin
* *
*/ */
void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv,
const char* name) const char* name)
{ {
unsigned long flags = 0; unsigned long flags = 0;
@ -460,14 +460,14 @@ void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv,
if ( hashbin->hb_type & HB_LOCK ) { if ( hashbin->hb_type & HB_LOCK ) {
spin_lock_irqsave(&hashbin->hb_spinlock, flags); spin_lock_irqsave(&hashbin->hb_spinlock, flags);
} /* Default is no-lock */ } /* Default is no-lock */
/* /*
* Store name and key * Store name and key
*/ */
entry->q_hash = hashv; entry->q_hash = hashv;
if ( name ) if ( name )
strlcpy( entry->q_name, name, sizeof(entry->q_name)); strlcpy( entry->q_name, name, sizeof(entry->q_name));
/* /*
* Insert new entry first * Insert new entry first
*/ */
@ -482,7 +482,7 @@ void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv,
} }
EXPORT_SYMBOL(hashbin_insert); EXPORT_SYMBOL(hashbin_insert);
/* /*
* Function hashbin_remove_first (hashbin) * Function hashbin_remove_first (hashbin)
* *
* Remove first entry of the hashbin * Remove first entry of the hashbin
@ -537,7 +537,7 @@ void *hashbin_remove_first( hashbin_t *hashbin)
} }
/* /*
* Function hashbin_remove (hashbin, hashv, name) * Function hashbin_remove (hashbin, hashv, name)
* *
* Remove entry with the given name * Remove entry with the given name
@ -561,7 +561,7 @@ void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name)
IRDA_ASSERT( hashbin != NULL, return NULL;); IRDA_ASSERT( hashbin != NULL, return NULL;);
IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;); IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;);
/* /*
* Locate hashbin * Locate hashbin
*/ */
@ -601,7 +601,7 @@ void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name)
entry = entry->q_next; entry = entry->q_next;
} while ( entry != hashbin->hb_queue[ bin ] ); } while ( entry != hashbin->hb_queue[ bin ] );
} }
/* /*
* If entry was found, dequeue it * If entry was found, dequeue it
*/ */
@ -622,18 +622,18 @@ void* hashbin_remove( hashbin_t* hashbin, long hashv, const char* name)
if ( hashbin->hb_type & HB_LOCK ) { if ( hashbin->hb_type & HB_LOCK ) {
spin_unlock_irqrestore(&hashbin->hb_spinlock, flags); spin_unlock_irqrestore(&hashbin->hb_spinlock, flags);
} /* Default is no-lock */ } /* Default is no-lock */
/* Return */ /* Return */
if ( found ) if ( found )
return entry; return entry;
else else
return NULL; return NULL;
} }
EXPORT_SYMBOL(hashbin_remove); EXPORT_SYMBOL(hashbin_remove);
/* /*
* Function hashbin_remove_this (hashbin, entry) * Function hashbin_remove_this (hashbin, entry)
* *
* Remove entry with the given name * Remove entry with the given name
@ -655,7 +655,7 @@ void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry)
IRDA_ASSERT( hashbin != NULL, return NULL;); IRDA_ASSERT( hashbin != NULL, return NULL;);
IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;); IRDA_ASSERT( hashbin->magic == HB_MAGIC, return NULL;);
IRDA_ASSERT( entry != NULL, return NULL;); IRDA_ASSERT( entry != NULL, return NULL;);
/* Synchronize */ /* Synchronize */
if ( hashbin->hb_type & HB_LOCK ) { if ( hashbin->hb_type & HB_LOCK ) {
spin_lock_irqsave(&hashbin->hb_spinlock, flags); spin_lock_irqsave(&hashbin->hb_spinlock, flags);
@ -722,7 +722,7 @@ void* hashbin_find( hashbin_t* hashbin, long hashv, const char* name )
if ( name ) if ( name )
hashv = hash( name ); hashv = hash( name );
bin = GET_HASHBIN( hashv ); bin = GET_HASHBIN( hashv );
/* /*
* Search for entry * Search for entry
*/ */
@ -829,7 +829,7 @@ void* hashbin_find_next( hashbin_t* hashbin, long hashv, const char* name,
* called before any calls to hashbin_get_next()! * called before any calls to hashbin_get_next()!
* *
*/ */
irda_queue_t *hashbin_get_first( hashbin_t* hashbin) irda_queue_t *hashbin_get_first( hashbin_t* hashbin)
{ {
irda_queue_t *entry; irda_queue_t *entry;
int i; int i;
@ -860,7 +860,7 @@ EXPORT_SYMBOL(hashbin_get_first);
* Get next item in hashbin. A series of hashbin_get_next() calls must * Get next item in hashbin. A series of hashbin_get_next() calls must
* be started by a call to hashbin_get_first(). The function returns * be started by a call to hashbin_get_first(). The function returns
* NULL when all items have been traversed * NULL when all items have been traversed
* *
* The context of the search is stored within the hashbin, so you must * The context of the search is stored within the hashbin, so you must
* protect yourself from concurrent enumerations. - Jean II * protect yourself from concurrent enumerations. - Jean II
*/ */
@ -876,13 +876,13 @@ irda_queue_t *hashbin_get_next( hashbin_t *hashbin)
if ( hashbin->hb_current == NULL) { if ( hashbin->hb_current == NULL) {
IRDA_ASSERT( hashbin->hb_current != NULL, return NULL;); IRDA_ASSERT( hashbin->hb_current != NULL, return NULL;);
return NULL; return NULL;
} }
entry = hashbin->hb_current->q_next; entry = hashbin->hb_current->q_next;
bin = GET_HASHBIN( entry->q_hash); bin = GET_HASHBIN( entry->q_hash);
/* /*
* Make sure that we are not back at the beginning of the queue * Make sure that we are not back at the beginning of the queue
* again * again
*/ */
if ( entry != hashbin->hb_queue[ bin ]) { if ( entry != hashbin->hb_queue[ bin ]) {
hashbin->hb_current = entry; hashbin->hb_current = entry;
@ -895,7 +895,7 @@ irda_queue_t *hashbin_get_next( hashbin_t *hashbin)
*/ */
if ( bin >= HASHBIN_SIZE) if ( bin >= HASHBIN_SIZE)
return NULL; return NULL;
/* /*
* Move to next queue in hashbin * Move to next queue in hashbin
*/ */
@ -904,7 +904,7 @@ irda_queue_t *hashbin_get_next( hashbin_t *hashbin)
entry = hashbin->hb_queue[ i]; entry = hashbin->hb_queue[ i];
if ( entry) { if ( entry) {
hashbin->hb_current = entry; hashbin->hb_current = entry;
return entry; return entry;
} }
} }

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irsysctl.c * Filename: irsysctl.c
* Version: 1.0 * Version: 1.0
* Description: Sysctl interface for IrDA * Description: Sysctl interface for IrDA
@ -8,19 +8,19 @@
* Created at: Sun May 24 22:12:06 1998 * Created at: Sun May 24 22:12:06 1998
* Modified at: Fri Jun 4 02:50:15 1999 * Modified at: Fri Jun 4 02:50:15 1999
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1997, 1999 Dag Brattli, All Rights Reserved. * Copyright (c) 1997, 1999 Dag Brattli, All Rights Reserved.
* Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com> * Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
#include <linux/mm.h> #include <linux/mm.h>
@ -111,7 +111,7 @@ static ctl_table irda_table[] = {
.strategy = &sysctl_string .strategy = &sysctl_string
}, },
#ifdef CONFIG_IRDA_DEBUG #ifdef CONFIG_IRDA_DEBUG
{ {
.ctl_name = DEBUG, .ctl_name = DEBUG,
.procname = "debug", .procname = "debug",
.data = &irda_debug, .data = &irda_debug,
@ -121,7 +121,7 @@ static ctl_table irda_table[] = {
}, },
#endif #endif
#ifdef CONFIG_IRDA_FAST_RR #ifdef CONFIG_IRDA_FAST_RR
{ {
.ctl_name = FAST_POLL, .ctl_name = FAST_POLL,
.procname = "fast_poll_increase", .procname = "fast_poll_increase",
.data = &sysctl_fast_poll_increase, .data = &sysctl_fast_poll_increase,
@ -287,7 +287,7 @@ int __init irda_sysctl_register(void)
* Unregister our sysctl interface * Unregister our sysctl interface
* *
*/ */
void __exit irda_sysctl_unregister(void) void __exit irda_sysctl_unregister(void)
{ {
unregister_sysctl_table(irda_table_header); unregister_sysctl_table(irda_table_header);
} }

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: irttp.c * Filename: irttp.c
* Version: 1.2 * Version: 1.2
* Description: Tiny Transport Protocol (TTP) implementation * Description: Tiny Transport Protocol (TTP) implementation
@ -8,18 +8,18 @@
* Created at: Sun Aug 31 20:14:31 1997 * Created at: Sun Aug 31 20:14:31 1997
* Modified at: Wed Jan 5 11:31:27 2000 * Modified at: Wed Jan 5 11:31:27 2000
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>, * Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>,
* All Rights Reserved. * All Rights Reserved.
* Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com> * Copyright (c) 2000-2003 Jean Tourrilhes <jt@hpl.hp.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
@ -42,17 +42,17 @@ static struct irttp_cb *irttp;
static void __irttp_close_tsap(struct tsap_cb *self); static void __irttp_close_tsap(struct tsap_cb *self);
static int irttp_data_indication(void *instance, void *sap, static int irttp_data_indication(void *instance, void *sap,
struct sk_buff *skb); struct sk_buff *skb);
static int irttp_udata_indication(void *instance, void *sap, static int irttp_udata_indication(void *instance, void *sap,
struct sk_buff *skb); struct sk_buff *skb);
static void irttp_disconnect_indication(void *instance, void *sap, static void irttp_disconnect_indication(void *instance, void *sap,
LM_REASON reason, struct sk_buff *); LM_REASON reason, struct sk_buff *);
static void irttp_connect_indication(void *instance, void *sap, static void irttp_connect_indication(void *instance, void *sap,
struct qos_info *qos, __u32 max_sdu_size, struct qos_info *qos, __u32 max_sdu_size,
__u8 header_size, struct sk_buff *skb); __u8 header_size, struct sk_buff *skb);
static void irttp_connect_confirm(void *instance, void *sap, static void irttp_connect_confirm(void *instance, void *sap,
struct qos_info *qos, __u32 max_sdu_size, struct qos_info *qos, __u32 max_sdu_size,
__u8 header_size, struct sk_buff *skb); __u8 header_size, struct sk_buff *skb);
static void irttp_run_tx_queue(struct tsap_cb *self); static void irttp_run_tx_queue(struct tsap_cb *self);
static void irttp_run_rx_queue(struct tsap_cb *self); static void irttp_run_rx_queue(struct tsap_cb *self);
@ -61,7 +61,7 @@ static void irttp_flush_queues(struct tsap_cb *self);
static void irttp_fragment_skb(struct tsap_cb *self, struct sk_buff *skb); static void irttp_fragment_skb(struct tsap_cb *self, struct sk_buff *skb);
static struct sk_buff *irttp_reassemble_skb(struct tsap_cb *self); static struct sk_buff *irttp_reassemble_skb(struct tsap_cb *self);
static void irttp_todo_expired(unsigned long data); static void irttp_todo_expired(unsigned long data);
static int irttp_param_max_sdu_size(void *instance, irda_param_t *param, static int irttp_param_max_sdu_size(void *instance, irda_param_t *param,
int get); int get);
static void irttp_flow_indication(void *instance, void *sap, LOCAL_FLOW flow); static void irttp_flow_indication(void *instance, void *sap, LOCAL_FLOW flow);
@ -109,7 +109,7 @@ int __init irttp_init(void)
* Called by module destruction/cleanup code * Called by module destruction/cleanup code
* *
*/ */
void __exit irttp_cleanup(void) void __exit irttp_cleanup(void)
{ {
/* Check for main structure */ /* Check for main structure */
IRDA_ASSERT(irttp->magic == TTP_MAGIC, return;); IRDA_ASSERT(irttp->magic == TTP_MAGIC, return;);
@ -865,7 +865,7 @@ static int irttp_udata_indication(void *instance, void *sap,
err = self->notify.udata_indication(self->notify.instance, err = self->notify.udata_indication(self->notify.instance,
self,skb); self,skb);
/* Same comment as in irttp_do_data_indication() */ /* Same comment as in irttp_do_data_indication() */
if (!err) if (!err)
return 0; return 0;
} }
/* Either no handler, or handler returns an error */ /* Either no handler, or handler returns an error */
@ -940,7 +940,7 @@ static int irttp_data_indication(void *instance, void *sap,
/* /*
* If the peer device has given us some credits and we didn't have * If the peer device has given us some credits and we didn't have
* anyone from before, then we need to shedule the tx queue. * anyone from before, then we need to shedule the tx queue.
* We need to do that because our Tx have stopped (so we may not * We need to do that because our Tx have stopped (so we may not
* get any LAP flow indication) and the user may be stopped as * get any LAP flow indication) and the user may be stopped as
* well. - Jean II * well. - Jean II
@ -1798,14 +1798,14 @@ static void *irttp_seq_start(struct seq_file *seq, loff_t *pos)
spin_lock_irq(&irttp->tsaps->hb_spinlock); spin_lock_irq(&irttp->tsaps->hb_spinlock);
iter->id = 0; iter->id = 0;
for (self = (struct tsap_cb *) hashbin_get_first(irttp->tsaps); for (self = (struct tsap_cb *) hashbin_get_first(irttp->tsaps);
self != NULL; self != NULL;
self = (struct tsap_cb *) hashbin_get_next(irttp->tsaps)) { self = (struct tsap_cb *) hashbin_get_next(irttp->tsaps)) {
if (iter->id == *pos) if (iter->id == *pos)
break; break;
++iter->id; ++iter->id;
} }
return self; return self;
} }

View file

@ -563,7 +563,7 @@ static int irda_param_extract(void *self, __u8 *buf, int len,
* safe. Returns the number of bytes that was parsed * safe. Returns the number of bytes that was parsed
* *
*/ */
int irda_param_extract_all(void *self, __u8 *buf, int len, int irda_param_extract_all(void *self, __u8 *buf, int len,
pi_param_info_t *info) pi_param_info_t *info)
{ {
int ret = -1; int ret = -1;

View file

@ -1,5 +1,5 @@
/********************************************************************* /*********************************************************************
* *
* Filename: qos.c * Filename: qos.c
* Version: 1.0 * Version: 1.0
* Description: IrLAP QoS parameter negotiation * Description: IrLAP QoS parameter negotiation
@ -8,26 +8,26 @@
* Created at: Tue Sep 9 00:00:26 1997 * Created at: Tue Sep 9 00:00:26 1997
* Modified at: Sun Jan 30 14:29:16 2000 * Modified at: Sun Jan 30 14:29:16 2000
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>, * Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>,
* All Rights Reserved. * All Rights Reserved.
* Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com> * Copyright (c) 2000-2001 Jean Tourrilhes <jt@hpl.hp.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA * MA 02111-1307 USA
* *
********************************************************************/ ********************************************************************/
#include <asm/byteorder.h> #include <asm/byteorder.h>
@ -84,16 +84,16 @@ unsigned sysctl_max_tx_data_size = 2042;
unsigned sysctl_max_tx_window = 7; unsigned sysctl_max_tx_window = 7;
static int irlap_param_baud_rate(void *instance, irda_param_t *param, int get); static int irlap_param_baud_rate(void *instance, irda_param_t *param, int get);
static int irlap_param_link_disconnect(void *instance, irda_param_t *parm, static int irlap_param_link_disconnect(void *instance, irda_param_t *parm,
int get); int get);
static int irlap_param_max_turn_time(void *instance, irda_param_t *param, static int irlap_param_max_turn_time(void *instance, irda_param_t *param,
int get); int get);
static int irlap_param_data_size(void *instance, irda_param_t *param, int get); static int irlap_param_data_size(void *instance, irda_param_t *param, int get);
static int irlap_param_window_size(void *instance, irda_param_t *param, static int irlap_param_window_size(void *instance, irda_param_t *param,
int get); int get);
static int irlap_param_additional_bofs(void *instance, irda_param_t *parm, static int irlap_param_additional_bofs(void *instance, irda_param_t *parm,
int get); int get);
static int irlap_param_min_turn_time(void *instance, irda_param_t *param, static int irlap_param_min_turn_time(void *instance, irda_param_t *param,
int get); int get);
#ifndef CONFIG_IRDA_DYNAMIC_WINDOW #ifndef CONFIG_IRDA_DYNAMIC_WINDOW
@ -101,7 +101,7 @@ static __u32 irlap_requested_line_capacity(struct qos_info *qos);
#endif #endif
static __u32 min_turn_times[] = { 10000, 5000, 1000, 500, 100, 50, 10, 0 }; /* us */ static __u32 min_turn_times[] = { 10000, 5000, 1000, 500, 100, 50, 10, 0 }; /* us */
static __u32 baud_rates[] = { 2400, 9600, 19200, 38400, 57600, 115200, 576000, static __u32 baud_rates[] = { 2400, 9600, 19200, 38400, 57600, 115200, 576000,
1152000, 4000000, 16000000 }; /* bps */ 1152000, 4000000, 16000000 }; /* bps */
static __u32 data_sizes[] = { 64, 128, 256, 512, 1024, 2048 }; /* bytes */ static __u32 data_sizes[] = { 64, 128, 256, 512, 1024, 2048 }; /* bytes */
static __u32 add_bofs[] = { 48, 24, 12, 5, 3, 2, 1, 0 }; /* bytes */ static __u32 add_bofs[] = { 48, 24, 12, 5, 3, 2, 1, 0 }; /* bytes */
@ -165,7 +165,7 @@ static pi_param_info_t irlap_param_info = { pi_major_call_table, 2, 0x7f, 7 };
static inline int value_index(__u32 value, __u32 *array, int size) static inline int value_index(__u32 value, __u32 *array, int size)
{ {
int i; int i;
for (i=0; i < size; i++) for (i=0; i < size; i++)
if (array[i] == value) if (array[i] == value)
break; break;
@ -178,7 +178,7 @@ static inline int value_index(__u32 value, __u32 *array, int size)
* Returns value to index in array, easy! * Returns value to index in array, easy!
* *
*/ */
static inline __u32 index_value(int index, __u32 *array) static inline __u32 index_value(int index, __u32 *array)
{ {
return array[index]; return array[index];
} }
@ -189,7 +189,7 @@ static inline __u32 index_value(int index, __u32 *array)
* Returns index to most significant bit (MSB) in word * Returns index to most significant bit (MSB) in word
* *
*/ */
static int msb_index (__u16 word) static int msb_index (__u16 word)
{ {
__u16 msb = 0x8000; __u16 msb = 0x8000;
int index = 15; /* Current MSB */ int index = 15; /* Current MSB */
@ -298,12 +298,12 @@ void irda_qos_compute_intersection(struct qos_info *qos, struct qos_info *new)
* *
* The purpose of this function is for layers and drivers to be able to * The purpose of this function is for layers and drivers to be able to
* set the maximum QoS possible and then "and in" their own limitations * set the maximum QoS possible and then "and in" their own limitations
* *
*/ */
void irda_init_max_qos_capabilies(struct qos_info *qos) void irda_init_max_qos_capabilies(struct qos_info *qos)
{ {
int i; int i;
/* /*
* These are the maximum supported values as specified on pages * These are the maximum supported values as specified on pages
* 39-43 in IrLAP * 39-43 in IrLAP
*/ */
@ -361,25 +361,25 @@ static void irlap_adjust_qos_settings(struct qos_info *qos)
qos->min_turn_time.value = sysctl_min_tx_turn_time; qos->min_turn_time.value = sysctl_min_tx_turn_time;
} }
/* /*
* Not allowed to use a max turn time less than 500 ms if the baudrate * Not allowed to use a max turn time less than 500 ms if the baudrate
* is less than 115200 * is less than 115200
*/ */
if ((qos->baud_rate.value < 115200) && if ((qos->baud_rate.value < 115200) &&
(qos->max_turn_time.value < 500)) (qos->max_turn_time.value < 500))
{ {
IRDA_DEBUG(0, IRDA_DEBUG(0,
"%s(), adjusting max turn time from %d to 500 ms\n", "%s(), adjusting max turn time from %d to 500 ms\n",
__FUNCTION__, qos->max_turn_time.value); __FUNCTION__, qos->max_turn_time.value);
qos->max_turn_time.value = 500; qos->max_turn_time.value = 500;
} }
/* /*
* The data size must be adjusted according to the baud rate and max * The data size must be adjusted according to the baud rate and max
* turn time * turn time
*/ */
index = value_index(qos->data_size.value, data_sizes, 6); index = value_index(qos->data_size.value, data_sizes, 6);
line_capacity = irlap_max_line_capacity(qos->baud_rate.value, line_capacity = irlap_max_line_capacity(qos->baud_rate.value,
qos->max_turn_time.value); qos->max_turn_time.value);
#ifdef CONFIG_IRDA_DYNAMIC_WINDOW #ifdef CONFIG_IRDA_DYNAMIC_WINDOW
@ -427,32 +427,32 @@ static void irlap_adjust_qos_settings(struct qos_info *qos)
* We just set the QoS capabilities for the peer station * We just set the QoS capabilities for the peer station
* *
*/ */
int irlap_qos_negotiate(struct irlap_cb *self, struct sk_buff *skb) int irlap_qos_negotiate(struct irlap_cb *self, struct sk_buff *skb)
{ {
int ret; int ret;
ret = irda_param_extract_all(self, skb->data, skb->len, ret = irda_param_extract_all(self, skb->data, skb->len,
&irlap_param_info); &irlap_param_info);
/* Convert the negotiated bits to values */ /* Convert the negotiated bits to values */
irda_qos_bits_to_value(&self->qos_tx); irda_qos_bits_to_value(&self->qos_tx);
irda_qos_bits_to_value(&self->qos_rx); irda_qos_bits_to_value(&self->qos_rx);
irlap_adjust_qos_settings(&self->qos_tx); irlap_adjust_qos_settings(&self->qos_tx);
IRDA_DEBUG(2, "Setting BAUD_RATE to %d bps.\n", IRDA_DEBUG(2, "Setting BAUD_RATE to %d bps.\n",
self->qos_tx.baud_rate.value); self->qos_tx.baud_rate.value);
IRDA_DEBUG(2, "Setting DATA_SIZE to %d bytes\n", IRDA_DEBUG(2, "Setting DATA_SIZE to %d bytes\n",
self->qos_tx.data_size.value); self->qos_tx.data_size.value);
IRDA_DEBUG(2, "Setting WINDOW_SIZE to %d\n", IRDA_DEBUG(2, "Setting WINDOW_SIZE to %d\n",
self->qos_tx.window_size.value); self->qos_tx.window_size.value);
IRDA_DEBUG(2, "Setting XBOFS to %d\n", IRDA_DEBUG(2, "Setting XBOFS to %d\n",
self->qos_tx.additional_bofs.value); self->qos_tx.additional_bofs.value);
IRDA_DEBUG(2, "Setting MAX_TURN_TIME to %d ms.\n", IRDA_DEBUG(2, "Setting MAX_TURN_TIME to %d ms.\n",
self->qos_tx.max_turn_time.value); self->qos_tx.max_turn_time.value);
IRDA_DEBUG(2, "Setting MIN_TURN_TIME to %d usecs.\n", IRDA_DEBUG(2, "Setting MIN_TURN_TIME to %d usecs.\n",
self->qos_tx.min_turn_time.value); self->qos_tx.min_turn_time.value);
IRDA_DEBUG(2, "Setting LINK_DISC to %d secs.\n", IRDA_DEBUG(2, "Setting LINK_DISC to %d secs.\n",
self->qos_tx.link_disc_time.value); self->qos_tx.link_disc_time.value);
return ret; return ret;
} }
@ -463,55 +463,55 @@ int irlap_qos_negotiate(struct irlap_cb *self, struct sk_buff *skb)
* Insert QoS negotiaion pararameters into frame * Insert QoS negotiaion pararameters into frame
* *
*/ */
int irlap_insert_qos_negotiation_params(struct irlap_cb *self, int irlap_insert_qos_negotiation_params(struct irlap_cb *self,
struct sk_buff *skb) struct sk_buff *skb)
{ {
int ret; int ret;
/* Insert data rate */ /* Insert data rate */
ret = irda_param_insert(self, PI_BAUD_RATE, skb->tail, ret = irda_param_insert(self, PI_BAUD_RATE, skb->tail,
skb_tailroom(skb), &irlap_param_info); skb_tailroom(skb), &irlap_param_info);
if (ret < 0) if (ret < 0)
return ret; return ret;
skb_put(skb, ret); skb_put(skb, ret);
/* Insert max turnaround time */ /* Insert max turnaround time */
ret = irda_param_insert(self, PI_MAX_TURN_TIME, skb->tail, ret = irda_param_insert(self, PI_MAX_TURN_TIME, skb->tail,
skb_tailroom(skb), &irlap_param_info); skb_tailroom(skb), &irlap_param_info);
if (ret < 0) if (ret < 0)
return ret; return ret;
skb_put(skb, ret); skb_put(skb, ret);
/* Insert data size */ /* Insert data size */
ret = irda_param_insert(self, PI_DATA_SIZE, skb->tail, ret = irda_param_insert(self, PI_DATA_SIZE, skb->tail,
skb_tailroom(skb), &irlap_param_info); skb_tailroom(skb), &irlap_param_info);
if (ret < 0) if (ret < 0)
return ret; return ret;
skb_put(skb, ret); skb_put(skb, ret);
/* Insert window size */ /* Insert window size */
ret = irda_param_insert(self, PI_WINDOW_SIZE, skb->tail, ret = irda_param_insert(self, PI_WINDOW_SIZE, skb->tail,
skb_tailroom(skb), &irlap_param_info); skb_tailroom(skb), &irlap_param_info);
if (ret < 0) if (ret < 0)
return ret; return ret;
skb_put(skb, ret); skb_put(skb, ret);
/* Insert additional BOFs */ /* Insert additional BOFs */
ret = irda_param_insert(self, PI_ADD_BOFS, skb->tail, ret = irda_param_insert(self, PI_ADD_BOFS, skb->tail,
skb_tailroom(skb), &irlap_param_info); skb_tailroom(skb), &irlap_param_info);
if (ret < 0) if (ret < 0)
return ret; return ret;
skb_put(skb, ret); skb_put(skb, ret);
/* Insert minimum turnaround time */ /* Insert minimum turnaround time */
ret = irda_param_insert(self, PI_MIN_TURN_TIME, skb->tail, ret = irda_param_insert(self, PI_MIN_TURN_TIME, skb->tail,
skb_tailroom(skb), &irlap_param_info); skb_tailroom(skb), &irlap_param_info);
if (ret < 0) if (ret < 0)
return ret; return ret;
skb_put(skb, ret); skb_put(skb, ret);
/* Insert link disconnect/threshold time */ /* Insert link disconnect/threshold time */
ret = irda_param_insert(self, PI_LINK_DISC, skb->tail, ret = irda_param_insert(self, PI_LINK_DISC, skb->tail,
skb_tailroom(skb), &irlap_param_info); skb_tailroom(skb), &irlap_param_info);
if (ret < 0) if (ret < 0)
return ret; return ret;
@ -537,12 +537,12 @@ static int irlap_param_baud_rate(void *instance, irda_param_t *param, int get)
if (get) { if (get) {
param->pv.i = self->qos_rx.baud_rate.bits; param->pv.i = self->qos_rx.baud_rate.bits;
IRDA_DEBUG(2, "%s(), baud rate = 0x%02x\n", IRDA_DEBUG(2, "%s(), baud rate = 0x%02x\n",
__FUNCTION__, param->pv.i); __FUNCTION__, param->pv.i);
} else { } else {
/* /*
* Stations must agree on baud rate, so calculate * Stations must agree on baud rate, so calculate
* intersection * intersection
*/ */
IRDA_DEBUG(2, "Requested BAUD_RATE: 0x%04x\n", (__u16) param->pv.i); IRDA_DEBUG(2, "Requested BAUD_RATE: 0x%04x\n", (__u16) param->pv.i);
final = (__u16) param->pv.i & self->qos_rx.baud_rate.bits; final = (__u16) param->pv.i & self->qos_rx.baud_rate.bits;
@ -558,24 +558,24 @@ static int irlap_param_baud_rate(void *instance, irda_param_t *param, int get)
/* /*
* Function irlap_param_link_disconnect (instance, param, get) * Function irlap_param_link_disconnect (instance, param, get)
* *
* Negotiate link disconnect/threshold time. * Negotiate link disconnect/threshold time.
* *
*/ */
static int irlap_param_link_disconnect(void *instance, irda_param_t *param, static int irlap_param_link_disconnect(void *instance, irda_param_t *param,
int get) int get)
{ {
__u16 final; __u16 final;
struct irlap_cb *self = (struct irlap_cb *) instance; struct irlap_cb *self = (struct irlap_cb *) instance;
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;);
if (get) if (get)
param->pv.i = self->qos_rx.link_disc_time.bits; param->pv.i = self->qos_rx.link_disc_time.bits;
else { else {
/* /*
* Stations must agree on link disconnect/threshold * Stations must agree on link disconnect/threshold
* time. * time.
*/ */
IRDA_DEBUG(2, "LINK_DISC: %02x\n", (__u8) param->pv.i); IRDA_DEBUG(2, "LINK_DISC: %02x\n", (__u8) param->pv.i);
@ -595,14 +595,14 @@ static int irlap_param_link_disconnect(void *instance, irda_param_t *param,
* will be negotiated independently for each station * will be negotiated independently for each station
* *
*/ */
static int irlap_param_max_turn_time(void *instance, irda_param_t *param, static int irlap_param_max_turn_time(void *instance, irda_param_t *param,
int get) int get)
{ {
struct irlap_cb *self = (struct irlap_cb *) instance; struct irlap_cb *self = (struct irlap_cb *) instance;
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;);
if (get) if (get)
param->pv.i = self->qos_rx.max_turn_time.bits; param->pv.i = self->qos_rx.max_turn_time.bits;
else else
@ -621,10 +621,10 @@ static int irlap_param_max_turn_time(void *instance, irda_param_t *param,
static int irlap_param_data_size(void *instance, irda_param_t *param, int get) static int irlap_param_data_size(void *instance, irda_param_t *param, int get)
{ {
struct irlap_cb *self = (struct irlap_cb *) instance; struct irlap_cb *self = (struct irlap_cb *) instance;
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;);
if (get) if (get)
param->pv.i = self->qos_rx.data_size.bits; param->pv.i = self->qos_rx.data_size.bits;
else else
@ -640,14 +640,14 @@ static int irlap_param_data_size(void *instance, irda_param_t *param, int get)
* will be negotiated independently for each station * will be negotiated independently for each station
* *
*/ */
static int irlap_param_window_size(void *instance, irda_param_t *param, static int irlap_param_window_size(void *instance, irda_param_t *param,
int get) int get)
{ {
struct irlap_cb *self = (struct irlap_cb *) instance; struct irlap_cb *self = (struct irlap_cb *) instance;
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;);
if (get) if (get)
param->pv.i = self->qos_rx.window_size.bits; param->pv.i = self->qos_rx.window_size.bits;
else else
@ -665,10 +665,10 @@ static int irlap_param_window_size(void *instance, irda_param_t *param,
static int irlap_param_additional_bofs(void *instance, irda_param_t *param, int get) static int irlap_param_additional_bofs(void *instance, irda_param_t *param, int get)
{ {
struct irlap_cb *self = (struct irlap_cb *) instance; struct irlap_cb *self = (struct irlap_cb *) instance;
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;);
if (get) if (get)
param->pv.i = self->qos_rx.additional_bofs.bits; param->pv.i = self->qos_rx.additional_bofs.bits;
else else
@ -683,14 +683,14 @@ static int irlap_param_additional_bofs(void *instance, irda_param_t *param, int
* Negotiate the minimum turn around time. This is a type 1 parameter and * Negotiate the minimum turn around time. This is a type 1 parameter and
* will be negotiated independently for each station * will be negotiated independently for each station
*/ */
static int irlap_param_min_turn_time(void *instance, irda_param_t *param, static int irlap_param_min_turn_time(void *instance, irda_param_t *param,
int get) int get)
{ {
struct irlap_cb *self = (struct irlap_cb *) instance; struct irlap_cb *self = (struct irlap_cb *) instance;
IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self != NULL, return -1;);
IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;); IRDA_ASSERT(self->magic == LAP_MAGIC, return -1;);
if (get) if (get)
param->pv.i = self->qos_rx.min_turn_time.bits; param->pv.i = self->qos_rx.min_turn_time.bits;
else else
@ -721,9 +721,9 @@ __u32 irlap_max_line_capacity(__u32 speed, __u32 max_turn_time)
line_capacity = max_line_capacities[i][j]; line_capacity = max_line_capacities[i][j];
IRDA_DEBUG(2, "%s(), line capacity=%d bytes\n", IRDA_DEBUG(2, "%s(), line capacity=%d bytes\n",
__FUNCTION__, line_capacity); __FUNCTION__, line_capacity);
return line_capacity; return line_capacity;
} }
@ -749,7 +749,7 @@ void irda_qos_bits_to_value(struct qos_info *qos)
int index; int index;
IRDA_ASSERT(qos != NULL, return;); IRDA_ASSERT(qos != NULL, return;);
index = msb_index(qos->baud_rate.bits); index = msb_index(qos->baud_rate.bits);
qos->baud_rate.value = baud_rates[index]; qos->baud_rate.value = baud_rates[index];
@ -761,13 +761,13 @@ void irda_qos_bits_to_value(struct qos_info *qos)
index = msb_index(qos->min_turn_time.bits); index = msb_index(qos->min_turn_time.bits);
qos->min_turn_time.value = min_turn_times[index]; qos->min_turn_time.value = min_turn_times[index];
index = msb_index(qos->max_turn_time.bits); index = msb_index(qos->max_turn_time.bits);
qos->max_turn_time.value = max_turn_times[index]; qos->max_turn_time.value = max_turn_times[index];
index = msb_index(qos->link_disc_time.bits); index = msb_index(qos->link_disc_time.bits);
qos->link_disc_time.value = link_disc_times[index]; qos->link_disc_time.value = link_disc_times[index];
index = msb_index(qos->additional_bofs.bits); index = msb_index(qos->additional_bofs.bits);
qos->additional_bofs.value = add_bofs[index]; qos->additional_bofs.value = add_bofs[index];
} }

View file

@ -1,25 +1,25 @@
/********************************************************************* /*********************************************************************
* *
* Filename: timer.c * Filename: timer.c
* Version: * Version:
* Description: * Description:
* Status: Experimental. * Status: Experimental.
* Author: Dag Brattli <dagb@cs.uit.no> * Author: Dag Brattli <dagb@cs.uit.no>
* Created at: Sat Aug 16 00:59:29 1997 * Created at: Sat Aug 16 00:59:29 1997
* Modified at: Wed Dec 8 12:50:34 1999 * Modified at: Wed Dec 8 12:50:34 1999
* Modified by: Dag Brattli <dagb@cs.uit.no> * Modified by: Dag Brattli <dagb@cs.uit.no>
* *
* Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>, * Copyright (c) 1997, 1999 Dag Brattli <dagb@cs.uit.no>,
* All Rights Reserved. * All Rights Reserved.
* Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com> * Copyright (c) 2000-2002 Jean Tourrilhes <jt@hpl.hp.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of * published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version. * the License, or (at your option) any later version.
* *
* Neither Dag Brattli nor University of Tromsø admit liability nor * Neither Dag Brattli nor University of Tromsø admit liability nor
* provide warranty for any of this software. This material is * provide warranty for any of this software. This material is
* provided "AS-IS" and at no charge. * provided "AS-IS" and at no charge.
* *
********************************************************************/ ********************************************************************/
@ -40,11 +40,11 @@ static void irlap_query_timer_expired(void* data);
static void irlap_final_timer_expired(void* data); static void irlap_final_timer_expired(void* data);
static void irlap_wd_timer_expired(void* data); static void irlap_wd_timer_expired(void* data);
static void irlap_backoff_timer_expired(void* data); static void irlap_backoff_timer_expired(void* data);
static void irlap_media_busy_expired(void* data); static void irlap_media_busy_expired(void* data);
void irlap_start_slot_timer(struct irlap_cb *self, int timeout) void irlap_start_slot_timer(struct irlap_cb *self, int timeout)
{ {
irda_start_timer(&self->slot_timer, timeout, (void *) self, irda_start_timer(&self->slot_timer, timeout, (void *) self,
irlap_slot_timer_expired); irlap_slot_timer_expired);
} }
@ -67,31 +67,31 @@ void irlap_start_query_timer(struct irlap_cb *self, int S, int s)
/* Set or re-set the timer. We reset the timer for each received /* Set or re-set the timer. We reset the timer for each received
* discovery query, which allow us to automatically adjust to * discovery query, which allow us to automatically adjust to
* the speed of the peer discovery (faster or slower). Jean II */ * the speed of the peer discovery (faster or slower). Jean II */
irda_start_timer( &self->query_timer, timeout, (void *) self, irda_start_timer( &self->query_timer, timeout, (void *) self,
irlap_query_timer_expired); irlap_query_timer_expired);
} }
void irlap_start_final_timer(struct irlap_cb *self, int timeout) void irlap_start_final_timer(struct irlap_cb *self, int timeout)
{ {
irda_start_timer(&self->final_timer, timeout, (void *) self, irda_start_timer(&self->final_timer, timeout, (void *) self,
irlap_final_timer_expired); irlap_final_timer_expired);
} }
void irlap_start_wd_timer(struct irlap_cb *self, int timeout) void irlap_start_wd_timer(struct irlap_cb *self, int timeout)
{ {
irda_start_timer(&self->wd_timer, timeout, (void *) self, irda_start_timer(&self->wd_timer, timeout, (void *) self,
irlap_wd_timer_expired); irlap_wd_timer_expired);
} }
void irlap_start_backoff_timer(struct irlap_cb *self, int timeout) void irlap_start_backoff_timer(struct irlap_cb *self, int timeout)
{ {
irda_start_timer(&self->backoff_timer, timeout, (void *) self, irda_start_timer(&self->backoff_timer, timeout, (void *) self,
irlap_backoff_timer_expired); irlap_backoff_timer_expired);
} }
void irlap_start_mbusy_timer(struct irlap_cb *self, int timeout) void irlap_start_mbusy_timer(struct irlap_cb *self, int timeout)
{ {
irda_start_timer(&self->media_busy_timer, timeout, irda_start_timer(&self->media_busy_timer, timeout,
(void *) self, irlap_media_busy_expired); (void *) self, irlap_media_busy_expired);
} }
@ -109,25 +109,25 @@ void irlap_stop_mbusy_timer(struct irlap_cb *self)
irlap_do_event(self, MEDIA_BUSY_TIMER_EXPIRED, NULL, NULL); irlap_do_event(self, MEDIA_BUSY_TIMER_EXPIRED, NULL, NULL);
} }
void irlmp_start_watchdog_timer(struct lsap_cb *self, int timeout) void irlmp_start_watchdog_timer(struct lsap_cb *self, int timeout)
{ {
irda_start_timer(&self->watchdog_timer, timeout, (void *) self, irda_start_timer(&self->watchdog_timer, timeout, (void *) self,
irlmp_watchdog_timer_expired); irlmp_watchdog_timer_expired);
} }
void irlmp_start_discovery_timer(struct irlmp_cb *self, int timeout) void irlmp_start_discovery_timer(struct irlmp_cb *self, int timeout)
{ {
irda_start_timer(&self->discovery_timer, timeout, (void *) self, irda_start_timer(&self->discovery_timer, timeout, (void *) self,
irlmp_discovery_timer_expired); irlmp_discovery_timer_expired);
} }
void irlmp_start_idle_timer(struct lap_cb *self, int timeout) void irlmp_start_idle_timer(struct lap_cb *self, int timeout)
{ {
irda_start_timer(&self->idle_timer, timeout, (void *) self, irda_start_timer(&self->idle_timer, timeout, (void *) self,
irlmp_idle_timer_expired); irlmp_idle_timer_expired);
} }
void irlmp_stop_idle_timer(struct lap_cb *self) void irlmp_stop_idle_timer(struct lap_cb *self)
{ {
/* If timer is activated, kill it! */ /* If timer is activated, kill it! */
del_timer(&self->idle_timer); del_timer(&self->idle_timer);
@ -147,7 +147,7 @@ static void irlap_slot_timer_expired(void *data)
IRDA_ASSERT(self->magic == LAP_MAGIC, return;); IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
irlap_do_event(self, SLOT_TIMER_EXPIRED, NULL, NULL); irlap_do_event(self, SLOT_TIMER_EXPIRED, NULL, NULL);
} }
/* /*
* Function irlap_query_timer_expired (data) * Function irlap_query_timer_expired (data)
@ -163,12 +163,12 @@ static void irlap_query_timer_expired(void *data)
IRDA_ASSERT(self->magic == LAP_MAGIC, return;); IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
irlap_do_event(self, QUERY_TIMER_EXPIRED, NULL, NULL); irlap_do_event(self, QUERY_TIMER_EXPIRED, NULL, NULL);
} }
/* /*
* Function irda_final_timer_expired (data) * Function irda_final_timer_expired (data)
* *
* *
* *
*/ */
static void irlap_final_timer_expired(void *data) static void irlap_final_timer_expired(void *data)
@ -184,32 +184,32 @@ static void irlap_final_timer_expired(void *data)
/* /*
* Function irda_wd_timer_expired (data) * Function irda_wd_timer_expired (data)
* *
* *
* *
*/ */
static void irlap_wd_timer_expired(void *data) static void irlap_wd_timer_expired(void *data)
{ {
struct irlap_cb *self = (struct irlap_cb *) data; struct irlap_cb *self = (struct irlap_cb *) data;
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == LAP_MAGIC, return;); IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
irlap_do_event(self, WD_TIMER_EXPIRED, NULL, NULL); irlap_do_event(self, WD_TIMER_EXPIRED, NULL, NULL);
} }
/* /*
* Function irda_backoff_timer_expired (data) * Function irda_backoff_timer_expired (data)
* *
* *
* *
*/ */
static void irlap_backoff_timer_expired(void *data) static void irlap_backoff_timer_expired(void *data)
{ {
struct irlap_cb *self = (struct irlap_cb *) data; struct irlap_cb *self = (struct irlap_cb *) data;
IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == LAP_MAGIC, return;); IRDA_ASSERT(self->magic == LAP_MAGIC, return;);
irlap_do_event(self, BACKOFF_TIMER_EXPIRED, NULL, NULL); irlap_do_event(self, BACKOFF_TIMER_EXPIRED, NULL, NULL);
} }
@ -217,7 +217,7 @@ static void irlap_backoff_timer_expired(void *data)
/* /*
* Function irtty_media_busy_expired (data) * Function irtty_media_busy_expired (data)
* *
* *
*/ */
void irlap_media_busy_expired(void* data) void irlap_media_busy_expired(void* data)
{ {

View file

@ -295,7 +295,7 @@ async_unwrap_bof(struct net_device *dev,
case OUTSIDE_FRAME: case OUTSIDE_FRAME:
case BEGIN_FRAME: case BEGIN_FRAME:
default: default:
/* We may receive multiple BOF at the start of frame */ /* We may receive multiple BOF at the start of frame */
break; break;
} }