Message ID | alpine.DEB.2.02.1301020827040.2241@localhost6.localdomain6 (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Jan 02, 2013 at 08:29:57AM +0100, Julia Lawall wrote: > There are dereferences to the result of clk_get a few times. I tried the > following semantic patch: And those are buggy; struct clk is _SUPPOSED_ to be an OPAQUE COOKIE and no one other than the clk code should be dereferencing it. I guess this is the danger of the common clk API - we now have a struct clk that is exposed in a linux/*.h include which anyone can include, and now anyone can get a definition for a struct clk and dereference it, destroying opaqueness of this cookie.
diff -u -p /var/linuxes/linux-next/arch/sh/kernel/cpufreq.c /tmp/nothing/arch/sh/kernel/cpufreq.c --- /var/linuxes/linux-next/arch/sh/kernel/cpufreq.c +++ /tmp/nothing/arch/sh/kernel/cpufreq.c @@ -117,15 +117,11 @@ static int sh_cpufreq_cpu_init(struct cp dev = get_cpu_device(cpu); - cpuclk = clk_get(dev, "cpu_clk"); - if (IS_ERR(cpuclk)) { dev_err(dev, "couldn't get CPU clk\n"); return PTR_ERR(cpuclk); } - policy->cur = policy->min = policy->max = sh_cpufreq_get(cpu); - freq_table = cpuclk->nr_freqs ? cpuclk->freq_table : NULL; if (freq_table) { int result; diff -u -p /var/linuxes/linux-next/arch/mips/kernel/cpufreq/loongson2_cpufreq.c /tmp/nothing/arch/mips/kernel/cpufreq/loongson2_cpufreq.c --- /var/linuxes/linux-next/arch/mips/kernel/cpufreq/loongson2_cpufreq.c +++ /tmp/nothing/arch/mips/kernel/cpufreq/loongson2_cpufreq.c @@ -111,13 +111,10 @@ static int loongson2_cpufreq_cpu_init(st if (!cpu_online(policy->cpu)) return -ENODEV; - cpuclk = clk_get(NULL, "cpu_clk"); - if (IS_ERR(cpuclk)) { printk(KERN_ERR "cpufreq: couldn't get CPU clk\n"); return PTR_ERR(cpuclk); } - cpuclk->rate = cpu_clock_freq / 1000; if (!cpuclk->rate) return -EINVAL; diff -u -p /var/linuxes/linux-next/drivers/net/ethernet/ti/cpts.c /tmp/nothing/drivers/net/ethernet/ti/cpts.c --- /var/linuxes/linux-next/drivers/net/ethernet/ti/cpts.c +++ /tmp/nothing/drivers/net/ethernet/ti/cpts.c @@ -241,14 +241,10 @@ static void cpts_overflow_check(struct w static void cpts_clk_init(struct cpts *cpts) { - cpts->refclk = clk_get(NULL, CPTS_REF_CLOCK_NAME); - if (IS_ERR(cpts->refclk)) { pr_err("Failed to clk_get %s\n", CPTS_REF_CLOCK_NAME); cpts->refclk = NULL; return; } - clk_enable(cpts->refclk); - cpts->freq = cpts->refclk->recalc(cpts->refclk); } static void cpts_clk_release(struct cpts *cpts) diff -u -p /var/linuxes/linux-next/drivers/i2c/busses/i2c-sh7760.c /tmp/nothing/drivers/i2c/busses/i2c-sh7760.c --- /var/linuxes/linux-next/drivers/i2c/busses/i2c-sh7760.c +++ /tmp/nothing/drivers/i2c/busses/i2c-sh7760.c @@ -397,11 +397,7 @@ static int calc_CCR(unsigned long scl_hz signed char cdf, cdfm; int scgd, scgdm, scgds; - mclk = clk_get(NULL, "peripheral_clk"); - if (IS_ERR(mclk)) { return PTR_ERR(mclk); - } else { - mck = mclk->rate; clk_put(mclk); }