mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
clk: at91: fix PERIPHERAL_MAX_SHIFT definition
Fix the PERIPHERAL_MAX_SHIFT definition (3 instead of 4) and adapt the round_rate and set_rate logic accordingly. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Reported-by: "Wu, Songjun" <Songjun.Wu@atmel.com>
This commit is contained in:
parent
6c7b03e1ae
commit
86e4404af2
@ -29,7 +29,7 @@
|
||||
#define PERIPHERAL_RSHIFT_MASK 0x3
|
||||
#define PERIPHERAL_RSHIFT(val) (((val) >> 16) & PERIPHERAL_RSHIFT_MASK)
|
||||
|
||||
#define PERIPHERAL_MAX_SHIFT 4
|
||||
#define PERIPHERAL_MAX_SHIFT 3
|
||||
|
||||
struct clk_peripheral {
|
||||
struct clk_hw hw;
|
||||
@ -242,7 +242,7 @@ static long clk_sam9x5_peripheral_round_rate(struct clk_hw *hw,
|
||||
return *parent_rate;
|
||||
|
||||
if (periph->range.max) {
|
||||
for (; shift < PERIPHERAL_MAX_SHIFT; shift++) {
|
||||
for (; shift <= PERIPHERAL_MAX_SHIFT; shift++) {
|
||||
cur_rate = *parent_rate >> shift;
|
||||
if (cur_rate <= periph->range.max)
|
||||
break;
|
||||
@ -254,7 +254,7 @@ static long clk_sam9x5_peripheral_round_rate(struct clk_hw *hw,
|
||||
|
||||
best_diff = cur_rate - rate;
|
||||
best_rate = cur_rate;
|
||||
for (; shift < PERIPHERAL_MAX_SHIFT; shift++) {
|
||||
for (; shift <= PERIPHERAL_MAX_SHIFT; shift++) {
|
||||
cur_rate = *parent_rate >> shift;
|
||||
if (cur_rate < rate)
|
||||
cur_diff = rate - cur_rate;
|
||||
@ -289,7 +289,7 @@ static int clk_sam9x5_peripheral_set_rate(struct clk_hw *hw,
|
||||
if (periph->range.max && rate > periph->range.max)
|
||||
return -EINVAL;
|
||||
|
||||
for (shift = 0; shift < PERIPHERAL_MAX_SHIFT; shift++) {
|
||||
for (shift = 0; shift <= PERIPHERAL_MAX_SHIFT; shift++) {
|
||||
if (parent_rate >> shift == rate) {
|
||||
periph->auto_div = false;
|
||||
periph->div = shift;
|
||||
|
Loading…
Reference in New Issue
Block a user