diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-03-11 23:49:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-12 14:35:30 -0400 |
commit | ec9f71c59e00388efc1337307511b59cc4c48394 (patch) | |
tree | 4798fe620f14eaab4403f0715aab12dbfaeed00f /lib | |
parent | cffaa9cb922472936b269017afdd3f147cb6f380 (diff) |
rhashtable: Remove obj_raw_hashfn
Now that the only caller of obj_raw_hashfn is head_hashfn, we can
simply kill it and fold it into the latter.
This patch also moves the common shift from head_hashfn/key_hashfn
into rht_bucket_index.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rhashtable.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/lib/rhashtable.c b/lib/rhashtable.c index 838cccc4ef7e..6ffc793145f3 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c | |||
@@ -63,36 +63,25 @@ static void *rht_obj(const struct rhashtable *ht, const struct rhash_head *he) | |||
63 | 63 | ||
64 | static u32 rht_bucket_index(const struct bucket_table *tbl, u32 hash) | 64 | static u32 rht_bucket_index(const struct bucket_table *tbl, u32 hash) |
65 | { | 65 | { |
66 | return hash & (tbl->size - 1); | 66 | return (hash >> HASH_RESERVED_SPACE) & (tbl->size - 1); |
67 | } | ||
68 | |||
69 | static u32 obj_raw_hashfn(struct rhashtable *ht, | ||
70 | const struct bucket_table *tbl, const void *ptr) | ||
71 | { | ||
72 | u32 hash; | ||
73 | |||
74 | if (unlikely(!ht->p.key_len)) | ||
75 | hash = ht->p.obj_hashfn(ptr, tbl->hash_rnd); | ||
76 | else | ||
77 | hash = ht->p.hashfn(ptr + ht->p.key_offset, ht->p.key_len, | ||
78 | tbl->hash_rnd); | ||
79 | |||
80 | return hash >> HASH_RESERVED_SPACE; | ||
81 | } | 67 | } |
82 | 68 | ||
83 | static u32 key_hashfn(struct rhashtable *ht, const struct bucket_table *tbl, | 69 | static u32 key_hashfn(struct rhashtable *ht, const struct bucket_table *tbl, |
84 | const void *key) | 70 | const void *key) |
85 | { | 71 | { |
86 | return rht_bucket_index(tbl, ht->p.hashfn(key, ht->p.key_len, | 72 | return rht_bucket_index(tbl, ht->p.hashfn(key, ht->p.key_len, |
87 | tbl->hash_rnd) >> | 73 | tbl->hash_rnd)); |
88 | HASH_RESERVED_SPACE); | ||
89 | } | 74 | } |
90 | 75 | ||
91 | static u32 head_hashfn(struct rhashtable *ht, | 76 | static u32 head_hashfn(struct rhashtable *ht, |
92 | const struct bucket_table *tbl, | 77 | const struct bucket_table *tbl, |
93 | const struct rhash_head *he) | 78 | const struct rhash_head *he) |
94 | { | 79 | { |
95 | return rht_bucket_index(tbl, obj_raw_hashfn(ht, tbl, rht_obj(ht, he))); | 80 | const char *ptr = rht_obj(ht, he); |
81 | |||
82 | return likely(ht->p.key_len) ? | ||
83 | key_hashfn(ht, tbl, ptr + ht->p.key_offset) : | ||
84 | rht_bucket_index(tbl, ht->p.obj_hashfn(ptr, tbl->hash_rnd)); | ||
96 | } | 85 | } |
97 | 86 | ||
98 | #ifdef CONFIG_PROVE_LOCKING | 87 | #ifdef CONFIG_PROVE_LOCKING |