From cb50abcb7ad4113e831a4c0e4b8dd429abc9e2eb Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Mon, 26 Mar 2012 09:01:29 +0000 Subject: [PATCH] powerpc: 512x: Fix mpc5121_clk_get() If try_module_get() fails, mpc5121_clk_get() might return a wrong clock. Signed-off-by: Richard Weinberger Signed-off-by: Anatolij Gustschin --- arch/powerpc/platforms/512x/clock.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/512x/clock.c b/arch/powerpc/platforms/512x/clock.c index 1d8700ff60b0..9f771e05457c 100644 --- a/arch/powerpc/platforms/512x/clock.c +++ b/arch/powerpc/platforms/512x/clock.c @@ -54,14 +54,16 @@ static DEFINE_MUTEX(clocks_mutex); static struct clk *mpc5121_clk_get(struct device *dev, const char *id) { struct clk *p, *clk = ERR_PTR(-ENOENT); - int dev_match = 0; - int id_match = 0; + int dev_match; + int id_match; if (dev == NULL || id == NULL) return clk; mutex_lock(&clocks_mutex); list_for_each_entry(p, &clocks, node) { + dev_match = id_match = 0; + if (dev == p->dev) dev_match++; if (strcmp(id, p->name) == 0) -- 2.39.5