From 887ac0a0bd78cca04126a072d162d41d7ef31922 Mon Sep 17 00:00:00 2001 From: Jean Tourrilhes Date: Fri, 28 Mar 2003 23:46:47 -0500 Subject: [PATCH] [PATCH] : IrNET module fix o [CORRECT] Fix module refcounting (MOD_INC/DEC => .owner) o [FEATURE] Add hints to discovery (control channel) --- net/irda/irnet/irnet.h | 5 +++++ net/irda/irnet/irnet_irda.c | 25 +++++++++++++++---------- net/irda/irnet/irnet_irda.h | 3 ++- net/irda/irnet/irnet_ppp.c | 22 ++++++++++++---------- net/irda/irnet/irnet_ppp.h | 1 + 5 files changed, 35 insertions(+), 21 deletions(-) diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h index 97381500fd206..7d819f72c570f 100644 --- a/net/irda/irnet/irnet.h +++ b/net/irda/irnet/irnet.h @@ -225,6 +225,10 @@ * * v13 - 30.5.02 - Jean II * o Update module init code + * + * v14 - 20.2.03 - Jean II + * o Add discovery hint bits in the control channel. + * o Remove obsolete MOD_INC/DEC_USE_COUNT in favor of .owner */ /***************************** INCLUDES *****************************/ @@ -476,6 +480,7 @@ typedef struct irnet_log __u32 saddr; __u32 daddr; char name[NICKNAME_MAX_LEN + 1]; /* 21 + 1 */ + __u16_host_order hints; /* Discovery hint bits */ } irnet_log; /* diff --git a/net/irda/irnet/irnet_irda.c b/net/irda/irnet/irnet_irda.c index 5175a201d6433..19ffeca433ffe 100644 --- a/net/irda/irnet/irnet_irda.c +++ b/net/irda/irnet/irnet_irda.c @@ -28,7 +28,8 @@ irnet_post_event(irnet_socket * ap, irnet_event event, __u32 saddr, __u32 daddr, - char * name) + char * name, + __u16 hints) { unsigned long flags; /* For spinlock */ int index; /* In the log */ @@ -52,6 +53,8 @@ irnet_post_event(irnet_socket * ap, strcpy(irnet_events.log[index].name, name); else irnet_events.log[index].name[0] = '\0'; + /* Copy hints */ + irnet_events.log[index].hints.word = hints; /* Try to get ppp unit number */ if((ap != (irnet_socket *) NULL) && (ap->ppp_open)) irnet_events.log[index].unit = ppp_unit_number(&ap->chan); @@ -609,7 +612,7 @@ irda_irnet_destroy(irnet_socket * self) * doesn't exist anymore when we post the event, so we need to pass * NULL as the first arg... */ irnet_post_event(NULL, IRNET_DISCONNECT_TO, - self->saddr, self->daddr, self->rname); + self->saddr, self->daddr, self->rname, 0); } /* Prevent various IrDA callbacks from messing up things @@ -862,7 +865,7 @@ irnet_connect_socket(irnet_socket * server, /* Notify the control channel */ irnet_post_event(new, IRNET_CONNECT_FROM, - new->saddr, new->daddr, server->rname); + new->saddr, new->daddr, server->rname, 0); DEXIT(IRDA_SERV_TRACE, "\n"); return 0; @@ -893,7 +896,7 @@ irnet_disconnect_server(irnet_socket * self, /* Notify the control channel (see irnet_find_socket()) */ irnet_post_event(NULL, IRNET_REQUEST_FROM, - self->saddr, self->daddr, self->rname); + self->saddr, self->daddr, self->rname, 0); /* Clean up the server to keep it in listen state */ irttp_listen(self->tsap); @@ -1108,12 +1111,12 @@ irnet_disconnect_indication(void * instance, /* If we were active, notify the control channel */ if(test_open) irnet_post_event(self, IRNET_DISCONNECT_FROM, - self->saddr, self->daddr, self->rname); + self->saddr, self->daddr, self->rname, 0); else /* If we were trying to connect, notify the control channel */ if((self->tsap) && (self != &irnet_server.s)) irnet_post_event(self, IRNET_NOANSWER_FROM, - self->saddr, self->daddr, self->rname); + self->saddr, self->daddr, self->rname, 0); /* Close our IrTTP connection, cleanup tsap */ if((self->tsap) && (self != &irnet_server.s)) @@ -1213,7 +1216,7 @@ irnet_connect_confirm(void * instance, /* Notify the control channel */ irnet_post_event(self, IRNET_CONNECT_TO, - self->saddr, self->daddr, self->rname); + self->saddr, self->daddr, self->rname, 0); DEXIT(IRDA_TCB_TRACE, "\n"); } @@ -1282,7 +1285,7 @@ irnet_status_indication(void * instance, { case STATUS_NO_ACTIVITY: irnet_post_event(self, IRNET_BLOCKED_LINK, - self->saddr, self->daddr, self->rname); + self->saddr, self->daddr, self->rname, 0); break; default: DEBUG(IRDA_CB_INFO, "Unknown status...\n"); @@ -1648,7 +1651,8 @@ irnet_discovery_indication(discinfo_t * discovery, /* Notify the control channel */ irnet_post_event(NULL, IRNET_DISCOVER, - discovery->saddr, discovery->daddr, discovery->info); + discovery->saddr, discovery->daddr, discovery->info, + u16ho(discovery->hints)); DEXIT(IRDA_OCB_TRACE, "\n"); } @@ -1678,7 +1682,8 @@ irnet_expiry_indication(discinfo_t * expiry, /* Notify the control channel */ irnet_post_event(NULL, IRNET_EXPIRE, - expiry->saddr, expiry->daddr, expiry->info); + expiry->saddr, expiry->daddr, expiry->info, + u16ho(expiry->hints)); DEXIT(IRDA_OCB_TRACE, "\n"); } diff --git a/net/irda/irnet/irnet_irda.h b/net/irda/irnet/irnet_irda.h index 02c1649ac42a5..f2fecd32d8f64 100644 --- a/net/irda/irnet/irnet_irda.h +++ b/net/irda/irnet/irnet_irda.h @@ -69,7 +69,8 @@ static void irnet_event, __u32, __u32, - char *); + char *, + __u16); /* ----------------------- IRDA SUBROUTINES ----------------------- */ static inline int irnet_open_tsap(irnet_socket *); diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c index 05379405d8000..38329c7972b93 100644 --- a/net/irda/irnet/irnet_ppp.c +++ b/net/irda/irnet/irnet_ppp.c @@ -213,10 +213,12 @@ irnet_read_discovery_log(irnet_socket * ap, if(ap->disco_index < ap->disco_number) { /* Write an event */ - sprintf(event, "Found %08x (%s) behind %08x\n", + sprintf(event, "Found %08x (%s) behind %08x {hints %02X-%02X}\n", ap->discoveries[ap->disco_index].daddr, ap->discoveries[ap->disco_index].info, - ap->discoveries[ap->disco_index].saddr); + ap->discoveries[ap->disco_index].saddr, + ap->discoveries[ap->disco_index].hints[0], + ap->discoveries[ap->disco_index].hints[1]); DEBUG(CTRL_INFO, "Writing discovery %d : %s\n", ap->disco_index, ap->discoveries[ap->disco_index].info); @@ -313,16 +315,20 @@ irnet_ctrl_read(irnet_socket * ap, switch(irnet_events.log[ap->event_index].event) { case IRNET_DISCOVER: - sprintf(event, "Discovered %08x (%s) behind %08x\n", + sprintf(event, "Discovered %08x (%s) behind %08x {hints %02X-%02X}\n", irnet_events.log[ap->event_index].daddr, irnet_events.log[ap->event_index].name, - irnet_events.log[ap->event_index].saddr); + irnet_events.log[ap->event_index].saddr, + irnet_events.log[ap->event_index].hints.byte[0], + irnet_events.log[ap->event_index].hints.byte[1]); break; case IRNET_EXPIRE: - sprintf(event, "Expired %08x (%s) behind %08x\n", + sprintf(event, "Expired %08x (%s) behind %08x {hints %02X-%02X}\n", irnet_events.log[ap->event_index].daddr, irnet_events.log[ap->event_index].name, - irnet_events.log[ap->event_index].saddr); + irnet_events.log[ap->event_index].saddr, + irnet_events.log[ap->event_index].hints.byte[0], + irnet_events.log[ap->event_index].hints.byte[1]); break; case IRNET_CONNECT_TO: sprintf(event, "Connected to %08x (%s) on ppp%d\n", @@ -445,8 +451,6 @@ dev_irnet_open(struct inode * inode, ap = kmalloc(sizeof(*ap), GFP_KERNEL); DABORT(ap == NULL, -ENOMEM, FS_ERROR, "Can't allocate struct irnet...\n"); - MOD_INC_USE_COUNT; - /* initialize the irnet structure */ memset(ap, 0, sizeof(*ap)); ap->file = file; @@ -469,7 +473,6 @@ dev_irnet_open(struct inode * inode, { DERROR(FS_ERROR, "Can't setup IrDA link...\n"); kfree(ap); - MOD_DEC_USE_COUNT; return err; } @@ -514,7 +517,6 @@ dev_irnet_close(struct inode * inode, } kfree(ap); - MOD_DEC_USE_COUNT; DEXIT(FS_TRACE, "\n"); return 0; diff --git a/net/irda/irnet/irnet_ppp.h b/net/irda/irnet/irnet_ppp.h index 47f096c09a762..0c84c8272c1eb 100644 --- a/net/irda/irnet/irnet_ppp.h +++ b/net/irda/irnet/irnet_ppp.h @@ -98,6 +98,7 @@ static int /* Filesystem callbacks (to call us) */ static struct file_operations irnet_device_fops = { + .owner = THIS_MODULE, .read = dev_irnet_read, .write = dev_irnet_write, .poll = dev_irnet_poll, -- 2.53.0