[PATCH 06/10] clk: Add support for a generic clock multiplexer

Stephen Boyd sboyd at codeaurora.org
Mon Apr 18 13:54:49 EDT 2011


On 04/18/2011 06:33 AM, Sascha Hauer wrote:
>>>  
>>> +/**
>>> + * clock multiplexer
>>> + *
>>> + * @clk		clock source
>>> + * @reg		the register this multiplexer can be configured with
>>> + * @shift	the shift to the start bit of this multiplexer
>>> + * @width	the width in bits of this multiplexer
>>> + * @num_clks	number of parent clocks
>>> + * @lock	register lock
>>> + * @clks	array of possible parents for this multiplexer. Can contain
>>> + *		holes with NULL in it for invalid register settings
>> NULL is a valid clk, isn't it?
> You're right. I think for invalid mux settings we should ERR_PTR(-EINVAL)
> or similar to the array.

Note that if you're using clkdev you can't actually return a NULL clock
to the caller of clk_get() due to:

struct clk *clk_get_sys(const char *dev_id, const char *con_id)
{
        struct clk *clk;

        mutex_lock(&clocks_mutex);
        clk = clk_find(dev_id, con_id);
        if (clk && !__clk_get(clk))
                clk = NULL;
        mutex_unlock(&clocks_mutex);

        return clk ? clk : ERR_PTR(-ENOENT);
}


So all this talk about NULL being a valid clock returned to drivers is
kinda pointless unless the mach has a custom clk_get() implementation.
Perhaps we should force clkdev on users of the generic struct clk framework?

-- 
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.




More information about the linux-arm-kernel mailing list