Skip to content

Commit 3237b51

Browse files
committed
Revert "clk: Use hashtable for global clk lookups"
This reverts commit 4bf2d27.
1 parent a8cff4a commit 3237b51

File tree

1 file changed

+32
-18
lines changed

1 file changed

+32
-18
lines changed

drivers/clk/clk.c

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <linux/clk-provider.h>
1313
#include <linux/device.h>
1414
#include <linux/err.h>
15-
#include <linux/hashtable.h>
1615
#include <linux/init.h>
1716
#include <linux/list.h>
1817
#include <linux/module.h>
@@ -22,8 +21,6 @@
2221
#include <linux/sched.h>
2322
#include <linux/slab.h>
2423
#include <linux/spinlock.h>
25-
#include <linux/string.h>
26-
#include <linux/stringhash.h>
2724

2825
#include "clk.h"
2926

@@ -36,9 +33,6 @@ static struct task_struct *enable_owner;
3633
static int prepare_refcnt;
3734
static int enable_refcnt;
3835

39-
#define CLK_HASH_BITS 9
40-
static DEFINE_HASHTABLE(clk_hashtable, CLK_HASH_BITS);
41-
4236
static HLIST_HEAD(clk_root_list);
4337
static HLIST_HEAD(clk_orphan_list);
4438
static LIST_HEAD(clk_notifier_list);
@@ -93,7 +87,6 @@ struct clk_core {
9387
struct clk_duty duty;
9488
struct hlist_head children;
9589
struct hlist_node child_node;
96-
struct hlist_node hashtable_node;
9790
struct hlist_head clks;
9891
unsigned int notifier_count;
9992
#ifdef CONFIG_DEBUG_FS
@@ -402,20 +395,45 @@ struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw)
402395
}
403396
EXPORT_SYMBOL_GPL(clk_hw_get_parent);
404397

398+
static struct clk_core *__clk_lookup_subtree(const char *name,
399+
struct clk_core *core)
400+
{
401+
struct clk_core *child;
402+
struct clk_core *ret;
403+
404+
if (!strcmp(core->name, name))
405+
return core;
406+
407+
hlist_for_each_entry(child, &core->children, child_node) {
408+
ret = __clk_lookup_subtree(name, child);
409+
if (ret)
410+
return ret;
411+
}
412+
413+
return NULL;
414+
}
415+
405416
static struct clk_core *clk_core_lookup(const char *name)
406417
{
407-
struct clk_core *core;
408-
u32 hash;
418+
struct clk_core *root_clk;
419+
struct clk_core *ret;
409420

410421
if (!name)
411422
return NULL;
412423

413-
hash = full_name_hash(NULL, name, strlen(name));
424+
/* search the 'proper' clk tree first */
425+
hlist_for_each_entry(root_clk, &clk_root_list, child_node) {
426+
ret = __clk_lookup_subtree(name, root_clk);
427+
if (ret)
428+
return ret;
429+
}
414430

415-
/* search the hashtable */
416-
hash_for_each_possible(clk_hashtable, core, hashtable_node, hash)
417-
if (!strcmp(core->name, name))
418-
return core;
431+
/* if not found, then search the orphan tree */
432+
hlist_for_each_entry(root_clk, &clk_orphan_list, child_node) {
433+
ret = __clk_lookup_subtree(name, root_clk);
434+
if (ret)
435+
return ret;
436+
}
419437

420438
return NULL;
421439
}
@@ -3995,8 +4013,6 @@ static int __clk_core_init(struct clk_core *core)
39954013
hlist_add_head(&core->child_node, &clk_orphan_list);
39964014
core->orphan = true;
39974015
}
3998-
hash_add(clk_hashtable, &core->hashtable_node,
3999-
full_name_hash(NULL, core->name, strlen(core->name)));
40004016

40014017
/*
40024018
* Set clk's accuracy. The preferred method is to use
@@ -4073,7 +4089,6 @@ static int __clk_core_init(struct clk_core *core)
40734089
clk_pm_runtime_put(core);
40744090
unlock:
40754091
if (ret) {
4076-
hash_del(&core->hashtable_node);
40774092
hlist_del_init(&core->child_node);
40784093
core->hw->core = NULL;
40794094
}
@@ -4595,7 +4610,6 @@ void clk_unregister(struct clk *clk)
45954610

45964611
clk_core_evict_parent_cache(clk->core);
45974612

4598-
hash_del(&clk->core->hashtable_node);
45994613
hlist_del_init(&clk->core->child_node);
46004614

46014615
if (clk->core->prepare_count)

0 commit comments

Comments
 (0)