[PATCH 1/2] [ARM] [IMX]: Removed superfluous checks for argument validity.

Uwe Kleine-König u.kleine-koenig at pengutronix.de
Thu Mar 18 04:37:28 EDT 2010


On Wed, Mar 17, 2010 at 01:34:50PM +0300, Vladimir Zapolskiy wrote:
> Hello Uwe,
> 
> __clk_enable() and __clk_disable() are recursive with another arguments,
> that means it is hardly possible to remove the checks from them.
ah, at least the check for NULL cannot go away.  However IS_ERR(clk)
should hardly matter, shouldn't it?

Maybe the generated code is more optimal when doing:

	static void __clk_disable(struct clk *clk)
	{
		WARN_ON(!clk->usecount);

		if (clk->parent)
			__clk_disable(clk->parent);

		if (clk->secondary)
			__clk_disable(clk->secondary);

		if (!(--clk->usecount) && clk->disable)
			clk->disable(clk);
	}

	void clk_disable(struct clk *clk)
	{
		BUG_ON(clk == NULL || IS_ERR(clk));
		mutex_lock(&clocks_mutex);
		__clk_disable(clk);
		mutex_unlock(&clocks_mutex);
	}
 
So unless the compiler optimizes well, this reduces the calls of
__clk_disable from three to one for a clock without parent and
secondary.

While at it I wonder if it isn't more correct in __clk_disable to
disable the clock first and only then parent and secondary?!

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |



More information about the linux-arm-kernel mailing list