示例#1
0
/* Set a clock to an exact rate. */
int local_clk_set_rate(struct clk *c, unsigned rate)
{
	struct rcg_clk *clk = to_rcg_clk(c);
	struct clk_freq_tbl *nf;

	for (nf = clk->freq_tbl; nf->freq_hz != FREQ_END
			&& nf->freq_hz != rate; nf++)
		;

	if (nf->freq_hz == FREQ_END)
		return ERR_INVALID_ARGS;

	return _local_clk_set_rate(clk, nf);
}
/* Set a clock to a rate greater than some minimum. */
int local_clk_set_min_rate(unsigned id, unsigned rate)
{
	struct clk_local *clk = &soc_clk_local_tbl[id];
	struct clk_freq_tbl *nf;

	if (clk->type == NORATE || clk->type == RESET)
		return -EPERM;

	for (nf = clk->freq_tbl; nf->freq_hz != FREQ_END
			&& nf->freq_hz < rate; nf++)
		;

	if (nf->freq_hz == FREQ_END)
		return -EINVAL;

	return _local_clk_set_rate(id, nf);
}