Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
230f720b
Commit
230f720b
authored
Feb 25, 2004
by
Stephen Hemminger
Committed by
David S. Miller
Feb 25, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IRDA]: Hashbin cleanups, remove unused code and add const where needed.
parent
055162dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
150 deletions
+14
-150
include/net/irda/irqueue.h
include/net/irda/irqueue.h
+5
-6
net/irda/irqueue.c
net/irda/irqueue.c
+9
-144
No files found.
include/net/irda/irqueue.h
View file @
230f720b
...
...
@@ -41,7 +41,6 @@
*/
#define HB_NOLOCK 0
/* No concurent access prevention */
#define HB_LOCK 1
/* Prevent concurent write with global lock */
#define HB_SORTED 4
/* Not yet supported */
/*
* Hash defines
...
...
@@ -81,13 +80,13 @@ hashbin_t *hashbin_new(int type);
int
hashbin_delete
(
hashbin_t
*
hashbin
,
FREE_FUNC
func
);
int
hashbin_clear
(
hashbin_t
*
hashbin
,
FREE_FUNC
free_func
);
void
hashbin_insert
(
hashbin_t
*
hashbin
,
irda_queue_t
*
entry
,
long
hashv
,
char
*
name
);
void
*
hashbin_remove
(
hashbin_t
*
hashbin
,
long
hashv
,
char
*
name
);
c
onst
c
har
*
name
);
void
*
hashbin_remove
(
hashbin_t
*
hashbin
,
long
hashv
,
c
onst
c
har
*
name
);
void
*
hashbin_remove_first
(
hashbin_t
*
hashbin
);
void
*
hashbin_remove_this
(
hashbin_t
*
hashbin
,
irda_queue_t
*
entry
);
void
*
hashbin_find
(
hashbin_t
*
hashbin
,
long
hashv
,
char
*
name
);
void
*
hashbin_lock_find
(
hashbin_t
*
hashbin
,
long
hashv
,
char
*
name
);
void
*
hashbin_find_next
(
hashbin_t
*
hashbin
,
long
hashv
,
char
*
name
,
void
*
hashbin_find
(
hashbin_t
*
hashbin
,
long
hashv
,
c
onst
c
har
*
name
);
void
*
hashbin_lock_find
(
hashbin_t
*
hashbin
,
long
hashv
,
c
onst
c
har
*
name
);
void
*
hashbin_find_next
(
hashbin_t
*
hashbin
,
long
hashv
,
c
onst
c
har
*
name
,
void
**
pnext
);
irda_queue_t
*
hashbin_get_first
(
hashbin_t
*
hashbin
);
irda_queue_t
*
hashbin_get_next
(
hashbin_t
*
hashbin
);
...
...
net/irda/irqueue.c
View file @
230f720b
...
...
@@ -208,7 +208,7 @@
* This function hash the input string 'name' using the ELF hash
* function for strings.
*/
static
__u32
hash
(
char
*
name
)
static
__u32
hash
(
c
onst
c
har
*
name
)
{
__u32
h
=
0
;
__u32
g
;
...
...
@@ -254,105 +254,6 @@ static void enqueue_first(irda_queue_t **queue, irda_queue_t* element)
}
}
#ifdef HASHBIN_UNUSED
/*
* Function enqueue_last (queue, proc)
*
* Insert item into end of queue.
*
*/
static
void
__enqueue_last
(
irda_queue_t
**
queue
,
irda_queue_t
*
element
)
{
IRDA_DEBUG
(
4
,
"%s()
\n
"
,
__FUNCTION__
);
/*
* Check if queue is empty.
*/
if
(
*
queue
==
NULL
)
{
/*
* Queue is empty. Insert one element into the queue.
*/
element
->
q_next
=
element
->
q_prev
=
*
queue
=
element
;
}
else
{
/*
* Queue is not empty. Insert element into end of queue.
*/
element
->
q_prev
=
(
*
queue
)
->
q_prev
;
element
->
q_prev
->
q_next
=
element
;
(
*
queue
)
->
q_prev
=
element
;
element
->
q_next
=
*
queue
;
}
}
static
inline
void
enqueue_last
(
irda_queue_t
**
queue
,
irda_queue_t
*
element
)
{
unsigned
long
flags
;
save_flags
(
flags
);
cli
();
__enqueue_last
(
queue
,
element
);
restore_flags
(
flags
);
}
/*
* Function enqueue_queue (queue, list)
*
* Insert a queue (list) into the start of the first queue
*
*/
static
void
enqueue_queue
(
irda_queue_t
**
queue
,
irda_queue_t
**
list
)
{
irda_queue_t
*
tmp
;
/*
* Check if queue is empty
*/
if
(
*
queue
)
{
(
*
list
)
->
q_prev
->
q_next
=
(
*
queue
);
(
*
queue
)
->
q_prev
->
q_next
=
(
*
list
);
tmp
=
(
*
list
)
->
q_prev
;
(
*
list
)
->
q_prev
=
(
*
queue
)
->
q_prev
;
(
*
queue
)
->
q_prev
=
tmp
;
}
else
{
*
queue
=
(
*
list
);
}
(
*
list
)
=
NULL
;
}
/*
* Function enqueue_second (queue, proc)
*
* Insert item behind head of queue.
*
*/
static
void
enqueue_second
(
irda_queue_t
**
queue
,
irda_queue_t
*
element
)
{
IRDA_DEBUG
(
0
,
"enqueue_second()
\n
"
);
/*
* Check if queue is empty.
*/
if
(
*
queue
==
NULL
)
{
/*
* Queue is empty. Insert one element into the queue.
*/
element
->
q_next
=
element
->
q_prev
=
*
queue
=
element
;
}
else
{
/*
* Queue is not empty. Insert element into ..
*/
element
->
q_prev
=
(
*
queue
);
(
*
queue
)
->
q_next
->
q_prev
=
element
;
element
->
q_next
=
(
*
queue
)
->
q_next
;
(
*
queue
)
->
q_next
=
element
;
}
}
#endif
/* HASHBIN_UNUSED */
/*
* Function dequeue (queue)
...
...
@@ -474,38 +375,6 @@ hashbin_t *hashbin_new(int type)
return
hashbin
;
}
#ifdef HASHBIN_UNUSED
/*
* Function hashbin_clear (hashbin, free_func)
*
* Remove all entries from the hashbin, see also the comments in
* hashbin_delete() below
*/
int
hashbin_clear
(
hashbin_t
*
hashbin
,
FREE_FUNC
free_func
)
{
irda_queue_t
*
queue
;
int
i
;
ASSERT
(
hashbin
!=
NULL
,
return
-
1
;);
ASSERT
(
hashbin
->
magic
==
HB_MAGIC
,
return
-
1
;);
/*
* Free the entries in the hashbin
*/
for
(
i
=
0
;
i
<
HASHBIN_SIZE
;
i
++
)
{
queue
=
dequeue_first
(
(
irda_queue_t
**
)
&
hashbin
->
hb_queue
[
i
]);
while
(
queue
)
{
if
(
free_func
)
(
*
free_func
)(
queue
);
queue
=
dequeue_first
(
(
irda_queue_t
**
)
&
hashbin
->
hb_queue
[
i
]);
}
}
hashbin
->
hb_size
=
0
;
return
0
;
}
#endif
/* HASHBIN_UNUSED */
/*
* Function hashbin_delete (hashbin, free_func)
...
...
@@ -567,7 +436,8 @@ int hashbin_delete( hashbin_t* hashbin, FREE_FUNC free_func)
* Insert an entry into the hashbin
*
*/
void
hashbin_insert
(
hashbin_t
*
hashbin
,
irda_queue_t
*
entry
,
long
hashv
,
char
*
name
)
void
hashbin_insert
(
hashbin_t
*
hashbin
,
irda_queue_t
*
entry
,
long
hashv
,
const
char
*
name
)
{
unsigned
long
flags
=
0
;
int
bin
;
...
...
@@ -598,14 +468,9 @@ void hashbin_insert(hashbin_t* hashbin, irda_queue_t* entry, long hashv, char* n
/*
* Insert new entry first
* TODO: Perhaps allow sorted lists?
* -> Merge sort if a sorted list should be created
*/
if
(
hashbin
->
hb_type
&
HB_SORTED
)
{
}
else
{
enqueue_first
(
(
irda_queue_t
**
)
&
hashbin
->
hb_queue
[
bin
],
entry
);
}
enqueue_first
(
(
irda_queue_t
**
)
&
hashbin
->
hb_queue
[
bin
],
entry
);
hashbin
->
hb_size
++
;
/* Release lock */
...
...
@@ -683,7 +548,7 @@ void *hashbin_remove_first( hashbin_t *hashbin)
* In other case, you must think hard to guarantee unicity of the index.
* Jean II
*/
void
*
hashbin_remove
(
hashbin_t
*
hashbin
,
long
hashv
,
char
*
name
)
void
*
hashbin_remove
(
hashbin_t
*
hashbin
,
long
hashv
,
c
onst
c
har
*
name
)
{
int
bin
,
found
=
FALSE
;
unsigned
long
flags
=
0
;
...
...
@@ -834,7 +699,7 @@ void* hashbin_remove_this( hashbin_t* hashbin, irda_queue_t* entry)
* Find item with the given hashv or name
*
*/
void
*
hashbin_find
(
hashbin_t
*
hashbin
,
long
hashv
,
char
*
name
)
void
*
hashbin_find
(
hashbin_t
*
hashbin
,
long
hashv
,
c
onst
c
har
*
name
)
{
int
bin
;
irda_queue_t
*
entry
;
...
...
@@ -888,7 +753,7 @@ void* hashbin_find( hashbin_t* hashbin, long hashv, char* name )
* I call it safe, but it's only safe with respect to the hashbin, not its
* content. - Jean II
*/
void
*
hashbin_lock_find
(
hashbin_t
*
hashbin
,
long
hashv
,
char
*
name
)
void
*
hashbin_lock_find
(
hashbin_t
*
hashbin
,
long
hashv
,
c
onst
c
har
*
name
)
{
unsigned
long
flags
=
0
;
irda_queue_t
*
entry
;
...
...
@@ -917,7 +782,7 @@ void* hashbin_lock_find( hashbin_t* hashbin, long hashv, char* name )
* context of the search. On the other hand, it might fail and return
* NULL if the entry is removed. - Jean II
*/
void
*
hashbin_find_next
(
hashbin_t
*
hashbin
,
long
hashv
,
char
*
name
,
void
*
hashbin_find_next
(
hashbin_t
*
hashbin
,
long
hashv
,
c
onst
c
har
*
name
,
void
**
pnext
)
{
unsigned
long
flags
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment