On Tue, Jan 4, 2011 at 7:54 PM, Amit Kucheria <amit.kuche...@linaro.org> wrote:
> On Tue, Jan 4, 2011 at 3:16 PM, Yong Shen <yong.s...@linaro.org> wrote:
>
>>>> In the last several weeks, Jeremy and I reviewed the clock debug code
>>>> based on common clock struct. In this code, I used below code to
>>>> expose clock information:
>>>>
>>>>
>>>> +static int clk_debug_rate_get(void *data, u64 *val)
>>>> +{
>>>> +       struct clk *clk = data;
>>>> +
>>>> +       *val = (u64)clk_get_rate(clk);
>>>> +       return 0;
>>>> +}
>>>> +DEFINE_SIMPLE_ATTRIBUTE(clk_debug_rate_fops, clk_debug_rate_get, NULL,
>>>> +               "%llu\n");
>>>> +
>>>> .....
>>>> +       d = debugfs_create_file("rate", S_IRUGO, clk->dentry, (void *)clk,
>>>> +                       &clk_debug_rate_fops);
>>>>
>>>> Therefore, whenever the clock information is accessed, it can reflect
>>>> the truth, since it calls clk interface like clk_get_rate() to get the
>>>> right value.
>>>
>>> Why is it called clk_debug_rate_get()? Is there not a standard
>>> clk_rate_get() that we can use?
>> There is. clk_get_rate() is called inside this function. By using
>> these lines of code, the purpose is to advocate using functions
>> provided by clock system like clk_rate_get() directly, instead of
>> using variable to store clock information.
>
> I guess I am confused why we don't directly use clk_get_rate() instead
> of clk_debug_get_rate() in the 'show' call for the sysfs entry.
>
Obviously, the kernel macro "DEFINE_SIMPLE_ATTRIBUTE" only take
function definition like:
int (*get)(void *, u64 *)
which is why clk_get_rate() had been wrapped by clk_debug_get_rate().

Yong
> /Amit
>

_______________________________________________
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev

Reply via email to