[PATCH 01/10] Add a common struct clk

Rob Herring robherring2 at gmail.com
Sun May 1 23:09:24 EDT 2011


Jeremy,

On 05/01/2011 08:09 PM, Jeremy Kerr wrote:
> Hi Rob,
>
>>> +int clk_prepare(struct clk *clk)
>>> +{
>>> +	int ret = 0;
>>> +
>>
>> Shouldn't all these functions have some clk pointer checks:
>>
>> 	if (IS_ERR_OR_NULL(clk))
>> 		return -EINVAL;
>>
>
> No, I'd prefer not to. The driver code should be responsible for passing
> a valid pointer here, by doing this check once (where the clock is
> initially acquired through clk_get), rather than the core code doing it
> on each function call.

I think you will find many examples in the kernel where that is not done 
by drivers. It is also common that the same driver is used on platforms 
with and without clock support. Adding NULL ptr checks around every clk 
api function makes for ugly and duplicated code.

Every implementation of clk_enable that I looked at does this check in 
their implementation. I looked at omap, imx, spear, and samsung. Seems 
like we should try to minimize breakage from switching to common struct clk.

Rob



More information about the linux-arm-kernel mailing list