Skip to content

Commit b68d820

Browse files
committed
sh: clkfwk: Make recalc return an unsigned long.
This is prep work for cleaning up some of the rate propagation bits. Trivial conversion. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent ccc1956 commit b68d820

23 files changed

Lines changed: 171 additions & 175 deletions

‎arch/sh/include/asm/clock.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct clk_ops {
1212
void (*init)(struct clk *clk);
1313
void (*enable)(struct clk *clk);
1414
void (*disable)(struct clk *clk);
15-
void (*recalc)(struct clk *clk);
15+
unsigned long (*recalc)(struct clk *clk);
1616
int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id);
1717
int (*set_parent)(struct clk *clk, struct clk *parent);
1818
long (*round_rate)(struct clk *clk, unsigned long rate);
@@ -96,4 +96,5 @@ enum clk_sh_algo_id {
9696

9797
IP_N1,
9898
};
99+
99100
#endif /* __ASM_SH_CLOCK_H */

‎arch/sh/kernel/cpu/clock.c‎

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ static struct clk *onchip_clocks[] = {
7575
&cpu_clk,
7676
};
7777

78+
/* Propagate rate to children */
7879
static void propagate_rate(struct clk *clk)
7980
{
8081
struct clk *clkp;
@@ -83,7 +84,7 @@ static void propagate_rate(struct clk *clk)
8384
if (likely(clkp->parent != clk))
8485
continue;
8586
if (likely(clkp->ops && clkp->ops->recalc))
86-
clkp->ops->recalc(clkp);
87+
clkp->rate = clkp->ops->recalc(clkp);
8788
if (unlikely(clkp->flags & CLK_RATE_PROPAGATES))
8889
propagate_rate(clkp);
8990
}
@@ -240,7 +241,7 @@ void clk_recalc_rate(struct clk *clk)
240241
unsigned long flags;
241242

242243
spin_lock_irqsave(&clock_lock, flags);
243-
clk->ops->recalc(clk);
244+
clk->rate = clk->ops->recalc(clk);
244245
spin_unlock_irqrestore(&clock_lock, flags);
245246
}
246247

@@ -377,20 +378,22 @@ static int clks_sysdev_suspend(struct sys_device *dev, pm_message_t state)
377378
switch (state.event) {
378379
case PM_EVENT_ON:
379380
/* Resumeing from hibernation */
380-
if (prev_state.event == PM_EVENT_FREEZE) {
381-
list_for_each_entry(clkp, &clock_list, node)
382-
if (likely(clkp->ops)) {
383-
unsigned long rate = clkp->rate;
384-
385-
if (likely(clkp->ops->set_parent))
386-
clkp->ops->set_parent(clkp,
387-
clkp->parent);
388-
if (likely(clkp->ops->set_rate))
389-
clkp->ops->set_rate(clkp,
390-
rate, NO_CHANGE);
391-
else if (likely(clkp->ops->recalc))
392-
clkp->ops->recalc(clkp);
393-
}
381+
if (prev_state.event != PM_EVENT_FREEZE)
382+
break;
383+
384+
list_for_each_entry(clkp, &clock_list, node) {
385+
if (likely(clkp->ops)) {
386+
unsigned long rate = clkp->rate;
387+
388+
if (likely(clkp->ops->set_parent))
389+
clkp->ops->set_parent(clkp,
390+
clkp->parent);
391+
if (likely(clkp->ops->set_rate))
392+
clkp->ops->set_rate(clkp,
393+
rate, NO_CHANGE);
394+
else if (likely(clkp->ops->recalc))
395+
clkp->rate = clkp->ops->recalc(clkp);
396+
}
394397
}
395398
break;
396399
case PM_EVENT_FREEZE:

‎arch/sh/kernel/cpu/sh2/clock-sh7619.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,28 @@ static struct clk_ops sh7619_master_clk_ops = {
3838
.init = master_clk_init,
3939
};
4040

41-
static void module_clk_recalc(struct clk *clk)
41+
static unsigned long module_clk_recalc(struct clk *clk)
4242
{
4343
int idx = (ctrl_inw(FREQCR) & 0x0007);
44-
clk->rate = clk->parent->rate / pfc_divisors[idx];
44+
return clk->parent->rate / pfc_divisors[idx];
4545
}
4646

4747
static struct clk_ops sh7619_module_clk_ops = {
4848
.recalc = module_clk_recalc,
4949
};
5050

51-
static void bus_clk_recalc(struct clk *clk)
51+
static unsigned long bus_clk_recalc(struct clk *clk)
5252
{
53-
clk->rate = clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 7];
53+
return clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 7];
5454
}
5555

5656
static struct clk_ops sh7619_bus_clk_ops = {
5757
.recalc = bus_clk_recalc,
5858
};
5959

60-
static void cpu_clk_recalc(struct clk *clk)
60+
static unsigned long cpu_clk_recalc(struct clk *clk)
6161
{
62-
clk->rate = clk->parent->rate;
62+
return clk->parent->rate;
6363
}
6464

6565
static struct clk_ops sh7619_cpu_clk_ops = {
@@ -78,4 +78,3 @@ void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
7878
if (idx < ARRAY_SIZE(sh7619_clk_ops))
7979
*ops = sh7619_clk_ops[idx];
8080
}
81-

‎arch/sh/kernel/cpu/sh2a/clock-sh7201.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,37 +34,37 @@ static const int pfc_divisors[]={1,2,3,4,6,8,12};
3434

3535
static void master_clk_init(struct clk *clk)
3636
{
37-
clk->rate = 10000000 * PLL2 * pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007];
37+
return 10000000 * PLL2 * pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007];
3838
}
3939

4040
static struct clk_ops sh7201_master_clk_ops = {
4141
.init = master_clk_init,
4242
};
4343

44-
static void module_clk_recalc(struct clk *clk)
44+
static unsigned long module_clk_recalc(struct clk *clk)
4545
{
4646
int idx = (ctrl_inw(FREQCR) & 0x0007);
47-
clk->rate = clk->parent->rate / pfc_divisors[idx];
47+
return clk->parent->rate / pfc_divisors[idx];
4848
}
4949

5050
static struct clk_ops sh7201_module_clk_ops = {
5151
.recalc = module_clk_recalc,
5252
};
5353

54-
static void bus_clk_recalc(struct clk *clk)
54+
static unsigned long bus_clk_recalc(struct clk *clk)
5555
{
5656
int idx = (ctrl_inw(FREQCR) & 0x0007);
57-
clk->rate = clk->parent->rate / pfc_divisors[idx];
57+
return clk->parent->rate / pfc_divisors[idx];
5858
}
5959

6060
static struct clk_ops sh7201_bus_clk_ops = {
6161
.recalc = bus_clk_recalc,
6262
};
6363

64-
static void cpu_clk_recalc(struct clk *clk)
64+
static unsigned long cpu_clk_recalc(struct clk *clk)
6565
{
6666
int idx = ((ctrl_inw(FREQCR) >> 4) & 0x0007);
67-
clk->rate = clk->parent->rate / ifc_divisors[idx];
67+
return clk->parent->rate / ifc_divisors[idx];
6868
}
6969

