Re: [PATCH 1/3] Clocklib: add generic framework for managing clocks.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Ben Dooks
Date: Thursday, July 3, 2008 - 1:31 pm

On Thu, Jun 26, 2008 at 04:51:38PM +0400, Dmitry Baryshkov wrote:

why under lib? drivers/clk might be a better place for this.



I'd much prefer to see the following changes:

1) enable and disable merged into one, and pass an enable
   parameter, ie:

	int (*set_enable)(struct clk *clk, bool on);

as most code I see is of the following:

int myclk_enable(struct clk *clk, bool on)
{
	clkbit = bit_for_clk(clk);
	reg = read_reg(reg_for_clk(clk));
	
	if (on)
		reg |= clkbit;
	else
		reg &= ~clkbit;

	write_reg(reg, reg_for_clk(clk));
	return 0;
}

whereas if you have seperate enable and disable methods you
end up duplicating quite a lot of that code, as so:

int myclk_enable(struct clk *clk)
{
	clkbit = bit_for_clk(clk);
	reg = read_reg(reg_for_clk(clk));
	
	reg |= clkbit;

	write_reg(reg, reg_for_clk(clk));
	return 0;
}

int myclk_disable(struct clk *clk)
{
	clkbit = bit_for_clk(clk);
	reg = read_reg(reg_for_clk(clk));
	
	reg &= ~clkbit;

	write_reg(reg, reg_for_clk(clk));
	return 0;
}


Can't you hide this in the code, say by wrappering the
struct with something else when it is registered?


why not call this CONFIG_GENERIC_CLK ?
  

possibly seperate the code out into a seperate file


clk->usage = 0; is the same, maybe also easier to encase
the whole lot in the same if block:

	if (clk->usage == 1) {
		rc = clk->ops->enable(clk);

		if (rc)
			clk->usage = 0;
	}


-- 
Ben (ben@fluff.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 2/3] Clocklib: Refactor PXA arm arch to use clocklib., Dmitry Baryshkov, (Thu Jun 26, 5:51 am)
[PATCH 3/3] Clocklib: refactor SA-1100 to use clocklib, Dmitry Baryshkov, (Thu Jun 26, 5:52 am)
Re: [PATCH 1/3] Clocklib: add generic framework for managi ..., Ben Dooks, (Thu Jul 3, 1:31 pm)
Re: [PATCH 1/3] Clocklib: add generic framework for managi ..., Haavard Skinnemoen, (Fri Jul 4, 2:12 am)