X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=net%2Firda%2Fdiscovery.c;h=a6f99b5a14995ff62e5620f042ca0821f3552cc3;hb=77f18f5e4ebdea35ec3d92343b0ed7546dc87637;hp=c4ba5fa1446a47da6ba85981cc8c4a7e693e73ad;hpb=1da177e4c3f41524e886b7f1b8a0c1fc7321cac2;p=safe%2Fjmp%2Flinux-2.6 diff --git a/net/irda/discovery.c b/net/irda/discovery.c index c4ba5fa..a6f99b5 100644 --- a/net/irda/discovery.c +++ b/net/irda/discovery.c @@ -1,5 +1,5 @@ /********************************************************************* - * + * * Filename: discovery.c * Version: 0.1 * Description: Routines for handling discoveries at the IrLMP layer @@ -10,28 +10,29 @@ * Modified by: Dag Brattli * Modified at: Fri May 28 3:11 CST 1999 * Modified by: Horst von Brand - * + * * Copyright (c) 1999 Dag Brattli, All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA - * + * ********************************************************************/ #include #include +#include #include #include @@ -39,6 +40,8 @@ #include +#include + /* * Function irlmp_add_discovery (cachelog, discovery) * @@ -64,9 +67,9 @@ void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *new) spin_lock_irqsave(&cachelog->hb_spinlock, flags); - /* - * Remove all discoveries of devices that has previously been - * discovered on the same link with the same name (info), or the + /* + * Remove all discoveries of devices that has previously been + * discovered on the same link with the same name (info), or the * same daddr. We do this since some devices (mostly PDAs) change * their device address between every discovery. */ @@ -78,15 +81,15 @@ void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *new) discovery = (discovery_t *) hashbin_get_next(cachelog); 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))) { - /* This discovery is a previous discovery + /* This discovery is a previous discovery * from the same device, so just remove it */ hashbin_remove_this(cachelog, (irda_queue_t *) node); /* Check if hints bits are unchanged */ - if(u16ho(node->data.hints) == u16ho(new->data.hints)) + if (get_unaligned((__u16 *)node->data.hints) == get_unaligned((__u16 *)new->data.hints)) /* Set time of first discovery for this node */ new->firststamp = node->firststamp; kfree(node); @@ -109,7 +112,7 @@ void irlmp_add_discovery_log(hashbin_t *cachelog, hashbin_t *log) { discovery_t *discovery; - IRDA_DEBUG(4, "%s()\n", __FUNCTION__); + IRDA_DEBUG(4, "%s()\n", __func__); /* * If log is missing this means that IrLAP was unable to perform the @@ -133,7 +136,7 @@ void irlmp_add_discovery_log(hashbin_t *cachelog, hashbin_t *log) discovery = (discovery_t *) hashbin_remove_first(log); } - + /* Delete the now empty log */ hashbin_delete(log, (FREE_FUNC) kfree); } @@ -156,7 +159,7 @@ void irlmp_expire_discoveries(hashbin_t *log, __u32 saddr, int force) int i = 0; /* How many we expired */ IRDA_ASSERT(log != NULL, return;); - IRDA_DEBUG(4, "%s()\n", __FUNCTION__); + IRDA_DEBUG(4, "%s()\n", __func__); spin_lock_irqsave(&log->hb_spinlock, flags); @@ -194,15 +197,14 @@ void irlmp_expire_discoveries(hashbin_t *log, __u32 saddr, int force) /* Remove it from the log */ curr = hashbin_remove_this(log, (irda_queue_t *) curr); - if (curr) - kfree(curr); + kfree(curr); } } /* Drop the spinlock before calling the higher layers, as * we can't guarantee they won't call us back and create a * deadlock. We will work on our own private data, so we - * don't care to be interupted. - Jean II */ + * don't care to be interrupted. - Jean II */ spin_unlock_irqrestore(&log->hb_spinlock, flags); if(buffer == NULL) @@ -232,7 +234,7 @@ void irlmp_dump_discoveries(hashbin_t *log) while (discovery != NULL) { IRDA_DEBUG(0, "Discovery:\n"); 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); discovery = (discovery_t *) hashbin_get_next(log); @@ -281,9 +283,9 @@ struct irda_device_info *irlmp_copy_discoveries(hashbin_t *log, int *pn, /* Mask out the ones we don't want : * We want to match the discovery mask, and to get only * the most recent one (unless we want old ones) */ - if ((u16ho(discovery->data.hints) & mask) && + if ((get_unaligned((__u16 *)discovery->data.hints) & mask) && ((old_entries) || - ((jiffies - discovery->firststamp) < j_timeout)) ) { + ((jiffies - discovery->firststamp) < j_timeout))) { /* Create buffer as needed. * As this function get called a lot and most time * we don't have anything to put in the log (we are @@ -321,26 +323,26 @@ static inline discovery_t *discovery_seq_idx(loff_t pos) { discovery_t *discovery; - for (discovery = (discovery_t *) hashbin_get_first(irlmp->cachelog); + for (discovery = (discovery_t *) hashbin_get_first(irlmp->cachelog); discovery != NULL; discovery = (discovery_t *) hashbin_get_next(irlmp->cachelog)) { if (pos-- == 0) break; } - + return discovery; } static void *discovery_seq_start(struct seq_file *seq, loff_t *pos) { 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) { ++*pos; - return (v == SEQ_START_TOKEN) + return (v == SEQ_START_TOKEN) ? (void *) hashbin_get_first(irlmp->cachelog) : (void *) hashbin_get_next(irlmp->cachelog); } @@ -357,9 +359,9 @@ static int discovery_seq_show(struct seq_file *seq, void *v) else { 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.hints[0], + discovery->data.hints[0], discovery->data.hints[1]); #if 0 if ( discovery->data.hints[0] & HINT_PNP) @@ -376,26 +378,26 @@ static int discovery_seq_show(struct seq_file *seq, void *v) seq_puts(seq, "Fax "); if ( discovery->data.hints[0] & HINT_LAN) seq_puts(seq, "LAN Access "); - + if ( discovery->data.hints[1] & HINT_TELEPHONY) seq_puts(seq, "Telephony "); 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) seq_puts(seq, "IrCOMM "); if ( discovery->data.hints[1] & HINT_OBEX) seq_puts(seq, "IrOBEX "); -#endif +#endif seq_printf(seq,", saddr: 0x%08x, daddr: 0x%08x\n\n", discovery->data.saddr, discovery->data.daddr); - + seq_putc(seq, '\n'); } return 0; } -static struct seq_operations discovery_seq_ops = { +static const struct seq_operations discovery_seq_ops = { .start = discovery_seq_start, .next = discovery_seq_next, .stop = discovery_seq_stop, @@ -409,7 +411,7 @@ static int discovery_seq_open(struct inode *inode, struct file *file) return seq_open(file, &discovery_seq_ops); } -struct file_operations discovery_seq_fops = { +const struct file_operations discovery_seq_fops = { .owner = THIS_MODULE, .open = discovery_seq_open, .read = seq_read,