7070
static struct clk_ops sh7201_cpu_clk_ops = {

‎arch/sh/kernel/cpu/sh2a/clock-sh7203.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,29 @@ static struct clk_ops sh7203_master_clk_ops = {
4646
.init = master_clk_init,
4747
};
4848

49-
static void module_clk_recalc(struct clk *clk)
49+
static unsigned long module_clk_recalc(struct clk *clk)
5050
{
5151
int idx = (ctrl_inw(FREQCR) & 0x0007);
52-
clk->rate = clk->parent->rate / pfc_divisors[idx];
52+
return clk->parent->rate / pfc_divisors[idx];
5353
}
5454

5555
static struct clk_ops sh7203_module_clk_ops = {
5656
.recalc = module_clk_recalc,
5757
};
5858

59-
static void bus_clk_recalc(struct clk *clk)
59+
static unsigned long bus_clk_recalc(struct clk *clk)
6060
{
6161
int idx = (ctrl_inw(FREQCR) & 0x0007);
62-
clk->rate = clk->parent->rate / pfc_divisors[idx-2];
62+
return clk->parent->rate / pfc_divisors[idx-2];
6363
}
6464

6565
static struct clk_ops sh7203_bus_clk_ops = {
6666
.recalc = bus_clk_recalc,
6767
};
6868

69-
static void cpu_clk_recalc(struct clk *clk)
69+
static unsigned long cpu_clk_recalc(struct clk *clk)
7070
{
71-
clk->rate = clk->parent->rate;
71+
return clk->parent->rate;
7272
}
7373

7474
static struct clk_ops sh7203_cpu_clk_ops = {

‎arch/sh/kernel/cpu/sh2a/clock-sh7206.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,29 @@ static struct clk_ops sh7206_master_clk_ops = {
4141
.init = master_clk_init,
4242
};
4343

44-
static void module_clk_recalc(struct clk *clk)
44+
static unsigned long module_clk_recalc(struct clk *clk)
4545
{
4646
int idx = (ctrl_inw(FREQCR) & 0x0007);
47-
clk->rate = clk->parent->rate / pfc_divisors[idx];
47+
return clk->parent->rate / pfc_divisors[idx];
4848
}
4949

5050
static struct clk_ops sh7206_module_clk_ops = {
5151
.recalc = module_clk_recalc,
5252
};
5353

54-
static void bus_clk_recalc(struct clk *clk)
54+
static unsigned long bus_clk_recalc(struct clk *clk)
5555
{
56-
clk->rate = clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007];
56+
return clk->parent->rate / pll1rate[(ctrl_inw(FREQCR) >> 8) & 0x0007];
5757
}
5858

5959
static struct clk_ops sh7206_bus_clk_ops = {
6060
.recalc = bus_clk_recalc,
6161
};
6262

63-
static void cpu_clk_recalc(struct clk *clk)
63+
static unsigned long cpu_clk_recalc(struct clk *clk)
6464
{
6565
int idx = (ctrl_inw(FREQCR) & 0x0007);
66-
clk->rate = clk->parent->rate / ifc_divisors[idx];
66+
return clk->parent->rate / ifc_divisors[idx];
6767
}
6868

6969
static struct clk_ops sh7206_cpu_clk_ops = {

‎arch/sh/kernel/cpu/sh3/clock-sh3.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,36 @@ static struct clk_ops sh3_master_clk_ops = {
3838
.init = master_clk_init,
3939
};
4040

41-
static void module_clk_recalc(struct clk *clk)
41+
static unsigned long module_clk_recalc(struct clk *clk)
4242
{
4343
int frqcr = ctrl_inw(FRQCR);
4444
int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);
4545

46-
clk->rate = clk->parent->rate / pfc_divisors[idx];
46+
return clk->parent->rate / pfc_divisors[idx];
4747
}
4848

4949
static struct clk_ops sh3_module_clk_ops = {
5050
.recalc = module_clk_recalc,
5151
};
5252

53-
static void bus_clk_recalc(struct clk *clk)
53+
static unsigned long bus_clk_recalc(struct clk *clk)
5454
{
5555
int frqcr = ctrl_inw(FRQCR);
5656
int idx = ((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4);
5757

58-
clk->rate = clk->parent->rate / stc_multipliers[idx];
58+
return clk->parent->rate / stc_multipliers[idx];
5959
}
6060

6161
static struct clk_ops sh3_bus_clk_ops = {
6262
.recalc = bus_clk_recalc,
6363
};
6464

65-
static void cpu_clk_recalc(struct clk *clk)
65+
static unsigned long cpu_clk_recalc(struct clk *clk)
6666
{
6767
int frqcr = ctrl_inw(FRQCR);
6868
int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2);
6969

70-
clk->rate = clk->parent->rate / ifc_divisors[idx];
70+
return clk->parent->rate / ifc_divisors[idx];
7171
}
7272

7373
static struct clk_ops sh3_cpu_clk_ops = {

‎arch/sh/kernel/cpu/sh3/clock-sh7705.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,30 @@ static struct clk_ops sh7705_master_clk_ops = {
3939
.init = master_clk_init,
4040
};
4141

42-
static void module_clk_recalc(struct clk *clk)
42+
static unsigned long module_clk_recalc(struct clk *clk)
4343
{
4444
int idx = ctrl_inw(FRQCR) & 0x0003;
45-
clk->rate = clk->parent->rate / pfc_divisors[idx];
45+
return clk->parent->rate / pfc_divisors[idx];
4646
}
4747

4848
static struct clk_ops sh7705_module_clk_ops = {
4949
.recalc = module_clk_recalc,
5050
};
5151

52-
static void bus_clk_recalc(struct clk *clk)
52+
static unsigned long bus_clk_recalc(struct clk *clk)
5353
{
5454
int idx = (ctrl_inw(FRQCR) & 0x0300) >> 8;
55-
clk->rate = clk->parent->rate / stc_multipliers[idx];
55+
return clk->parent->rate / stc_multipliers[idx];
5656
}
5757

5858
static struct clk_ops sh7705_bus_clk_ops = {
5959
.recalc = bus_clk_recalc,
6060
};
6161

62-
static void cpu_clk_recalc(struct clk *clk)
62+
static unsigned long cpu_clk_recalc(struct clk *clk)
6363
{
6464
int idx = (ctrl_inw(FRQCR) & 0x0030) >> 4;
65-
clk->rate = clk->parent->rate / ifc_divisors[idx];
65+
return clk->parent->rate / ifc_divisors[idx];
6666
}
6767

6868
static struct clk_ops sh7705_cpu_clk_ops = {

‎arch/sh/kernel/cpu/sh3/clock-sh7706.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,36 @@ static struct clk_ops sh7706_master_clk_ops = {
3434
.init = master_clk_init,
3535
};
3636

37-
static void module_clk_recalc(struct clk *clk)
37+
static unsigned long module_clk_recalc(struct clk *clk)
3838
{
3939
int frqcr = ctrl_inw(FRQCR);
4040
int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);
4141

42-
clk->rate = clk->parent->rate / pfc_divisors[idx];
42+
return clk->parent->rate / pfc_divisors[idx];
4343
}
4444

4545
static struct clk_ops sh7706_module_clk_ops = {
4646
.recalc = module_clk_recalc,
4747
};
4848

49-
static void bus_clk_recalc(struct clk *clk)
49+
static unsigned long bus_clk_recalc(struct clk *clk)
5050
{
5151
int frqcr = ctrl_inw(FRQCR);
5252
int idx = ((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4);
5353

54-
clk->rate = clk->parent->rate / stc_multipliers[idx];
54+
return clk->parent->rate / stc_multipliers[idx];
5555
}
5656

5757
static struct clk_ops sh7706_bus_clk_ops = {
5858
.recalc = bus_clk_recalc,
5959
};
6060

61-
static void cpu_clk_recalc(struct clk *clk)
61+
static unsigned long cpu_clk_recalc(struct clk *clk)
6262
{
6363
int frqcr = ctrl_inw(FRQCR);
6464
int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2);
6565

66-
clk->rate = clk->parent->rate / ifc_divisors[idx];
66+
return clk->parent->rate / ifc_divisors[idx];
6767
}
6868

6969
static struct clk_ops sh7706_cpu_clk_ops = {

0 commit comments

Comments
 (0)