Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /********************************************************************* |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 2 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * Filename: discovery.c |
| 4 | * Version: 0.1 |
| 5 | * Description: Routines for handling discoveries at the IrLMP layer |
| 6 | * Status: Experimental. |
| 7 | * Author: Dag Brattli <dagb@cs.uit.no> |
| 8 | * Created at: Tue Apr 6 15:33:50 1999 |
| 9 | * Modified at: Sat Oct 9 17:11:31 1999 |
| 10 | * Modified by: Dag Brattli <dagb@cs.uit.no> |
| 11 | * Modified at: Fri May 28 3:11 CST 1999 |
| 12 | * Modified by: Horst von Brand <vonbrand@sleipnir.valparaiso.cl> |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 13 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | * Copyright (c) 1999 Dag Brattli, All Rights Reserved. |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 15 | * |
| 16 | * This program is free software; you can redistribute it and/or |
| 17 | * modify it under the terms of the GNU General Public License as |
| 18 | * published by the Free Software Foundation; either version 2 of |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | * the License, or (at your option) any later version. |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 20 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | * This program is distributed in the hope that it will be useful, |
| 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | * GNU General Public License for more details. |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 25 | * |
| 26 | * You should have received a copy of the GNU General Public License |
| 27 | * along with this program; if not, write to the Free Software |
| 28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | * MA 02111-1307 USA |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 30 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | ********************************************************************/ |
| 32 | |
| 33 | #include <linux/string.h> |
| 34 | #include <linux/socket.h> |
Al Viro | d7fe0f2 | 2006-12-03 23:15:30 -0500 | [diff] [blame] | 35 | #include <linux/fs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | #include <linux/seq_file.h> |
| 37 | |
| 38 | #include <net/irda/irda.h> |
| 39 | #include <net/irda/irlmp.h> |
| 40 | |
| 41 | #include <net/irda/discovery.h> |
| 42 | |
Graf Yang | 3322238 | 2008-05-13 23:25:57 -0700 | [diff] [blame] | 43 | #include <asm/unaligned.h> |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | /* |
| 46 | * Function irlmp_add_discovery (cachelog, discovery) |
| 47 | * |
| 48 | * Add a new discovery to the cachelog, and remove any old discoveries |
| 49 | * from the same device |
| 50 | * |
| 51 | * Note : we try to preserve the time this device was *first* discovered |
| 52 | * (as opposed to the time of last discovery used for cleanup). This is |
| 53 | * used by clients waiting for discovery events to tell if the device |
| 54 | * discovered is "new" or just the same old one. They can't rely there |
| 55 | * on a binary flag (new/old), because not all discovery events are |
| 56 | * propagated to them, and they might not always listen, so they would |
| 57 | * miss some new devices popping up... |
| 58 | * Jean II |
| 59 | */ |
| 60 | void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *new) |
| 61 | { |
| 62 | discovery_t *discovery, *node; |
| 63 | unsigned long flags; |
| 64 | |
| 65 | /* Set time of first discovery if node is new (see below) */ |
| 66 | new->firststamp = new->timestamp; |
| 67 | |
| 68 | spin_lock_irqsave(&cachelog->hb_spinlock, flags); |
| 69 | |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 70 | /* |
| 71 | * Remove all discoveries of devices that has previously been |
| 72 | * discovered on the same link with the same name (info), or the |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | * same daddr. We do this since some devices (mostly PDAs) change |
| 74 | * their device address between every discovery. |
| 75 | */ |
| 76 | discovery = (discovery_t *) hashbin_get_first(cachelog); |
| 77 | while (discovery != NULL ) { |
| 78 | node = discovery; |
| 79 | |
| 80 | /* Be sure to stay one item ahead */ |
| 81 | discovery = (discovery_t *) hashbin_get_next(cachelog); |
| 82 | |
| 83 | if ((node->data.saddr == new->data.saddr) && |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 84 | ((node->data.daddr == new->data.daddr) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | (strcmp(node->data.info, new->data.info) == 0))) |
| 86 | { |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 87 | /* This discovery is a previous discovery |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | * from the same device, so just remove it |
| 89 | */ |
| 90 | hashbin_remove_this(cachelog, (irda_queue_t *) node); |
| 91 | /* Check if hints bits are unchanged */ |
Graf Yang | 3322238 | 2008-05-13 23:25:57 -0700 | [diff] [blame] | 92 | if (get_unaligned((__u16 *)node->data.hints) == get_unaligned((__u16 *)new->data.hints)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | /* Set time of first discovery for this node */ |
| 94 | new->firststamp = node->firststamp; |
| 95 | kfree(node); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | /* Insert the new and updated version */ |
| 100 | hashbin_insert(cachelog, (irda_queue_t *) new, new->data.daddr, NULL); |
| 101 | |
| 102 | spin_unlock_irqrestore(&cachelog->hb_spinlock, flags); |
| 103 | } |
| 104 | |
| 105 | /* |
| 106 | * Function irlmp_add_discovery_log (cachelog, log) |
| 107 | * |
| 108 | * Merge a disovery log into the cachelog. |
| 109 | * |
| 110 | */ |
| 111 | void irlmp_add_discovery_log(hashbin_t *cachelog, hashbin_t *log) |
| 112 | { |
| 113 | discovery_t *discovery; |
| 114 | |
Harvey Harrison | 0dc4787 | 2008-03-05 20:47:47 -0800 | [diff] [blame] | 115 | IRDA_DEBUG(4, "%s()\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | |
| 117 | /* |
| 118 | * If log is missing this means that IrLAP was unable to perform the |
| 119 | * discovery, so restart discovery again with just the half timeout |
| 120 | * of the normal one. |
| 121 | */ |
| 122 | /* Well... It means that there was nobody out there - Jean II */ |
| 123 | if (log == NULL) { |
| 124 | /* irlmp_start_discovery_timer(irlmp, 150); */ |
| 125 | return; |
| 126 | } |
| 127 | |
| 128 | /* |
| 129 | * Locking : we are the only owner of this discovery log, so |
| 130 | * no need to lock it. |
| 131 | * We just need to lock the global log in irlmp_add_discovery(). |
| 132 | */ |
| 133 | discovery = (discovery_t *) hashbin_remove_first(log); |
| 134 | while (discovery != NULL) { |
| 135 | irlmp_add_discovery(cachelog, discovery); |
| 136 | |
| 137 | discovery = (discovery_t *) hashbin_remove_first(log); |
| 138 | } |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 139 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | /* Delete the now empty log */ |
| 141 | hashbin_delete(log, (FREE_FUNC) kfree); |
| 142 | } |
| 143 | |
| 144 | /* |
| 145 | * Function irlmp_expire_discoveries (log, saddr, force) |
| 146 | * |
| 147 | * Go through all discoveries and expire all that has stayed too long |
| 148 | * |
| 149 | * Note : this assume that IrLAP won't change its saddr, which |
| 150 | * currently is a valid assumption... |
| 151 | */ |
| 152 | void irlmp_expire_discoveries(hashbin_t *log, __u32 saddr, int force) |
| 153 | { |
| 154 | discovery_t * discovery; |
| 155 | discovery_t * curr; |
| 156 | unsigned long flags; |
| 157 | discinfo_t * buffer = NULL; |
| 158 | int n; /* Size of the full log */ |
| 159 | int i = 0; /* How many we expired */ |
| 160 | |
| 161 | IRDA_ASSERT(log != NULL, return;); |
Harvey Harrison | 0dc4787 | 2008-03-05 20:47:47 -0800 | [diff] [blame] | 162 | IRDA_DEBUG(4, "%s()\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | |
| 164 | spin_lock_irqsave(&log->hb_spinlock, flags); |
| 165 | |
| 166 | discovery = (discovery_t *) hashbin_get_first(log); |
| 167 | while (discovery != NULL) { |
| 168 | /* Be sure to be one item ahead */ |
| 169 | curr = discovery; |
| 170 | discovery = (discovery_t *) hashbin_get_next(log); |
| 171 | |
| 172 | /* Test if it's time to expire this discovery */ |
| 173 | if ((curr->data.saddr == saddr) && |
| 174 | (force || |
| 175 | ((jiffies - curr->timestamp) > DISCOVERY_EXPIRE_TIMEOUT))) |
| 176 | { |
| 177 | /* Create buffer as needed. |
| 178 | * As this function get called a lot and most time |
| 179 | * we don't have anything to put in the log (we are |
| 180 | * quite picky), we can save a lot of overhead |
| 181 | * by not calling kmalloc. Jean II */ |
| 182 | if(buffer == NULL) { |
| 183 | /* Create the client specific buffer */ |
| 184 | n = HASHBIN_GET_SIZE(log); |
| 185 | buffer = kmalloc(n * sizeof(struct irda_device_info), GFP_ATOMIC); |
| 186 | if (buffer == NULL) { |
| 187 | spin_unlock_irqrestore(&log->hb_spinlock, flags); |
| 188 | return; |
| 189 | } |
| 190 | |
| 191 | } |
| 192 | |
| 193 | /* Copy discovery information */ |
| 194 | memcpy(&(buffer[i]), &(curr->data), |
| 195 | sizeof(discinfo_t)); |
| 196 | i++; |
| 197 | |
| 198 | /* Remove it from the log */ |
| 199 | curr = hashbin_remove_this(log, (irda_queue_t *) curr); |
Jesper Juhl | a51482b | 2005-11-08 09:41:34 -0800 | [diff] [blame] | 200 | kfree(curr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | } |
| 202 | } |
| 203 | |
| 204 | /* Drop the spinlock before calling the higher layers, as |
| 205 | * we can't guarantee they won't call us back and create a |
| 206 | * deadlock. We will work on our own private data, so we |
Robert P. J. Day | 3a4fa0a | 2007-10-19 23:10:43 +0200 | [diff] [blame] | 207 | * don't care to be interrupted. - Jean II */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | spin_unlock_irqrestore(&log->hb_spinlock, flags); |
| 209 | |
| 210 | if(buffer == NULL) |
| 211 | return; |
| 212 | |
| 213 | /* Tell IrLMP and registered clients about it */ |
| 214 | irlmp_discovery_expiry(buffer, i); |
| 215 | |
| 216 | /* Free up our buffer */ |
| 217 | kfree(buffer); |
| 218 | } |
| 219 | |
| 220 | #if 0 |
| 221 | /* |
| 222 | * Function irlmp_dump_discoveries (log) |
| 223 | * |
| 224 | * Print out all discoveries in log |
| 225 | * |
| 226 | */ |
| 227 | void irlmp_dump_discoveries(hashbin_t *log) |
| 228 | { |
| 229 | discovery_t *discovery; |
| 230 | |
| 231 | IRDA_ASSERT(log != NULL, return;); |
| 232 | |
| 233 | discovery = (discovery_t *) hashbin_get_first(log); |
| 234 | while (discovery != NULL) { |
| 235 | IRDA_DEBUG(0, "Discovery:\n"); |
| 236 | IRDA_DEBUG(0, " daddr=%08x\n", discovery->data.daddr); |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 237 | IRDA_DEBUG(0, " saddr=%08x\n", discovery->data.saddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | IRDA_DEBUG(0, " nickname=%s\n", discovery->data.info); |
| 239 | |
| 240 | discovery = (discovery_t *) hashbin_get_next(log); |
| 241 | } |
| 242 | } |
| 243 | #endif |
| 244 | |
| 245 | /* |
| 246 | * Function irlmp_copy_discoveries (log, pn, mask) |
| 247 | * |
| 248 | * Copy all discoveries in a buffer |
| 249 | * |
| 250 | * This function implement a safe way for lmp clients to access the |
| 251 | * discovery log. The basic problem is that we don't want the log |
| 252 | * to change (add/remove) while the client is reading it. If the |
| 253 | * lmp client manipulate directly the hashbin, he is sure to get |
| 254 | * into troubles... |
| 255 | * The idea is that we copy all the current discovery log in a buffer |
| 256 | * which is specific to the client and pass this copy to him. As we |
| 257 | * do this operation with the spinlock grabbed, we are safe... |
| 258 | * Note : we don't want those clients to grab the spinlock, because |
| 259 | * we have no control on how long they will hold it... |
| 260 | * Note : we choose to copy the log in "struct irda_device_info" to |
| 261 | * save space... |
| 262 | * Note : the client must kfree himself() the log... |
| 263 | * Jean II |
| 264 | */ |
| 265 | struct irda_device_info *irlmp_copy_discoveries(hashbin_t *log, int *pn, |
| 266 | __u16 mask, int old_entries) |
| 267 | { |
| 268 | discovery_t * discovery; |
| 269 | unsigned long flags; |
| 270 | discinfo_t * buffer = NULL; |
| 271 | int j_timeout = (sysctl_discovery_timeout * HZ); |
| 272 | int n; /* Size of the full log */ |
| 273 | int i = 0; /* How many we picked */ |
| 274 | |
| 275 | IRDA_ASSERT(pn != NULL, return NULL;); |
| 276 | IRDA_ASSERT(log != NULL, return NULL;); |
| 277 | |
| 278 | /* Save spin lock */ |
| 279 | spin_lock_irqsave(&log->hb_spinlock, flags); |
| 280 | |
| 281 | discovery = (discovery_t *) hashbin_get_first(log); |
| 282 | while (discovery != NULL) { |
| 283 | /* Mask out the ones we don't want : |
| 284 | * We want to match the discovery mask, and to get only |
| 285 | * the most recent one (unless we want old ones) */ |
Graf Yang | 3322238 | 2008-05-13 23:25:57 -0700 | [diff] [blame] | 286 | if ((get_unaligned((__u16 *)discovery->data.hints) & mask) && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | ((old_entries) || |
Graf Yang | 3322238 | 2008-05-13 23:25:57 -0700 | [diff] [blame] | 288 | ((jiffies - discovery->firststamp) < j_timeout))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | /* Create buffer as needed. |
| 290 | * As this function get called a lot and most time |
| 291 | * we don't have anything to put in the log (we are |
| 292 | * quite picky), we can save a lot of overhead |
| 293 | * by not calling kmalloc. Jean II */ |
| 294 | if(buffer == NULL) { |
| 295 | /* Create the client specific buffer */ |
| 296 | n = HASHBIN_GET_SIZE(log); |
| 297 | buffer = kmalloc(n * sizeof(struct irda_device_info), GFP_ATOMIC); |
| 298 | if (buffer == NULL) { |
| 299 | spin_unlock_irqrestore(&log->hb_spinlock, flags); |
| 300 | return NULL; |
| 301 | } |
| 302 | |
| 303 | } |
| 304 | |
| 305 | /* Copy discovery information */ |
| 306 | memcpy(&(buffer[i]), &(discovery->data), |
| 307 | sizeof(discinfo_t)); |
| 308 | i++; |
| 309 | } |
| 310 | discovery = (discovery_t *) hashbin_get_next(log); |
| 311 | } |
| 312 | |
| 313 | spin_unlock_irqrestore(&log->hb_spinlock, flags); |
| 314 | |
| 315 | /* Get the actual number of device in the buffer and return */ |
| 316 | *pn = i; |
| 317 | return(buffer); |
| 318 | } |
| 319 | |
| 320 | #ifdef CONFIG_PROC_FS |
| 321 | static inline discovery_t *discovery_seq_idx(loff_t pos) |
| 322 | |
| 323 | { |
| 324 | discovery_t *discovery; |
| 325 | |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 326 | for (discovery = (discovery_t *) hashbin_get_first(irlmp->cachelog); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | discovery != NULL; |
| 328 | discovery = (discovery_t *) hashbin_get_next(irlmp->cachelog)) { |
| 329 | if (pos-- == 0) |
| 330 | break; |
| 331 | } |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 332 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | return discovery; |
| 334 | } |
| 335 | |
| 336 | static void *discovery_seq_start(struct seq_file *seq, loff_t *pos) |
| 337 | { |
| 338 | spin_lock_irq(&irlmp->cachelog->hb_spinlock); |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 339 | return *pos ? discovery_seq_idx(*pos - 1) : SEQ_START_TOKEN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | static void *discovery_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
| 343 | { |
| 344 | ++*pos; |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 345 | return (v == SEQ_START_TOKEN) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | ? (void *) hashbin_get_first(irlmp->cachelog) |
| 347 | : (void *) hashbin_get_next(irlmp->cachelog); |
| 348 | } |
| 349 | |
| 350 | static void discovery_seq_stop(struct seq_file *seq, void *v) |
| 351 | { |
| 352 | spin_unlock_irq(&irlmp->cachelog->hb_spinlock); |
| 353 | } |
| 354 | |
| 355 | static int discovery_seq_show(struct seq_file *seq, void *v) |
| 356 | { |
| 357 | if (v == SEQ_START_TOKEN) |
| 358 | seq_puts(seq, "IrLMP: Discovery log:\n\n"); |
| 359 | else { |
| 360 | const discovery_t *discovery = v; |
| 361 | |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 362 | seq_printf(seq, "nickname: %s, hint: 0x%02x%02x", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | discovery->data.info, |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 364 | discovery->data.hints[0], |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | discovery->data.hints[1]); |
| 366 | #if 0 |
| 367 | if ( discovery->data.hints[0] & HINT_PNP) |
| 368 | seq_puts(seq, "PnP Compatible "); |
| 369 | if ( discovery->data.hints[0] & HINT_PDA) |
| 370 | seq_puts(seq, "PDA/Palmtop "); |
| 371 | if ( discovery->data.hints[0] & HINT_COMPUTER) |
| 372 | seq_puts(seq, "Computer "); |
| 373 | if ( discovery->data.hints[0] & HINT_PRINTER) |
| 374 | seq_puts(seq, "Printer "); |
| 375 | if ( discovery->data.hints[0] & HINT_MODEM) |
| 376 | seq_puts(seq, "Modem "); |
| 377 | if ( discovery->data.hints[0] & HINT_FAX) |
| 378 | seq_puts(seq, "Fax "); |
| 379 | if ( discovery->data.hints[0] & HINT_LAN) |
| 380 | seq_puts(seq, "LAN Access "); |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 381 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | if ( discovery->data.hints[1] & HINT_TELEPHONY) |
| 383 | seq_puts(seq, "Telephony "); |
| 384 | if ( discovery->data.hints[1] & HINT_FILE_SERVER) |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 385 | seq_puts(seq, "File Server "); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | if ( discovery->data.hints[1] & HINT_COMM) |
| 387 | seq_puts(seq, "IrCOMM "); |
| 388 | if ( discovery->data.hints[1] & HINT_OBEX) |
| 389 | seq_puts(seq, "IrOBEX "); |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 390 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | seq_printf(seq,", saddr: 0x%08x, daddr: 0x%08x\n\n", |
| 392 | discovery->data.saddr, |
| 393 | discovery->data.daddr); |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 394 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | seq_putc(seq, '\n'); |
| 396 | } |
| 397 | return 0; |
| 398 | } |
| 399 | |
Philippe De Muyter | 56b3d97 | 2007-07-10 23:07:31 -0700 | [diff] [blame] | 400 | static const struct seq_operations discovery_seq_ops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | .start = discovery_seq_start, |
| 402 | .next = discovery_seq_next, |
| 403 | .stop = discovery_seq_stop, |
| 404 | .show = discovery_seq_show, |
| 405 | }; |
| 406 | |
| 407 | static int discovery_seq_open(struct inode *inode, struct file *file) |
| 408 | { |
| 409 | IRDA_ASSERT(irlmp != NULL, return -EINVAL;); |
| 410 | |
| 411 | return seq_open(file, &discovery_seq_ops); |
| 412 | } |
| 413 | |
Arjan van de Ven | 9a32144 | 2007-02-12 00:55:35 -0800 | [diff] [blame] | 414 | const struct file_operations discovery_seq_fops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | .owner = THIS_MODULE, |
| 416 | .open = discovery_seq_open, |
| 417 | .read = seq_read, |
| 418 | .llseek = seq_lseek, |
| 419 | .release = seq_release, |
| 420 | }; |
| 421 | #endif |