• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/include/net/irda/
1/*********************************************************************
2 *
3 * Filename:      irqueue.h
4 * Version:       0.3
5 * Description:   General queue implementation
6 * Status:        Experimental.
7 * Author:        Dag Brattli <dagb@cs.uit.no>
8 * Created at:    Tue Jun  9 13:26:50 1998
9 * Modified at:   Thu Oct  7 13:25:16 1999
10 * Modified by:   Dag Brattli <dagb@cs.uit.no>
11 *
12 *     Copyright (C) 1998-1999, Aage Kvalnes <aage@cs.uit.no>
13 *     Copyright (c) 1998, Dag Brattli
14 *     All Rights Reserved.
15 *
16 *     This code is taken from the Vortex Operating System written by Aage
17 *     Kvalnes and has been ported to Linux and Linux/IR by Dag Brattli
18 *
19 *     This program is free software; you can redistribute it and/or
20 *     modify it under the terms of the GNU General Public License as
21 *     published by the Free Software Foundation; either version 2 of
22 *     the License, or (at your option) any later version.
23 *
24 *     Neither Dag Brattli nor University of Troms�� admit liability nor
25 *     provide warranty for any of this software. This material is
26 *     provided "AS-IS" and at no charge.
27 *
28 ********************************************************************/
29
30#include <linux/types.h>
31#include <linux/spinlock.h>
32
33#ifndef IRDA_QUEUE_H
34#define IRDA_QUEUE_H
35
36#define NAME_SIZE      32
37
38/*
39 * Hash types (some flags can be xored)
40 * See comments in irqueue.c for which one to use...
41 */
42#define HB_NOLOCK	0	/* No concurent access prevention */
43#define HB_LOCK		1	/* Prevent concurent write with global lock */
44
45/*
46 * Hash defines
47 */
48#define HASHBIN_SIZE   8
49#define HASHBIN_MASK   0x7
50
51#ifndef IRDA_ALIGN
52#define IRDA_ALIGN __attribute__((aligned))
53#endif
54
55#define Q_NULL { NULL, NULL, "", 0 }
56
57typedef void (*FREE_FUNC)(void *arg);
58
59struct irda_queue {
60	struct irda_queue *q_next;
61	struct irda_queue *q_prev;
62
63	char   q_name[NAME_SIZE];
64	long   q_hash;			/* Must be able to cast a (void *) */
65};
66typedef struct irda_queue irda_queue_t;
67
68typedef struct hashbin_t {
69	__u32      magic;
70	int        hb_type;
71	int        hb_size;
72	spinlock_t hb_spinlock;		/* HB_LOCK - Can be used by the user */
73
74	irda_queue_t* hb_queue[HASHBIN_SIZE] IRDA_ALIGN;
75
76	irda_queue_t* hb_current;
77} hashbin_t;
78
79hashbin_t *hashbin_new(int type);
80int      hashbin_delete(hashbin_t* hashbin, FREE_FUNC func);
81int      hashbin_clear(hashbin_t* hashbin, FREE_FUNC free_func);
82void     hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv,
83			const char* name);
84void*    hashbin_remove(hashbin_t* hashbin, long hashv, const char* name);
85void*    hashbin_remove_first(hashbin_t *hashbin);
86void*	 hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry);
87void*    hashbin_find(hashbin_t* hashbin, long hashv, const char* name);
88void*    hashbin_lock_find(hashbin_t* hashbin, long hashv, const char* name);
89void*    hashbin_find_next(hashbin_t* hashbin, long hashv, const char* name,
90			   void ** pnext);
91irda_queue_t *hashbin_get_first(hashbin_t *hashbin);
92irda_queue_t *hashbin_get_next(hashbin_t *hashbin);
93
94#define HASHBIN_GET_SIZE(hashbin) hashbin->hb_size
95
96#endif
97