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>

Changed files
+4 -4
drivers
clk
+4 -4
drivers/clk/at91/clk-peripheral.c
··· 29 29 #define PERIPHERAL_RSHIFT_MASK 0x3 30 30 #define PERIPHERAL_RSHIFT(val) (((val) >> 16) & PERIPHERAL_RSHIFT_MASK) 31 31 32 - #define PERIPHERAL_MAX_SHIFT 4 32 + #define PERIPHERAL_MAX_SHIFT 3 33 33 34 34 struct clk_peripheral { 35 35 struct clk_hw hw; ··· 242 242 return *parent_rate; 243 243 244 244 if (periph->range.max) { 245 - for (; shift < PERIPHERAL_MAX_SHIFT; shift++) { 245 + for (; shift <= PERIPHERAL_MAX_SHIFT; shift++) { 246 246 cur_rate = *parent_rate >> shift; 247 247 if (cur_rate <= periph->range.max) 248 248 break; ··· 254 254 255 255 best_diff = cur_rate - rate; 256 256 best_rate = cur_rate; 257 - for (; shift < PERIPHERAL_MAX_SHIFT; shift++) { 257 + for (; shift <= PERIPHERAL_MAX_SHIFT; shift++) { 258 258 cur_rate = *parent_rate >> shift; 259 259 if (cur_rate < rate) 260 260 cur_diff = rate - cur_rate; ··· 289 289 if (periph->range.max && rate > periph->range.max) 290 290 return -EINVAL; 291 291 292 - for (shift = 0; shift < PERIPHERAL_MAX_SHIFT; shift++) { 292 + for (shift = 0; shift <= PERIPHERAL_MAX_SHIFT; shift++) { 293 293 if (parent_rate >> shift == rate) { 294 294 periph->auto_div = false; 295 295 periph->div = shift;